Skip to content

Commit

Permalink
Merge pull request #6 from vitorpamplona/main
Browse files Browse the repository at this point in the history
Fixes for the DVCLMToIPS map
  • Loading branch information
ritikarawlani authored Sep 24, 2024
2 parents a13264f + ac8c2a8 commit 77ee14e
Showing 1 changed file with 38 additions and 26 deletions.
64 changes: 38 additions & 26 deletions input/maps/DVCLMToIPS.map
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,27 @@ uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias IPS as target
group DVCLMToIPS(source lm : DVCLogicalModel, target ips : IPS) {
lm -> ips.type = 'document' "setIPSType";
lm -> uuid() as bid, ips.identifier as id, id.value = bid, id.system = "urn:oid:2.16.724.4.8.10.200.10" "setId";
lm -> (now()) as timestamp,uuid() as cid, uuid() as pid, uuid() as mid, uuid() as aid, uuid() as proid, uuid() as immid then {
lm -> ips.timestamp = timestamp "setBundleTimestamp";
lm -> uuid() as cid, uuid() as pid, uuid() as mid, uuid() as aid, uuid() as proid, uuid() as immid then {
lm -> ips.entry as entry, entry.resource = create('Composition') as composition, entry.fullUrl = append('urn:uuid:', cid) then {
lm -> lm then LmToComposition(lm, ips, composition, timestamp,cid, pid, mid, aid, proid, immid ) "set";
lm then LmToComposition(lm, ips, composition, cid, pid, mid, aid, proid, immid ) "set LmToComposition";
lm -> ips.entry as entry, entry.fullUrl = append('urn:uuid:', pid), create('Patient') as patient then {
lm -> lm then DemographicsToPatient(lm, patient, pid) "createPatient";
lm then DemographicsToPatient(lm, patient, pid) "createPatient";
lm -> entry.resource = patient "setPatientEntry";
} "mapPatientResource";
lm.issuer as issuer then {
issuer.reference as id -> ips.entry as entry, entry.fullUrl = append('urn:uuid:', id), create('Organization') as organization then {
lm -> organization then createAuthor(issuer, organization) "createOrganization";
lm -> entry.resource = organization "setOrganizationEntry";
} "mapOrganizationResource";
} "mapOrganizationResource";
} "ss";
} "mapCompositionResource";
} "setEntries" ;
}

// create Composition
group LmToComposition(source lm : DVCLogicalModel, target ips : Bundle, target composition : Composition,source timestamp, source cid, source pid, source mid, source aid, source proid, source immid) {
group LmToComposition(source lm : DVCLogicalModel, target ips : Bundle, target composition : Composition, source cid, source pid, source mid, source aid, source proid, source immid) {
cid -> composition.id = cid "setCid";
lm -> composition.status = "final" "setStatus";
timestamp -> composition.date = timestamp "setCompositionDate";
lm -> composition.title = "International Patient Summary" "setTitle";
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";
lm -> composition.subject as subject then {
Expand All @@ -49,15 +47,24 @@ group LmToComposition(source lm : DVCLogicalModel, target ips : Bundle, target c
// create Patient
group DemographicsToPatient(source lm:DVCLogicalModel , target patient: Patient, source pid) {
pid -> patient.id = pid "setPatientId";
lm.name as sourceName -> patient.name as targetName then {
sourceName -> sourceName then humanNameToHumanName(sourceName, targetName) "CopyName";
} "Setname";
lm.name as sourceName -> patient.name as targetName then nameToHumanName(sourceName, targetName) "Setname";
lm.dob as dob -> patient.birthDate = dob "setDateofBirth";
lm.sex as sex -> patient.gender = sex "setSex";
lm.sex as sex then ExtractGender(sex, patient) "Patient Gender";
//lm.sex as sex -> patient.gender = sex "setSex";
lm.nid as id -> patient.identifier as identifier, identifier.value = id "setNationalIdentifier";
lm.guardian as guardian -> patient.contact as parentContact, parentContact.name as parentName then {
guardian -> guardian then humanNameToHumanName(guardian, parentName) "copyName";
} "setGuardianName";
lm.guardian as guardian -> patient.contact as parentContact, parentContact.name as parentName then nameToHumanName(guardian, parentName) "setGuardianName";
}

// deals with short and case sensitive codes
group ExtractGender(source sex, target patient: Patient) {
sex where(sex = "M") -> patient.gender = "male" "set male";
sex where(sex = "F") -> patient.gender = "female" "set female";
sex where(sex = "m") -> patient.gender = "male" "set male";
sex where(sex = "f") -> patient.gender = "female" "set female";
sex where(sex = "Male") -> patient.gender = "male" "set male";
sex where(sex = "Female") -> patient.gender = "female" "set female";
sex where(sex = "male") -> patient.gender = "male" "set male";
sex where(sex = "female") -> patient.gender = "female" "set female";
}

// create author
Expand Down Expand Up @@ -94,14 +101,13 @@ lm -> create('Coding') as coding, coding.code = "unavailable", coding.system = "

// create sectionImmunizations
group createSectionImmunizations(source lm:DVCLogicalModel, target bundle: Bundle, target composition: Composition, source immid, source pid ) {
lm -> composition.section as imm then {
immid -> imm.id = immid "setImmunizationsId";
lm -> imm.title = "Immunizations Section" "setImmunizationTitle";
lm -> imm.text as text then generateNarrativeText(imm,text) "setText";
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";
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";
lm -> composition.section as imm then {
immid -> imm.id = immid "setImmunizationsId";
lm -> imm.title = "Immunizations Section" "setImmunizationTitle";
lm -> imm.text as text then generateNarrativeText(imm,text) "setText";
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";
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";
} "set";

}

group createImmunizationResource (source vax : vaccineDetails, target immunization : Immunization, source pid) {
Expand All @@ -111,31 +117,37 @@ group createImmunizationResource (source vax : vaccineDetails, target immunizati
vax.batchNo as batchNo -> immunization.lotNumber = batchNo "setBatchNo";
vax -> immunization.protocolApplied as protocol then {
vax.doseNumber as doseNo then {
doseNo.text as text -> protocol.doseNumber = text "setDoseNo";
doseNo.coding as coding then {
coding.code as code -> protocol.doseNumber = code "setDoseNo";
} "setDoseNo";
} "setDoseNo";
/* vax.disease as disease -> create('Coding') as coding, coding = disease, create('CodeableConcept') as code, code.coding = coding, protocol.targetDisease = code "setTargetDisease"; */
vax.disease as disease -> create('CodeableConcept') as code, code.coding = disease, protocol.targetDisease = code "setTargetDisease";
} "setProtocolApplied";
vax -> immunization.patient as subject, subject.reference = append('urn:uuid:',pid) "setSubject";

vax.manufacturerId as maId -> create('Reference') as maRef, maRef.identifier = maId, immunization.manufacturer = maRef "set Manufacturer";
}

//helper function
group generateNarrativeText(source src: Section, target text: string) {
src -> text.status = "empty" "setstatus";
src -> text.div = '<div xmlns="http://www.w3.org/1999/xhtml">Narrative not available</div>' "setdiv";
}

group nameToHumanName (source sourceName, target targetName: HumanName) {
sourceName as patientName -> targetName.text = patientName "Patient Name";
}

group humanNameToHumanName (source sourceName, target targetName: HumanName) {
sourceName.use as use -> targetName.use = use "CopyUse";
sourceName.text as text -> targetName.text = text "CopyText";
sourceName.family as family -> targetName.family = family "CopyFamily";
sourceName.given as given -> targetName.given = given "CopyGiven";
sourceName.prefix as prefix -> targetName.prefix = prefix "CopyPrefix";
sourceName.suffix as suffix -> targetName.suffix = suffix "CopySuffix";

// Copy the period using the previously defined group function
sourceName.period as sourcePeriod -> targetName.period as targetPeriod then {
sourcePeriod -> sourcePeriod then periodToPeriod(sourcePeriod, targetPeriod) "CopyPeriod";
sourcePeriod then periodToPeriod(sourcePeriod, targetPeriod) "CopyPeriod";
} "copyPeriod";
}

Expand Down

0 comments on commit 77ee14e

Please sign in to comment.