def fmt(snapshot, snapshot_number): return { "timestamp": datetime.datetime.strptime(snapshot["timestamp"][:19], "%Y-%m-%d %H:%M:%S"), "value": get_cde_value(form_model, section_model, cde_model, snapshot["record"]), "user": snapshot.get("username", ""), "id": str(snapshot_number), }
def _get_cde_value_from_current_data(self, patient_record, form_model, section_model, cde_model): if patient_record is None: return None try: return get_cde_value(form_model, section_model, cde_model, patient_record) except Exception as ex: cde = "%s/%s/%s" % (form_model.name, section_model.code, cde_model.code) logger.error("Error getting current cde %s for %s: %s" % (cde, patient_record["django_id"], ex)) return "??ERROR??"
def _get_cde_value_from_snapshot(self, snapshot, form_model, section_model, cde_model): patient_record = snapshot["record"] if patient_record is None: return "" try: return self._human( form_model, section_model, cde_model, get_cde_value(form_model, section_model, cde_model, patient_record)) except Exception as ex: patient_id = patient_record["django_id"] logger.error( "Error getting cde %s/%s/%s for patient %s snapshot: %s" % (form_model.name, section_model.code, cde_model.code, patient_id, ex)) return "?ERROR?"
def _get_cde_value_from_current_data(self, patient_record, form_model, section_model, cde_model): if patient_record is None: return None try: return get_cde_value(form_model, section_model, cde_model, patient_record) except Exception as ex: cde = "%s/%s/%s" % (form_model.name, section_model.code, cde_model.code) patient_id = patient_record["django_id"] from registry.patients.models import Patient patient_model = Patient.objects.get(id=patient_id) logger.error( "Error getting current cde %s for patient %s: %s" % (cde, getattr(patient_model, settings.LOG_PATIENT_FIELDNAME), ex)) return "??ERROR??"
def _get_cde_value_from_snapshot(self, snapshot, form_model, section_model, cde_model): patient_record = snapshot["record"] if patient_record is None: return "" try: return self._human( form_model, section_model, cde_model, get_cde_value(form_model, section_model, cde_model, patient_record)) except Exception as ex: patient_id = patient_record["django_id"] from registry.patients.models import Patient patient_model = Patient.objects.get(id=patient_id) logger.error( "Error getting cde %s/%s/%s for patient %s snapshot: %s" % (form_model.name, section_model.code, cde_model.code, getattr(patient_model, settings.LOG_PATIENT_FIELDNAME), ex)) return "?ERROR?"
def evaluate(self, patient_model, mongo_record): return get_cde_value(self.form_model, self.section_model, self.cde_model, mongo_record)