Generated Narrative: StructureMap ServiceRequestSGHI5 #xD; /// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ServiceRequestSGHI5'#xD; /// name = 'ServiceRequestSGHI5'#xD; /// title = 'ServiceRequest Transforms: R4 → SGHI R5'#xD; /// status = 'active'#xD; #xD; uses "http://hl7.org/fhir/4.0/StructureDefinition/ServiceRequest" alias ServiceRequestR4 as source#xD; uses "https://fhir.slade360.co.ke/fhir/StructureDefinition/servicerequest" alias SGHIServiceRequest as target#xD; #xD; group SGHIServiceRequest(source src : ServiceRequestR4, target tgt : SGHIServiceRequest) <<type+>> {#xD; src.id as uuid -> tgt.id = uuid;#xD; src.active -> tgt.active = 'true';#xD; src.language as sl -> tgt.language = sl;#xD; src.authoredOn as sa -> tgt.authoredOn = sa;#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 -> tgt.text = create('Narrative') as ttt then {#xD; src.text as st then {#xD; st.status as s -> ttt.status = s;#xD; st.div as d -> ttt.div = (' ' + d + ' ') "wraptextinhtml";#xD; };#xD; } "setting text";#xD; src.id as s_id -> tgt.identifier = create('Identifier') as t_ident then {#xD; s_id as uuid -> t_ident.value = uuid "copyid";#xD; src -> t_ident.use = 'official' "setuse";#xD; src -> t_ident.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/identifier-codesystem' "setsystem";#xD; src -> t_ident.type = create('CodeableConcept') as t_type then {#xD; src -> t_type.coding = create('Coding') as t_code then {#xD; src -> t_code.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/identifier-codesystem' "typesystem";#xD; src -> t_code.code = 'fhir-id' "typecode";#xD; src -> t_code.display = 'FHIR Id' "typedisplay";#xD; } "initcoding";#xD; } "inittype";#xD; src.meta as sm then {#xD; sm.tag last as st -> t_ident.assigner = create('Reference') as ta then TransformAssigner(st, ta);#xD; } "setting owner";#xD; } "addfhirididentifier"; // Create identifier#xD; src.meta as s_meta -> tgt.meta as t_meta then {#xD; s_meta.lastUpdated as sl -> t_meta.lastUpdated = sl;#xD; s_meta.language as sl -> t_meta.language = sl;#xD; s_meta.tags as st -> t_meta.tags = st;#xD; src.meta as sp where profile.exists().not() -> t_meta.profile = 'https://fhir.slade360.co.ke/fhir/StructureDefinition/servicerequest' "setprofileinmeta";#xD; } "set profile in meta";#xD; src where status != 'finished' then {#xD; src.status as sd -> tgt.status = sd;#xD; } "coppying status";#xD; src where status = 'finished' -> tgt.status = 'completed' "settingR5status";#xD; src.dateTime as sd -> tgt.date = sd;#xD; src.basedOn as sb -> tgt.basedOn as tb then TransformReference(sb, tb);#xD; src.category as scat -> tgt.category as tcat then {#xD; scat.coding as d where d.system.exists().not() -> tcat.coding = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoFHIRCategoryCodeBindingsMap', 'Coding');#xD; scat.coding as d where d.system.exists() -> tcat.coding = create('Coding') as tcoding then {#xD; d.code as d -> tcoding.code = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoFHIRCategoryCodeBindingsMap', 'code');#xD; d.code as d -> tcoding.system = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoFHIRCategoryCodeBindingsMap', 'system');#xD; d.code as d -> tcoding.display = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoFHIRCategoryCodeBindingsMap', 'display');#xD; d.code as d -> tcat.text = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoFHIRCategoryCodeBindingsMap', 'display');#xD; };#xD; };#xD; src.encounter as se -> tgt.encounter as te then TransformReference(se, te);#xD; src.requester as sr -> tgt.requester as tr then TransformReference(sr, tr);#xD; src.subject as sbb -> tgt.subject as tbb then TransformReference(sbb, tbb);#xD; src.performer as sp -> tgt.performer as tp then TransformReference(sp, tp);#xD; src where performer.exists().not() then {#xD; src.meta as sm then {#xD; sm.tag last as sp -> tgt.performer = create('Reference') as tp then TransformAssigner(sp, tp);#xD; } "setting performer";#xD; } "settingperformer";#xD; src where requester.exists().not() then {#xD; src.meta as sm then {#xD; sm.tag last as sr -> tgt.requester = create('Reference') as tr then TransformAssigner(sr, tr);#xD; } "setting requester";#xD; } "settingrequester";#xD; src.priority as sp -> tgt.priority = sp;#xD; src.intent as sti -> tgt.intent = sti;#xD; src -> tgt.code = create('CodeableReference') as trf then {#xD; src.code as scc -> trf.concept = create('CodeableConcept') as tcc then TranslateCoding(scc, tcc);#xD; } "translate codeableConcept to CodeableReference in R5";#xD; src -> tgt.reason = create('CodeableReference') as tr then {#xD; src.code as scc -> tr.concept = create('CodeableConcept') as tcc then TranslateCoding(scc, tcc);#xD; } "setting reason";#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 as d -> tgt.display = d;#xD; src.code as dc -> tgt.id = dc;#xD; }#xD; #xD; group TransformReference(source src, target tgt) <<types>> {#xD; src.id as sid -> tgt.id = sid;#xD; src.reference as sf -> tgt.reference = sf;#xD; src.display as sd -> tgt.display = sd;#xD; src where display.exists().not() -> tgt.display = 'Unknown display' "setting display";#xD; }#xD; #xD; group TranslateCoding(source scc, target tcc) <<types>> {#xD; scc.coding as d where d.system.exists().not() -> tcc.coding = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoLOINCServiceRequestMap', 'Coding');#xD; scc.coding as scode where (scode.code = '1271').exists() and (scode.display = 'Pap smear/cytology') -> tcc.coding as tcode then {#xD; scode -> tcode.code = 'LA16047-5' "override code";#xD; scode.display as d -> tcode.display = d;#xD; scode -> tcode.system = 'http://loinc.org' "overriedsystem";#xD; };#xD; scc.coding as scode where (scode.code = '1271').exists() and (scode.display = 'HPV') -> tcc.coding as tcode then {#xD; scode -> tcode.code = 'LP14836-8' "override code";#xD; scode -> tcode.display = 'Human papilloma virus' "settinghpvdisplay";#xD; scode -> tcode.system = 'http://loinc.org' "overriedsystem";#xD; };#xD; scc.coding as scode where (scode.code = '1271').exists() and (scode.display = 'Mammogram') -> tcc.coding as tcode then {#xD; scode -> tcode.code = 'LA16046-7' "override code";#xD; scode.display as d -> tcode.display = d;#xD; scode -> tcode.system = 'http://loinc.org' "overriedsystem";#xD; };#xD; scc.coding as scode where (scode.code = '1271').exists() and (scode.display = 'VIA') -> tcc.coding as tcode then {#xD; scode -> tcode.code = 'LP404404-8' "override code";#xD; scode -> tcode.display = 'Screening techniques | Cervix or Vagina | Cytology' "settingdisplay";#xD; scode -> tcode.system = 'http://loinc.org' "overriedsystem";#xD; };#xD; scc.coding as scode where (scode.code = '1271').exists() and (scode.display = 'Biopsy') -> tcc.coding as tcode then {#xD; scode -> tcode.code = 'LA15393-4' "override code";#xD; scode -> tcode.display = 'Biopsy' "settingdisplay";#xD; scode -> tcode.system = 'http://loinc.org' "overriedsystem";#xD; };#xD; scc.coding as scode where (scode.code = '1271').exists() and (scode.display = 'Ultrasound') -> tcc.coding as tcode then {#xD; scode -> tcode.code = '24630-6' "override code";#xD; scode -> tcode.display = 'US Chest' "settingdisplay";#xD; scode -> tcode.system = 'http://loinc.org' "overriedsystem";#xD; };#xD; scc.coding as scode where (scode.code = '1271').exists() and (scode.display = 'MRI') -> tcc.coding as tcode then {#xD; scode -> tcode.code = '30794-2' "override code";#xD; scode -> tcode.display = 'MR Breast' "settingdisplay";#xD; scode -> tcode.system = 'http://loinc.org' "overriedsystem";#xD; };#xD; scc.coding as scode where (scode.code = '1271').exists() and (scode.display = 'Prostate Specific Antigen - Serum') -> tcc.coding as tcode then {#xD; scode -> tcode.code = '32465-7' "override code";#xD; scode -> tcode.display = 'Physical findings of Prostate' "settingdisplay";#xD; scode -> tcode.system = 'http://loinc.org' "overriedsystem";#xD; };#xD; scc.coding as scode where (scode.code = '1271').exists() and (scode.display = 'Prostate Specific Antigen - Whole Blood') -> tcc.coding as tcode then {#xD; scode -> tcode.code = 'LP15247-7' "override code";#xD; scode -> tcode.display = 'Whole Blood' "settingdisplay";#xD; scode -> tcode.system = 'http://loinc.org' "overriedsystem";#xD; };#xD; scc.coding as d where d.system.exists() -> tcc.coding = create('Coding') as tcoding then {#xD; d.code as d -> tcoding.code = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoLOINCServiceRequestMap', 'code');#xD; d.code as d -> tcoding.system = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoLOINCServiceRequestMap', 'system');#xD; d.code as d -> tcoding.display = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoLOINCServiceRequestMap', 'display');#xD; d.code as d -> tcoding.text = translate(d, 'https://fhir.slade360.co.ke/fhir/ConceptMap/CIELtoLOINCServiceRequestMap', 'display');#xD; };#xD; }#xD; #xD;
Generated text
translate codeableConcept to CodeableReference in R5
(scode.code = '1271').exists() and (scode.display = 'Pap smear/cytology')
(scode.code = '1271').exists() and (scode.display = 'HPV')
(scode.code = '1271').exists() and (scode.display = 'Mammogram')
(scode.code = '1271').exists() and (scode.display = 'VIA')
Screening techniques | Cervix or Vagina | Cytology
(scode.code = '1271').exists() and (scode.display = 'Biopsy')
(scode.code = '1271').exists() and (scode.display = 'Ultrasound')
(scode.code = '1271').exists() and (scode.display = 'MRI')
(scode.code = '1271').exists() and (scode.display = 'Prostate Specific Antigen - Serum')
(scode.code = '1271').exists() and (scode.display = 'Prostate Specific Antigen - Whole Blood')