Ejemplo n.º 1
0
 def create_test_fhir_instance(self):
     fhir_practitioner = Practitioner()
     name = HumanName()
     name.family = self._TEST_LAST_NAME
     name.given = [self._TEST_OTHER_NAME]
     name.use = NameUse.USUAL.value
     fhir_practitioner.name = [name]
     identifiers = []
     chf_id = PractitionerConverter.build_fhir_identifier(
         self._TEST_CODE,
         Stu3IdentifierConfig.get_fhir_identifier_type_system(),
         Stu3IdentifierConfig.get_fhir_claim_admin_code_type())
     identifiers.append(chf_id)
     fhir_practitioner.identifier = identifiers
     fhir_practitioner.birthDate = self._TEST_DOB
     telecom = []
     phone = PractitionerConverter.build_fhir_contact_point(
         self._TEST_PHONE, ContactPointSystem.PHONE.value,
         ContactPointUse.HOME.value)
     telecom.append(phone)
     email = PractitionerConverter.build_fhir_contact_point(
         self._TEST_EMAIL, ContactPointSystem.EMAIL.value,
         ContactPointUse.HOME.value)
     telecom.append(email)
     fhir_practitioner.telecom = telecom
     return fhir_practitioner
class PractitionerSerializer(BaseFHIRSerializer):

    fhirConverter = PractitionerConverter()

    def create(self, validated_data):
        code = validated_data.get('code')
        if ClaimAdmin.objects.filter(code=code).count() > 0:
            raise FHIRException(
                'Exists practitioner with following code `{}`'.format(code))
        copied_data = copy.deepcopy(validated_data)
        del copied_data['_state']
        return ClaimAdmin.objects.create(**copied_data)

    def update(self, instance, validated_data):
        instance.code = validated_data.get('code', instance.code)
        instance.last_name = validated_data.get('last_name',
                                                instance.last_name)
        instance.other_names = validated_data.get('other_names',
                                                  instance.other_names)
        instance.dob = validated_data.get('dob', instance.dob)
        instance.phone = validated_data.get('phone', instance.phone)
        instance.email_id = validated_data.get('email_id', instance.email_id)
        instance.audit_user_id = self.get_audit_user_id()
        instance.save()
        return instance
Ejemplo n.º 3
0
 def build_contract_agent(cls, contract, imis_coverage):
     agent = ContractAgent()
     actor = PractitionerConverter.build_fhir_resource_reference(
         imis_coverage.officer)
     agent.actor = actor
     provider_role = cls.build_simple_codeable_concept(
         Stu3CoverageConfig.get_practitioner_role_code())
     agent.role = [provider_role]
     contract.agent = [agent]
 def build_imis_claim_admin(cls, imis_claim, fhir_claim, errors):
     if fhir_claim.enterer:
         admin = PractitionerConverter.get_imis_obj_by_fhir_reference(
             fhir_claim.enterer)
         if admin:
             imis_claim.admin = admin
             imis_claim.claim_admin_code = admin.code
     cls.valid_condition(imis_claim.admin is None,
                         gettext('Missing the enterer reference'), errors)
    def to_imis_obj(cls, fhir_practitioner_role, audit_user_id):
        errors = []
        practitioner = fhir_practitioner_role.practitioner
        claim_admin = PractitionerConverter.get_imis_obj_by_fhir_reference(practitioner, errors)
        location_references = fhir_practitioner_role.location
        health_facility = cls.get_location_by_reference(location_references, errors)

        if not cls.valid_condition(claim_admin is None, "Practitioner doesn't exists", errors):
            claim_admin.health_facility = health_facility
        cls.check_errors(errors)
        return claim_admin
 def create_test_fhir_instance(self):
     fhir_claim = FHIRClaim()
     fhir_claim.id = self._TEST_CODE
     fhir_claim.patient = PatientConverter.build_fhir_resource_reference(
         self._TEST_INSUREE)
     claim_code = ClaimConverter.build_fhir_identifier(
         self._TEST_CODE,
         Stu3IdentifierConfig.get_fhir_identifier_type_system(),
         Stu3IdentifierConfig.get_fhir_claim_code_type())
     fhir_claim.identifier = [claim_code]
     billable_period = Period()
     billable_period.start = self._TEST_DATE_FROM
     billable_period.end = self._TEST_DATE_TO
     fhir_claim.billablePeriod = billable_period
     diagnoses = []
     ClaimConverter.build_fhir_diagnosis(diagnoses,
                                         self._TEST_DIAGNOSIS_CODE.code,
                                         ImisClaimIcdTypes.ICD_0.value)
     fhir_claim.diagnosis = diagnoses
     total = Money()
     total.value = self._TEST_CLAIMED
     fhir_claim.total = total
     fhir_claim.created = self._TEST_DATE_CLAIMED
     fhir_claim.facility = LocationConverter.build_fhir_resource_reference(
         self._TEST_HF)
     information = []
     guarantee_id_code = Stu3ClaimConfig.get_fhir_claim_information_guarantee_id_code(
     )
     ClaimConverter.build_fhir_string_information(information,
                                                  guarantee_id_code,
                                                  self._TEST_GUARANTEE_ID)
     explanation_code = Stu3ClaimConfig.get_fhir_claim_information_explanation_code(
     )
     ClaimConverter.build_fhir_string_information(information,
                                                  explanation_code,
                                                  self._TEST_EXPLANATION)
     fhir_claim.information = information
     fhir_claim.enterer = PractitionerConverter.build_fhir_resource_reference(
         self._TEST_CLAIM_ADMIN)
     fhir_claim.type = ClaimConverter.build_simple_codeable_concept(
         self._TEST_VISIT_TYPE)
     type = Stu3ClaimConfig.get_fhir_claim_item_code()
     ClaimConverter.build_fhir_item(fhir_claim, self._TEST_ITEM_CODE, type,
                                    self._TEST_ITEM)
     type = Stu3ClaimConfig.get_fhir_claim_service_code()
     ClaimConverter.build_fhir_item(fhir_claim, self._TEST_SERVICE_CODE,
                                    type, self._TEST_SERVICE)
     return fhir_claim
 def to_fhir_obj(cls, imis_claim):
     fhir_claim = FHIRClaim()
     cls.build_fhir_pk(fhir_claim, imis_claim.code)
     fhir_claim.created = imis_claim.date_claimed.isoformat()
     fhir_claim.facility = LocationConverter.build_fhir_resource_reference(
         imis_claim.health_facility)
     cls.build_fhir_identifiers(fhir_claim, imis_claim)
     fhir_claim.patient = PatientConverter.build_fhir_resource_reference(
         imis_claim.insuree)
     cls.build_fhir_billable_period(fhir_claim, imis_claim)
     cls.build_fhir_diagnoses(fhir_claim, imis_claim)
     cls.build_fhir_total(fhir_claim, imis_claim)
     fhir_claim.enterer = PractitionerConverter.build_fhir_resource_reference(
         imis_claim.admin)
     cls.build_fhir_type(fhir_claim, imis_claim)
     cls.build_fhir_information(fhir_claim, imis_claim)
     cls.build_fhir_items(fhir_claim, imis_claim)
     return fhir_claim
Ejemplo n.º 8
0
 def verify_fhir_instance(self, fhir_obj):
     self.assertEqual(1, len(fhir_obj.name))
     human_name = fhir_obj.name[0]
     self.assertTrue(isinstance(human_name, HumanName))
     self.assertEqual(self._TEST_OTHER_NAME, human_name.given[0])
     self.assertEqual(self._TEST_LAST_NAME, human_name.family)
     self.assertEqual(NameUse.USUAL.value, human_name.use)
     for identifier in fhir_obj.identifier:
         self.assertTrue(isinstance(identifier, Identifier))
         code = PractitionerConverter.get_first_coding_from_codeable_concept(
             identifier.type).code
         if code == Stu3IdentifierConfig.get_fhir_claim_admin_code_type():
             self.assertEqual(self._TEST_CODE, identifier.value)
         elif code == Stu3IdentifierConfig.get_fhir_id_type_code():
             self.assertEqual(str(self._TEST_ID), identifier.value)
     self.assertEqual(self._TEST_DOB, fhir_obj.birthDate)
     self.assertEqual(2, len(fhir_obj.telecom))
     for telecom in fhir_obj.telecom:
         self.assertTrue(isinstance(telecom, ContactPoint))
         if telecom.system == ContactPointSystem.PHONE.value:
             self.assertEqual(self._TEST_PHONE, telecom.value)
         elif telecom.system == ContactPointSystem.EMAIL.value:
             self.assertEqual(self._TEST_EMAIL, telecom.value)
 def build_fhir_practitioner_reference(cls, fhir_practitioner_role, imis_claim_admin):
     fhir_practitioner_role.practitioner = PractitionerConverter.build_fhir_resource_reference(imis_claim_admin)
 def test_to_imis_obj(self):
     fhir_practitioner = self.create_test_fhir_instance()
     imis_claim_admin = PractitionerConverter.to_imis_obj(
         fhir_practitioner, None)
     self.verify_imis_instance(imis_claim_admin)
 def test_to_fhir_obj(self):
     imis_claim_admin = self.create_test_imis_instance()
     fhir_practitioner = PractitionerConverter.to_fhir_obj(imis_claim_admin)
     self.verify_fhir_instance(fhir_practitioner)