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

: ExtractComplexSmap - 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 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 "ExtractComplexSmap"] ; # 
  fhir:text [
fhir:status [ fhir:v "additional" ] ;
fhir:div "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n      <pre>/// url = &quot;http://hl7.org/fhir/uv/sdc/StructureMap/ExtractComplexSmap&quot;\n/// name = &quot;ExtractComplexSmap&quot;\n/// status = &quot;active&quot;\n/// title = &quot;Complex extraction structure map example&quot;\n/// description = &quot;An example of a StructureMap used to support extraction from a QuestionnaireResponse&quot;\n/// experimental = &quot;true&quot;\n\nmap &quot;http://hl7.org/fhir/uv/sdc/StructureMap/ExtractComplexSmap&quot; = &quot;ExtractComplexSmap&quot;\n\nuses &quot;http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse&quot; as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/Bundle&quot; as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Patient&quot; as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/RelatedPerson&quot; as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Observation&quot; as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Coding&quot; as target\n\ngroup ExtractBundle(source src : QuestionnaireResponse, target tgt : Bundle) {\n\n  // Patient\n    src.item as patientItem where (linkId = 'patient') -&gt; tgt.entry as patientEntry, uuid() as patientFullUrl then {\n      src -&gt; patientEntry.resource = create('Patient') as pat //, pat.id = (%patientFullUrl)\n        then PopulatePatient(src, patientItem, pat), PopulateBundleEntry(src, patientEntry, patientFullUrl) &quot;popPatient&quot;;\n  \n  // Related Person(s)\n    src.item as rpItem where (linkId = 'contacts') -&gt; tgt.entry as entry, uuid() as fullUrl then {\n      src -&gt; entry.resource = create('RelatedPerson') as rp //, rp.id = (%fullUrl)\n        then PopulateRelatedPerson(src, rpItem, rp, patientFullUrl), PopulateBundleEntry(src, entry, fullUrl) &quot;popRelatedPerson&quot;;\n    } &quot;CreateRelatedPersonEntry&quot;;\n  \n  src.item as obsItems where (linkId = 'obs') -&gt; tgt then {\n    // Height Observation\n    obsItems.item as heightItem where (linkId = 'height') -&gt; tgt.entry as entry, uuid() as fullUrl then {\n      src -&gt; entry.resource = create('Observation') as obs,\n        cc('http://loinc.org', '8302-2', 'Body height') as coding,\n        obs.value = create('Quantity') as q, q.value = (%heightItem.answer.value.first()), q.unit = 'm'\n        then PopulateObservation(src, heightItem, obs, coding, patientFullUrl), \n             PopulateBundleEntry(src, entry, fullUrl) &quot;popObs&quot;;\n    } &quot;CreateHeightObsEntry&quot;;\n  \n    // Weight Observation\n    obsItems.item as weightItem where (linkId = 'weight') -&gt; tgt.entry as entry, uuid() as fullUrl then {\n      src -&gt; entry.resource = create('Observation') as obs,\n        cc('http://loinc.org', '29463-7', 'Weight') as coding,\n        obs.value = create('Quantity') as q, q.value = (%weightItem.answer.value.first()), q.unit = 'kg'\n        then PopulateObservation(src, weightItem, obs, coding, patientFullUrl), \n             PopulateBundleEntry(src, entry, fullUrl) &quot;popObs&quot;;\n    } &quot;CreateWeightObsEntry&quot;;\n\n    // Prepare the bundle entry\n    obsItems.item as complicationItem where (linkId = 'complication') -&gt; tgt.entry as entry, uuid() as fullUrl then {\n      src -&gt; entry.resource = create('Observation') as obs,\n        cc('http://example.org/sdh/demo/CodeSystem/cc-screening-codes', 'sigmoidoscopy-complication') as coding,\n        obs.value = (%complicationItem.answer.value.first())\n        then PopulateObservation(src, complicationItem, obs, coding, patientFullUrl), \n             PopulateBundleEntry(src, entry, fullUrl) &quot;popObs&quot;;\n    } &quot;CreateComplicationObsEntry&quot;;\n  };\n    } &quot;CreatePatientEntry&quot;;\n}\n\ngroup PopulateBundleEntry(source src : QuestionnaireResponse, target entry, target fullUrl) {\n    src -&gt; entry.fullUrl = ('urn:uuid:' &amp; %fullUrl) &quot;SetFullUrl&quot;;\n    src -&gt; entry.request as req then {\n      src -&gt; req.method = 'POST' &quot;setMethod&quot;;\n    } &quot;SetRequest&quot;;\n}\n\ngroup PopulatePatient(source src: QuestionnaireResponse, source patientItem, target pat : Patient) {\n  patientItem.item as gender where (linkId = 'gender') -&gt; pat.gender = (%gender.answer.value.first().code) &quot;SetGender&quot;;\n  patientItem.item as dob where (linkId = 'dob') -&gt; pat.birthDate = (%dob.answer.value) &quot;SetBirthDate&quot;;\n  \n  // name\n  patientItem.item as name where (linkId = 'name') -&gt; pat.name as tgtName then {\n    name -&gt; tgtName.text = (%name.item.where(linkId='given' or linkId='family').answer.value.join(' ')) &quot;SetNameText&quot;;\n    name.item as family where (linkId = 'family') -&gt; tgtName.family = (%family.answer.value) &quot;SetFamily&quot;;\n    name.item as given where (linkId = 'given') then { \n      given.answer as answer -&gt; tgtName.given = (%answer.value) &quot;AnswerValue&quot;;\n    }  &quot;SetGiven&quot;;\n  } &quot;SetName&quot;;\n  \n  // identifier\n  patientItem.item as itemIdentifier where (linkId = 'ihi') -&gt; pat.identifier as tgtIdentifier then {\n    itemIdentifier -&gt; tgtIdentifier.type as t, t.text = 'National Identifier (IHI)' &quot;SetIdentifierType&quot;;\n    itemIdentifier -&gt; tgtIdentifier.system = 'http://example.org/nhio' &quot;SetIdentifierSystem&quot;;\n    itemIdentifier -&gt; tgtIdentifier.value = (%itemIdentifier.answer.value) &quot;SetIdentifierValue&quot;;\n  } &quot;SetIdentifier&quot;;\n  \n  // telecom\n  patientItem.item as itemMobile where (linkId = 'mobile-phone') -&gt; pat.telecom as t, t.system='phone', t.value = (%itemMobile.answer.value), t.use = 'mobile' &quot;SetTelecom&quot;;\n}\n\ngroup PopulateRelatedPerson(source src: QuestionnaireResponse, source rpItem, target rp : RelatedPerson, target patientFullUrl) {\n  rpItem -&gt; rp.patient as p, p.reference = (%patientFullUrl) &quot;SetPatientRef&quot;;\n  rpItem.item as name where (linkId = 'contact-name') -&gt; rp.name as n, n.text = (%name.answer.value) &quot;SetName&quot;;\n  rpItem.item as rel where (linkId = 'relationship') -&gt; rp.relationship as r, r.coding = (%rel.answer.value) &quot;SetRelationship&quot;;\n  rpItem.item as phone where (linkId = 'phone') -&gt; rp.telecom as t, t.system = 'phone', t.value = (%phone.answer.value), t.use = 'mobile' &quot;SetPhone&quot;;\n}\n\ngroup PopulateObservation(source src : QuestionnaireResponse, source complicationItem, target tgt : Observation, target coding : Coding, target patientFullUrl) {\n  src -&gt; tgt.code = (%coding) &quot;SetObservationCode&quot;;\n  src -&gt; tgt.status = 'final' &quot;SetStatus&quot;;\n  // src.subject as s -&gt; tgt.subject = s; // not using the the subject, as this is intended to be created from the data instead (as is outgoing referral)\n  src.subject as s -&gt; tgt.subject as p, p.reference = (%patientFullUrl) &quot;SetSubjectRef&quot;;\n  src.authored as s -&gt; tgt.issued = s &quot;SetAuthored&quot;;\n  src.authored as s -&gt; tgt.effective = s &quot;SetEffective&quot;;\n  src.author as s -&gt; tgt.performer = s;\n  src.id -&gt; tgt.derivedFrom as df, df.reference = ('QuestionnaireResponse/' &amp; %src.id) &quot;SetDerivedFrom&quot;;\n}</pre>\n    </div>"
  ] ; # 
  fhir:extension ( [
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg"^^xsd:anyURI ] ;
fhir:value [ fhir:v "fhir" ]
  ] ) ; # 
  fhir:url [ fhir:v "http://hl7.org/fhir/uv/sdc/StructureMap/ExtractComplexSmap"^^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.3" ]
  ] ) ; # 
  fhir:version [ fhir:v "4.0.0-ballot"] ; # 
  fhir:name [ fhir:v "ExtractComplexSmap"] ; # 
  fhir:status [ fhir:v "draft"] ; # 
  fhir:date [ fhir:v "2024-12-16T09:47:19+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/QuestionnaireResponse"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse>     ] ;
fhir:mode [ fhir:v "source" ]
  ] [
fhir:url [
fhir:v "http://hl7.org/fhir/StructureDefinition/Bundle"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Bundle>     ] ;
fhir:mode [ fhir:v "target" ]
  ] [
fhir:url [
fhir:v "http://hl7.org/fhir/StructureDefinition/Patient"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Patient>     ] ;
fhir:mode [ fhir:v "target" ]
  ] [
fhir:url [
fhir:v "http://hl7.org/fhir/StructureDefinition/RelatedPerson"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/RelatedPerson>     ] ;
fhir:mode [ fhir:v "target" ]
  ] [
fhir:url [
fhir:v "http://hl7.org/fhir/StructureDefinition/Observation"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Observation>     ] ;
fhir:mode [ fhir:v "target" ]
  ] [
fhir:url [
fhir:v "http://hl7.org/fhir/StructureDefinition/Coding"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Coding>     ] ;
fhir:mode [ fhir:v "target" ]
  ] ) ; # 
  fhir:group ( [
fhir:name [ fhir:v "ExtractBundle" ] ;
fhir:typeMode [ fhir:v "none" ] ;
    ( fhir:input [
fhir:name [ fhir:v "src" ] ;
fhir:type [ fhir:v "QuestionnaireResponse" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "tgt" ] ;
fhir:type [ fhir:v "Bundle" ] ;
fhir:mode [ fhir:v "target" ]     ] ) ;
    ( fhir:rule [
fhir:name [ fhir:v "CreatePatientEntry" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "patientItem" ] ;
fhir:condition [ fhir:v "(linkId = 'patient')" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:variable [ fhir:v "patientEntry" ]       ] [
fhir:contextType [ fhir:v "variable" ] ;
fhir:variable [ fhir:v "patientFullUrl" ] ;
fhir:transform [ fhir:v "uuid" ]       ] ) ;
      ( fhir:rule [
fhir:name [ fhir:v "popPatient" ] ;
        ( fhir:source [
fhir:context [ fhir:v "src" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "patientEntry" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "pat" ] ;
fhir:transform [ fhir:v "create" ] ;
          ( fhir:parameter [
fhir:value [ fhir:v "Patient" ]           ] )         ] ) ;
        ( fhir:dependent [
fhir:name [ fhir:v "PopulatePatient" ] ;
          ( fhir:variable [ fhir:v "src" ] [ fhir:v "patientItem" ] [ fhir:v "pat" ] )         ] [
fhir:name [ fhir:v "PopulateBundleEntry" ] ;
          ( fhir:variable [ fhir:v "src" ] [ fhir:v "patientEntry" ] [ fhir:v "patientFullUrl" ] )         ] )       ] [
fhir:name [ fhir:v "CreateRelatedPersonEntry" ] ;
        ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "rpItem" ] ;
fhir:condition [ fhir:v "(linkId = 'contacts')" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:variable [ fhir:v "entry" ]         ] [
fhir:contextType [ fhir:v "variable" ] ;
fhir:variable [ fhir:v "fullUrl" ] ;
fhir:transform [ fhir:v "uuid" ]         ] ) ;
        ( fhir:rule [
fhir:name [ fhir:v "popRelatedPerson" ] ;
          ( fhir:source [
fhir:context [ fhir:v "src" ]           ] ) ;
          ( fhir:target [
fhir:context [ fhir:v "entry" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "rp" ] ;
fhir:transform [ fhir:v "create" ] ;
            ( fhir:parameter [
fhir:value [ fhir:v "RelatedPerson" ]             ] )           ] ) ;
          ( fhir:dependent [
fhir:name [ fhir:v "PopulateRelatedPerson" ] ;
            ( fhir:variable [ fhir:v "src" ] [ fhir:v "rpItem" ] [ fhir:v "rp" ] [ fhir:v "patientFullUrl" ] )           ] [
fhir:name [ fhir:v "PopulateBundleEntry" ] ;
            ( fhir:variable [ fhir:v "src" ] [ fhir:v "entry" ] [ fhir:v "fullUrl" ] )           ] )         ] )       ] [
fhir:name [ fhir:v "item" ] ;
        ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "obsItems" ] ;
fhir:condition [ fhir:v "(linkId = 'obs')" ]         ] ) ;
        ( fhir:target [
fhir:contextType [ fhir:v "variable" ] ;
fhir:transform [ fhir:v "copy" ] ;
          ( fhir:parameter [
fhir:value [ fhir:v "tgt" ]           ] )         ] ) ;
        ( fhir:rule [
fhir:name [ fhir:v "CreateHeightObsEntry" ] ;
          ( fhir:source [
fhir:context [ fhir:v "obsItems" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "heightItem" ] ;
fhir:condition [ fhir:v "(linkId = 'height')" ]           ] ) ;
          ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:variable [ fhir:v "entry" ]           ] [
fhir:contextType [ fhir:v "variable" ] ;
fhir:variable [ fhir:v "fullUrl" ] ;
fhir:transform [ fhir:v "uuid" ]           ] ) ;
          ( fhir:rule [
fhir:name [ fhir:v "popObs" ] ;
            ( fhir:source [
fhir:context [ fhir:v "src" ]             ] ) ;
            ( fhir:target [
fhir:context [ fhir:v "entry" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "obs" ] ;
fhir:transform [ fhir:v "create" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "Observation" ]               ] )             ] [
fhir:contextType [ fhir:v "variable" ] ;
fhir:variable [ fhir:v "coding" ] ;
fhir:transform [ fhir:v "cc" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "http://loinc.org" ]               ] [
fhir:value [ fhir:v "8302-2" ]               ] [
fhir:value [ fhir:v "Body height" ]               ] )             ] [
fhir:context [ fhir:v "obs" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:variable [ fhir:v "q" ] ;
fhir:transform [ fhir:v "create" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "Quantity" ]               ] )             ] [
fhir:context [ fhir:v "q" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "%heightItem.answer.value.first()" ]               ] )             ] [
fhir:context [ fhir:v "q" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "unit" ] ;
fhir:transform [ fhir:v "copy" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "m" ]               ] )             ] ) ;
            ( fhir:dependent [
fhir:name [ fhir:v "PopulateObservation" ] ;
              ( fhir:variable [ fhir:v "src" ] [ fhir:v "heightItem" ] [ fhir:v "obs" ] [ fhir:v "coding" ] [ fhir:v "patientFullUrl" ] )             ] [
fhir:name [ fhir:v "PopulateBundleEntry" ] ;
              ( fhir:variable [ fhir:v "src" ] [ fhir:v "entry" ] [ fhir:v "fullUrl" ] )             ] )           ] )         ] [
fhir:name [ fhir:v "CreateWeightObsEntry" ] ;
          ( fhir:source [
fhir:context [ fhir:v "obsItems" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "weightItem" ] ;
fhir:condition [ fhir:v "(linkId = 'weight')" ]           ] ) ;
          ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:variable [ fhir:v "entry" ]           ] [
fhir:contextType [ fhir:v "variable" ] ;
fhir:variable [ fhir:v "fullUrl" ] ;
fhir:transform [ fhir:v "uuid" ]           ] ) ;
          ( fhir:rule [
fhir:name [ fhir:v "popObs" ] ;
            ( fhir:source [
fhir:context [ fhir:v "src" ]             ] ) ;
            ( fhir:target [
fhir:context [ fhir:v "entry" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "obs" ] ;
fhir:transform [ fhir:v "create" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "Observation" ]               ] )             ] [
fhir:contextType [ fhir:v "variable" ] ;
fhir:variable [ fhir:v "coding" ] ;
fhir:transform [ fhir:v "cc" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "http://loinc.org" ]               ] [
fhir:value [ fhir:v "29463-7" ]               ] [
fhir:value [ fhir:v "Weight" ]               ] )             ] [
fhir:context [ fhir:v "obs" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:variable [ fhir:v "q" ] ;
fhir:transform [ fhir:v "create" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "Quantity" ]               ] )             ] [
fhir:context [ fhir:v "q" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "%weightItem.answer.value.first()" ]               ] )             ] [
fhir:context [ fhir:v "q" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "unit" ] ;
fhir:transform [ fhir:v "copy" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "kg" ]               ] )             ] ) ;
            ( fhir:dependent [
fhir:name [ fhir:v "PopulateObservation" ] ;
              ( fhir:variable [ fhir:v "src" ] [ fhir:v "weightItem" ] [ fhir:v "obs" ] [ fhir:v "coding" ] [ fhir:v "patientFullUrl" ] )             ] [
fhir:name [ fhir:v "PopulateBundleEntry" ] ;
              ( fhir:variable [ fhir:v "src" ] [ fhir:v "entry" ] [ fhir:v "fullUrl" ] )             ] )           ] )         ] [
fhir:name [ fhir:v "CreateComplicationObsEntry" ] ;
          ( fhir:source [
fhir:context [ fhir:v "obsItems" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "complicationItem" ] ;
fhir:condition [ fhir:v "(linkId = 'complication')" ]           ] ) ;
          ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "entry" ] ;
fhir:variable [ fhir:v "entry" ]           ] [
fhir:contextType [ fhir:v "variable" ] ;
fhir:variable [ fhir:v "fullUrl" ] ;
fhir:transform [ fhir:v "uuid" ]           ] ) ;
          ( fhir:rule [
fhir:name [ fhir:v "popObs" ] ;
            ( fhir:source [
fhir:context [ fhir:v "src" ]             ] ) ;
            ( fhir:target [
fhir:context [ fhir:v "entry" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "resource" ] ;
fhir:variable [ fhir:v "obs" ] ;
fhir:transform [ fhir:v "create" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "Observation" ]               ] )             ] [
fhir:contextType [ fhir:v "variable" ] ;
fhir:variable [ fhir:v "coding" ] ;
fhir:transform [ fhir:v "cc" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "http://example.org/sdh/demo/CodeSystem/cc-screening-codes" ]               ] [
fhir:value [ fhir:v "sigmoidoscopy-complication" ]               ] )             ] [
fhir:context [ fhir:v "obs" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
              ( fhir:parameter [
fhir:value [ fhir:v "%complicationItem.answer.value.first()" ]               ] )             ] ) ;
            ( fhir:dependent [
fhir:name [ fhir:v "PopulateObservation" ] ;
              ( fhir:variable [ fhir:v "src" ] [ fhir:v "complicationItem" ] [ fhir:v "obs" ] [ fhir:v "coding" ] [ fhir:v "patientFullUrl" ] )             ] [
fhir:name [ fhir:v "PopulateBundleEntry" ] ;
              ( fhir:variable [ fhir:v "src" ] [ fhir:v "entry" ] [ fhir:v "fullUrl" ] )             ] )           ] )         ] )       ] )     ] )
  ] [
fhir:name [ fhir:v "PopulateBundleEntry" ] ;
fhir:typeMode [ fhir:v "none" ] ;
    ( fhir:input [
fhir:name [ fhir:v "src" ] ;
fhir:type [ fhir:v "QuestionnaireResponse" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "entry" ] ;
fhir:mode [ fhir:v "target" ]     ] [
fhir:name [ fhir:v "fullUrl" ] ;
fhir:mode [ fhir:v "target" ]     ] ) ;
    ( fhir:rule [
fhir:name [ fhir:v "SetFullUrl" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "entry" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "fullUrl" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "'urn:uuid:' & %fullUrl" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetRequest" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "entry" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "request" ] ;
fhir:variable [ fhir:v "req" ]       ] ) ;
      ( fhir:rule [
fhir:name [ fhir:v "setMethod" ] ;
        ( fhir:source [
fhir:context [ fhir:v "src" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "req" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "method" ] ;
fhir:transform [ fhir:v "copy" ] ;
          ( fhir:parameter [
fhir:value [ fhir:v "POST" ]           ] )         ] )       ] )     ] )
  ] [
fhir:name [ fhir:v "PopulatePatient" ] ;
fhir:typeMode [ fhir:v "none" ] ;
    ( fhir:input [
fhir:name [ fhir:v "src" ] ;
fhir:type [ fhir:v "QuestionnaireResponse" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "patientItem" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "pat" ] ;
fhir:type [ fhir:v "Patient" ] ;
fhir:mode [ fhir:v "target" ]     ] ) ;
    ( fhir:rule [
fhir:name [ fhir:v "SetGender" ] ;
      ( fhir:source [
fhir:context [ fhir:v "patientItem" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "gender" ] ;
fhir:condition [ fhir:v "(linkId = 'gender')" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "pat" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "gender" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "%gender.answer.value.first().code" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetBirthDate" ] ;
      ( fhir:source [
fhir:context [ fhir:v "patientItem" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "dob" ] ;
fhir:condition [ fhir:v "(linkId = 'dob')" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "pat" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "birthDate" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "%dob.answer.value" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetName" ] ;
      ( fhir:source [
fhir:context [ fhir:v "patientItem" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "name" ] ;
fhir:condition [ fhir:v "(linkId = 'name')" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "pat" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "name" ] ;
fhir:variable [ fhir:v "tgtName" ]       ] ) ;
      ( fhir:rule [
fhir:name [ fhir:v "SetNameText" ] ;
        ( fhir:source [
fhir:context [ fhir:v "name" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "tgtName" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "text" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
          ( fhir:parameter [
fhir:value [ fhir:v "%name.item.where((linkId = 'given') or (linkId = 'family')).answer.value.join(' ')" ]           ] )         ] )       ] [
fhir:name [ fhir:v "SetFamily" ] ;
        ( fhir:source [
fhir:context [ fhir:v "name" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "family" ] ;
fhir:condition [ fhir:v "(linkId = 'family')" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "tgtName" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "family" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
          ( fhir:parameter [
fhir:value [ fhir:v "%family.answer.value" ]           ] )         ] )       ] [
fhir:name [ fhir:v "SetGiven" ] ;
        ( fhir:source [
fhir:context [ fhir:v "name" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "given" ] ;
fhir:condition [ fhir:v "(linkId = 'given')" ]         ] ) ;
        ( fhir:rule [
fhir:name [ fhir:v "AnswerValue" ] ;
          ( fhir:source [
fhir:context [ fhir:v "given" ] ;
fhir:element [ fhir:v "answer" ] ;
fhir:variable [ fhir:v "answer" ]           ] ) ;
          ( fhir:target [
fhir:context [ fhir:v "tgtName" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "given" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
            ( fhir:parameter [
fhir:value [ fhir:v "%answer.value" ]             ] )           ] )         ] )       ] )     ] [
fhir:name [ fhir:v "SetIdentifier" ] ;
      ( fhir:source [
fhir:context [ fhir:v "patientItem" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "itemIdentifier" ] ;
fhir:condition [ fhir:v "(linkId = 'ihi')" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "pat" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "identifier" ] ;
fhir:variable [ fhir:v "tgtIdentifier" ]       ] ) ;
      ( fhir:rule [
fhir:name [ fhir:v "SetIdentifierType" ] ;
        ( fhir:source [
fhir:context [ fhir:v "itemIdentifier" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "tgtIdentifier" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "type" ] ;
fhir:variable [ fhir:v "t" ]         ] [
fhir:context [ fhir:v "t" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "text" ] ;
fhir:transform [ fhir:v "copy" ] ;
          ( fhir:parameter [
fhir:value [ fhir:v "National Identifier (IHI)" ]           ] )         ] )       ] [
fhir:name [ fhir:v "SetIdentifierSystem" ] ;
        ( fhir:source [
fhir:context [ fhir:v "itemIdentifier" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "tgtIdentifier" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "system" ] ;
fhir:transform [ fhir:v "copy" ] ;
          ( fhir:parameter [
fhir:value [ fhir:v "http://example.org/nhio" ]           ] )         ] )       ] [
fhir:name [ fhir:v "SetIdentifierValue" ] ;
        ( fhir:source [
fhir:context [ fhir:v "itemIdentifier" ]         ] ) ;
        ( fhir:target [
fhir:context [ fhir:v "tgtIdentifier" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
          ( fhir:parameter [
fhir:value [ fhir:v "%itemIdentifier.answer.value" ]           ] )         ] )       ] )     ] [
fhir:name [ fhir:v "SetTelecom" ] ;
      ( fhir:source [
fhir:context [ fhir:v "patientItem" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "itemMobile" ] ;
fhir:condition [ fhir:v "(linkId = 'mobile-phone')" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "pat" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "telecom" ] ;
fhir:variable [ fhir:v "t" ]       ] [
fhir:context [ fhir:v "t" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "system" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "phone" ]         ] )       ] [
fhir:context [ fhir:v "t" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "%itemMobile.answer.value" ]         ] )       ] [
fhir:context [ fhir:v "t" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "use" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "mobile" ]         ] )       ] )     ] )
  ] [
fhir:name [ fhir:v "PopulateRelatedPerson" ] ;
fhir:typeMode [ fhir:v "none" ] ;
    ( fhir:input [
fhir:name [ fhir:v "src" ] ;
fhir:type [ fhir:v "QuestionnaireResponse" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "rpItem" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "rp" ] ;
fhir:type [ fhir:v "RelatedPerson" ] ;
fhir:mode [ fhir:v "target" ]     ] [
fhir:name [ fhir:v "patientFullUrl" ] ;
fhir:mode [ fhir:v "target" ]     ] ) ;
    ( fhir:rule [
fhir:name [ fhir:v "SetPatientRef" ] ;
      ( fhir:source [
fhir:context [ fhir:v "rpItem" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "rp" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "patient" ] ;
fhir:variable [ fhir:v "p" ]       ] [
fhir:context [ fhir:v "p" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "reference" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "%patientFullUrl" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetName" ] ;
      ( fhir:source [
fhir:context [ fhir:v "rpItem" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "name" ] ;
fhir:condition [ fhir:v "(linkId = 'contact-name')" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "rp" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "name" ] ;
fhir:variable [ fhir:v "n" ]       ] [
fhir:context [ fhir:v "n" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "text" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "%name.answer.value" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetRelationship" ] ;
      ( fhir:source [
fhir:context [ fhir:v "rpItem" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "rel" ] ;
fhir:condition [ fhir:v "(linkId = 'relationship')" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "rp" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "relationship" ] ;
fhir:variable [ fhir:v "r" ]       ] [
fhir:context [ fhir:v "r" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "coding" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "%rel.answer.value" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetPhone" ] ;
      ( fhir:source [
fhir:context [ fhir:v "rpItem" ] ;
fhir:element [ fhir:v "item" ] ;
fhir:variable [ fhir:v "phone" ] ;
fhir:condition [ fhir:v "(linkId = 'phone')" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "rp" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "telecom" ] ;
fhir:variable [ fhir:v "t" ]       ] [
fhir:context [ fhir:v "t" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "system" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "phone" ]         ] )       ] [
fhir:context [ fhir:v "t" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "value" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "%phone.answer.value" ]         ] )       ] [
fhir:context [ fhir:v "t" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "use" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "mobile" ]         ] )       ] )     ] )
  ] [
fhir:name [ fhir:v "PopulateObservation" ] ;
fhir:typeMode [ fhir:v "none" ] ;
    ( fhir:input [
fhir:name [ fhir:v "src" ] ;
fhir:type [ fhir:v "QuestionnaireResponse" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "complicationItem" ] ;
fhir:mode [ fhir:v "source" ]     ] [
fhir:name [ fhir:v "tgt" ] ;
fhir:type [ fhir:v "Observation" ] ;
fhir:mode [ fhir:v "target" ]     ] [
fhir:name [ fhir:v "coding" ] ;
fhir:type [ fhir:v "Coding" ] ;
fhir:mode [ fhir:v "target" ]     ] [
fhir:name [ fhir:v "patientFullUrl" ] ;
fhir:mode [ fhir:v "target" ]     ] ) ;
    ( fhir:rule [
fhir:name [ fhir:v "SetObservationCode" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "code" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "%coding" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetStatus" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "status" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "final" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetSubjectRef" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "subject" ] ;
fhir:variable [ fhir:v "s" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "subject" ] ;
fhir:variable [ fhir:v "p" ]       ] [
fhir:context [ fhir:v "p" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "reference" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "%patientFullUrl" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetAuthored" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "authored" ] ;
fhir:variable [ fhir:v "s" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "issued" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "s" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetEffective" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "authored" ] ;
fhir:variable [ fhir:v "s" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "effective" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "s" ]         ] )       ] )     ] [
fhir:name [ fhir:v "author" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "author" ] ;
fhir:variable [ fhir:v "s" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "performer" ] ;
fhir:transform [ fhir:v "copy" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "s" ]         ] )       ] )     ] [
fhir:name [ fhir:v "SetDerivedFrom" ] ;
      ( fhir:source [
fhir:context [ fhir:v "src" ] ;
fhir:element [ fhir:v "id" ]       ] ) ;
      ( fhir:target [
fhir:context [ fhir:v "tgt" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "derivedFrom" ] ;
fhir:variable [ fhir:v "df" ]       ] [
fhir:context [ fhir:v "df" ] ;
fhir:contextType [ fhir:v "variable" ] ;
fhir:element [ fhir:v "reference" ] ;
fhir:transform [ fhir:v "evaluate" ] ;
        ( fhir:parameter [
fhir:value [ fhir:v "'QuestionnaireResponse/' & %src.id" ]         ] )       ] )     ] )
  ] ) . #