Generated Narrative: StructureMap DIVOCtoDDCC #xD; map "http://smart.who.int/ddcc/StructureMap/CertDIVOCtoDDCC" = "DIVOCtoDDCC"#xD; #xD; uses "http://smart.who.int/ddcc/StructureDefinition/CertDIVOC" alias W3CVC as source#xD; uses "http://hl7.org/fhir/ig/divoc/StructureDefinition/CredentialSubject" alias CredentialSubject as source#xD; uses "http://hl7.org/fhir/ig/divoc/StructureDefinition/Proof" alias Proof as source#xD; uses "http://hl7.org/fhir/ig/divoc/StructureDefinition/Address" alias Address as source#xD; uses "http://hl7.org/fhir/ig/divoc/StructureDefinition/Evidence" alias Evidence as source#xD; uses "http://hl7.org/fhir/ig/divoc/StructureDefinition/Verifier" alias Verifier as source#xD; uses "http://hl7.org/fhir/ig/divoc/StructureDefinition/Facility" alias Facility as source#xD; uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target#xD; #xD; group DIVOCtoDDCC(source src : W3CVC, target bundle : Bundle) {#xD; src -> bundle.type = 'transaction' "set bundle type";#xD; src -> bundle, bundle.entry as entry, entry.resource = create('Composition') as comp then {#xD; src -> bundle then ExtractCert(src, bundle, comp) "Certificate";#xD; src -> bundle then ExtractComposition(src, comp) "Composition";#xD; } "Patient and Composition Create";#xD; }#xD; #xD; group ExtractCert(source src : W3CVC, target bundle : Bundle, target comp : Composition) {#xD; src -> comp, bundle.entry as entry, entry.resource = create('Patient') as patient, uuid() as pid then {#xD; src -> patient then ExtractPatient(src, pid, patient) "extract patient";#xD; src -> comp.subject as subj, subj.reference = append('Patient/', pid) "Set patient";#xD; src where (src.evidence.count() > 0) -> comp.section as section then {#xD; src -> section.code as code, code.coding as coding, coding.system = 'http://loinc.org', coding.code = '11369-6', coding.display = 'History of Immunization Narrative' "add section";#xD; src.evidence as ev -> comp, bundle.entry as entryImm, entryImm.resource = create('Immunization') as immunization, uuid() as iid, bundle.entry as entryOrg, entryOrg.resource = create('Organization') as org, uuid() as oid, bundle.entry as entryManuf, entryOrg.resource = create('Organization') as manuf, uuid() as mid then {#xD; src -> immunization.id = iid "Immunization ID";#xD; src -> org.id = oid "Organization ID";#xD; src -> manuf.id = mid "Organization ID";#xD; src -> section.entry as entry, entry.reference = append('Immunization/', iid), section.author as author, author.reference = append('Organization/', oid) "add entry/author to section";#xD; src -> comp.author as author, author.reference = append('Organization/', oid) "Set org";#xD; src -> immunization.patient as subj, subj.reference = append('Patient/', pid) "Set patient";#xD; ev.facility as facility then {#xD; facility.name as name -> org.name = name "Set Organization name";#xD; };#xD; ev.manufacturer as manufName -> manuf.name = manufName "Set Manufacturer name";#xD; ev.verifier as practitioner then {#xD; practitioner.name as practName -> bundle.entry as entry, entry.resource = create('Practitioner') as practitioner, practitioner.id = uuid() as pracid, practitioner.name = create('HumanName') as humanName, humanName.text = practName, immunization.performer as performer, performer.actor as actor, actor.reference = append('Practitioner/', pracid) "set pract name";#xD; } "create practitioner";#xD; src -> bundle then ExtractVaccine(ev, oid, mid, immunization, bundle) "extract vaccine info";#xD; } "Immunization Create";#xD; } "Vaccination List";#xD; } "Patient Create";#xD; }#xD; #xD; group ExtractVaccine(source ev : Evidence, source oid, source mid, target immunization : Immunization, target bundle : Bundle) {#xD; ev.date as dt -> immunization.occurrence = dt "set occurrence date";#xD; ev.batch as lot -> immunization.lotNumber = lot "set lot number";#xD; ev.icd11Code as icd11Code then {#xD; ev.prophylaxis as prophylaxis -> immunization.vaccineCode as type, type.coding as coding, coding.system = 'http://hl7.org/fhir/sid/icd-11', coding.code = icd11Code, coding.display = prophylaxis "set vaccine coding";#xD; } "Parse ICD11Code and Prophylaxis";#xD; ev.certificateId as ci -> immunization.identifier as identif, identif.value = ci "set identifier ci";#xD; ev.vaccine as mp -> immunization.extension as ext, ext.value = create('Coding') as coding, ext.url = 'https://smart.who.int/ddcc/StructureDefinition/DDCCVaccineBrand', coding.display = mp "set brand";#xD; ev.facility as facility then {#xD; facility.address as address then {#xD; address.addressCountry as contry -> immunization.extension as ext, ext.value = create('Coding') as coding, ext.url = 'https://smart.who.int/ddcc/StructureDefinition/DDCCCountryOfVaccination', coding.code = contry, coding.system = 'urn:iso:std:iso:3166' "set country";#xD; };#xD; } "facility rule";#xD; ev.effectiveUntil as validFrom -> immunization.extension as ext, ext.value = validFrom, ext.url = 'https://smart.who.int/ddcc/StructureDefinition/DDCCVaccineValidFrom' "effectiveUntil rule";#xD; oid -> immunization.manufacturer as manuf, manuf.reference = append('Organization/', oid) "set manuf";#xD; ev.facility as w3cFacility -> bundle.entry as entry, entry.resource = create('Location') as location, location.id = uuid() as locid, immunization.location as loc, loc.reference = append('Location/', locid) then ExtractLocation(w3cFacility, location) "Extracting Immunization Location";#xD; ev -> immunization.protocolApplied as protocolApplied then ExtractProtocolApplied(ev, oid, protocolApplied) "set protocol applied";#xD; }#xD; #xD; group ExtractProtocolApplied(source ev : Evidence, source oid, target protocol : ProtocolApplied) {#xD; ev.dose as dn -> protocol.doseNumber = dn "set dose number";#xD; ev.totalDoses as sd -> protocol.seriesDoses = sd "set series doses";#xD; ev -> protocol.targetDisease as codeable, codeable.coding as coding, coding.system = 'http://snomed.info/sct', coding.code = '840539006' "set target disease type";#xD; ev -> protocol.authority as authority, authority.reference = append('Organization/', oid) "set authority";#xD; }#xD; #xD; group ExtractPatient(source src : W3CVC, source pid, target patient : Patient) {#xD; pid -> patient.id = pid "Patient ID";#xD; src.credentialSubject as credentialSubject -> patient then ExtractPatientFromSubj(credentialSubject, patient) "Patient Data from Subj";#xD; src.credentialSubject as credSubj then {#xD; src.issuanceDate as issuanceDate then {#xD; credSubj.age as age -> patient.birthDate = evaluate(issuanceDate, (($this - age).toString().substring(0, 4))) "set age";#xD; } "set age issuance date";#xD; } "set cred age";#xD; }#xD; #xD; group ExtractPatientFromSubj(source src : CredentialSubject, target patient : Patient) {#xD; src.name as patientName -> patient.name = create('HumanName') as humanName, humanName.text = patientName "Patient Name";#xD; src.id as id -> patient.identifier as identif, identif.value = id "set patient identifier";#xD; src.dob as birthDate -> patient.birthDate = birthDate "set birthDate";#xD; src.gender as gender -> patient then ExtractGender(gender, patient) "Extract Gender";#xD; src.sex as sex -> patient then ExtractGender(sex, patient) "Extract Sex";#xD; src.address as w3cAddress -> patient.address as fhirAddress then ExtractAddress(w3cAddress, fhirAddress) "Extracting Patient Address";#xD; }#xD; #xD; group ExtractLocation(source facility : Facility, target location : Address) {#xD; facility.name as name -> location.name = name "facility name";#xD; facility.address as w3cAddress -> location.address as fhirAddress then ExtractAddress(w3cAddress, fhirAddress) "facility address";#xD; }#xD; #xD; group ExtractAddress(source w3cAddress : Address, target fhirAddress : Address) {#xD; w3cAddress.streetAddress as line1 -> fhirAddress.line = line1 "Line 1";#xD; w3cAddress.streetAddress2 as line2 -> fhirAddress.line = line2 "Line 2";#xD; w3cAddress.city as city -> fhirAddress.city = city "City";#xD; w3cAddress.district as district -> fhirAddress.district = district "District";#xD; w3cAddress.postalCode as postal -> fhirAddress.postalCode = postal "Postal";#xD; w3cAddress.addressRegion as region -> fhirAddress.state = region "Region";#xD; w3cAddress.addressCountry as country -> fhirAddress.country = country "Country";#xD; }#xD; #xD; group ExtractGender(source gender, target patient : Patient) {#xD; gender where (gender = 'M') -> patient.gender = 'male' "set male";#xD; gender where (gender = 'F') -> patient.gender = 'female' "set female";#xD; gender where (gender = 'Male') -> patient.gender = 'male' "set male";#xD; gender where (gender = 'Female') -> patient.gender = 'female' "set female";#xD; }#xD; #xD; group ExtractComposition(source src : W3CVC, target composition : Composition) {#xD; src -> composition.title = 'International Certificate of Vaccination or Prophylaxis' "Title";#xD; src -> composition.category as category, category.coding as coding then {#xD; src -> coding.code = 'ddcc-vs' "Category";#xD; } "set category";#xD; src -> composition.type as type, type.coding as coding then {#xD; src -> coding.system = 'http://loinc.org', coding.code = '82593-5', coding.display = 'Immunization summary report' "set type coding";#xD; } "set type";#xD; src -> composition.event as event, event.period = create('Period') as period then ExtractPeriod(src, period) "Extract Period";#xD; src.credentialSubject as credentialSubject -> composition then {#xD; credentialSubject.refId as refId -> composition.identifier as identif, identif.value = refId "set comp identifier";#xD; } "set comp identifier parent";#xD; }#xD; #xD; group ExtractPeriod(source src : W3CVC, target tgt : Period) {#xD; src.issuanceDate as issuanceDate -> tgt.start = issuanceDate "Start issuedAt";#xD; }#xD; #xD;
(($this - age).toString().substring(0, 4))
International Certificate of Vaccination or Prophylaxis