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 - JSON Representation

Page standards status: Trial-use Maturity Level: 4

Raw json | Download

{
  "resourceType" : "StructureMap",
  "id" : "ExtractComplexSmap",
  "text" : {
    "status" : "additional",
    "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>"
  },
  "extension" : [
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg",
      "valueCode" : "fhir"
    }
  ],
  "url" : "http://hl7.org/fhir/uv/sdc/StructureMap/ExtractComplexSmap",
  "identifier" : [
    {
      "system" : "urn:ietf:rfc:3986",
      "value" : "urn:oid:2.16.840.1.113883.4.642.40.17.43.3"
    }
  ],
  "version" : "4.0.0-ballot",
  "name" : "ExtractComplexSmap",
  "status" : "draft",
  "date" : "2024-12-16T09:47:19+00:00",
  "publisher" : "HL7 International / FHIR Infrastructure",
  "contact" : [
    {
      "name" : "HL7 International / FHIR Infrastructure",
      "telecom" : [
        {
          "system" : "url",
          "value" : "http://www.hl7.org/Special/committees/fiwg"
        }
      ]
    },
    {
      "telecom" : [
        {
          "system" : "url",
          "value" : "http://www.hl7.org/Special/committees/fiwg"
        }
      ]
    }
  ],
  "jurisdiction" : [
    {
      "coding" : [
        {
          "system" : "http://unstats.un.org/unsd/methods/m49/m49.htm",
          "code" : "001",
          "display" : "World"
        }
      ]
    }
  ],
  "structure" : [
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse",
      "mode" : "source"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
      "mode" : "target"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Patient",
      "mode" : "target"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/RelatedPerson",
      "mode" : "target"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Observation",
      "mode" : "target"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Coding",
      "mode" : "target"
    }
  ],
  "group" : [
    {
      "name" : "ExtractBundle",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "CreatePatientEntry",
          "source" : [
            {
              "context" : "src",
              "element" : "item",
              "variable" : "patientItem",
              "condition" : "(linkId = 'patient')"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "patientEntry"
            },
            {
              "contextType" : "variable",
              "variable" : "patientFullUrl",
              "transform" : "uuid"
            }
          ],
          "rule" : [
            {
              "name" : "popPatient",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "patientEntry",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "pat",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Patient"
                    }
                  ]
                }
              ],
              "dependent" : [
                {
                  "name" : "PopulatePatient",
                  "variable" : [
                    "src",
                    "patientItem",
                    "pat"
                  ]
                },
                {
                  "name" : "PopulateBundleEntry",
                  "variable" : [
                    "src",
                    "patientEntry",
                    "patientFullUrl"
                  ]
                }
              ]
            },
            {
              "name" : "CreateRelatedPersonEntry",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "rpItem",
                  "condition" : "(linkId = 'contacts')"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "entry"
                },
                {
                  "contextType" : "variable",
                  "variable" : "fullUrl",
                  "transform" : "uuid"
                }
              ],
              "rule" : [
                {
                  "name" : "popRelatedPerson",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "entry",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "rp",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "RelatedPerson"
                        }
                      ]
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "PopulateRelatedPerson",
                      "variable" : [
                        "src",
                        "rpItem",
                        "rp",
                        "patientFullUrl"
                      ]
                    },
                    {
                      "name" : "PopulateBundleEntry",
                      "variable" : [
                        "src",
                        "entry",
                        "fullUrl"
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "item",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "obsItems",
                  "condition" : "(linkId = 'obs')"
                }
              ],
              "target" : [
                {
                  "contextType" : "variable",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "tgt"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "CreateHeightObsEntry",
                  "source" : [
                    {
                      "context" : "obsItems",
                      "element" : "item",
                      "variable" : "heightItem",
                      "condition" : "(linkId = 'height')"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "tgt",
                      "contextType" : "variable",
                      "element" : "entry",
                      "variable" : "entry"
                    },
                    {
                      "contextType" : "variable",
                      "variable" : "fullUrl",
                      "transform" : "uuid"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "popObs",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "entry",
                          "contextType" : "variable",
                          "element" : "resource",
                          "variable" : "obs",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Observation"
                            }
                          ]
                        },
                        {
                          "contextType" : "variable",
                          "variable" : "coding",
                          "transform" : "cc",
                          "parameter" : [
                            {
                              "valueString" : "http://loinc.org"
                            },
                            {
                              "valueString" : "8302-2"
                            },
                            {
                              "valueString" : "Body height"
                            }
                          ]
                        },
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "value",
                          "variable" : "q",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Quantity"
                            }
                          ]
                        },
                        {
                          "context" : "q",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "%heightItem.answer.value.first()"
                            }
                          ]
                        },
                        {
                          "context" : "q",
                          "contextType" : "variable",
                          "element" : "unit",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "m"
                            }
                          ]
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "PopulateObservation",
                          "variable" : [
                            "src",
                            "heightItem",
                            "obs",
                            "coding",
                            "patientFullUrl"
                          ]
                        },
                        {
                          "name" : "PopulateBundleEntry",
                          "variable" : [
                            "src",
                            "entry",
                            "fullUrl"
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "CreateWeightObsEntry",
                  "source" : [
                    {
                      "context" : "obsItems",
                      "element" : "item",
                      "variable" : "weightItem",
                      "condition" : "(linkId = 'weight')"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "tgt",
                      "contextType" : "variable",
                      "element" : "entry",
                      "variable" : "entry"
                    },
                    {
                      "contextType" : "variable",
                      "variable" : "fullUrl",
                      "transform" : "uuid"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "popObs",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "entry",
                          "contextType" : "variable",
                          "element" : "resource",
                          "variable" : "obs",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Observation"
                            }
                          ]
                        },
                        {
                          "contextType" : "variable",
                          "variable" : "coding",
                          "transform" : "cc",
                          "parameter" : [
                            {
                              "valueString" : "http://loinc.org"
                            },
                            {
                              "valueString" : "29463-7"
                            },
                            {
                              "valueString" : "Weight"
                            }
                          ]
                        },
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "value",
                          "variable" : "q",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Quantity"
                            }
                          ]
                        },
                        {
                          "context" : "q",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "%weightItem.answer.value.first()"
                            }
                          ]
                        },
                        {
                          "context" : "q",
                          "contextType" : "variable",
                          "element" : "unit",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "kg"
                            }
                          ]
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "PopulateObservation",
                          "variable" : [
                            "src",
                            "weightItem",
                            "obs",
                            "coding",
                            "patientFullUrl"
                          ]
                        },
                        {
                          "name" : "PopulateBundleEntry",
                          "variable" : [
                            "src",
                            "entry",
                            "fullUrl"
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "CreateComplicationObsEntry",
                  "source" : [
                    {
                      "context" : "obsItems",
                      "element" : "item",
                      "variable" : "complicationItem",
                      "condition" : "(linkId = 'complication')"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "tgt",
                      "contextType" : "variable",
                      "element" : "entry",
                      "variable" : "entry"
                    },
                    {
                      "contextType" : "variable",
                      "variable" : "fullUrl",
                      "transform" : "uuid"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "popObs",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "entry",
                          "contextType" : "variable",
                          "element" : "resource",
                          "variable" : "obs",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Observation"
                            }
                          ]
                        },
                        {
                          "contextType" : "variable",
                          "variable" : "coding",
                          "transform" : "cc",
                          "parameter" : [
                            {
                              "valueString" : "http://example.org/sdh/demo/CodeSystem/cc-screening-codes"
                            },
                            {
                              "valueString" : "sigmoidoscopy-complication"
                            }
                          ]
                        },
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "%complicationItem.answer.value.first()"
                            }
                          ]
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "PopulateObservation",
                          "variable" : [
                            "src",
                            "complicationItem",
                            "obs",
                            "coding",
                            "patientFullUrl"
                          ]
                        },
                        {
                          "name" : "PopulateBundleEntry",
                          "variable" : [
                            "src",
                            "entry",
                            "fullUrl"
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "PopulateBundleEntry",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "entry",
          "mode" : "target"
        },
        {
          "name" : "fullUrl",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "SetFullUrl",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "entry",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'urn:uuid:' & %fullUrl"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetRequest",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "entry",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "req"
            }
          ],
          "rule" : [
            {
              "name" : "setMethod",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "req",
                  "contextType" : "variable",
                  "element" : "method",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "POST"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "PopulatePatient",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "patientItem",
          "mode" : "source"
        },
        {
          "name" : "pat",
          "type" : "Patient",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "SetGender",
          "source" : [
            {
              "context" : "patientItem",
              "element" : "item",
              "variable" : "gender",
              "condition" : "(linkId = 'gender')"
            }
          ],
          "target" : [
            {
              "context" : "pat",
              "contextType" : "variable",
              "element" : "gender",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%gender.answer.value.first().code"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetBirthDate",
          "source" : [
            {
              "context" : "patientItem",
              "element" : "item",
              "variable" : "dob",
              "condition" : "(linkId = 'dob')"
            }
          ],
          "target" : [
            {
              "context" : "pat",
              "contextType" : "variable",
              "element" : "birthDate",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%dob.answer.value"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetName",
          "source" : [
            {
              "context" : "patientItem",
              "element" : "item",
              "variable" : "name",
              "condition" : "(linkId = 'name')"
            }
          ],
          "target" : [
            {
              "context" : "pat",
              "contextType" : "variable",
              "element" : "name",
              "variable" : "tgtName"
            }
          ],
          "rule" : [
            {
              "name" : "SetNameText",
              "source" : [
                {
                  "context" : "name"
                }
              ],
              "target" : [
                {
                  "context" : "tgtName",
                  "contextType" : "variable",
                  "element" : "text",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "%name.item.where((linkId = 'given') or (linkId = 'family')).answer.value.join(' ')"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "SetFamily",
              "source" : [
                {
                  "context" : "name",
                  "element" : "item",
                  "variable" : "family",
                  "condition" : "(linkId = 'family')"
                }
              ],
              "target" : [
                {
                  "context" : "tgtName",
                  "contextType" : "variable",
                  "element" : "family",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "%family.answer.value"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "SetGiven",
              "source" : [
                {
                  "context" : "name",
                  "element" : "item",
                  "variable" : "given",
                  "condition" : "(linkId = 'given')"
                }
              ],
              "rule" : [
                {
                  "name" : "AnswerValue",
                  "source" : [
                    {
                      "context" : "given",
                      "element" : "answer",
                      "variable" : "answer"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "tgtName",
                      "contextType" : "variable",
                      "element" : "given",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "%answer.value"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "SetIdentifier",
          "source" : [
            {
              "context" : "patientItem",
              "element" : "item",
              "variable" : "itemIdentifier",
              "condition" : "(linkId = 'ihi')"
            }
          ],
          "target" : [
            {
              "context" : "pat",
              "contextType" : "variable",
              "element" : "identifier",
              "variable" : "tgtIdentifier"
            }
          ],
          "rule" : [
            {
              "name" : "SetIdentifierType",
              "source" : [
                {
                  "context" : "itemIdentifier"
                }
              ],
              "target" : [
                {
                  "context" : "tgtIdentifier",
                  "contextType" : "variable",
                  "element" : "type",
                  "variable" : "t"
                },
                {
                  "context" : "t",
                  "contextType" : "variable",
                  "element" : "text",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "National Identifier (IHI)"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "SetIdentifierSystem",
              "source" : [
                {
                  "context" : "itemIdentifier"
                }
              ],
              "target" : [
                {
                  "context" : "tgtIdentifier",
                  "contextType" : "variable",
                  "element" : "system",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "http://example.org/nhio"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "SetIdentifierValue",
              "source" : [
                {
                  "context" : "itemIdentifier"
                }
              ],
              "target" : [
                {
                  "context" : "tgtIdentifier",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "%itemIdentifier.answer.value"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "SetTelecom",
          "source" : [
            {
              "context" : "patientItem",
              "element" : "item",
              "variable" : "itemMobile",
              "condition" : "(linkId = 'mobile-phone')"
            }
          ],
          "target" : [
            {
              "context" : "pat",
              "contextType" : "variable",
              "element" : "telecom",
              "variable" : "t"
            },
            {
              "context" : "t",
              "contextType" : "variable",
              "element" : "system",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "phone"
                }
              ]
            },
            {
              "context" : "t",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%itemMobile.answer.value"
                }
              ]
            },
            {
              "context" : "t",
              "contextType" : "variable",
              "element" : "use",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "mobile"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "PopulateRelatedPerson",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "rpItem",
          "mode" : "source"
        },
        {
          "name" : "rp",
          "type" : "RelatedPerson",
          "mode" : "target"
        },
        {
          "name" : "patientFullUrl",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "SetPatientRef",
          "source" : [
            {
              "context" : "rpItem"
            }
          ],
          "target" : [
            {
              "context" : "rp",
              "contextType" : "variable",
              "element" : "patient",
              "variable" : "p"
            },
            {
              "context" : "p",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%patientFullUrl"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetName",
          "source" : [
            {
              "context" : "rpItem",
              "element" : "item",
              "variable" : "name",
              "condition" : "(linkId = 'contact-name')"
            }
          ],
          "target" : [
            {
              "context" : "rp",
              "contextType" : "variable",
              "element" : "name",
              "variable" : "n"
            },
            {
              "context" : "n",
              "contextType" : "variable",
              "element" : "text",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%name.answer.value"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetRelationship",
          "source" : [
            {
              "context" : "rpItem",
              "element" : "item",
              "variable" : "rel",
              "condition" : "(linkId = 'relationship')"
            }
          ],
          "target" : [
            {
              "context" : "rp",
              "contextType" : "variable",
              "element" : "relationship",
              "variable" : "r"
            },
            {
              "context" : "r",
              "contextType" : "variable",
              "element" : "coding",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%rel.answer.value"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetPhone",
          "source" : [
            {
              "context" : "rpItem",
              "element" : "item",
              "variable" : "phone",
              "condition" : "(linkId = 'phone')"
            }
          ],
          "target" : [
            {
              "context" : "rp",
              "contextType" : "variable",
              "element" : "telecom",
              "variable" : "t"
            },
            {
              "context" : "t",
              "contextType" : "variable",
              "element" : "system",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "phone"
                }
              ]
            },
            {
              "context" : "t",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%phone.answer.value"
                }
              ]
            },
            {
              "context" : "t",
              "contextType" : "variable",
              "element" : "use",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "mobile"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "PopulateObservation",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "complicationItem",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "Observation",
          "mode" : "target"
        },
        {
          "name" : "coding",
          "type" : "Coding",
          "mode" : "target"
        },
        {
          "name" : "patientFullUrl",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "SetObservationCode",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%coding"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetStatus",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "status",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "final"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetSubjectRef",
          "source" : [
            {
              "context" : "src",
              "element" : "subject",
              "variable" : "s"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "subject",
              "variable" : "p"
            },
            {
              "context" : "p",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%patientFullUrl"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetAuthored",
          "source" : [
            {
              "context" : "src",
              "element" : "authored",
              "variable" : "s"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "issued",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "s"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetEffective",
          "source" : [
            {
              "context" : "src",
              "element" : "authored",
              "variable" : "s"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "effective",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "s"
                }
              ]
            }
          ]
        },
        {
          "name" : "author",
          "source" : [
            {
              "context" : "src",
              "element" : "author",
              "variable" : "s"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "performer",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "s"
                }
              ]
            }
          ]
        },
        {
          "name" : "SetDerivedFrom",
          "source" : [
            {
              "context" : "src",
              "element" : "id"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "derivedFrom",
              "variable" : "df"
            },
            {
              "context" : "df",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'QuestionnaireResponse/' & %src.id"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}