{"name":"Aidbox Forms: Populate & Extract","tags":["Community"],"cells":[{"id":"93bf9b68-5d8e-4b69-bf7a-fd44f98bebf4","type":"markdown","value":"#Introduction\n\nAidbox Forms let you populate forms with previous measurements or already existing data. Also, you can update existing data and save new measurements. \n\n### Populate\nAidbox forms supports two ways of populating questionnaire:\n- [Observation-based](https://build.fhir.org/ig/HL7/sdc/populate.html#observation-based-population)\n- [Expression-based](https://build.fhir.org/ig/HL7/sdc/populate.html#observation-based-population)\n\n### Extraction\nAidbox forms suppotrs two-ways of extraction captured date to FHIR resources\n- [Observation-based](https://build.fhir.org/ig/HL7/sdc/extraction.html#observation-based-extraction)\n- [Definition-based](https://build.fhir.org/ig/HL7/sdc/extraction.html#definition-based-extraction)\n\nIn this tutorial we will create some resources to demonstrate how population works and how extract can be used to create and update resources. ","folded":{"code":true,"result":false},"result":"<h1>Introduction</h1><p>Aidbox Forms let you populate forms with previous measurements or already existing data. Also, you can update existing data and save new measurements. </p><h3>Populate</h3><p>Aidbox forms supports two ways of populating questionnaire:</p><ul><li><a href='https://build.fhir.org/ig/HL7/sdc/populate.html#observation-based-population'>Observation-based</a></li><li><a href='https://build.fhir.org/ig/HL7/sdc/populate.html#observation-based-population'>Expression-based</a></li></ul><h3>Extraction</h3><p>Aidbox forms suppotrs two-ways of extraction captured date to FHIR resources</p><ul><li><a href='https://build.fhir.org/ig/HL7/sdc/extraction.html#observation-based-extraction'>Observation-based</a></li><li><a href='https://build.fhir.org/ig/HL7/sdc/extraction.html#definition-based-extraction'>Definition-based</a></li></ul><p>In this tutorial we will create some resources to demonstrate how population works and how extract can be used to create and update resources. </p>","nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false},{"id":"a4f9628a-0595-4494-8833-e8b58956daa8","type":"markdown","value":"# 1. Prepare data\n\nLet's create Patient, Observations and AllergyIntolerance","folded":{"code":true,"result":false},"result":"<h1>1. Prepare data</h1>","nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false},{"id":"97afb6ea-4d22-4243-9f54-0ddc77bcfc57","type":"rest","value":"POST /\nContent-type: application/yaml\n\nresourceType: Bundle\ntype: transaction\nentry:\n- resource:\n    resourceType: Patient\n    id: john\n    name:\n    - given:\n      - John\n      family: Doe\n    birthDate: '1968-09-11'\n  request:\n    method: POST\n    url: /Patient\n- resource:\n    value:\n      Quantity:\n        unit: kg\n        value: 105\n    resourceType: Observation\n    status: final\n    effective:\n      dateTime: '2024-06-27T11:10:14.475Z'\n    code:\n      coding:\n      - code: 29463-7\n        system: http://loinc.org\n        display: Body weight\n    subject:\n      id: john\n      resourceType: Patient\n  request:\n    method: POST\n    url: /Observation\n- resource:\n    value:\n      Quantity:\n        unit: m\n        value: 1.78\n    resourceType: Observation\n    status: final\n    effective:\n      dateTime: '2024-06-27T11:10:14.475Z'\n    code:\n      coding:\n      - code: 8302-2\n        system: http://loinc.org\n        display: Body height\n    subject:\n      id: john\n      resourceType: Patient\n  request:\n    method: POST\n    url: /Observation\n- resource:\n    patient:\n      id: john\n      resourceType: Patient\n    category:\n    - food\n    clinicalStatus:\n      coding:\n      - code: active\n        system: http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical\n        display: Active\n    resourceType: AllergyIntolerance\n  request:\n    method: POST\n    url: /AllergyIntolerance","folded":{"code":false,"result":true},"result":{"body":"type: transaction-response\nresourceType: Bundle\nentry:\n- resource:\n    name:\n    - given: [John]\n      family: Doe\n    birthDate: '1968-09-11'\n    id: john\n    resourceType: Patient\n    meta: {lastUpdated: '2024-06-27T11:28:07.857560Z', createdAt: '2024-06-27T11:28:07.857560Z', versionId: '181'}\n  response: {etag: '181', location: /Patient/john/_history/181, status: '201', lastModified: '2024-06-27T11:28:07.857560Z'}\n- resource:\n    code:\n      coding:\n      - {code: 29463-7, system: 'http://loinc.org', display: Body weight}\n    value:\n      Quantity: {unit: kg, value: 105}\n    status: final\n    subject: {id: john, resourceType: Patient}\n    effective: {dateTime: '2024-06-27T11:10:14.475Z'}\n    id: b62c62c1-c10f-4b05-9fc2-d30f05812b35\n    resourceType: Observation\n    meta: {lastUpdated: '2024-06-27T11:28:07.857560Z', createdAt: '2024-06-27T11:28:07.857560Z', versionId: '182'}\n  response: {etag: '182', location: /Observation/b62c62c1-c10f-4b05-9fc2-d30f05812b35/_history/182, status: '201', lastModified: '2024-06-27T11:28:07.857560Z'}\n- resource:\n    code:\n      coding:\n      - {code: 8302-2, system: 'http://loinc.org', display: Body height}\n    value:\n      Quantity: {unit: m, value: 1.78}\n    status: final\n    subject: {id: john, resourceType: Patient}\n    effective: {dateTime: '2024-06-27T11:10:14.475Z'}\n    id: 2db90741-7cb6-4f50-8e9f-571adcfa7935\n    resourceType: Observation\n    meta: {lastUpdated: '2024-06-27T11:28:07.857560Z', createdAt: '2024-06-27T11:28:07.857560Z', versionId: '183'}\n  response: {etag: '183', location: /Observation/2db90741-7cb6-4f50-8e9f-571adcfa7935/_history/183, status: '201', lastModified: '2024-06-27T11:28:07.857560Z'}\n- resource:\n    patient: {id: john, resourceType: Patient}\n    category: [food]\n    clinicalStatus:\n      coding:\n      - {code: active, system: 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical', display: Active}\n    id: f6a8ef20-735b-47eb-b8dc-b5cefc1db676\n    resourceType: AllergyIntolerance\n    meta: {lastUpdated: '2024-06-27T11:28:07.857560Z', createdAt: '2024-06-27T11:28:07.857560Z', versionId: '184'}\n  response: {etag: '184', location: /AllergyIntolerance/f6a8ef20-735b-47eb-b8dc-b5cefc1db676/_history/184, status: '201', lastModified: '2024-06-27T11:28:07.857560Z'}\nid: '185'\n","status":200,"headers":{"x-duration":55,"content-type":"text/yaml","license-mode":"normal","x-request-id":"1c17791a8f130dd9","x-temp-dur-in-pg":"0"}},"nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false},{"id":"6174873d-609e-4206-a4e2-a0b1222f75bb","type":"markdown","value":"# 2. Create Questionnaire\n\nThis Questionnaire contains 3 sections:\n- General Patient Info\n\n  This section will be populated from Patient resource and will update Patient on extract\n  \n- Height & Weight\n\n  This section uses Observation-based approach to populate items and extract\n- Allergies\n\n  This section uses Expression-based approach to populate `AllergyIntolerance` resources and Definition-based approach to update existing allergies and add new\n","folded":{"code":true,"result":false},"result":"<h1>2. Create Questionnaire</h1><p>This Questionnaire contains 3 sections:</p><ul><li>General Patient Info</li></ul><p>  > This section will be populated from Patient resource and will update Patient on extract   </p><ul><li>Height & Weight</li></ul><p>  This section uses Observation-based approach to populate items and extract</p><ul><li>Allergies</li></ul><p>  This section uses Expression-based approach to populate <code>AllergyIntolerance</code> resources and Definition-based approach to update existing allergies and add new</p>","nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false},{"id":"a5ab2e1e-b0ed-4f40-a1a3-b58cf45b979f","type":"rest","value":"POST /Questionnaire\nContent-type: application/yaml\n\nurl: http://forms.aidbox.io/questionnaire/patient-test-form\nitem:\n- item:\n  - text: Given\n    type: string\n    linkId: given\n    extension:\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value:\n        integer: 4\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression:\n          language: text/fhirpath\n          expression: '%patient.name.given'\n    definition: Patient.name.given\n  - text: Family\n    type: string\n    linkId: 9FwYzNVk\n    extension:\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value:\n        integer: 4\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression:\n          language: text/fhirpath\n          expression: '%patient.name.family'\n    definition: Patient.name.family\n  - text: Date\n    type: date\n    linkId: birthDate\n    extension:\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value:\n        integer: 4\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression:\n          language: text/fhirpath\n          expression: '%patient.birthDate'\n    definition: Patient.birthDate\n  text: General\n  type: group\n  linkId: general\n  extension:\n  - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext\n    value:\n      Expression:\n        name: patient\n        language: application/x-fhir-query\n        expression: /Patient/{{%subject.id}}\n  - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemExtractionContext\n    value:\n      Expression:\n        language: application/x-fhir-query\n        expression: /Patient/{{%resource.subject.id}}\n- item:\n  - code:\n    - code: 8302-2\n      system: http://loinc.org\n      display: Body height\n    text: Height\n    type: quantity\n    linkId: height\n    extension:\n    - url: http://hl7.org/fhir/StructureDefinition/questionnaire-unitOption\n      value:\n        Coding:\n          display: m\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value:\n        integer: 4\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract\n      value:\n        boolean: true\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod\n      value:\n        Duration:\n          code: a\n          value: 1\n          system: ucum\n  - code:\n    - code: 29463-7\n      system: http://loinc.org\n      display: Body height\n    text: Weight\n    type: quantity\n    linkId: weight\n    extension:\n    - url: http://hl7.org/fhir/StructureDefinition/questionnaire-unitOption\n      value:\n        Coding:\n          display: kg\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value:\n        integer: 4\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod\n      value:\n        Duration:\n          code: a\n          value: 1\n          system: ucum\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract\n      value:\n        boolean: true\n  - code:\n    - code: 39156-5\n      system: http://loinc.org\n      display: Body height\n    text: BMI\n    type: decimal\n    linkId: bmi\n    extension:\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression\n      value:\n        Expression:\n          language: text/fhirpath\n          expression: \"%resource.repeat(item).where(linkId='weight').answer.value.value / \\n%resource.repeat(item).where(linkId='height').answer.value.value.power(2)\"\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value:\n        integer: 4\n  text: Height & Weight\n  type: group\n  linkId: hZsHDBA2\n- item:\n  - text: (id)\n    type: string\n    linkId: id\n    extension:\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression:\n          language: text/fhirpath\n          expression: '%allergies.id'\n    - url: http://hl7.org/fhir/StructureDefinition/questionnaire-hidden\n      value:\n        boolean: true\n    definition: AllergyIntolerance.id\n  - text: (pt. reference)\n    type: reference\n    linkId: reference\n    extension:\n    - url: http://hl7.org/fhir/StructureDefinition/questionnaire-hidden\n      value:\n        boolean: true\n    - url: http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression\n      value:\n        Expression:\n          language: text/fhirpath\n          expression: '%resource.subject'\n    definition: AllergyIntolerance.patient\n  - text: Status\n    type: choice\n    linkId: FmqK7esk\n    extension:\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression:\n          language: text/fhirpath\n          expression: '%allergies.clinicalStatus.coding.first()'\n    definition: AllergyIntolerance.clinicalStatus.coding\n    answerOption:\n    - value:\n        Coding:\n          code: active\n          system: http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical\n          display: Active\n    - value:\n        Coding:\n          code: inactive\n          system: http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical\n          display: Inactive\n    - value:\n        Coding:\n          code: resolved\n          system: http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical\n          display: Resolved\n  - text: Category\n    type: choice\n    linkId: RZsAnKZH\n    extension:\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression:\n          language: text/fhirpath\n          expression: '%qitem.answerOption.valueCoding.where(code=%allergies.category)'\n    definition: AllergyIntolerance.category\n    answerOption:\n    - value:\n        Coding:\n          code: food\n          system: http://hl7.org/fhir/allergy-intolerance-category\n          display: Food\n    - value:\n        Coding:\n          code: medication\n          system: http://hl7.org/fhir/allergy-intolerance-category\n          display: Medication\n    - value:\n        Coding:\n          code: environment\n          system: http://hl7.org/fhir/allergy-intolerance-category\n          display: Environment\n    - value:\n        Coding:\n          code: biologic\n          system: http://hl7.org/fhir/allergy-intolerance-category\n          display: Biologic\n  text: Allergies\n  type: group\n  linkId: allergies\n  repeats: true\n  extension:\n  - url: http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl\n    value:\n      CodeableConcept:\n        coding:\n        - code: gtable\n  - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext\n    value:\n      Expression:\n        name: allergies\n        language: application/x-fhir-query\n        expression: /AllergyIntolerance?.patient.id={{%subject.id}}\n  - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemExtractionContext\n    value:\n      Expression:\n        language: application/x-fhir-query\n        expression: /AllergyIntolerance?.patient.id={{%resource.subject.id}}\ntitle: Patient Info\nid: patient-info\nstatus: draft\nresourceType: Questionnaire","folded":{"result":true},"result":{"body":"url: http://forms.aidbox.io/questionnaire/patient-test-form\nitem:\n- item:\n  - text: Given\n    type: string\n    linkId: given\n    extension:\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value: {integer: 4}\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression: {language: text/fhirpath, expression: '%patient.name.given'}\n    definition: Patient.name.given\n  - text: Family\n    type: string\n    linkId: 9FwYzNVk\n    extension:\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value: {integer: 4}\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression: {language: text/fhirpath, expression: '%patient.name.family'}\n    definition: Patient.name.family\n  - text: Date\n    type: date\n    linkId: birthDate\n    extension:\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value: {integer: 4}\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression: {language: text/fhirpath, expression: '%patient.birthDate'}\n    definition: Patient.birthDate\n  text: General\n  type: group\n  linkId: general\n  extension:\n  - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext\n    value:\n      Expression: {name: patient, language: application/x-fhir-query, expression: '/Patient/{{%subject.id}}'}\n  - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemExtractionContext\n    value:\n      Expression: {language: application/x-fhir-query, expression: '/Patient/{{%resource.subject.id}}'}\n- item:\n  - code:\n    - {code: 8302-2, system: 'http://loinc.org', display: Body height}\n    text: Height\n    type: quantity\n    linkId: height\n    extension:\n    - url: http://hl7.org/fhir/StructureDefinition/questionnaire-unitOption\n      value:\n        Coding: {display: m}\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value: {integer: 4}\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract\n      value: {boolean: true}\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod\n      value:\n        Duration: {code: a, value: 1, system: ucum}\n  - code:\n    - {code: 29463-7, system: 'http://loinc.org', display: Body height}\n    text: Weight\n    type: quantity\n    linkId: weight\n    extension:\n    - url: http://hl7.org/fhir/StructureDefinition/questionnaire-unitOption\n      value:\n        Coding: {display: kg}\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value: {integer: 4}\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod\n      value:\n        Duration: {code: a, value: 1, system: ucum}\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract\n      value: {boolean: true}\n  - code:\n    - {code: 39156-5, system: 'http://loinc.org', display: Body height}\n    text: BMI\n    type: decimal\n    linkId: bmi\n    extension:\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression\n      value:\n        Expression:\n          language: text/fhirpath\n          expression: \"%resource.repeat(item).where(linkId='weight').answer.value.value / \\n%resource.repeat(item).where(linkId='height').answer.value.value.power(2)\"\n    - url: http://aidbox.io/questionnaire-itemColumnSize\n      value: {integer: 4}\n  text: Height & Weight\n  type: group\n  linkId: hZsHDBA2\n- item:\n  - text: (id)\n    type: string\n    linkId: id\n    extension:\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression: {language: text/fhirpath, expression: '%allergies.id'}\n    - url: http://hl7.org/fhir/StructureDefinition/questionnaire-hidden\n      value: {boolean: true}\n    definition: AllergyIntolerance.id\n  - text: (pt. reference)\n    type: reference\n    linkId: reference\n    extension:\n    - url: http://hl7.org/fhir/StructureDefinition/questionnaire-hidden\n      value: {boolean: true}\n    - {url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource'}\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression\n      value:\n        Expression: {language: text/fhirpath, expression: '%resource.subject'}\n    definition: AllergyIntolerance.patient\n  - text: Status\n    type: choice\n    linkId: FmqK7esk\n    extension:\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression: {language: text/fhirpath, expression: '%allergies.clinicalStatus.coding.first()'}\n    definition: AllergyIntolerance.clinicalStatus.coding\n    answerOption:\n    - value:\n        Coding: {code: active, system: 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical', display: Active}\n    - value:\n        Coding: {code: inactive, system: 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical', display: Inactive}\n    - value:\n        Coding: {code: resolved, system: 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical', display: Resolved}\n  - text: Category\n    type: choice\n    linkId: RZsAnKZH\n    extension:\n    - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression\n      value:\n        Expression: {language: text/fhirpath, expression: '%qitem.answerOption.valueCoding.where(code=%allergies.category)'}\n    definition: AllergyIntolerance.category\n    answerOption:\n    - value:\n        Coding: {code: food, system: 'http://hl7.org/fhir/allergy-intolerance-category', display: Food}\n    - value:\n        Coding: {code: medication, system: 'http://hl7.org/fhir/allergy-intolerance-category', display: Medication}\n    - value:\n        Coding: {code: environment, system: 'http://hl7.org/fhir/allergy-intolerance-category', display: Environment}\n    - value:\n        Coding: {code: biologic, system: 'http://hl7.org/fhir/allergy-intolerance-category', display: Biologic}\n  text: Allergies\n  type: group\n  linkId: allergies\n  repeats: true\n  extension:\n  - url: http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl\n    value:\n      CodeableConcept:\n        coding:\n        - {code: gtable}\n  - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext\n    value:\n      Expression: {name: allergies, language: application/x-fhir-query, expression: '/AllergyIntolerance?.patient.id={{%subject.id}}'}\n  - url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemExtractionContext\n    value:\n      Expression: {language: application/x-fhir-query, expression: '/AllergyIntolerance?.patient.id={{%resource.subject.id}}'}\ntitle: Patient Info\nstatus: draft\nid: patient-info\nresourceType: Questionnaire\nmeta: {lastUpdated: '2024-06-27T13:48:49.177920Z', createdAt: '2024-06-27T13:48:49.177920Z', versionId: '191'}\n","status":201,"headers":{"x-temp-dur-in-pg":"0","x-duration":12,"etag":"191","last-modified":"Thu, 27 Jun 2024 13:48:49 GMT","license-mode":"normal","cache-control":"no-cache","content-type":"text/yaml","location":"/Questionnaire/patient-info/_history/191","x-request-id":"9abf352a78cf632f"}},"nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false},{"id":"7d2729be-e67e-4414-937e-1b7d7f1bf1dd","type":"markdown","value":"# 3. Populate Questionnaire\n\nNow, we are ready to see how to populate Questionnaire with existing data. Let's call `$populate` operation to get QuestionnarieResponse with prefilled items: \n- general patient info items were filled from Patient resource\n- width and height items were filled from Observation resources\n- allergies info was populated from AllergyIntolerance resource","folded":{"code":false,"result":false},"result":"<h1>3. Populate Questionnaire</h1><p>Now, we are ready to see how to populate Questionnaire with existing data. Let's call <code>$populate</code> operation to get QuestionnarieResponse with prefilled items</p>","nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false},{"id":"cc368571-464c-4bbd-b041-269a25c6f85c","type":"rest","value":"POST /Questionnaire/patient-info/$populate\ncontent-type: application/yaml\n\nresourceType: Parameters\nparameter: \n  - name: subject\n    value: \n      Reference:\n        id: john\n        resourceType: Patient\n      ","folded":{"code":false,"result":true},"result":{"body":"resourceType: Parameters\nparameter:\n- name: response\n  resource:\n    resourceType: QuestionnaireResponse\n    questionnaire: http://forms.aidbox.io/questionnaire/patient-test-form\n    status: in-progress\n    subject: {id: john, resourceType: Patient}\n    item:\n    - linkId: general\n      text: General\n      item:\n      - linkId: given\n        text: Given\n        answer:\n        - {valueString: Morgan}\n      - linkId: 9FwYzNVk\n        text: Family\n        answer:\n        - {valueString: James}\n      - linkId: birthDate\n        text: Date\n        answer:\n        - {valueDate: '1996-12-05'}\n    - linkId: hZsHDBA2\n      text: Height & Weight\n      item:\n      - linkId: height\n        text: Height\n        answer:\n        - valueQuantity: {unit: m, value: 1.78}\n      - linkId: weight\n        text: Weight\n        answer:\n        - valueQuantity: {unit: kg, value: 105}\n      - {linkId: bmi, text: BMI}\n    - linkId: allergies\n      text: Allergies\n      item:\n      - linkId: id\n        text: (id)\n        answer:\n        - {valueString: f6a8ef20-735b-47eb-b8dc-b5cefc1db676}\n      - {linkId: reference, text: (pt. reference)}\n      - linkId: FmqK7esk\n        text: Status\n        answer:\n        - valueCoding: {code: active, system: 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical', display: Active}\n      - linkId: RZsAnKZH\n        text: Category\n        answer:\n        - valueCoding: {code: food, system: 'http://hl7.org/fhir/allergy-intolerance-category', display: Food}\n","status":200,"headers":{"x-duration":1924,"content-type":"text/yaml","license-mode":"normal","x-request-id":"2cc1308b2f8e0c55","x-temp-dur-in-pg":"0"}},"nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false},{"id":"57a4b85d-31d9-4ab7-94f0-2d1c3533cdc2","type":"markdown","value":"# 4. Extraction\n\nWhen form is filled, we want to extract some info into new resources or update existing ones. Here we send our filled QuestionnarieResponse to `$extract` operation to get Bundle.","folded":{"code":true,"result":false},"result":"<h1>4. Extraction</h1><p>When form is filled, we want to extract some info into new resources or update existing ones. Here we send our filled QuestionnarieResponse to <code>$extract</code> operation to get Bundle.</p>","nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false},{"id":"44db78d9-82b2-4740-8a21-24e94e6927e5","type":"rest","value":"POST /QuestionnaireResponse/$extract\ncontent-type: application/yaml\n\nresourceType: Parameters\nparameter:\n- name: questionnaire-response\n  resource:\n    item:\n    - item:\n      - text: Given\n        answer:\n        - value:\n            string: Jane\n        linkId: given\n      - text: Family\n        answer:\n        - value:\n            string: Doe\n        linkId: 9FwYzNVk\n      - text: Date\n        answer:\n        - value:\n            date: '2003-08-11'\n        linkId: birthDate\n      text: General\n      linkId: general\n    - item:\n      - text: Height\n        answer:\n        - value:\n            Quantity:\n              unit: m\n              value: 1.56\n        linkId: height\n      - text: Weight\n        answer:\n        - value:\n            Quantity:\n              unit: kg\n              value: 50\n        linkId: weight\n      - text: BMI\n        answer:\n        - value:\n            decimal: 20.5456936226167\n        linkId: bmi\n      text: Height & Weight\n      linkId: hZsHDBA2\n    - item:\n      - text: (pt. reference)\n        answer:\n        - value:\n            Reference:\n              id: john\n              resourceType: Patient\n        linkId: reference\n      - text: Status\n        answer:\n        - value:\n            Coding:\n              code: active\n              system: http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical\n              display: Active\n        linkId: FmqK7esk\n      - text: Category\n        answer:\n        - value:\n            Coding:\n              code: medication\n              system: http://hl7.org/fhir/allergy-intolerance-category\n              display: Medication\n        linkId: RZsAnKZH\n      text: Allergies\n      linkId: allergies\n    - item:\n      - text: (pt. reference)\n        answer:\n        - value:\n            Reference:\n              id: john\n              resourceType: Patient\n        linkId: reference\n      - text: Status\n        answer:\n        - value:\n            Coding:\n              code: active\n              system: http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical\n              display: Active\n        linkId: FmqK7esk\n      - text: Category\n        answer:\n        - value:\n            Coding:\n              code: food\n              system: http://hl7.org/fhir/allergy-intolerance-category\n              display: Food\n        linkId: RZsAnKZH\n      text: Allergies\n      linkId: allergies\n    status: completed\n    subject:\n      id: john\n      resourceType: Patient\n    authored: '2024-06-27T13:59:19.317Z'\n    questionnaire: http://forms.aidbox.io/questionnaire/patient-test-form\n    resourceType: QuestionnaireResponse","folded":{"code":false,"result":true},"result":{"body":"resourceType: Parameters\nparameter:\n- name: return\n  resource:\n    resourceType: Bundle\n    type: transaction\n    entry:\n    - resource:\n        name:\n        - given: [Jane]\n          family: Doe\n        birthDate: '2003-08-11'\n        id: john\n        resourceType: Patient\n      request: {method: PUT, url: /Patient/john}\n    - resource:\n        resourceType: Observation\n        status: final\n        code:\n          coding:\n          - {code: 8302-2, system: 'http://loinc.org', display: Body height}\n        subject: {id: john, resourceType: Patient}\n        value:\n          Quantity: {unit: m, value: 1.56}\n        encounter: {}\n        effective: {dateTime: '2024-06-27T13:59:19.317Z'}\n        id: cf76156a-b7a9-4693-ba67-e14988a74412\n      request: {method: POST, url: /Observation}\n    - resource:\n        resourceType: Observation\n        status: final\n        code:\n          coding:\n          - {code: 29463-7, system: 'http://loinc.org', display: Body height}\n        subject: {id: john, resourceType: Patient}\n        value:\n          Quantity: {unit: kg, value: 50}\n        encounter: {}\n        effective: {dateTime: '2024-06-27T13:59:19.317Z'}\n        id: 387963a9-fb3f-42b2-b711-b20bfc69e19b\n      request: {method: POST, url: /Observation}\n    - resource:\n        patient: {id: john, resourceType: Patient}\n        category: [medication]\n        clinicalStatus:\n          coding:\n          - {code: active, system: 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical', display: Active}\n        id: f6a8ef20-735b-47eb-b8dc-b5cefc1db676\n        resourceType: AllergyIntolerance\n      request: {method: PUT, url: /AllergyIntolerance/f6a8ef20-735b-47eb-b8dc-b5cefc1db676}\n    - resource:\n        resourceType: AllergyIntolerance\n        patient: {id: john, resourceType: Patient}\n        clinicalStatus:\n          coding:\n          - {code: active, system: 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical', display: Active}\n        category: [food]\n        id: b66c832c-2469-466c-80d0-86918672a9a0\n      request: {method: POST, url: /AllergyIntolerance}\n- name: issues\n  resource:\n    resourceType: OperationOutcome\n    issues:\n    - {severity: warning, code: value, expression: QuestionnaireResponse.id, diagnostics: Provenance cannot be created due to lack id information}\n    - {severity: warning, code: value, expression: QuestionnaireResponse.author, diagnostics: Provenance cannot be created due to lack of author information}\n","status":200,"headers":{"x-duration":51,"content-type":"text/yaml","license-mode":"normal","x-request-id":"a3732e3eb42ec821","x-temp-dur-in-pg":"0"}},"nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false},{"id":"57306858-e0e4-48da-84f3-bb01f64398d4","type":"markdown","value":"# Final\n\nAs you see, with Aidbox forms you can create forms that can be prefilled with existing data and after capturing needed data you can update or create any FHIR resources. ","folded":{"code":true,"result":false},"result":"<h1>Final</h1><p>As you see, with Aidbox forms you can create forms that can be prefilled with existing data and after capturing needed data you can update or create any FHIR resources. </p>","nb-title":"Aidbox Forms: Populate & Extract","evaluating?":false}],"import-url":"https://aidbox.app/ExportedNotebook/10b1ea71-8e25-4f5e-aaff-e64ae50a27d5","description":"How to create smart forms that may be prefilled with existing data, may update or create new resources","id":"10b1ea71-8e25-4f5e-aaff-e64ae50a27d5","resourceType":"ExportedNotebook","meta":{"lastUpdated":"2024-06-28T14:43:16.939633Z","createdAt":"2024-06-28T14:43:16.939633Z","versionId":"65801660"}}