Structured Data Capture
3.0.0 - STU 3 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 3.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

StructureMap: SDC Map population StructureMap example (Experimental)

Official URL: http://hl7.org/fhir/uv/sdc/StructureMap/questionnaire-population-transform Version: 3.0.0
Standards status: Informative Computable Name: QuestionnairePopulationTransform

Sample structure map showing process for auto-populating a QuestionnaireResponse from a query bundle

map "http://hl7.org/fhir/uv/sdc/StructureMap/questionnaire-population-transform" = "QuestionnairePopulationTransform"

// Sample structure map showing process for auto-populating a QuestionnaireResponse from a query bundle

uses "http://hl7.org/fhir/StructureDefinition/Bundle" as source
uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" as target

group main(source src : Bundle, target qr : QuestionnaireResponse) {
  src -> qr.questionnaire = 'http://hl7.org/fhir/uv/sdc/Questionnaire/questionnaire-sdc-test-fhirpath-prepop-source-query' "questionnaire";
  src -> qr.status = 'in-progress' "status";
  src -> qr.authored = (now()) "authored";
  src.entry first as patient ->  qr.subject as subject,  subject.reference = (patient.resource.entry.fullUrl) "subject";
  src ->  qr.item as grp,  grp.linkId = 'grp' then {
    src ->  grp.item as partDetails,  partDetails.linkId = 'part-details' then {
      src.entry first as patient -> partDetails then {
        patient.resource as patientRes ->  partDetails.item as participantId,  participantId.linkId = 'participant-id' then {
          patientRes.entry as patientResEntry ->  participantId.answer as participantIdAnswer,  participantIdAnswer.value = (patientResEntry.resource.id) "participantIdValue";
        } "participantId";
        patient.resource as patientRes ->  partDetails.item as familyName,  familyName.linkId = 'family-name' then {
          patientRes.entry as patientResEntry ->  familyName.answer as familyNameAnswer,  familyNameAnswer.value = (patientResEntry.resource.name.first().family) "familyNameValue";
        } "familyName";
        patient.resource as patientRes ->  partDetails.item as givenName,  givenName.linkId = 'given-name' then {
          patientRes.entry as patientResEntry ->  givenName.answer as givenNameAnswer,  givenNameAnswer.value = (patientResEntry.resource.name.first().given.aggregate(iif($total.empty(), $this, $total & ' ' & $this))) "givenNameValue";
        } "givenName";
        patient.resource as patientRes ->  partDetails.item as dob,  dob.linkId = 'dob' then {
          patientRes.entry as patientResEntry ->  dob.answer as dobAnswer,  dobAnswer.value = (patientResEntry.resource.birthDate) "dobValue";
        } "dob";
      } "patientDetails";
      src.entry as conditions where (resource.link.url.contains('/Condition?')) ->  partDetails.item as conditionItem,  conditionItem.linkId = 'condition-count' then {
        conditions ->  conditionItem.answer as conditionCountAnswer,  conditionCountAnswer.value = (conditions.resource.entry.count()) "conditionCountAnswer";
      } "condition-count";
    } "part-details";
    src.entry as medications where (resource.link.url.contains('/MedicationStatement?')) -> grp then {
      medications.resource as medRes -> grp then {
        medRes.entry as med where (resource is MedicationStatement) ->  grp.item as medsItem,  medsItem.linkId = 'meds' then {
          med.resource as medResource ->  medsItem.item as medsName,  medsName.linkId = 'meds-name' then {
            medResource.medication as medMedication ->  medsName.answer as medsNameAnswer,  medsNameAnswer.value = (medMedication.select(iif(text, text, coding.display.first()))) "medsNameAnswer";
          } "medsName";
          med.resource as medResource ->  medsItem.item as medsStatus,  medsStatus.linkId = 'med-status' then {
            medResource.medication as medsMedication ->  medsStatus.answer as medsStatusAnswer,  medsStatusAnswer.value = (medResource.status) "medsStatusAnswer";
          } "medsStatus";
          med.resource as medResource where (category.coding.where(system = 'http://terminology.hl7.org/CodeSystem/medicationrequest-category').exists()) ->  medsItem.item as medsCategory,  medsCategory.linkId = 'meds-category' then {
            medResource ->  medsCategory.answer as medsCategoryAnswer,  medsCategoryAnswer.value = (medResource.category.coding.where(system = 'http://terminology.hl7.org/CodeSystem/medicationrequest-category').code.aggregate(iif($total.empty(), $this, $total & ' ' & $this))) "medsCategoryAnswer";
          } "medsCategory";
        } "medItem";
      } "medEntry";
    } "meds";
  } "grp";
}