|
| 1 | +map "http://smart.who.int/immunizations/StructureMap/IMMZCLMToPatient" = "IMMZCLMToPatient" |
| 2 | +// Immunization Client Registry - Transform Logical Model to Patient resources |
| 3 | + |
| 4 | +uses "http://smart.who.int/immunizations/StructureDefinition/IMMZCClientregistration" alias IMMZC as source |
| 5 | +uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target |
| 6 | +// uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as produced |
| 7 | +// uses "http://hl7.org/fhir/StructureDefinition/RelatedPerson" alias RelatedPerson as produced |
| 8 | + |
| 9 | +group IMMZCToPatient (source immzc : IMMZC, target bundle: Bundle) { |
| 10 | + |
| 11 | + immzc -> bundle.type = "transaction" "SetBundleType"; |
| 12 | + |
| 13 | + immzc -> uuid() as pid, |
| 14 | + bundle.entry as entry, |
| 15 | + entry.fullUrl = append("urn:uuid:", pid), |
| 16 | + entry.request as request, |
| 17 | + request.method = "PUT", |
| 18 | + request.url = append("Patient/", pid), |
| 19 | + entry.resource = create("Patient") as patient |
| 20 | + then { |
| 21 | + |
| 22 | + immzc -> patient.id = pid "SetId"; |
| 23 | + |
| 24 | + immzc.uniqueId as id -> patient.identifier as identifier then { |
| 25 | + id -> identifier.value = id "SetIdentifierValue"; |
| 26 | + } "SetIdentifier"; |
| 27 | + |
| 28 | + immzc -> patient.name as pname then { |
| 29 | + immzc.name as fullName -> pname.text = fullName "SetFullName"; |
| 30 | + immzc.firstName as firstName -> pname.given = firstName "SetFirstName"; |
| 31 | + immzc.familyName as familyName -> pname.family = familyName "SetFamilyName"; |
| 32 | + }"SetName"; |
| 33 | + |
| 34 | + immzc.sex as sex -> patient.gender = translate(sex, 'http://smart.who.int/immunizations/ConceptMap/IMMZ.C.ConceptMap', 'code') "SetGender"; |
| 35 | + |
| 36 | + immzc.dateOfBirth as birthDate -> patient.birthDate = birthDate "SetBirthDate"; |
| 37 | + |
| 38 | + immzc.contactPhoneNumber as phone -> patient.telecom as telecom then { |
| 39 | + phone as content -> telecom.value = content, telecom.system = 'phone' "SetPhoneValue"; |
| 40 | + } "SetPhone"; |
| 41 | + |
| 42 | + immzc.address as address -> patient.address as taddress then { |
| 43 | + address as content -> taddress.text = content "SetAddressText"; |
| 44 | + } "SetAddress"; |
| 45 | + |
| 46 | + immzc.caregiversMultiple as caregiver -> uuid() as rpid, |
| 47 | + bundle.entry as entry, |
| 48 | + entry.fullUrl = append("urn:uuid:", rpid), |
| 49 | + entry.request as request, |
| 50 | + request.method = "PUT", |
| 51 | + request.url = append("RelatedPerson/", rpid), |
| 52 | + entry.resource = create("RelatedPerson") as person |
| 53 | + then { |
| 54 | + caregiver -> person.id = rpid "SetId"; |
| 55 | + caregiver -> person.patient as patient, patient.reference = append("Patient/", pid ) "setPatient"; |
| 56 | + caregiver -> person.name as pname then { |
| 57 | + caregiver.caregiversFullName as fullName -> pname.text = fullName "SetFullName"; |
| 58 | + caregiver.caregiversFirstName as firstName -> pname.given = firstName "SetFirstName"; |
| 59 | + caregiver.caregiversFamilyName as familyName -> pname.family = familyName "SetFamilyName"; |
| 60 | + } "SetCaregiverName"; |
| 61 | + } "CreateRelatedPerson"; |
| 62 | + |
| 63 | + } "CreatePatient"; |
| 64 | + |
| 65 | +} |
0 commit comments