Structured Data Capture
4.0.0-ci-build - STU 4 CI-build International flag

Structured Data Capture, published by HL7 International / FHIR Infrastructure. This guide is not an authorized publication; it is the continuous build for version 4.0.0-ci-build built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/sdc/ and changes regularly. See the Directory of published versions

: QuestionnairePopulationTransform

Page standards status: Trial-use Maturity Level: 4

Raw ttl | Download

@prefix fhir: <http://hl7.org/fhir/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

<http://hl7.org/fhir/StructureMap/QuestionnairePopulationTransform> a fhir:StructureMap ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:Resource.id [ fhir:value "QuestionnairePopulationTransform"] ;
  fhir:Resource.language [ fhir:value "en"] ;
  fhir:DomainResource.text [
     fhir:Narrative.status [ fhir:value "additional" ] ;
     fhir:Narrative.div "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n      <pre>/// name = \"QuestionnairePopulationTransform\"\n/// status = \"active\"\n/// title = \"Questionnaire Population Transform Example\"\n/// description = \"An example of a StructureMap used to support population of a QuestionnaireResponse from a search bundle\"\n/// experimental = \"true\"\n\nmap \"http://hl7.org/fhir/uv/sdc/StructureMap/QuestionnairePopulationTransform\" = \"QuestionnairePopulationTransform\"\n\nuses 'http://hl7.org/fhir/StructureDefinition/Bundle' as source\nuses 'http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse' as target\nuses 'http://hl7.org/fhir/StructureDefinition/MedicationStatement' as source\n\n// The input bundle is a search bundle that contains search bundles for patient, condition, and medication statement resources\n\ngroup main(source src : Bundle, target qr : QuestionnaireResponse) {\n  src -&gt; qr.questionnaire = 'http://hl7.org/fhir/uv/sdc/Questionnaire/questionnaire-sdc-test-fhirpath-prepop-source-query' \"questionnaire\";\n  src -&gt; qr.status = 'in-progress' \"status\";\n  src -&gt; qr.authored = (now()) \"authored\";\n  src.entry first as patient -&gt; qr.subject as subject, subject.reference = (%patient.resource.entry.fullUrl.toString()) \"subject\";\n\n  src -&gt; qr.item as grp, grp.linkId = 'grp' then {\n    src -&gt; grp.item as partDetails, partDetails.linkId = 'part-details' then {\n      src.entry first as patient then {\n        patient.resource : Bundle as patientRes -&gt; partDetails then populatePatientGroup(patientRes, partDetails) \"partBundleDetails\";\n      } \"patientDetails\";\n      src.entry as conditions where (resource.link.url.contains(\"/Condition?\")) -&gt; partDetails.item as conditionItem, conditionItem.linkId = 'condition-count' then {\n        conditions -&gt; conditionItem.answer as conditionCountAnswer, conditionCountAnswer.value = (%conditions.resource.entry.count()) \"conditionCountAnswer\";\n      } \"conditionCount\";\n    } \"partDetails\";\n\n    // Scan the search bundle for a medication statement bunde\n    src.entry as medications where (resource.link.url.contains(\"/MedicationStatement?\")) -&gt; grp then {\n      medications.resource : Bundle as medRes then populateMedicationsGroup(medRes, grp) \"medEntry\";\n    } \"meds\";\n  } \"grp\";\n}\n\ngroup populatePatientGroup(source patientRes : Bundle, target partDetails) {\n  patientRes -&gt; partDetails.item as participantId, \n                    participantId.linkId = 'participant-id',\n                    participantId.answer as participantIdAnswer,\n                    participantIdAnswer.value = (%patientRes.entry.resource.id.toString()) \"participantIdValue\";\n\n  patientRes -&gt; partDetails.item as familyName,\n                    familyName.linkId = 'family-name',\n                    familyName.answer as familyNameAnswer,\n                    familyNameAnswer.value = (%patientRes.entry.resource.name.first().family) \"familyNameValue\";\n\n  patientRes -&gt; partDetails.item as givenName,\n                    givenName.linkId = 'given-names',\n                    givenName.answer as givenNameAnswer,\n                    givenNameAnswer.value = (%patientRes.entry.resource.name.first().given.join(', ')) \"givenNameValue\";\n  patientRes -&gt; partDetails.item as dob, \n                    dob.linkId = 'dob',\n                    dob.answer as dobAnswer,\n                    dobAnswer.value = (%patientRes.entry.resource.birthDate) \"dobValue\";\n}\n\ngroup populateMedicationsGroup(source medRes : Bundle, target grp) {\n  medRes.entry as med where (resource is MedicationStatement) -&gt; grp.item as medsItem, medsItem.linkId = 'meds' then {\n    med.resource : MedicationStatement as medResource -&gt; medsItem.item as medsName, \n                    medsName.linkId = 'med-name',\n                    medsName.answer as medsNameAnswer, \n                    medsNameAnswer.value = (%medResource.medication.select(iif(text.exists(), text, coding.display.first()))) \"medsNameAnswer\";\n/* Todo handle medicationReference once resolve is supported\n        iif($this is Reference, iif($this.resolve().text.exists(), $this.resolve().text, $this.resolve().coding.display.first()), iif(text, text, coding.display.first())))) \"medsNameAnswer\";\n*/\n    \n    med.resource : MedicationStatement as medResource -&gt; medsItem.item as medsStatus, medsStatus.linkId = 'med-status' then {\n      medResource.status as medsMedicationStatus -&gt; medsStatus.answer as medsStatusAnswer, medsStatusAnswer.value = c('http://hl7.org/fhir/CodeSystem/medication-status', medsMedicationStatus) \"medsStatusAnswer\";\n    } \"medsStatus\";\n    \n    med.resource as medResource where (category.coding.where(system='http://terminology.hl7.org/CodeSystem/medicationrequest-category').exists()) -&gt; medsItem.item as medsCategory, medsCategory.linkId = 'meds-category' then {\n      medResource -&gt; medsCategory.answer as medsCategoryAnswer, medsCategoryAnswer.value = (%medResource.category.coding.where(system='http://terminology.hl7.org/CodeSystem/medicationrequest-category').code.join(' ')) \"medsCategoryAnswer\";\n    } \"medsCategory\";\n  } \"medItem\";\n}\n</pre>\n    </div>"
  ] ;
  fhir:DomainResource.extension [
     fhir:index -1 ;
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg" ] ;
     fhir:Extension.valueCode [ fhir:value "fhir" ]
  ] ;
  fhir:StructureMap.url [ fhir:value "http://hl7.org/fhir/uv/sdc/StructureMap/QuestionnairePopulationTransform"] ;
  fhir:StructureMap.identifier [
     fhir:index -1 ;
     fhir:Identifier.system [ fhir:value "urn:ietf:rfc:3986" ] ;
     fhir:Identifier.value [ fhir:value "urn:oid:2.16.840.1.113883.4.642.40.17.43.4" ]
  ] ;
  fhir:StructureMap.version [ fhir:value "4.0.0-ci-build"] ;
  fhir:StructureMap.name [ fhir:value "QuestionnairePopulationTransform"] ;
  fhir:StructureMap.status [ fhir:value "draft"] ;
  fhir:StructureMap.date [ fhir:value "2026-07-15T05:01:03+00:00"^^xsd:dateTime] ;
  fhir:StructureMap.publisher [ fhir:value "HL7 International / FHIR Infrastructure"] ;
  fhir:StructureMap.contact [
     fhir:index -1 ;
     fhir:ContactDetail.name [ fhir:value "HL7 International / FHIR Infrastructure" ] ;
     fhir:ContactDetail.telecom [
       fhir:index -1 ;
       fhir:ContactPoint.system [ fhir:value "url" ] ;
       fhir:ContactPoint.value [ fhir:value "http://www.hl7.org/Special/committees/fiwg" ]
     ]
  ], [
     fhir:index -1 ;
     fhir:ContactDetail.telecom [
       fhir:index -1 ;
       fhir:ContactPoint.system [ fhir:value "url" ] ;
       fhir:ContactPoint.value [ fhir:value "http://www.hl7.org/Special/committees/fiwg" ]
     ]
  ] ;
  fhir:StructureMap.jurisdiction [
     fhir:index -1 ;
     fhir:CodeableConcept.coding [
       fhir:index -1 ;
       fhir:Coding.system [ fhir:value "http://unstats.un.org/unsd/methods/m49/m49.htm" ] ;
       fhir:Coding.code [ fhir:value "001" ] ;
       fhir:Coding.display [ fhir:value "World" ]
     ]
  ] ;
  fhir:StructureMap.structure [
     fhir:index -1 ;
     fhir:StructureMap.structure.url [
       fhir:value "http://hl7.org/fhir/StructureDefinition/Bundle" ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/Bundle>
     ] ;
     fhir:StructureMap.structure.mode [ fhir:value "source" ]
  ], [
     fhir:index -1 ;
     fhir:StructureMap.structure.url [
       fhir:value "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse>
     ] ;
     fhir:StructureMap.structure.mode [ fhir:value "target" ]
  ], [
     fhir:index -1 ;
     fhir:StructureMap.structure.url [
       fhir:value "http://hl7.org/fhir/StructureDefinition/MedicationStatement" ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/MedicationStatement>
     ] ;
     fhir:StructureMap.structure.mode [ fhir:value "source" ]
  ] ;
  fhir:StructureMap.group [
     fhir:index -1 ;
     fhir:StructureMap.group.name [ fhir:value "main" ] ;
     fhir:StructureMap.group.typeMode [ fhir:value "none" ] ;
     fhir:StructureMap.group.input [
       fhir:index -1 ;
       fhir:StructureMap.group.input.name [ fhir:value "src" ] ;
       fhir:StructureMap.group.input.type [ fhir:value "Bundle" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "source" ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.input.name [ fhir:value "qr" ] ;
       fhir:StructureMap.group.input.type [ fhir:value "QuestionnaireResponse" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "target" ]
     ] ;
     fhir:StructureMap.group.rule [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "questionnaire" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "qr" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "questionnaire" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "http://hl7.org/fhir/uv/sdc/Questionnaire/questionnaire-sdc-test-fhirpath-prepop-source-query" ]
         ]
       ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "status" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "qr" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "status" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "in-progress" ]
         ]
       ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "authored" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "qr" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "authored" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "evaluate" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "now()" ]
         ]
       ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "subject" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ] ;
         fhir:StructureMap.group.rule.source.element [ fhir:value "entry" ] ;
         fhir:StructureMap.group.rule.source.listMode [ fhir:value "first" ] ;
         fhir:StructureMap.group.rule.source.variable [ fhir:value "patient" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "qr" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "subject" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "subject" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "subject" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "reference" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "evaluate" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "%patient.resource.entry.fullUrl.toString()" ]
         ]
       ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "grp" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "qr" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "grp" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "grp" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "grp" ]
         ]
       ] ;
       fhir:StructureMap.group.rule.rule [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.name [ fhir:value "partDetails" ] ;
         fhir:StructureMap.group.rule.source [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.source.context [ fhir:value "src" ]
         ] ;
         fhir:StructureMap.group.rule.target [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "grp" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
           fhir:StructureMap.group.rule.target.variable [ fhir:value "partDetails" ]
         ], [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "partDetails" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
           fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
           fhir:StructureMap.group.rule.target.parameter [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "part-details" ]
           ]
         ] ;
         fhir:StructureMap.group.rule.rule [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.name [ fhir:value "patientDetails" ] ;
           fhir:StructureMap.group.rule.source [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.source.context [ fhir:value "src" ] ;
             fhir:StructureMap.group.rule.source.element [ fhir:value "entry" ] ;
             fhir:StructureMap.group.rule.source.listMode [ fhir:value "first" ] ;
             fhir:StructureMap.group.rule.source.variable [ fhir:value "patient" ]
           ] ;
           fhir:StructureMap.group.rule.rule [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.name [ fhir:value "partBundleDetails" ] ;
             fhir:StructureMap.group.rule.source [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.source.context [ fhir:value "patient" ] ;
               fhir:StructureMap.group.rule.source.type [ fhir:value "Bundle" ] ;
               fhir:StructureMap.group.rule.source.element [ fhir:value "resource" ] ;
               fhir:StructureMap.group.rule.source.variable [ fhir:value "patientRes" ]
             ] ;
             fhir:StructureMap.group.rule.target [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
               fhir:StructureMap.group.rule.target.parameter [
                 fhir:index -1 ;
                 fhir:StructureMap.group.rule.target.parameter.valueId [ fhir:value "partDetails" ]
               ]
             ] ;
             fhir:StructureMap.group.rule.dependent [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.dependent.name [ fhir:value "populatePatientGroup" ] ;
               fhir:StructureMap.group.rule.dependent.variable [
                 fhir:value "patientRes" ;
                 fhir:index -1
               ], [
                 fhir:value "partDetails" ;
                 fhir:index -1
               ]
             ]
           ]
         ], [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.name [ fhir:value "conditionCount" ] ;
           fhir:StructureMap.group.rule.source [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.source.context [ fhir:value "src" ] ;
             fhir:StructureMap.group.rule.source.element [ fhir:value "entry" ] ;
             fhir:StructureMap.group.rule.source.variable [ fhir:value "conditions" ] ;
             fhir:StructureMap.group.rule.source.condition [ fhir:value "(resource.link.url.contains('/Condition?'))" ]
           ] ;
           fhir:StructureMap.group.rule.target [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.context [ fhir:value "partDetails" ] ;
             fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
             fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
             fhir:StructureMap.group.rule.target.variable [ fhir:value "conditionItem" ]
           ], [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.context [ fhir:value "conditionItem" ] ;
             fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
             fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
             fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
             fhir:StructureMap.group.rule.target.parameter [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "condition-count" ]
             ]
           ] ;
           fhir:StructureMap.group.rule.rule [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.name [ fhir:value "conditionCountAnswer" ] ;
             fhir:StructureMap.group.rule.source [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.source.context [ fhir:value "conditions" ]
             ] ;
             fhir:StructureMap.group.rule.target [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.target.context [ fhir:value "conditionItem" ] ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.element [ fhir:value "answer" ] ;
               fhir:StructureMap.group.rule.target.variable [ fhir:value "conditionCountAnswer" ]
             ], [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.target.context [ fhir:value "conditionCountAnswer" ] ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
               fhir:StructureMap.group.rule.target.transform [ fhir:value "evaluate" ] ;
               fhir:StructureMap.group.rule.target.parameter [
                 fhir:index -1 ;
                 fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "%conditions.resource.entry.count()" ]
               ]
             ]
           ]
         ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.name [ fhir:value "meds" ] ;
         fhir:StructureMap.group.rule.source [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.source.context [ fhir:value "src" ] ;
           fhir:StructureMap.group.rule.source.element [ fhir:value "entry" ] ;
           fhir:StructureMap.group.rule.source.variable [ fhir:value "medications" ] ;
           fhir:StructureMap.group.rule.source.condition [ fhir:value "(resource.link.url.contains('/MedicationStatement?'))" ]
         ] ;
         fhir:StructureMap.group.rule.target [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
           fhir:StructureMap.group.rule.target.parameter [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.parameter.valueId [ fhir:value "grp" ]
           ]
         ] ;
         fhir:StructureMap.group.rule.rule [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.name [ fhir:value "medEntry" ] ;
           fhir:StructureMap.group.rule.source [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.source.context [ fhir:value "medications" ] ;
             fhir:StructureMap.group.rule.source.type [ fhir:value "Bundle" ] ;
             fhir:StructureMap.group.rule.source.element [ fhir:value "resource" ] ;
             fhir:StructureMap.group.rule.source.variable [ fhir:value "medRes" ]
           ] ;
           fhir:StructureMap.group.rule.dependent [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.dependent.name [ fhir:value "populateMedicationsGroup" ] ;
             fhir:StructureMap.group.rule.dependent.variable [
               fhir:value "medRes" ;
               fhir:index -1
             ], [
               fhir:value "grp" ;
               fhir:index -1
             ]
           ]
         ]
       ]
     ]
  ], [
     fhir:index -1 ;
     fhir:StructureMap.group.name [ fhir:value "populatePatientGroup" ] ;
     fhir:StructureMap.group.typeMode [ fhir:value "none" ] ;
     fhir:StructureMap.group.input [
       fhir:index -1 ;
       fhir:StructureMap.group.input.name [ fhir:value "patientRes" ] ;
       fhir:StructureMap.group.input.type [ fhir:value "Bundle" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "source" ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.input.name [ fhir:value "partDetails" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "target" ]
     ] ;
     fhir:StructureMap.group.rule [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "participantIdValue" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "patientRes" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "partDetails" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "participantId" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "participantId" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "participant-id" ]
         ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "participantId" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "answer" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "participantIdAnswer" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "participantIdAnswer" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "evaluate" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "%patientRes.entry.resource.id.toString()" ]
         ]
       ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "familyNameValue" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "patientRes" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "partDetails" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "familyName" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "familyName" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "family-name" ]
         ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "familyName" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "answer" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "familyNameAnswer" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "familyNameAnswer" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "evaluate" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "%patientRes.entry.resource.name.first().family" ]
         ]
       ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "givenNameValue" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "patientRes" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "partDetails" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "givenName" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "givenName" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "given-names" ]
         ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "givenName" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "answer" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "givenNameAnswer" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "givenNameAnswer" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "evaluate" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "%patientRes.entry.resource.name.first().given.join(', ')" ]
         ]
       ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "dobValue" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "patientRes" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "partDetails" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "dob" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "dob" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "dob" ]
         ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "dob" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "answer" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "dobAnswer" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "dobAnswer" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "evaluate" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "%patientRes.entry.resource.birthDate" ]
         ]
       ]
     ]
  ], [
     fhir:index -1 ;
     fhir:StructureMap.group.name [ fhir:value "populateMedicationsGroup" ] ;
     fhir:StructureMap.group.typeMode [ fhir:value "none" ] ;
     fhir:StructureMap.group.input [
       fhir:index -1 ;
       fhir:StructureMap.group.input.name [ fhir:value "medRes" ] ;
       fhir:StructureMap.group.input.type [ fhir:value "Bundle" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "source" ]
     ], [
       fhir:index -1 ;
       fhir:StructureMap.group.input.name [ fhir:value "grp" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "target" ]
     ] ;
     fhir:StructureMap.group.rule [
       fhir:index -1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "medItem" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "medRes" ] ;
         fhir:StructureMap.group.rule.source.element [ fhir:value "entry" ] ;
         fhir:StructureMap.group.rule.source.variable [ fhir:value "med" ] ;
         fhir:StructureMap.group.rule.source.condition [ fhir:value "(resource is MedicationStatement)" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "grp" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "medsItem" ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "medsItem" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "meds" ]
         ]
       ] ;
       fhir:StructureMap.group.rule.rule [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.name [ fhir:value "medsNameAnswer" ] ;
         fhir:StructureMap.group.rule.source [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.source.context [ fhir:value "med" ] ;
           fhir:StructureMap.group.rule.source.type [ fhir:value "MedicationStatement" ] ;
           fhir:StructureMap.group.rule.source.element [ fhir:value "resource" ] ;
           fhir:StructureMap.group.rule.source.variable [ fhir:value "medResource" ]
         ] ;
         fhir:StructureMap.group.rule.target [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "medsItem" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
           fhir:StructureMap.group.rule.target.variable [ fhir:value "medsName" ]
         ], [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "medsName" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
           fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
           fhir:StructureMap.group.rule.target.parameter [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "med-name" ]
           ]
         ], [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "medsName" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "answer" ] ;
           fhir:StructureMap.group.rule.target.variable [ fhir:value "medsNameAnswer" ]
         ], [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "medsNameAnswer" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
           fhir:StructureMap.group.rule.target.transform [ fhir:value "evaluate" ] ;
           fhir:StructureMap.group.rule.target.parameter [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "%medResource.medication.select(iif(text.exists(), text, coding.display.first()))" ]
           ]
         ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.name [ fhir:value "medsStatus" ] ;
         fhir:StructureMap.group.rule.source [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.source.context [ fhir:value "med" ] ;
           fhir:StructureMap.group.rule.source.type [ fhir:value "MedicationStatement" ] ;
           fhir:StructureMap.group.rule.source.element [ fhir:value "resource" ] ;
           fhir:StructureMap.group.rule.source.variable [ fhir:value "medResource" ]
         ] ;
         fhir:StructureMap.group.rule.target [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "medsItem" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
           fhir:StructureMap.group.rule.target.variable [ fhir:value "medsStatus" ]
         ], [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "medsStatus" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
           fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
           fhir:StructureMap.group.rule.target.parameter [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "med-status" ]
           ]
         ] ;
         fhir:StructureMap.group.rule.rule [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.name [ fhir:value "medsStatusAnswer" ] ;
           fhir:StructureMap.group.rule.source [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.source.context [ fhir:value "medResource" ] ;
             fhir:StructureMap.group.rule.source.element [ fhir:value "status" ] ;
             fhir:StructureMap.group.rule.source.variable [ fhir:value "medsMedicationStatus" ]
           ] ;
           fhir:StructureMap.group.rule.target [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.context [ fhir:value "medsStatus" ] ;
             fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
             fhir:StructureMap.group.rule.target.element [ fhir:value "answer" ] ;
             fhir:StructureMap.group.rule.target.variable [ fhir:value "medsStatusAnswer" ]
           ], [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.context [ fhir:value "medsStatusAnswer" ] ;
             fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
             fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
             fhir:StructureMap.group.rule.target.transform [ fhir:value "c" ] ;
             fhir:StructureMap.group.rule.target.parameter [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "http://hl7.org/fhir/CodeSystem/medication-status" ]
             ], [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.target.parameter.valueId [ fhir:value "medsMedicationStatus" ]
             ]
           ]
         ]
       ], [
         fhir:index -1 ;
         fhir:StructureMap.group.rule.name [ fhir:value "medsCategory" ] ;
         fhir:StructureMap.group.rule.source [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.source.context [ fhir:value "med" ] ;
           fhir:StructureMap.group.rule.source.element [ fhir:value "resource" ] ;
           fhir:StructureMap.group.rule.source.variable [ fhir:value "medResource" ] ;
           fhir:StructureMap.group.rule.source.condition [ fhir:value "(category.coding.where(system = 'http://terminology.hl7.org/CodeSystem/medicationrequest-category').exists())" ]
         ] ;
         fhir:StructureMap.group.rule.target [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "medsItem" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "item" ] ;
           fhir:StructureMap.group.rule.target.variable [ fhir:value "medsCategory" ]
         ], [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.target.context [ fhir:value "medsCategory" ] ;
           fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
           fhir:StructureMap.group.rule.target.element [ fhir:value "linkId" ] ;
           fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
           fhir:StructureMap.group.rule.target.parameter [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "meds-category" ]
           ]
         ] ;
         fhir:StructureMap.group.rule.rule [
           fhir:index -1 ;
           fhir:StructureMap.group.rule.name [ fhir:value "medsCategoryAnswer" ] ;
           fhir:StructureMap.group.rule.source [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.source.context [ fhir:value "medResource" ]
           ] ;
           fhir:StructureMap.group.rule.target [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.context [ fhir:value "medsCategory" ] ;
             fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
             fhir:StructureMap.group.rule.target.element [ fhir:value "answer" ] ;
             fhir:StructureMap.group.rule.target.variable [ fhir:value "medsCategoryAnswer" ]
           ], [
             fhir:index -1 ;
             fhir:StructureMap.group.rule.target.context [ fhir:value "medsCategoryAnswer" ] ;
             fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
             fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
             fhir:StructureMap.group.rule.target.transform [ fhir:value "evaluate" ] ;
             fhir:StructureMap.group.rule.target.parameter [
               fhir:index -1 ;
               fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "%medResource.category.coding.where(system = 'http://terminology.hl7.org/CodeSystem/medicationrequest-category').code.join(' ')" ]
             ]
           ]
         ]
       ]
     ]
  ] .

# - ontology header ------------------------------------------------------------

<http://hl7.org/fhir/StructureMap/QuestionnairePopulationTransform.ttl> a owl:Ontology ;
  owl:imports fhir:fhir.ttl ;
  owl:versionIRI <http://build.fhir.org/StructureMap/QuestionnairePopulationTransform.ttl> .