Stream: implementers
Topic: FHIR Mapping Language - FHIRPath expressions for source?
Oliver Egger (Jan 16 2019 at 22:18):
During the FHIR SDC Connectathon track I tried to extract information from a QuestionnaireResponses to a Patient. QuestonnaireResponse has the answerValues in different (potential) nested items which can be referenced by linkId as one approach.
To create one HumanName datatype with family and given of the patient I constructed a rule that two source variables are created and the target is the HumanName (otherwise I get two HumanName elements):
group item(source src, target tgt: Patient) { src.item as itemFirstName where linkId.value in ('patient.firstname'), src.item as itemLastName where linkId.value in ('patient.lastname') -> tgt.name = create('HumanName') as hn then setName(itemFirstName, itemLastName, hn) "Setting Names"; }
To execute the rules I grouped over the items
group QuestionnaireResponse(source src : QuestionnaireResponse, target tgt : Patient) { src.item as item -> tgt as patient then item(item, patient); }
However this approach works only when all items are on the same level, if the answers are in different nested item levels this does not work. The only solution I came up with is to introduce a FHIRPath rule on the source element like this (not specified in the FHIR Mapping language):
group QuestionnaireResponse(source src : QuestionnaireResponse, target tgt : Patient) { (src.descendants().select(item.where(linkId.value in ('patient.firstname')))) as itemFirstName, (src.descendants().select(item.where(linkId.value in ('patient.lastname')))) as itemLastName -> tgt.name = create('HumanName') as hn then setName(itemFirstName, itemLastName, hn) "Setting Names"; }
- is there a more elegant approach to map nested QuestionaireResponse items to FHIR resources?
- would introducing of a FHIRPath expression in the FHIR Mapping language conflict with the general FHIR Mapping language approach?
any feedback, samples more than welcome, will show up at 6pm ...
qr2pat9.map qr.json
Grahame Grieve (Jan 16 2019 at 22:39):
this is what we'll discuss at 6pm tonight
Grahame Grieve (Jan 17 2019 at 00:19):
here is what I think the map is:
Grahame Grieve (Jan 17 2019 at 00:19):
map "http://ahdis.ch/fhir/mappingtutorial/qr2pat9" = "mapping tutorial questionnairetopat" uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target group entry(source src : QuestionnaireResponse, target tgt : Patient) { src.item as i then qri1(i, tgt); } group gri1(source src, target tgt) { src.item as i then qrgg1(i, tgt); src.item as ln where item.linkId = 'patient.lastname' -> tgt.name as t share then familyName(ln, t); src.item as ln where item.linkId = 'patient.firstname' -> tgt.name as t share then firstName(ln, t); } group familyName(source src, target tgt) { src.answer as a familyName2(a, tgt); } group familyName2(source src, target tgt) { src.valueString -> tgt.family; } group firstName(source src, target tgt) { src.answer as a then firstName2(a, tgt); } group firstName2(source src, target tgt) { src.valueString -> tgt.given; }
Last updated: Apr 12 2022 at 19:14 UTC