コード例 #1
0
ファイル: test_delivery_cases.py プロジェクト: dimagi/bhoma
 def _add_form(self, form_name, **kwargs):
     with open(os.path.join(self.folder_name, form_name)) as f:
         date_string = datetime.utcnow().date().strftime("%Y-%m-%d")
         form = f.read().format(
             date=date_string,
             patient_id=self.patient._id,
             **kwargs
         )
         return export.add_form_to_patient(self.patient._id, form)
コード例 #2
0
ファイル: util.py プロジェクト: dimagi/bhoma
def add_form_with_date_offset(patient_id, filename, days_from_today=0, 
                              date_template_tag="date", format_string="%Y-%m-%d"):
    """
    Like the export command to add forms to patients, but allows you to 
    pass in date offsets for specific tags in the XML so that you can 
    control the dates getting set in the test.
    
    This is necessary because if you don't pass in a recent date the 
    case gets closed as LTFU
    """
    with open(filename) as f:
        form_with_updated_date = replace_date(f.read(), days_from_today=days_from_today,
                                              date_template_tag=date_template_tag, 
                                              format_string=format_string)
        return export.add_form_to_patient(patient_id, form_with_updated_date)