Exemplo n.º 1
0
    def get_detail_representation(self, patient: Any):
        if isinstance(patient, dict):
            medical_history = patient.pop("medical_history")
            patient = PatientRegistration(**patient)
            patient.medical_history.set(medical_history)

        return {
            "id": patient.id,
            "name": patient.name,
            "age": patient.age,
            "gender": patient.gender,
            "phone_number": patient.phone_number,
            "address": patient.address,
            "contact_with_suspected_carrier":
            patient.contact_with_suspected_carrier,
            "contact_with_confirmed_carrier":
            patient.contact_with_confirmed_carrier,
            "estimated_contact_date": patient.estimated_contact_date,
            "medical_history": [],
            "tele_consultation_history": [],
            "is_active": True,
            "state": patient.state,
            "district": patient.district,
            "local_body": patient.local_body,
            "past_travel": patient.past_travel,
            "present_health": patient.present_health,
            "has_SARI": patient.has_SARI,
            "facility": patient.facility,
            "countries_travelled": patient.countries_travelled,
            "last_consultation": None,
            "state_object": None,
            "local_body_object": None,
            "district_object": None,
            "facility_object": None,
        }
Exemplo n.º 2
0
    def get_list_representation(self, patient=None):

        if isinstance(patient, dict):
            medical_history = patient.pop("medical_history", [])
            patient = PatientRegistration(**patient)
            patient.medical_history.set(medical_history)

        facility_id = None
        if getattr(patient.facility, "external_id", None):
            facility_id = str(getattr(patient.facility, "external_id", None))
        return {
            "id": str(str(patient.external_id)),
            "name": patient.name,
            "age": patient.age,
            "date_of_birth": mock_equal,
            "gender": patient.gender,
            "is_medical_worker": patient.is_medical_worker,
            "is_antenatal": patient.is_antenatal,
            "phone_number": patient.phone_number,
            "address": patient.address,
            "pincode": patient.pincode,
            "nationality": patient.nationality,
            "passport_no": patient.passport_no,
            # "aadhar_no": patient.aadhar_no,
            "contact_with_confirmed_carrier": patient.contact_with_confirmed_carrier,
            "contact_with_suspected_carrier": patient.contact_with_suspected_carrier,
            "estimated_contact_date": patient.estimated_contact_date,
            "past_travel": patient.past_travel,
            "countries_travelled": patient.countries_travelled,
            "present_health": patient.present_health,
            "has_SARI": patient.has_SARI,
            "is_active": patient.is_active,
            "facility": facility_id,
            "facility_object": self.get_facility_representation(patient.facility),
            "blood_group": patient.blood_group,
            "allow_transfer": patient.allow_transfer,
            "date_of_return": patient.date_of_return,
            "disease_status": self._get_disease_state_representation(patient.disease_status),
            "number_of_aged_dependents": patient.number_of_aged_dependents,
            "number_of_chronic_diseased_dependents": patient.number_of_chronic_diseased_dependents,
            "created_date": mock_equal,
            "modified_date": mock_equal,
            "source": patient.get_source_display(),
            "nearest_facility": getattr(patient.nearest_facility, "id", None),
            **self.get_local_body_district_state_representation(patient),
            "date_of_receipt_of_information": patient.date_of_receipt_of_information,
        }
Exemplo n.º 3
0
    def get_detail_representation(self, patient: Any):

        if isinstance(patient, dict):
            this_patient = patient.copy()
            medical_history = this_patient.pop("medical_history", [])
            this_patient_data = this_patient.copy()
            district_id = this_patient_data.pop("district")
            state_id = this_patient_data.pop("state")
            this_patient_data.update({"district_id": district_id, "state_id": state_id})
            patient = PatientRegistration(**this_patient_data)

        else:
            medical_history = patient.medical_history

        return {
            "id": mock_equal,
            "name": patient.name,
            "age": patient.age,
            "date_of_birth": mock_equal,
            "nationality": patient.nationality,
            "passport_no": patient.passport_no,
            # "aadhar_no": patient.aadhar_no,
            "is_medical_worker": patient.is_medical_worker,
            "is_antenatal": patient.is_antenatal,
            "blood_group": patient.blood_group,
            "allergies": patient.allergies,
            "allow_transfer": patient.allow_transfer,
            "ongoing_medication": patient.ongoing_medication,
            "date_of_return": patient.date_of_return,
            "disease_status": self._get_disease_state_representation(patient.disease_status),
            "gender": patient.gender,
            "phone_number": patient.phone_number,
            "address": patient.address,
            "pincode": patient.pincode,
            "contact_with_suspected_carrier": patient.contact_with_suspected_carrier,
            "contact_with_confirmed_carrier": patient.contact_with_confirmed_carrier,
            "estimated_contact_date": patient.estimated_contact_date,
            "number_of_aged_dependents": patient.number_of_aged_dependents,
            "number_of_chronic_diseased_dependents": patient.number_of_chronic_diseased_dependents,
            "medical_history": self._get_medical_history_representation(medical_history),
            "tele_consultation_history": [],
            "is_active": True,
            "past_travel": patient.past_travel,
            "present_health": patient.present_health,
            "has_SARI": patient.has_SARI,
            "facility": patient.facility,
            "countries_travelled": patient.countries_travelled,
            "last_consultation": None,
            "facility_object": None,
            "created_date": mock_equal,
            "modified_date": mock_equal,
            "source": patient.get_source_display(),
            **self.get_local_body_district_state_representation(patient),
            "nearest_facility": patient.nearest_facility,
            "nearest_facility_object": self.get_facility_representation(patient.nearest_facility),
            "meta_info": self._get_metainfo_representation(patient),
            "contacted_patients": self._get_contact_patients_representation(patient),
            "date_of_receipt_of_information": mock_equal,
        }
Exemplo n.º 4
0
    def get_list_representation(self, patient=None):

        if isinstance(patient, dict):
            medical_history = patient.pop("medical_history", default="[]")
            patient = PatientRegistration(**patient)
            patient.medical_history.set(medical_history)

        return {
            "id":
            patient.id,
            "name":
            patient.name,
            "age":
            patient.age,
            "gender":
            patient.gender,
            "is_medical_worker":
            patient.is_medical_worker,
            "phone_number":
            patient.phone_number,
            "address":
            patient.address,
            "contact_with_confirmed_carrier":
            patient.contact_with_confirmed_carrier,
            "contact_with_suspected_carrier":
            patient.contact_with_suspected_carrier,
            "estimated_contact_date":
            patient.estimated_contact_date,
            "past_travel":
            patient.past_travel,
            "countries_travelled":
            patient.countries_travelled,
            "present_health":
            patient.present_health,
            "has_SARI":
            patient.has_SARI,
            "is_active":
            patient.is_active,
            "facility":
            getattr(patient.facility, "id", None),
            "facility_object":
            self._get_facility_representation(patient.facility),
            "blood_group":
            patient.blood_group,
            "date_of_return":
            patient.date_of_return,
            "disease_status":
            self._get_disease_state_representation(patient.disease_status),
            "number_of_aged_dependents":
            patient.number_of_aged_dependents,
            "number_of_chronic_diseased_dependents":
            patient.number_of_chronic_diseased_dependents,
            **self.get_local_body_district_state_representation(patient),
        }