Generated Narrative: StructureMap ConsenttoSGHI5 #xD; /// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ConsenttoSGHI5'#xD; /// name = 'ConsenttoSGHI5'#xD; /// title = 'Consent Transforms: R4 → SGHI R5'#xD; /// status = 'active'#xD; #xD; uses "http://hl7.org/fhir/4.0/StructureDefinition/Consent" alias ConsentR4 as source#xD; uses "https://fhir.slade360.co.ke/fhir/StructureDefinition/consent" alias SGHIConsent as target#xD; #xD; imports "http://hl7.org/fhir/StructureMap/*4to5"#xD; #xD; group SGHIConsent(source src : ConsentR4, target tgt : SGHIConsent) extends DomainResource <<type+>> {#xD; src.id -> tgt.id;#xD; src.active -> tgt.active = 'true';#xD; src.language -> tgt.language;#xD; src where text.exists().not() -> tgt.text = create('Narrative') as tgt_n then {#xD; src -> tgt_n.status = 'generated' "settextstatus";#xD; src -> tgt_n.div = ' Generated text ' "settextdiv";#xD; } "createhardcodedtext";#xD; src.text as st -> tgt.text as tt then {#xD; st.status -> tt.status;#xD; st.div -> tt.div;#xD; };#xD; src as sc where identifier.exists().not() -> tgt.identifier = create('Identifier') as tt_id then {#xD; src.id as uuid -> tt_id.value = uuid "creating id";#xD; src -> tt_id.use = 'official' "creating use";#xD; src -> tt_id.type as ty then {#xD; src -> ty.coding = create('CodeableConcept') as ty_c then {#xD; src -> ty_c.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/identifier-codesystem' "creating coding";#xD; src -> ty_c.code = 'fhir-id' "creating code";#xD; src -> ty_c.display = 'FHIR Id' "creating display";#xD; } "creating identifier type";#xD; src -> tt_id.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/identifier-codesystem' "creating system";#xD; src.meta as sm then {#xD; sm.tag first as sm -> tt_id.assigner = create('Reference') as t_assigner then TransformAssigner(sm, t_assigner);#xD; } "setting owner"; // creating identifier assigner#xD; } "setting identifier type";#xD; } "setting identifier"; // Create identifier#xD; src.meta as s_meta -> tgt.meta as t_meta then {#xD; s_meta.lastUpdated -> t_meta.lastUpdated;#xD; s_meta.language -> t_meta.language;#xD; s_meta.tags -> t_meta.tags;#xD; src.meta where profile.exists().not() -> t_meta.profile = 'https://fhir.slade360.co.ke/fhir/StructureDefinition/consent' "setprofileinmeta";#xD; } "set profile in meta";#xD; src.status -> tgt.status;#xD; src.category as sc -> tgt.category as tc then TransformCoding(sc, tc);#xD; src.patient as sp -> tgt.subject as tp then TransformReference(sp, tp); // Patient has been translated to subject in R5#xD; src.dateTime -> tgt.date;#xD; src.provision as spr -> tgt.provision as tpr then {#xD; spr.data as sd -> tpr.data as td then {#xD; sd.meaning -> td.meaning;#xD; sd.reference as sf -> td.reference as tf then TransformReference(sf, tf);#xD; };#xD; };#xD; src.performer as sp where performer.exists() -> tgt.grantee as tp then TransformReference(sp, tp); // Performer has been translated to grantee in R5#xD; src where performer.exists().not() then {#xD; src.patient as sp -> tgt.grantee as tp then TransformReference(sp, tp);#xD; src.patient as sp -> tgt.grantor as tp then TransformReference(sp, tp);#xD; } "populating grantee with patient details"; // Handles cases where performer does not exists in legacy R4 data#xD; src.organization as so where organization.exists() -> tgt.manager as tm then TransformReference(so, tm); // handles cases where organization exists in legacy R4 data#xD; src.organization as so where organization.exists() -> tgt.controller as tm then TransformReference(so, tm);#xD; src where organization.exists().not() then {#xD; src.meta as sm then {#xD; sm.tag first as st -> tgt.manager as tp then TransformAssigner(st, tp);#xD; sm.tag first as st -> tgt.controller as tp then TransformAssigner(st, tp);#xD; };#xD; } "setting manager and controller"; // handles cases where organization does not exists in legacy R4 data#xD; src.policyRule as sr where text.exists() -> tgt.regulatoryBasis = create('CodeableConcept') as tr then {#xD; sr.text -> tr.text;#xD; src -> tr.coding = create('Coding') as tcc, tcc.system = 'https://hl7.org/fhir/R4/codesystem-consent-policy.html', tcc.code = 'cric', tcc.display = 'Common Rule Informed Consent' "setting coding";#xD; } "setting rule policy"; // Policyrule has been translated to regulatoryBasis in R4#xD; src where verification.exists().not() -> tgt.verification = create('BackboneElement') as tb then {#xD; src -> tb.verified = 'true' "setting verified status";#xD; src -> tb.verificationDate = '2025-06-16' "setting verification date";#xD; src.meta as sm then {#xD; sm.tag last as st -> tb.verifiedBy = create('Reference') as tf then {#xD; st.code as org -> tf.reference = append('Organization/', org);#xD; st.display -> tf.display;#xD; st.display where display.exists().not() -> tf.display = 'Unknown display';#xD; st.code -> tf.id;#xD; } "setting verified by";#xD; } "setting verify by";#xD; src.patient as sp -> tb.verifiedWith = create('Reference') as trf then TransformReference(sp, trf) "setting reference";#xD; } "setting verification";#xD; src.category as sc -> tgt.category as tc then {#xD; sc.text -> tc.text;#xD; sc.coding as scc -> tc.coding as tcc then TransformCoding(scc, tcc);#xD; };#xD; src.provision as sp then {#xD; sp.type -> tgt.decision;#xD; };#xD; src.dateTime as sdt where dateTime.exists() -> tgt.date = sdt;#xD; src -> tgt.date = '2025-06-16' "setting consent date";#xD; }#xD; #xD; group TransformAssigner(source src, target tgt) <<types>> {#xD; src.code as code -> tgt.reference = append('Organization/', code);#xD; src where display.exists().not() -> tgt.display = 'Unknown display' "setting default display";#xD; src.display -> tgt.display;#xD; src.code -> tgt.id;#xD; }#xD; #xD; group TransformReference(source src, target tgt) <<types>> {#xD; src.id -> tgt.id;#xD; src.reference -> tgt.reference;#xD; src.display -> tgt.display;#xD; src where display.exists().not() -> tgt.display = 'Unknown display' "setting display";#xD; }#xD; #xD; group TransformCoding(source src, target tgt) <<types>> {#xD; src.system -> tgt.system;#xD; src.code -> tgt.code;#xD; src.display -> tgt.display;#xD; }#xD; #xD;
Generated text
Patient has been translated to subject in R5
Performer has been translated to grantee in R5
Handles cases where performer does not exists in legacy R4 data
handles cases where organization exists in legacy R4 data
handles cases where organization does not exists in legacy R4 data
Policyrule has been translated to regulatoryBasis in R4