Generated Narrative: StructureMap ICVPLMToIPS #xD; map "http://smart.who.int/icvp/StructureMap/ICVPLMToIPS" = "ICVPLMToIPS"#xD; #xD; uses "http://smart.who.int/icvp/StructureDefinition/ICVP" alias ICVPLogicalModel as source#xD; uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias IPS as target#xD; #xD; // uses "http://smart.who.int/icvp/ConceptMap/ICVPProductIdToVaccineType" alias ICVPProductIdToVaccineType as conceptmap#xD; // create Bundle#xD; group ICVPLMToIPS(source lm : ICVPLogicalModel, target ips : IPS) {#xD; lm -> ips.type = 'document' "setIPSType";#xD; lm -> uuid() as bid, ips.identifier as id, id.value = bid, id.system = 'urn:oid:2.16.724.4.8.10.200.10' "setId";#xD; lm -> uuid() as cid, uuid() as pid, uuid() as mid, uuid() as aid, uuid() as proid, uuid() as immid then {#xD; lm -> ips.entry as entry, entry.resource = create('Composition') as composition, entry.fullUrl = append('urn:uuid:', cid) then {#xD; lm then LmToComposition(lm, ips, composition, cid, pid, mid, aid, proid, immid) "setLmToComposition";#xD; lm -> ips.entry as entry, entry.fullUrl = append('urn:uuid:', pid), create('Patient') as patient then {#xD; lm then DemographicsToPatient(lm, patient, pid) "createPatient";#xD; lm -> entry.resource = patient "setPatientEntry";#xD; } "mapPatientResource";#xD; lm.issuer as issuer then {#xD; issuer.reference as id -> ips.entry as entry, entry.fullUrl = append('urn:uuid:', id), create('Organization') as organization then {#xD; lm -> organization then createAuthor(issuer, organization) "createOrganization";#xD; lm -> entry.resource = organization "setOrganizationEntry";#xD; } "mapOrganizationResource";#xD; } "ss";#xD; } "mapCompositionResource";#xD; } "setEntries";#xD; }#xD; #xD; // create Composition#xD; group LmToComposition(source lm : ICVPLogicalModel, target ips : Bundle, target composition : Composition, source cid, source pid, source mid, source aid, source proid, source immid) {#xD; cid -> composition.id = cid "setCid";#xD; lm -> composition.status = 'final' "setStatus";#xD; lm -> composition.title = 'International Patient Summary' "setTitle";#xD; lm -> create('Coding') as coding, coding.code = '60591-5', coding.system = 'http://loinc.org', create('CodeableConcept') as code, code.coding = coding, composition.type = code "setType";#xD; lm -> composition.subject as subject then {#xD; lm -> subject.reference = append('urn:uuid:', pid) "setSubject";#xD; } "setSubject";#xD; lm.issuer as issuer then {#xD; issuer.reference as id -> composition.author as author then {#xD; id -> author.reference = append('urn:uuid:', id) "setAuthor";#xD; } "setauthr";#xD; } "setid";#xD; lm -> composition.section as medication then createSectionMedications(lm, medication, mid) "createMedication";#xD; lm -> composition.section as allergies then createSectionAllergies(lm, allergies, aid) "createAllergies";#xD; lm -> composition.section as problems then createSectionProblems(lm, problems, proid) "createProblems";#xD; lm then createSectionImmunizations(lm, ips, composition, immid, pid) "createImmunizations";#xD; }#xD; #xD; // create Patient#xD; group DemographicsToPatient(source lm : ICVPLogicalModel, target patient : Patient, source pid) {#xD; pid -> patient.id = pid "setPatientId";#xD; lm.name as sourceName -> patient.name as targetName then nameToHumanName(sourceName, targetName) "Setname";#xD; lm.dob as dob -> patient.birthDate = dob "setDateofBirth";#xD; lm.sex as sex then ExtractGender(sex, patient) "PatientGender";#xD; // lm.sex as sex -> patient.gender = sex "setSex";#xD; lm.nid as id -> patient.identifier as identifier, identifier.value = id "setNationalIdentifier";#xD; lm.guardian as guardian -> patient.contact as parentContact, parentContact.name as parentName then nameToHumanName(guardian, parentName) "setGuardianName";#xD; }#xD; #xD; // deals with short and case sensitive codes#xD; group ExtractGender(source sex, target patient : Patient) {#xD; sex where (sex = 'M') -> patient.gender = 'male' "setMale";#xD; sex where (sex = 'F') -> patient.gender = 'female' "setFemale";#xD; sex where (sex = 'm') -> patient.gender = 'male' "setMale";#xD; sex where (sex = 'f') -> patient.gender = 'female' "setFemale";#xD; sex where (sex = 'Male') -> patient.gender = 'male' "setMale";#xD; sex where (sex = 'Female') -> patient.gender = 'female' "setFemale";#xD; sex where (sex = 'male') -> patient.gender = 'male' "setMale";#xD; sex where (sex = 'female') -> patient.gender = 'female' "setFemale";#xD; }#xD; #xD; // create author#xD; group createAuthor(source issuer, target org : Organization) {#xD; issuer.reference as id -> org.id = id "setID";#xD; }#xD; #xD; // create sectionMedications#xD; group createSectionMedications(source lm : ICVPLogicalModel, target med : BackboneElement, source mid) {#xD; mid -> med.id = mid "setmedicationid";#xD; lm -> med.title = 'Medication Summary Section' "setMedicationTitle";#xD; lm -> med.text as text then generateNarrativeText(med, text) "setText";#xD; lm -> create('Coding') as coding, coding.code = '10160-0', coding.system = 'http://loinc.org', create('CodeableConcept') as code, code.coding = coding, med.code = code "setCode";#xD; lm -> create('Coding') as coding, coding.code = 'unavailable', coding.system = 'http://terminology.hl7.org/CodeSystem/list-empty-reason', create('CodeableConcept') as code, code.coding = coding, med.emptyReason = code "setCode";#xD; }#xD; #xD; // create sectionAllergies#xD; group createSectionAllergies(source lm : ICVPLogicalModel, target all : BackboneElement, source aid) {#xD; aid -> all.id = aid "setAllergyId";#xD; lm -> all.title = 'Allergies Section' "setAllergyTitle";#xD; lm -> all.text as text then generateNarrativeText(all, text) "setText";#xD; lm -> create('Coding') as coding, coding.code = '48765-2', coding.system = 'http://loinc.org', create('CodeableConcept') as code, code.coding = coding, all.code = code "setCode";#xD; lm -> create('Coding') as coding, coding.code = 'unavailable', coding.system = 'http://terminology.hl7.org/CodeSystem/list-empty-reason', create('CodeableConcept') as code, code.coding = coding, all.emptyReason = code "setCode";#xD; }#xD; #xD; // create sectionProblems#xD; group createSectionProblems(source lm : ICVPLogicalModel, target prb : BackboneElement, source proid) {#xD; proid -> prb.id = proid "setProblemsId";#xD; lm -> prb.title = 'Problems Section' "setProblemTitle";#xD; lm -> prb.text as text then generateNarrativeText(prb, text) "setText";#xD; lm -> create('Coding') as coding, coding.code = '11450-4', coding.system = 'http://loinc.org', create('CodeableConcept') as code, code.coding = coding, prb.code = code "setCode";#xD; lm -> create('Coding') as coding, coding.code = 'unavailable', coding.system = 'http://terminology.hl7.org/CodeSystem/list-empty-reason', create('CodeableConcept') as code, code.coding = coding, prb.emptyReason = code "setCode";#xD; }#xD; #xD; // create sectionImmunizations#xD; group createSectionImmunizations(source lm : ICVPLogicalModel, target bundle : Bundle, target composition : Composition, source immid, source pid) {#xD; lm -> composition.section as imm then {#xD; immid -> imm.id = immid "setImmunizationsId";#xD; lm -> imm.title = 'Immunizations Section' "setImmunizationTitle";#xD; lm -> imm.text as text then generateNarrativeText(imm, text) "setText";#xD; lm -> create('Coding') as coding, coding.code = '11369-6', coding.system = 'http://loinc.org', create('CodeableConcept') as code, code.coding = coding, imm.code = code "setCode";#xD; lm.vaccineDetails as vax -> uuid() as id, bundle.entry as entry, entry.fullUrl = append('urn:uuid:', id), imm.entry as sectionEntry, sectionEntry.reference = append('urn:uuid:', id), entry.resource = create('Immunization') as immunization, immunization.id = id then createImmunizationResource(vax, immunization, pid) "setImmz";#xD; } "set";#xD; }#xD; #xD; group createImmunizationResource(source vax : vaccineDetails, target immunization : Immunization, source pid) {#xD; vax -> immunization.status = 'completed' "setStatus";#xD; vax.productID as vaccine then {#xD; // Keep the original productID as-is in the extension#xD; vaccine -> immunization.extension as ext, ext.url = 'http://smart.who.int/pcmt/StructureDefinition/ProductID', ext.value = vaccine "keepProductIdExt";#xD; // Normalize system just for translate(): CM source = .../PreQualProductIds (camel 'Ids')#xD; vaccine.code as pcode -> create('Coding') as src, src.system = 'http://smart.who.int/pcmt-vaxprequal/CodeSystem/PreQualProductIds', src.code = pcode, create('Coding') as vcoding, vcoding.system = 'http://smart.who.int/pcmt-vaxprequal/CodeSystem/PreQualVaccineType', vcoding.code = translate(src, 'http://smart.who.int/icvp/ConceptMap/ICVPProductIdToVaccineType', 'code'), create('CodeableConcept') as tgtVaccineCode, tgtVaccineCode.coding = vcoding, immunization.vaccineCode = tgtVaccineCode "mapVaxCode";#xD; } "setVaccine";#xD; vax.date as date -> immunization.occurrence = append(date, 'T00:00:00.000Z') "setDate";#xD; vax.batchNo as batchNo then {#xD; batchNo.text as text -> immunization.lotNumber = text "setBatchNoFromText";#xD; } "setBatchNo";#xD; vax -> immunization.protocolApplied as protocol then {#xD; vax.disease as disease -> create('CodeableConcept') as code, code.coding = disease, protocol.targetDisease = code "setTargetDisease";#xD; } "setProtocolApplied";#xD; vax -> immunization.patient as subject, subject.reference = append('urn:uuid:', pid) "setSubject";#xD; vax.manufacturerId as maId -> create('Reference') as maRef, maRef.identifier = maId, immunization.manufacturer = maRef "setManufacturer";#xD; }#xD; #xD; // helper function#xD; group generateNarrativeText(source src : Section, target text : string) {#xD; src -> text.status = 'empty' "setstatus";#xD; src -> text.div = ' Narrative not available ' "setdiv";#xD; }#xD; #xD; group nameToHumanName(source sourceName, target targetName : HumanName) {#xD; sourceName as patientName -> targetName.text = patientName "PatientName";#xD; }#xD; #xD; group humanNameToHumanName(source sourceName, target targetName : HumanName) {#xD; sourceName.use as use -> targetName.use = use "CopyUse";#xD; sourceName.text as text -> targetName.text = text "CopyText";#xD; sourceName.family as family -> targetName.family = family "CopyFamily";#xD; sourceName.given as given -> targetName.given = given "CopyGiven";#xD; sourceName.prefix as prefix -> targetName.prefix = prefix "CopyPrefix";#xD; sourceName.suffix as suffix -> targetName.suffix = suffix "CopySuffix";#xD; // Copy the period using the previously defined group function#xD; sourceName.period as sourcePeriod -> targetName.period as targetPeriod then {#xD; sourcePeriod then periodToPeriod(sourcePeriod, targetPeriod) "CopyPeriod";#xD; } "copyPeriod";#xD; }#xD; #xD; group periodToPeriod(source sourcePeriod, target targetPeriod : Period) {#xD; sourcePeriod.start as start -> targetPeriod.start = start "setPeriodStart";#xD; sourcePeriod.end as end -> targetPeriod.end = end "setPeriodEnd";#xD; }#xD; #xD;
uses "http://smart.who.int/icvp/ConceptMap/ICVPProductIdToVaccineType" alias ICVPProductIdToVaccineType as conceptmap create Bundle
deals with short and case sensitive codes
Narrative not available