def map(self):
        try:
            sub_encounter = mii_encounter_abfall.Encounter()
            id_value = sha256(
                self.data['concat_elements'].encode('utf-8')).hexdigest()

            sub_encounter.id = id_value
            sub_encounter.identifier = [
                identifier.Identifier({
                    "use": "usual",
                    "system": self.systems['subencounter_id'],
                    "value": id_value
                })
            ]
            sub_encounter.status = "in-progress"
            enc_class_system = "http://terminology.hl7.org/CodeSystem/v3-ActCode"
            sub_encounter.class_fhir = mii_coding.Coding({
                "system":
                enc_class_system,
                "code":
                "IMP",
                "display":
                "inpatient encounter"
            })
            ref = {"reference": f"Patient/{self.data['patient_psn']}"}
            sub_encounter.subject = fhirreference.FHIRReference(jsondict=ref)
            ref = {"reference": f"Encounter/{self.data['encounter_psn']}"}
            sub_encounter.partOf = fhirreference.FHIRReference(jsondict=ref)

            fab_code = self.data['dep_full_code']
            service_type = mii_codeableconcept.CodeableConcept()
            service_type_sys = "http://terminology.hl7.org/CodeSystem/service-type"
            service_type.coding = [
                mii_coding.Coding({
                    "system": service_type_sys,
                    "code": fab_code,
                    "display": self._dep_name_lookup(fab_code)
                })
            ]
            sub_encounter.serviceType = service_type

            enc_period = mii_period.Period()
            enc_period.start = fhirdate.FHIRDate(
                datetime.strftime(self.data['admission_dt'],
                                  '%Y-%m-%dT%H:%M:%S'))
            if not pd.isna(self.data['discharge_dt']):
                sub_encounter.status = "finished"
                enc_period.end = fhirdate.FHIRDate(
                    datetime.strftime(self.data['discharge_dt'],
                                      '%Y-%m-%dT%H:%M:%S'))
            sub_encounter.period = enc_period

            enc_meta = meta.Meta()
            enc_meta.source = "#sap-ish"
            sub_encounter.meta = enc_meta

            sub_encounter.location = []
            location_list = []
            added_res_loc = 0
            res_loc_invalid = 0
            for loc_name, loc_am_ts, loc_dc_ts in zip(
                    self.data['loc_name_set'], self.data['loc_am_ts_set'],
                    self.data['loc_dc_ts_set']):
                new_location = location.Location()
                id_value = sha256(loc_name.encode('utf-8')).hexdigest()
                new_location.id = id_value
                new_location.identifier = [
                    identifier.Identifier({
                        "use": "usual",
                        "system":
                        "https://diz.mii.de/fhir/CodeSystem/TestOrganisationAbteilungen",
                        "value": id_value
                    })
                ]
                new_location.name = loc_name

                loc = mii_encounter_abfall.EncounterLocation()
                loc.status = 'active'
                loc_period = mii_period.Period()
                loc_period.start = fhirdate.FHIRDate(
                    datetime.strftime(loc_am_ts, '%Y-%m-%dT%H:%M:%S'))
                if not pd.isna(loc_dc_ts):
                    loc.status = "completed"
                    loc_period.end = fhirdate.FHIRDate(
                        datetime.strftime(loc_dc_ts, '%Y-%m-%dT%H:%M:%S'))
                loc.period = loc_period
                ref = {"reference": f"Location/{id_value}"}
                loc.location = fhirreference.FHIRReference(jsondict=ref)
                try:
                    loc.as_json()
                    sub_encounter.location.append(loc)
                    location_list.append(new_location)
                    added_res_loc += 1
                except FHIRValidationError:
                    self.logger.warning(
                        "Validation error for created Location resource "
                        f"(id: {self.data['encounter_psn']})")
                    res_loc_invalid += 1

            return sub_encounter, location_list, added_res_loc, res_loc_invalid
        except KeyError as exc:
            self.logger.error(
                f"In {__name__}: Key {exc} not found in dictionary")
            raise
    def map(self):
        try:
            new_medication = []
            medication_stm = []

            #id_value = sha256(self.data['concat_elements'].encode('utf-8')).hexdigest()
            id_value = str(self.data['encounter_psn']) + '_' + str(
                self.data['procedure_nr'])

            pat_procedure = mii_procedure.Procedure()
            pat_procedure.id = id_value
            pat_procedure.identifier = [
                identifier.Identifier({
                    "system": self.systems['prod_id'],
                    "value": id_value
                })
            ]
            pat_procedure.status = "completed"

            ref = {"reference": f"Encounter/{self.data['encounter_psn']}"}
            encounter_ref = fhirreference.FHIRReference(jsondict=ref)
            ref = {"reference": f"Patient/{self.data['patient_psn']}"}
            patient_ref = fhirreference.FHIRReference(jsondict=ref)

            pat_procedure.encounter = encounter_ref
            pat_procedure.subject = patient_ref

            category = mii_codeableconcept.CodeableConcept()
            category.coding = [
                mii_coding.Coding({
                    "system": "http://snomed.info/sct",
                    "code": "387713003"
                })
            ]
            pat_procedure.category = category

            procedure_code = mii_codeableconcept.CodeableConcept()
            procedure_code.coding = [
                mii_coding.Coding({
                    "system": "http://fhir.de/CodeSystem/dimdi/ops",
                    "code": self.data['ops_kode'],
                    "version": self.data['ops_version']
                })
            ]
            pat_procedure.code = procedure_code

            if self.data['ops_kode'][0] == '6':
                [new_medication, medication_stm
                 ] = self._map_dmpro2medi(encounter_ref, patient_ref)

            if not pd.isna(self.data['ops_datum']):
                ops_datum_fhir = datetime.strftime(self.data['ops_datum'],
                                                   '%Y-%m-%dT%H:%M:%S')
                pat_procedure.performedDateTime = fhirdate.FHIRDate(
                    ops_datum_fhir)

            if self.data['lokalisation']:
                pat_procedure.bodySite = []
                snomed_ver = "http://snomed.info/sct/900000000000207008/version/20200309"
                if self.data['lokalisation'] == 'L' or self.data[
                        'lokalisation'] == 'B':
                    left_body_part = mii_codeableconcept.CodeableConcept()
                    left_body_part.coding = [
                        mii_coding.Coding({
                            "system": "http://snomed.info/sct",
                            "code": "31156008",
                            "display": '''Structure of left half
                                                                of body (body structure)''',
                            "version": snomed_ver
                        })
                    ]
                    pat_procedure.bodySite.append(left_body_part)

                if self.data['lokalisation'] == 'R' or self.data[
                        'lokalisation'] == 'B':
                    right_body_part = mii_codeableconcept.CodeableConcept()
                    right_body_part.coding = [
                        mii_coding.Coding({
                            "system": "http://snomed.info/sct",
                            "code": "85421007",
                            "display": '''Structure of right half
                                                                 of body (body structure)''',
                            "version": snomed_ver
                        })
                    ]
                    pat_procedure.bodySite.append(right_body_part)

            pro_meta = meta.Meta()
            pro_meta.source = "#sap-ish"
            pat_procedure.meta = pro_meta

            return [pat_procedure, new_medication, medication_stm]
        except KeyError as exc:
            self.logger.error(
                f"In {__name__}: Key {exc} not found in dictionary")
            raise
    def map(self):
        try:
            pat_encounter = mii_encounter_verfall.Encounter()
            pat_encounter.id = self.data['encounter_psn']
            identifier_type = mii_codeableconcept.CodeableConcept()
            identifier_type.coding = [
                mii_coding.Coding({
                    "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                    "code": "VN"
                })
            ]
            pat_encounter.identifier = [
                mii_identifier.Identifier({
                    "use":
                    "usual",
                    "system":
                    self.systems['encounter_id'],
                    "value":
                    self.data['encounter_psn'],
                    "assigner": {
                        "reference": "Organization/1111"
                    },
                    "type":
                    identifier_type.as_json()
                })
            ]
            enc_class_system = "http://terminology.hl7.org/CodeSystem/v3-ActCode"
            pat_encounter.class_fhir = mii_coding.Coding({
                "system":
                enc_class_system,
                "code":
                "IMP",
                "display":
                "inpatient encounter"
            })
            ref = {"reference": f"Patient/{self.data['patient_psn']}"}
            pat_encounter.subject = fhirreference.FHIRReference(jsondict=ref)

            enc_period = mii_period.Period()
            pat_encounter.status = "in-progress"
            if not pd.isna(self.data['admission_dt']):
                enc_period.start = fhirdate.FHIRDate(
                    datetime.strftime(self.data['admission_dt'],
                                      '%Y-%m-%dT%H:%M:%S'))
                pat_encounter.period = enc_period
            if not pd.isna(self.data['discharge_dt']):
                enc_period.end = fhirdate.FHIRDate(
                    datetime.strftime(self.data['discharge_dt'],
                                      '%Y-%m-%dT%H:%M:%S'))
                pat_encounter.status = "finished"

            pat_encounter.extension = []
            if self.data['admission_reason']:
                admission_reason_obj = self._admission_reason_lookup(
                    self.data['admission_reason'])
                admission_reason_coding = mii_coding.Coding({
                    "system":
                    self.systems['admission_reason'],
                    "code":
                    self.data['admission_reason'],
                    "display":
                    admission_reason_obj[0]
                })
                admission_ext = extension.Extension({
                    "url":
                    self.systems['admission_reason_url'],
                    "valueCoding":
                    admission_reason_coding.as_json()
                })
                pat_encounter.extension.append(admission_ext)

            if self.data['discharge_reason']:
                discharge_reason_obj = self._discharge_reason_lookup(
                    self.data['discharge_reason'])
                discharge_reason_cc = mii_codeableconcept.CodeableConcept()
                discharge_reason_cc.coding = [
                    mii_coding.Coding({
                        "system":
                        self.systems['discharge_reason'],
                        "code":
                        self.data['discharge_reason'],
                        "display":
                        discharge_reason_obj[0]
                    })
                ]
                discharge_ext = extension.Extension({
                    "url":
                    self.systems['discharge_reason_url'],
                    "valueCodeableConcept":
                    discharge_reason_cc.as_json()
                })
                pat_encounter.extension.append(discharge_ext)

                discharge_dispo = mii_codeableconcept.CodeableConcept()
                discharge_dispo_sys = "http://terminology.hl7.org/CodeSystem/discharge-disposition"
                discharge_dispo.coding = [
                    mii_coding.Coding({
                        "system": discharge_dispo_sys,
                        "code": discharge_reason_obj[1],
                        "display": discharge_reason_obj[2]
                    })
                ]

                hospitalization_encounter = mii_encounter_verfall.EncounterHospitalization(
                )
                hospitalization_encounter.dischargeDisposition = discharge_dispo
                pat_encounter.hospitalization = hospitalization_encounter

            diagnosis_use = mii_codeableconcept.CodeableConcept()
            diag_use_sys = "http://terminology.hl7.org/CodeSystem/diagnosis-role"
            diagnosis_use.coding = [
                mii_coding.Coding({
                    "system": diag_use_sys,
                    "code": "billing"
                })
            ]

            if self.data['ranked_cond_ref']:
                pat_encounter.diagnosis = []
                for condition_ref in self.data['ranked_cond_ref']:
                    cond_diagnosis = mii_encounter_verfall.EncounterDiagnosis()
                    cond_diagnosis.condition = condition_ref[0]
                    cond_diagnosis.rank = condition_ref[1]
                    cond_diagnosis.use = diagnosis_use
                    pat_encounter.diagnosis.append(cond_diagnosis)

            enc_meta = meta.Meta()
            enc_meta.source = "#sap-ish"
            pat_encounter.meta = enc_meta

            return pat_encounter

        except KeyError as exc:
            self.logger.error(
                f"In {__name__}: Key {exc} not found in dictionary")
            raise
    def map(self):
        try:
            id_value = str(
                self.data['result_id']
            )  #2sha256(self.data['concat_elements'].encode('utf-8')).hexdigest()

            lab_observation = mii_observation.Observation()
            lab_observation.id = id_value
            identifier_type = mii_codeableconcept.CodeableConcept()
            identifier_type.coding = [
                mii_coding.Coding({
                    "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                    "code": "MR"
                })
            ]
            lab_observation.identifier = [
                mii_identifier.Identifier({
                    "system": self.systems['lab_id'],
                    "value": id_value,
                    "assigner": {
                        "reference": "Organization/1111"
                    },
                    "type": identifier_type.as_json()
                })
            ]
            ref = {"reference": f"Encounter/{self.data['encounter_psn']}"}
            lab_observation.encounter = fhirreference.FHIRReference(
                jsondict=ref)
            ref = {"reference": f"Patient/{self.data['patient_psn']}"}
            lab_observation.subject = fhirreference.FHIRReference(jsondict=ref)
            lab_observation.status = "final"

            if not pd.isna(self.data['collect_ts']):
                collect_ts_fhir = datetime.strftime(self.data['collect_ts'],
                                                    '%Y-%m-%dT%H:%M:%S')
                lab_observation.effectiveDateTime = fhirdate.FHIRDate(
                    collect_ts_fhir)

            if not pd.isna(self.data['value_num']):
                if (self.data['loinc_code']
                        and self.data['loinc_code'] != 'noLoinc'
                        and self.data['value_unit']):
                    if self.data['value_unit'] == '10E12/L':
                        self.data['value_unit'] = '10*6/uL'
                    elif self.data['value_unit'] == '10E9/L':
                        self.data['value_unit'] = '10*3/uL'
                    elif self.data['value_unit'] == 'mE/l':
                        self.data['value_unit'] = 'm[IU]/L'
                    elif (self.data['value_unit'] == 'ug/l'
                          or self.data['value_unit'] == 'µg/l'):
                        self.data['value_unit'] = 'ng/mL'

                    if self.loinc_url:
                        result = self._convert_loinc()
                        #print(f"{self.data['loinc_code']} {self.data['value_num']} {self.data['value_unit']}")
                        #print(result)

                        if result and isinstance(
                                result, list) and not 'error' in result[0]:
                            if result[0]['loinc'] and result[0][
                                    'value'] and result[0]['unit']:
                                self.data['loinc_code'] = result[0]['loinc']
                                self.data['value_num'] = result[0]['value']
                                self.data['value_unit'] = result[0]['unit']
                                self.data['value_unit'] = self.data[
                                    'value_unit'].replace("'", "''")
                    #else:
                    #  print(f"{self.data['loinc_code']} {self.data['value_num']} {self.data['value_unit']}")
                    #  print(result)

                if (self.data['value_comp'] == '!='
                        or self.data['value_comp'] == '='
                        or self.data['value_comp'] == '=='):
                    self.data['value_comp'] = None

                lab_quantity = mii_quantity.Quantity({
                    "value":
                    self.data['value_num'],
                    "unit":
                    self.data['value_unit'],
                    "comparator":
                    self.data['value_comp'],
                    "system":
                    "http://unitsofmeasure.org",
                    "code":
                    self.data['value_unit']
                })
                lab_observation.valueQuantity = lab_quantity
            elif self.data['value_text']:
                lab_observation.valueString = self.data['value_text']

            lab_code = codeableconcept.CodeableConcept()
            lab_code.coding = [
                coding.Coding({
                    "system": "http://loinc.org",
                    "code": self.data['loinc_code']
                })
            ]
            lab_observation.code = lab_code

            if not pd.isna(self.data['ref_high_num']) and not pd.isna(
                    self.data['ref_low_num']):
                reference_range = mii_observation.ObservationReferenceRange()
                reference_range.high = quantity.Quantity({
                    "value":
                    self.data['ref_high_num'],
                    "unit":
                    self.data['value_unit'],
                    "system":
                    "http://unitsofmeasure.org",
                    "code":
                    self.data['value_unit']
                })
                reference_range.low = quantity.Quantity({
                    "value":
                    self.data['ref_low_num'],
                    "unit":
                    self.data['value_unit'],
                    "system":
                    "http://unitsofmeasure.org",
                    "code":
                    self.data['value_unit']
                })
                lab_observation.referenceRange = [reference_range]

            lab_method = codeableconcept.CodeableConcept()
            lab_method.coding = [
                coding.Coding({
                    "system": "http://methodConcept",
                    "display": self.data['method']
                })
            ]
            lab_observation.method = lab_method

            lab_meta = meta.Meta()
            lab_meta.source = "#laboratory"
            lab_observation.meta = lab_meta

            lab_cat = mii_codeableconcept.CodeableConcept()
            lab_cat_sys = "http://terminology.hl7.org/CodeSystem/observation-category"
            lab_cat.coding = [
                mii_coding.Coding({
                    "system": lab_cat_sys,
                    "display": "Laboratory",
                    "code": "laboratory"
                })
            ]
            lab_observation.category = lab_cat

            #lab_annotation = annotation_model.Annotation({"text": note})
            #lab_observation.note = [lab_annotation]

            if self.data['int_flag']:
                if self.data['int_flag'] == "N":
                    int_flag_long = "Normal"
                elif self.data['int_flag'] == "L":
                    int_flag_long = "Low"
                elif self.data['int_flag'] == "H":
                    int_flag_long = "High"
                else:
                    int_flag_long = "Unknown"

                lab_interpretation = codeableconcept.CodeableConcept()
                lab_int_sys = "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation"
                lab_interpretation.coding = [
                    coding.Coding({
                        "system": lab_int_sys,
                        "code": self.data['int_flag'],
                        "display": int_flag_long
                    })
                ]
                lab_observation.interpretation = [lab_interpretation]

            return lab_observation
        except KeyError as exc:
            self.logger.error(
                f"In {__name__}: Key {exc} not found in dictionary")
            raise
        except FHIRValidationError:
            raise
    def map(self):
        try:
            id_value = str(self.data['encounter_psn']) + '_' + str(
                self.data['diagnosis_nr'])
            #sha256(self.data['concat_elements'].encode('utf-8')).hexdigest()

            icd_condition = mii_condition.Condition()
            icd_condition.id = id_value
            icd_condition.identifier = [
                identifier.Identifier({
                    "system": self.systems['condition_id'],
                    "value": id_value
                })
            ]

            clinic_status = codeableconcept.CodeableConcept()
            clinic_status.coding = [
                coding.Coding({
                    "system":
                    "http://terminology.hl7.org/CodeSystem/condition-clinical",
                    "code": "active"
                })
            ]
            icd_condition.clinicalStatus = clinic_status

            full_code = self.data['code']
            if self.data['sec_code']:
                full_code = self.data['code'] + " " + self.data['sec_code']
            condition_coding = mii_coding.Coding()
            condition_coding.system = "http://fhir.de/CodeSystem/dimdi/icd-10-gm"
            condition_coding.code = full_code
            condition_coding.version = self.data['code_ver']

            if self.data['sec_code']:
                main_cross_ext = extension.Extension()
                main_cross_ext.url = "http://fhir.de/StructureDefinition/icd-10-gm-haupt-kreuz"
                main_cross_ext.valueCoding = coding.Coding({
                    "system":
                    condition_coding.system,
                    "version":
                    self.data['code_ver'],
                    "code":
                    re.sub(r"[+†]", "", self.data['code'])
                })
                condition_coding.extension = [main_cross_ext]

                if '!' in self.data['sec_code']:
                    excl_ext = extension.Extension()
                    excl_ext.url = "http://fhir.de/StructureDefinition/icd-10-gm-ausrufezeichen"
                    excl_ext.valueCoding = coding.Coding({
                        "system":
                        condition_coding.system,
                        "version":
                        self.data['code_ver'],
                        "code":
                        re.sub(r"!", "", self.data['sec_code'])
                    })
                    condition_coding.extension.append(excl_ext)

                if '*' in self.data['sec_code']:
                    star_ext = extension.Extension()
                    star_ext.url = "http://fhir.de/StructureDefinition/icd-10-gm-stern"
                    star_ext.valueCoding = coding.Coding({
                        "system":
                        condition_coding.system,
                        "version":
                        self.data['code_ver'],
                        "code":
                        re.sub(r"\*", "", self.data['sec_code'])
                    })
                    condition_coding.extension.append(star_ext)

            condition_code = mii_codeableconcept.CodeableConcept()
            condition_code.coding = [condition_coding]
            icd_condition.code = condition_code

            # todo: what value of the data mart should be mapped?
            icd_condition.onsetString = '2002-01-01'

            ref = {"reference": f"Encounter/{self.data['encounter_psn']}"}
            icd_condition.encounter = fhirreference.FHIRReference(jsondict=ref)
            ref = {"reference": f"Patient/{self.data['patient_psn']}"}
            icd_condition.subject = fhirreference.FHIRReference(jsondict=ref)

            if not pd.isna(self.data['admission_dt']):
                icd_condition.recordedDate = fhirdate.FHIRDate(
                    datetime.strftime(self.data['admission_dt'],
                                      '%Y-%m-%dT%H:%M:%S'))

            if self.data['loc']:
                icd_condition.bodySite = []
                if self.data['loc'] == "L" or self.data['loc'] == "B":
                    left_body_part = mii_codeableconcept.CodeableConcept()
                    icd_loc_sys = "http://fhir.de/CodeSystem/kbv/s_icd_seitenlokalisation"
                    left_body_part.coding = [
                        mii_coding.Coding({
                            "system": icd_loc_sys,
                            "code": "L",
                            "display": "links"
                        })
                    ]
                    icd_condition.bodySite.append(left_body_part)

                if self.data['loc'] == "R" or self.data['loc'] == "B":
                    right_body_part = mii_codeableconcept.CodeableConcept()
                    icd_loc_sys = "http://fhir.de/CodeSystem/kbv/s_icd_seitenlokalisation"
                    right_body_part.coding = [
                        mii_coding.Coding({
                            "system": icd_loc_sys,
                            "code": "R",
                            "display": "rechts"
                        })
                    ]
                    icd_condition.bodySite.append(right_body_part)

            rank = 2
            if self.data['diag_type'] == 1:
                rank = 1

            icd_meta = meta.Meta()
            icd_meta.source = "#sap-ish"
            icd_condition.meta = icd_meta

            return [icd_condition, rank]

        except KeyError as exc:
            self.logger.error(
                f"In {__name__}: Key {exc} not found in dictionary")
            raise
Example #6
0
    def map(self):
        try:
            inpatient = mii_patient.Patient()
            inpatient.id = self.data['patient_psn']
            identifier_type = mii_codeableconcept.CodeableConcept()
            identifier_type.coding = [
                mii_coding.Coding({
                    "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                    "code": "MR"
                })
            ]
            inpatient.identifier = [
                mii_identifier_pat.Identifier({
                    "use":
                    "official",
                    "system":
                    self.systems['patient_id'],
                    "value":
                    self.data['patient_psn'],
                    "assigner": {
                        "reference": "Organization/1111"
                    },
                    "type":
                    identifier_type.as_json()
                })
            ]

            if self.data['insurance_id']:
                insurance_id_type = mii_codeableconcept.CodeableConcept()
                insurance_type_sys = "http://fhir.de/CodeSystem/identifier-type-de-basis"
                insurance_id_type.coding = [
                    mii_coding.Coding({
                        "system":
                        insurance_type_sys,
                        "code":
                        "GKV",
                        "display":
                        "Gesetzliche Krankenversicherung"
                    })
                ]
                gkv_sys = "http://fhir.de/NamingSystem/gkv/kvid-10"
                identifier_type.coding = [
                    mii_coding.Coding({
                        "system":
                        "http://fhir.de/CodeSystem/identifier-type-de-basi",
                        "code": "GKV"
                    })
                ]
                inpatient.identifier.append(
                    mii_identifier_pat.Identifier({
                        "use":
                        "official",
                        "system":
                        gkv_sys,
                        "type":
                        insurance_id_type.as_json(),
                        "value":
                        self.data['insurance_id'],
                        "assigner": {
                            "reference": "Organization/1111"
                        }
                    }))

            if self.data['gender'] == 'm':
                gender_code = "male"
            elif self.data['gender'] == 'w':
                gender_code = "female"
            elif self.data['gender'] == 'x':
                gender_code = "other"
            else:
                gender_code = "unknown"
            inpatient.gender = gender_code

            inpatient.birthDate = fhirdate.FHIRDate(
                str(self.data['birth_date']))

            inpatient.deceasedBoolean = False
            if self.data['deceased_flag']:
                inpatient.deceasedBoolean = True

            inpatient.address = mii_address.Address({
                "city":
                self.data['city'],
                "postalCode":
                self.data['postal_code'],
                "line":
                self.data['street'],
                "country":
                self.data['country'],
                "type":
                ""
            })

            inpatient.name = [
                mii_humanname.HumanName({
                    "use": 'official',
                    "family": self.data['family_name'],
                    "given": [self.data['given_name']]
                })
            ]

            pat_meta = meta.Meta()
            pat_meta.source = "#sap-ish"
            inpatient.meta = pat_meta

            return inpatient

        except KeyError as exc:
            self.logger.error(
                f"In {__name__}: Key {exc} not found in dictionary")
            raise