コード例 #1
0
    def get_baseline_LDL(self):
        CM2_form_dict = get_form_dict(self.case, CM2)
        baseline_LDL = dict()
        if CM2_form_dict is not None and 'CM2_LDL_group' in CM2_form_dict:
            baseline_LDL['lab_LDL'] = CM2_form_dict['CM2_LDL_group'].get(
                'CM2_lab_LDL', EMPTY_FIELD)
            baseline_LDL['lab_LDL_date'] = format_date(
                CM2_form_dict['CM2_LDL_group'].get('CM2_lab_LDL_date',
                                                   EMPTY_FIELD),
                OUTPUT_DATE_FORMAT)
            baseline_LDL['lab_LDL_fasting'] = CM2_form_dict[
                'CM2_LDL_group'].get('CM2_lab_LDL_fasting', EMPTY_FIELD)
            baseline_LDL['lab_LDL_statin'] = CM2_form_dict[
                'CM2_LDL_group'].get('CM2_lab_LDL_statin', EMPTY_FIELD)

        return {
            'label':
            _('Baseline LDL'),
            'value': [
                _("Value: ") + baseline_LDL.get('lab_LDL', EMPTY_FIELD),
                _("Date: ") + baseline_LDL.get('lab_LDL_date', EMPTY_FIELD),
                _("Fasting? ") +
                baseline_LDL.get('lab_LDL_fasting', EMPTY_FIELD),
                _("Taking statin at time of draw? ") +
                baseline_LDL.get('lab_LDL_statin', EMPTY_FIELD),
            ]
        }
コード例 #2
0
ファイル: patient_Info.py プロジェクト: ye-man/commcare-hq
    def get_recent_blood_pressure(self, number):
        CM2_form_dict = get_form_dict(self.case, CM2)
        blood_pressure = dict()
        if CM2_form_dict is not None and 'CM2_bp_%s_group' % number in CM2_form_dict:
            group = 'CM2_bp_%s_group' % number
            blood_pressure['CM2_bp_%s_sbp' % number] = CM2_form_dict[group].get('CM2_bp_%s_sbp' % number, EMPTY_FIELD) \
                                                       + '/' + CM2_form_dict[group].get('CM2_bp_%s_dbp' % number, EMPTY_FIELD)
            blood_pressure['CM2_patient_bp_%s_date' % number] = format_date(CM2_form_dict[group].get('CM2_patient_bp_%s_date' % number, EMPTY_FIELD), OUTPUT_DATE_FORMAT)

        return {'label': _('Recent Blood Pressure %s' % number),
                'value': [
                  _("Value: ") + blood_pressure.get('CM2_bp_%s_sbp' % number, EMPTY_FIELD),
                  _("Date: ") + blood_pressure.get('CM2_patient_bp_%s_date' % number, EMPTY_FIELD)
                ]}
コード例 #3
0
ファイル: patient_Info.py プロジェクト: ye-man/commcare-hq
 def _get_field_value(label, value, is_date=None):
     val = getattr(self.case, value, EMPTY_FIELD)
     if val and is_date:
         val = format_date(val, OUTPUT_DATE_FORMAT)
     return _(label) + ': ' + str(val)
コード例 #4
0
 def form_completion_time(self, date_string):
     if date_string != EMPTY_FIELD:
         return format_date(date_string, INTERACTION_OUTPUT_DATE_FORMAT, localize=True)
     else:
         return EMPTY_FIELD
コード例 #5
0
    def report_context(self):
        self.report_template_path = "patient_interactions.html"
        ret = super(PatientInteractionsReport, self).report_context
        ret['view_mode'] = 'interactions'
        ret['problem_url'] = self.get_form_url(self.cm_app_dict,
                                               self.latest_cm_build,
                                               CM_APP_PD_MODULE, PD1,
                                               ret['patient']['_id'])
        ret['huddle_url'] = self.get_form_url(self.cm_app_dict,
                                              self.latest_cm_build,
                                              CM_APP_HUD_MODULE, HUD2,
                                              ret['patient']['_id'])
        ret['cm_phone_url'] = self.get_form_url(self.cm_app_dict,
                                                self.latest_cm_build,
                                                CM_APP_CM_MODULE, CM6,
                                                ret['patient']['_id'])
        ret['chw_phone_url'] = self.get_form_url(self.cm_app_dict,
                                                 self.latest_cm_build,
                                                 CM_APP_CHW_MODULE, CHW3,
                                                 ret['patient']['_id'])
        ret['cm_visits_url'] = self.get_form_url(self.cm_app_dict,
                                                 self.latest_cm_build,
                                                 CM_APP_APPOINTMENTS_MODULE,
                                                 AP2, ret['patient']['_id'])

        ret['anti_thrombotic_url'] = self.get_form_url(
            self.cm_app_dict, self.latest_cm_build, CM_APP_MEDICATIONS_MODULE,
            PD2AM, ret['patient']['_id'])
        ret['blood_pressure_url'] = self.get_form_url(
            self.cm_app_dict, self.latest_cm_build, CM_APP_MEDICATIONS_MODULE,
            PD2BPM, ret['patient']['_id'])
        ret['cholesterol_url'] = self.get_form_url(self.cm_app_dict,
                                                   self.latest_cm_build,
                                                   CM_APP_MEDICATIONS_MODULE,
                                                   PD2CHM,
                                                   ret['patient']['_id'])
        ret['depression_url'] = self.get_form_url(self.cm_app_dict,
                                                  self.latest_cm_build,
                                                  CM_APP_MEDICATIONS_MODULE,
                                                  PD2DIABM,
                                                  ret['patient']['_id'])
        ret['diabetes_url'] = self.get_form_url(self.cm_app_dict,
                                                self.latest_cm_build,
                                                CM_APP_MEDICATIONS_MODULE,
                                                PD2DEPM, ret['patient']['_id'])
        ret['smoking_cessation_url'] = self.get_form_url(
            self.cm_app_dict, self.latest_cm_build, CM_APP_MEDICATIONS_MODULE,
            PD2SCM, ret['patient']['_id'])
        ret['other_meds_url'] = self.get_form_url(self.cm_app_dict,
                                                  self.latest_cm_build,
                                                  CM_APP_MEDICATIONS_MODULE,
                                                  PD2OM, ret['patient']['_id'])

        ret['interaction_table'] = []
        for visit_key, visit in enumerate(VISIT_SCHEDULE):
            if ret['patient']["randomization_date"]:
                try:
                    target_date = (ret['patient']["randomization_date"] +
                                   timedelta(days=visit['days'])
                                   ).strftime(OUTPUT_DATE_FORMAT)
                except TypeError:
                    target_date = _("Bad Date Format!")
            else:
                target_date = EMPTY_FIELD
            interaction = {
                'url': '',
                'name': visit['visit_name'],
                'target_date': target_date,
                'received_date': EMPTY_FIELD,
                'completed_by': EMPTY_FIELD,
                'scheduled_date': EMPTY_FIELD
            }
            for key, action in enumerate(ret['patient']['actions']):
                if visit['xmlns'] == action['xform_xmlns']:
                    interaction['received_date'] = action['date'].strftime(
                        INTERACTION_OUTPUT_DATE_FORMAT)
                    try:
                        user = self.get_user(action['user_id'])
                        interaction['completed_by'] = user.human_friendly_name
                    except ResourceNotFound:
                        interaction['completed_by'] = EMPTY_FIELD
                    del ret['patient']['actions'][key]
                    break
            if visit['show_button']:
                interaction['url'] = self.get_form_url(self.cm_app_dict,
                                                       self.latest_cm_build,
                                                       visit['module_idx'],
                                                       visit['xmlns'],
                                                       ret['patient']['_id'])
            if 'scheduled_source' in visit and ret[
                    'patient'].get_case_property(visit['scheduled_source']):
                interaction['scheduled_date'] = format_date(
                    ret['patient'].get_case_property(
                        visit['scheduled_source']),
                    INTERACTION_OUTPUT_DATE_FORMAT,
                    localize=True)

            ret['interaction_table'].append(interaction)

            medication = []
            for med_prop in MEDICATION_DETAILS:
                medication.append(
                    getattr(ret['patient'], med_prop, EMPTY_FIELD))
            ret['medication_table'] = medication
        return ret