Structured Data Capture
4.0.0 - STU 4 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 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 - TTL Representation

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 rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

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

 a fhir:StructureMap ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:id [ fhir:v "QuestionnairePopulationTransform"] ; # 
  fhir:text [
fhir:status [ fhir:v "additional" ] ;
fhir: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>"^^rdf:XMLLiteral
  ] ; # 
  fhir:extension ( [
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg"^^xsd:anyURI ] ;
fhir:value [
a fhir:code ;
fhir:v "fhir"     ]
  ] ) ; # 
  fhir:url [ fhir:v "http://hl7.org/fhir/uv/sdc/StructureMap/QuestionnairePopulationTransform"^^xsd:anyURI] ; # 
  fhir:identifier ( [
fhir:system [ fhir:v "urn:ietf:rfc:3986"^^xsd:anyURI ] ;
fhir:value [ fhir:v "urn:oid:2.16.840.1.113883.4.642.40.17.43.4" ]
  ] ) ; # 
  fhir:version [ fhir:v "4.0.0"] ; # 
  fhir:name [ fhir:v "QuestionnairePopulationTransform"] ; # 
  fhir:status [ fhir:v "draft"] ; # 
  fhir:date [ fhir:v "2025-09-18T22:51:11+00:00"^^xsd:dateTime] ; # 
  fhir:publisher [ fhir:v "HL7 International / FHIR Infrastructure"] ; # 
  fhir:contact ( [
fhir:name [ fhir:v "HL7 International / FHIR Infrastructure" ] ;
    ( fhir:telecom [
fhir:system [ fhir:v "url" ] ;
fhir:value [ fhir:v "http://www.hl7.org/Special/committees/fiwg" ]     ] )
  ] [
    ( fhir:telecom [
fhir:system [ fhir:v "url" ] ;
fhir:value [ fhir:v "http://www.hl7.org/Special/committees/fiwg" ]     ] )
  ] ) ; # 
  fhir:jurisdiction ( [
    ( fhir:coding [
fhir:system [ fhir:v "http://unstats.un.org/unsd/methods/m49/m49.htm"^^xsd:anyURI ] ;
fhir:code [ fhir:v "001" ] ;
fhir:display [ fhir:v "World" ]     ] )
  ] ) ; # 
  fhir:structure ( [
fhir:url [
fhir:v "http://hl7.org/fhir/StructureDefinition/Bundle"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Bundle>     ] ;
fhir:mode [ fhir:v "source" ]
  ] [
fhir:url [
fhir:v "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse>     ] ;
fhir:mode [ fhir:v "target" ]
  ] [
fhir:url [
fhir:v "http://hl7.org/fhir/StructureDefinition/MedicationStatement"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/MedicationStatement>     ] ;
fhir:mode [ fhir:v "source" ]
  ] ) ; # 
  fhir:group ( [
fhir:name [ fhir:v "main" ] ;
fhir:typeMode [ fhir:v "none" ] ;
    ( fhir:input [
fhir:name [ fhir:v "src" ] ;
fhir:type [ fhir:v "Bundle" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "qr" ] ;
fhir:type [ fhir:v "QuestionnaireResponse" ] ;
fhir:mode [ fhir:v "target" ]     ] ) ;
    ( fhir:rule [
fhir:name [ fhir:v "questionnaire" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "qr" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "questionnaire" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "http://hl7.org/fhir/uv/sdc/Questionnaire/questionnaire-sdc-test-fhirpath-prepop-source-query"           ]         ] )       ] )     ] [
fhir:name [ fhir:v "status" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "qr" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "status" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "in-progress"           ]         ] )       ] )     ] [
fhir:name [ fhir:v "authored" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "qr" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "authored" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "now()"           ]         ] )       ] )     ] [
fhir:name [ fhir:v "subject" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:listMode [ fhir:v "first" ] ;
fhir:variable [ fhir:v "patient" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "qr" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "subject" ] ;
fhir:variable [ fhir:v "subject" ]       ] [
fhir:context [ fhir:v "subject" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "reference" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "%patient.resource.entry.fullUrl.toString()"           ]         ] )       ] )     ] [
fhir:name [ fhir:v "grp" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "qr" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "grp" ]       ] [
fhir:context [ fhir:v "grp" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "grp"           ]         ] )       ] ) ;
      ( fhir:rule [
fhir:name [ fhir:v "partDetails" ] ;
        ( fhir:source [
fhir:context [ fhir:v "src" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "grp" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "partDetails" ]         ] [
fhir:context [ fhir:v "partDetails" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
          ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "part-details"             ]           ] )         ] ) ;
        ( fhir:rule [
fhir:name [ fhir:v "patientDetails" ] ;
          ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:listMode [ fhir:v "first" ] ;
fhir:variable [ fhir:v "patient" ]           ] ) ;
          ( fhir:rule [
fhir:name [ fhir:v "partBundleDetails" ] ;
            ( fhir:source [
fhir:context [ fhir:v "patient" ] ;
fhir:type [ fhir:v "Bundle" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "patientRes" ]             ] ) ;
            ( fhir:target [
fhir:contextType [ fhir:v "variable" ] ;
fhir:transform [ fhir:v "copy" ] ;
              ( fhir:parameter [
fhir:value [
a fhir:id ;
fhir:v "partDetails"                 ]               ] )             ] ) ;
            ( fhir:dependent [
fhir:name [ fhir:v "populatePatientGroup" ] ;
              ( fhir:variable [ fhir:v "patientRes" ] [ fhir:v "partDetails" ] )             ] )           ] )         ] [
fhir:name [ fhir:v "conditionCount" ] ;
          ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:variable [ fhir:v "conditions" ] ;
fhir:condition [ fhir:v "(resource.link.url.contains('/Condition?'))" ]           ] ) ;
          ( fhir:target [
fhir:context [ fhir:v "partDetails" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "conditionItem" ]           ] [
fhir:context [ fhir:v "conditionItem" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "condition-count"               ]             ] )           ] ) ;
          ( fhir:rule [
fhir:name [ fhir:v "conditionCountAnswer" ] ;
            ( fhir:source [
fhir:context [ fhir:v "conditions" ]             ] ) ;
            ( fhir:target [
fhir:context [ fhir:v "conditionItem" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "answer" ] ;
fhir:variable [ fhir:v "conditionCountAnswer" ]             ] [
fhir:context [ fhir:v "conditionCountAnswer" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
              ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "%conditions.resource.entry.count()"                 ]               ] )             ] )           ] )         ] )       ] [
fhir:name [ fhir:v "meds" ] ;
        ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:variable [ fhir:v "medications" ] ;
fhir:condition [ fhir:v "(resource.link.url.contains('/MedicationStatement?'))" ]         ] ) ;
        ( fhir:target [
fhir:contextType [ fhir:v "variable" ] ;
fhir:transform [ fhir:v "copy" ] ;
          ( fhir:parameter [
fhir:value [
a fhir:id ;
fhir:v "grp"             ]           ] )         ] ) ;
        ( fhir:rule [
fhir:name [ fhir:v "medEntry" ] ;
          ( fhir:source [
fhir:context [ fhir:v "medications" ] ;
fhir:type [ fhir:v "Bundle" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "medRes" ]           ] ) ;
          ( fhir:dependent [
fhir:name [ fhir:v "populateMedicationsGroup" ] ;
            ( fhir:variable [ fhir:v "medRes" ] [ fhir:v "grp" ] )           ] )         ] )       ] )     ] )
  ] [
fhir:name [ fhir:v "populatePatientGroup" ] ;
fhir:typeMode [ fhir:v "none" ] ;
    ( fhir:input [
fhir:name [ fhir:v "patientRes" ] ;
fhir:type [ fhir:v "Bundle" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "partDetails" ] ;
fhir:mode [ fhir:v "target" ]     ] ) ;
    ( fhir:rule [
fhir:name [ fhir:v "participantIdValue" ] ;
      ( fhir:source [
fhir:context [ fhir:v "patientRes" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "partDetails" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "participantId" ]       ] [
fhir:context [ fhir:v "participantId" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "participant-id"           ]         ] )       ] [
fhir:context [ fhir:v "participantId" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "answer" ] ;
fhir:variable [ fhir:v "participantIdAnswer" ]       ] [
fhir:context [ fhir:v "participantIdAnswer" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "%patientRes.entry.resource.id.toString()"           ]         ] )       ] )     ] [
fhir:name [ fhir:v "familyNameValue" ] ;
      ( fhir:source [
fhir:context [ fhir:v "patientRes" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "partDetails" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "familyName" ]       ] [
fhir:context [ fhir:v "familyName" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "family-name"           ]         ] )       ] [
fhir:context [ fhir:v "familyName" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "answer" ] ;
fhir:variable [ fhir:v "familyNameAnswer" ]       ] [
fhir:context [ fhir:v "familyNameAnswer" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "%patientRes.entry.resource.name.first().family"           ]         ] )       ] )     ] [
fhir:name [ fhir:v "givenNameValue" ] ;
      ( fhir:source [
fhir:context [ fhir:v "patientRes" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "partDetails" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "givenName" ]       ] [
fhir:context [ fhir:v "givenName" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "given-names"           ]         ] )       ] [
fhir:context [ fhir:v "givenName" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "answer" ] ;
fhir:variable [ fhir:v "givenNameAnswer" ]       ] [
fhir:context [ fhir:v "givenNameAnswer" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "%patientRes.entry.resource.name.first().given.join(', ')"           ]         ] )       ] )     ] [
fhir:name [ fhir:v "dobValue" ] ;
      ( fhir:source [
fhir:context [ fhir:v "patientRes" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "partDetails" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "dob" ]       ] [
fhir:context [ fhir:v "dob" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "dob"           ]         ] )       ] [
fhir:context [ fhir:v "dob" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "answer" ] ;
fhir:variable [ fhir:v "dobAnswer" ]       ] [
fhir:context [ fhir:v "dobAnswer" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "%patientRes.entry.resource.birthDate"           ]         ] )       ] )     ] )
  ] [
fhir:name [ fhir:v "populateMedicationsGroup" ] ;
fhir:typeMode [ fhir:v "none" ] ;
    ( fhir:input [
fhir:name [ fhir:v "medRes" ] ;
fhir:type [ fhir:v "Bundle" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "grp" ] ;
fhir:mode [ fhir:v "target" ]     ] ) ;
    ( fhir:rule [
fhir:name [ fhir:v "medItem" ] ;
      ( fhir:source [
fhir:context [ fhir:v "medRes" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:variable [ fhir:v "med" ] ;
fhir:condition [ fhir:v "(resource is MedicationStatement)" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "grp" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "medsItem" ]       ] [
fhir:context [ fhir:v "medsItem" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "meds"           ]         ] )       ] ) ;
      ( fhir:rule [
fhir:name [ fhir:v "medsNameAnswer" ] ;
        ( fhir:source [
fhir:context [ fhir:v "med" ] ;
fhir:type [ fhir:v "MedicationStatement" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "medResource" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "medsItem" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "medsName" ]         ] [
fhir:context [ fhir:v "medsName" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
          ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "med-name"             ]           ] )         ] [
fhir:context [ fhir:v "medsName" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "answer" ] ;
fhir:variable [ fhir:v "medsNameAnswer" ]         ] [
fhir:context [ fhir:v "medsNameAnswer" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
          ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "%medResource.medication.select(iif(text.exists(), text, coding.display.first()))"             ]           ] )         ] )       ] [
fhir:name [ fhir:v "medsStatus" ] ;
        ( fhir:source [
fhir:context [ fhir:v "med" ] ;
fhir:type [ fhir:v "MedicationStatement" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "medResource" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "medsItem" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "medsStatus" ]         ] [
fhir:context [ fhir:v "medsStatus" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
          ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "med-status"             ]           ] )         ] ) ;
        ( fhir:rule [
fhir:name [ fhir:v "medsStatusAnswer" ] ;
          ( fhir:source [
fhir:context [ fhir:v "medResource" ] ;
fhir:element [ fhir:v "status" ] ;
fhir:variable [ fhir:v "medsMedicationStatus" ]           ] ) ;
          ( fhir:target [
fhir:context [ fhir:v "medsStatus" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "answer" ] ;
fhir:variable [ fhir:v "medsStatusAnswer" ]           ] [
fhir:context [ fhir:v "medsStatusAnswer" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "c" ] ;
            ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "http://hl7.org/fhir/CodeSystem/medication-status"               ]             ] [
fhir:value [
a fhir:id ;
fhir:v "medsMedicationStatus"               ]             ] )           ] )         ] )       ] [
fhir:name [ fhir:v "medsCategory" ] ;
        ( fhir:source [
fhir:context [ fhir:v "med" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "medResource" ] ;
fhir:condition [ fhir:v "(category.coding.where(system = 'http://terminology.hl7.org/CodeSystem/medicationrequest-category').exists())" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "medsItem" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "medsCategory" ]         ] [
fhir:context [ fhir:v "medsCategory" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "linkId" ] ;
fhir:transform [ fhir:v "copy" ] ;
          ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "meds-category"             ]           ] )         ] ) ;
        ( fhir:rule [
fhir:name [ fhir:v "medsCategoryAnswer" ] ;
          ( fhir:source [
fhir:context [ fhir:v "medResource" ]           ] ) ;
          ( fhir:target [
fhir:context [ fhir:v "medsCategory" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "answer" ] ;
fhir:variable [ fhir:v "medsCategoryAnswer" ]           ] [
fhir:context [ fhir:v "medsCategoryAnswer" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
            ( fhir:parameter [
fhir:value [
a fhir:string ;
fhir:v "%medResource.category.coding.where(system = 'http://terminology.hl7.org/CodeSystem/medicationrequest-category').code.join(' ')"               ]             ] )           ] )         ] )       ] )     ] )
  ] ) . #