def build_imis_date_range(cls, imis_claim, fhir_claim, errors): billable_period = fhir_claim.billablePeriod if billable_period: if billable_period.start: imis_claim.date_from = TimeUtils.str_to_date( billable_period.start) if billable_period.end: imis_claim.date_to = TimeUtils.str_to_date(billable_period.end) cls.valid_condition(imis_claim.date_from is None, gettext('Missing the billable start date'), errors)
def _create_and_save_hf(self): imis_hf = LocationTestMixin().create_test_imis_instance() imis_hf.id = None imis_hf.validity_from = TimeUtils.now() imis_hf.offline = False imis_hf.audit_user_id = self._TEST_ADMIN_USER_ID imis_hf.code = self._TEST_LOCATION_CODE imis_hf.save() return imis_hf
def createDefaultInsuree(cls, audit_user_id): imis_insuree = Insuree() imis_insuree.head = GeneralConfiguration.get_default_value_of_patient_head_attribute( ) imis_insuree.card_issued = GeneralConfiguration.get_default_value_of_patient_card_issued_attribute( ) imis_insuree.validity_from = TimeUtils.now() imis_insuree.audit_user_id = audit_user_id return imis_insuree
def createDefaultInsuree(cls, audit_user_id): imis_hf = HealthFacility() # TODO legalForm isn't covered because that value is missing in the model (value need to be nullable in DB) # TODO LocationId isn't covered because that value is missing in the model (value need to be nullable in DB) imis_hf.offline = GeneralConfiguration.get_default_value_of_location_offline_attribute( ) imis_hf.care_type = GeneralConfiguration.get_default_value_of_location_care_type( ) imis_hf.validity_from = TimeUtils.now() imis_hf.audit_user_id = audit_user_id return imis_hf
def create_test_imis_instance(self): imis_feedback = Feedback() imis_feedback.id = self._TEST_FEEDBACK_ID imis_feedback.uuid = self._TEST_FEEDBACK_UUID imis_feedback.feedback_date = TimeUtils.str_to_date(self._TEST_FEEDBACK_DATE) imis_feedback.care_rendered = self._TEST_CARE_RENDERED imis_feedback.payment_asked = self._TEST_PAYMENT_ASKED imis_feedback.drug_prescribed = self._TEST_DRUG_PRESCRIBED imis_feedback.drug_received = self._TEST_DRUG_RECEIVED imis_feedback.asessment = self._TEST_ASESSMENT return imis_feedback
def verify_imis_instance(self, imis_obj): self.assertEqual(self._TEST_LAST_NAME, imis_obj.last_name) self.assertEqual(self._TEST_OTHER_NAME, imis_obj.other_names) self.assertEqual(self._TEST_CHF_ID, imis_obj.chf_id) self.assertEqual(self._TEST_PASSPORT, imis_obj.passport) expected_date = TimeUtils.str_to_date(self._TEST_DOB) self.assertEqual(expected_date, imis_obj.dob) self.assertEqual(self._TEST_GENDER_CODE, imis_obj.gender.code) self.assertEqual(ImisMaritalStatus.DIVORCED.value, imis_obj.marital) self.assertEqual(self._TEST_PHONE, imis_obj.phone) self.assertEqual(self._TEST_EMAIL, imis_obj.email) self.assertEqual(self._TEST_ADDRESS, imis_obj.current_address) self.assertEqual(self._TEST_GEOLOCATION, imis_obj.geolocation)
def test_str_converting_datetime_with_time_zone(self): str_value = "2010-11-16T15:22:01+01:00" expected = core.datetime.datetime(2010, 11, 16, 15, 22, 1, 0, tzinfo=dateutil.tz.tzoffset( None, self.__OFFSET_IN_SECONDS)) actual = TimeUtils.str_to_date(str_value) self.assertEqual(expected, actual)
def create_test_imis_instance(self): imis_claim = Claim() imis_claim.id = self._TEST_ID imis_claim.uuid = self._TEST_UUID imis_claim.insuree = PatientTestMixin().create_test_imis_instance() imis_claim.code = self._TEST_CODE imis_claim.date_from = TimeUtils.str_to_date(self._TEST_DATE_FROM) imis_claim.date_to = TimeUtils.str_to_date(self._TEST_DATE_TO) icd = Diagnosis() icd.code = self._TEST_MAIN_ICD_CODE imis_claim.icd = icd imis_claim.claimed = self._TEST_CLAIMED imis_claim.date_claimed = TimeUtils.str_to_date( self._TEST_DATE_CLAIMED) imis_claim.health_facility = LocationTestMixin( ).create_test_imis_instance() imis_claim.guarantee_id = self._TEST_GUARANTEE_ID imis_claim.admin = PractitionerTestMixin().create_test_imis_instance() imis_claim.icd_1 = Diagnosis(code=self._TEST_ICD_1) imis_claim.icd_2 = Diagnosis(code=self._TEST_ICD_2) imis_claim.icd_3 = Diagnosis(code=self._TEST_ICD_3) imis_claim.icd_4 = Diagnosis(code=self._TEST_ICD_4) imis_claim.visit_type = self._TEST_VISIT_TYPE return imis_claim
def create_test_imis_instance(self): imis_claim = Claim() imis_claim.id = self._TEST_ID imis_claim.uuid = self._TEST_UUID imis_claim.code = self._TEST_CODE imis_claim.status = self._TEST_STATUS imis_claim.adjustment = self._TEST_ADJUSTMENT imis_claim.date_processed = TimeUtils.str_to_date( self._TEST_DATE_PROCESSED) imis_claim.approved = self._TEST_APPROVED imis_claim.rejection_reason = self._TEST_REJECTION_REASON feedback = Feedback() feedback.id = self._TEST_FEEDBACK_ID feedback.uuid = self._TEST_FEEDBACK_UUID imis_claim.feedback = feedback return imis_claim
def create_test_imis_instance(self): self.setUp() imis_insuree = Insuree() imis_insuree.last_name = self._TEST_LAST_NAME imis_insuree.other_names = self._TEST_OTHER_NAME imis_insuree.id = self._TEST_ID imis_insuree.uuid = self._TEST_UUID imis_insuree.chf_id = self._TEST_CHF_ID imis_insuree.passport = self._TEST_PASSPORT imis_insuree.dob = TimeUtils.str_to_date(self._TEST_DOB) imis_insuree.gender = self._TEST_GENDER imis_insuree.marital = ImisMaritalStatus.DIVORCED.value imis_insuree.phone = self._TEST_PHONE imis_insuree.email = self._TEST_EMAIL imis_insuree.current_address = self._TEST_ADDRESS imis_insuree.geolocation = self._TEST_GEOLOCATION return imis_insuree
def build_imis_photo(cls, imis_insuree, fhir_patient, errors): url = fhir_patient.photo.url url = url.split("\\", 2) folder = url[0] filename = url[1] creation = fhir_patient.photo.creation if not cls.valid_condition( creation is None, gettext('Missing patient `photo url` attribute'), errors): imis_insuree.photo.date = TimeUtils.str_to_date(creation) if not cls.valid_condition( folder is None, gettext('Missing patient `photo folder` attribute'), errors): imis_insuree.photo.folder = folder if not cls.valid_condition( filename is None, gettext('Missing patient `photo filename` attribute'), errors): imis_insuree.photo.filename = filename
def to_fhir_obj(cls, imis_claim): fhir_claim_response = ClaimResponse() fhir_claim_response.created = TimeUtils.date().isoformat() fhir_claim_response.request = ClaimConverter.build_fhir_resource_reference( imis_claim) cls.build_fhir_pk(fhir_claim_response, imis_claim.uuid) ClaimConverter.build_fhir_identifiers(fhir_claim_response, imis_claim) cls.build_fhir_outcome(fhir_claim_response, imis_claim) cls.build_fhir_errors(fhir_claim_response, imis_claim) cls.build_fhir_items(fhir_claim_response, imis_claim) cls.build_patient_reference(fhir_claim_response, imis_claim) cls.build_fhir_total(fhir_claim_response, imis_claim) cls.build_fhir_communication_request_reference(fhir_claim_response, imis_claim) cls.build_fhir_type(fhir_claim_response, imis_claim) cls.build_fhir_status(fhir_claim_response) cls.build_fhir_use(fhir_claim_response) cls.build_fhir_insurer(fhir_claim_response, imis_claim) return fhir_claim_response
def create_default_claim_admin(cls, audit_user_id): imis_claim_admin = ClaimAdmin() imis_claim_admin.validity_from = TimeUtils.now() imis_claim_admin.audit_user_id = audit_user_id return imis_claim_admin
def build_imis_birth_date(cls, imis_insuree, fhir_patient, errors): birth_date = fhir_patient.birthDate if not cls.valid_condition( birth_date is None, gettext('Missing patient `birthDate` attribute'), errors): imis_insuree.dob = TimeUtils.str_to_date(birth_date)
def build_imis_date_claimed(cls, imis_claim, fhir_claim, errors): if fhir_claim.created: imis_claim.date_claimed = TimeUtils.str_to_date(fhir_claim.created) cls.valid_condition(imis_claim.date_claimed is None, gettext('Missing the date of creation'), errors)
def build_imis_birth_date(cls, imis_claim_admin, fhir_practitioner): birth_date = fhir_practitioner.birthDate if birth_date: imis_claim_admin.dob = TimeUtils.str_to_date(birth_date)
def test_str_converting_date(self): str_value = "2010-11-16" expected = core.datetime.date(2010, 11, 16) actual = TimeUtils.str_to_date(str_value) self.assertEqual(expected, actual)