FHIR © HL7.org  |  Server Home  |  XIG Home  |  XIG Stats  |  Server Source  |  FHIR  

FHIR IG Statistics: Questionnaire/BMI

Packagehl7.fhir.uv.javascript
Resource TypeQuestionnaire
IdBMI
FHIR VersionR4
Sourcehttp://hl7.org/fhir/uv/javascript/https://build.fhir.org/ig/bvdh/hl7-javascript-expression/Questionnaire-BMI.html
URLhttp://research.philips.com/fhirplayground/r4/sdc/Questionnaire/bmi-example
Version0.1.0
Statusactive
Date2025-05-12T10:18:26+00:00
TitleBMI example
Realmuv
Authorityhl7
DescriptionPrepopulates height and weight based on data in the repository based on Observations in the repository. BMI is calculated and presented when weight and height are present. When stored, weight and height observations are created/updated and a BMI observation is added.

Resources that use this resource

No resources found


Resources that this resource uses

No resources found


Narrative

Note: links and images are rebased to the (stated) source

Generated Narrative: Questionnaire BMI

LinkIDTextCardinalityTypeFlagsDescription & Constraintsdoco
.. Prepopulates height and weight based on data in the repository based on Observations in the repository. BMI is calculated and presented when weight and height are present. When stored, weight and height observations are created/updated and a BMI observation is added.Questionnairehttp://research.philips.com/fhirplayground/r4/sdc/Questionnaire/bmi-example#0.1.0
... weightBody weight1..1decimal
... heightBody height1..1decimal
... bmiBody Mass index (BMI)1..1decimaliconicon

doco Documentation for this format

Source

{
  "resourceType": "Questionnaire",
  "id": "BMI",
  "meta": {
    "profile": [
      "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-pop-obsn",
      "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-extr-obsn",
      "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-render"
    ]
  },
  "text": {
    "status": "extensions",
    "div": "<!-- snip (see above) -->"
  },
  "extension": [
    {
      "extension": [
        {
          "url": "name",
          "valueId": "launchPatient"
        },
        {
          "url": "type",
          "valueCode": "Patient"
        },
        {
          "url": "description",
          "valueString": "Patient the questionnaire is about."
        }
      ],
      "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext"
    },
    {
      "url": "http://hl7.org/fhir/uv/javascript/StructureDefinition/JavascriptTargetExpression",
      "valueExpression": {
        "language": "javascript",
        "expression": "createBundle();\n\nfunction createBundle(){\n\n  let resTemplate = {\n      resourceType: 'Bundle',\n      type: 'transaction',\n      entry: [\n          {\n              fullUrl: 'questionnaire-response',\n              resource: ENV.resource,\n              request: {\n                  method: \"POST\",\n                  url: \"QuestionnaireResponse\"\n              }\n          },\n          {\n              fullUrl: 'height',\n              resource: createHeightObservation(),\n              request: {\n                  method: \"POST\",\n                  url: \"Observation\"\n              }\n          },\n          {\n              fullUrl: 'height',\n              resource: createWeightObservation(),\n              request: {\n                  method: \"POST\",\n                  url: \"Observation\"\n              }\n          },\n          {\n              fullUrl: 'bmi',\n              resource: createWeightObservation(),\n              request: {\n                  method: \"POST\",\n                  url: \"Observation\"\n              }\n          },\n          {\n              fullUrl: 'provenance',\n              resource: createProvenance(),\n              request: {\n                  method: \"POST\",\n                  url: \"Provenance\"\n              }\n          }\n\n      ]\n  }\n}\n\nfunction createHeightObservation(){\n    let obs =  {\n            resourceType: 'Observation',\n            active: true,\n            status: `final`,\n            category:[\n                {\n                    \"coding\": [\n                    {\n                        \"system\": \"http://terminology.hl7.org/CodeSystem/observation-category\",\n                        \"code\": \"vital-signs\",\n                        \"display\": \"Vital Signs\"\n                    }\n                    ]\n                }\n            ],\n            derivedFrom: {\n                reference:  \"questionnaire-response\"\n            },\n            code: FHIR.fhirpath( ENV.resource, '%resource.item.where(linkId=\\'height\\')' ),\n            subject: ENV.resource.subject,\n            issued: FHIR.fhirpath( ENV.resource, 'now()'),\n            effectiveDateTime: FHIR.fhirpath( ENV.resource, 'now()'),\n            performer: ENV.resource.author,\n            valueQuantity: {\n                value: ENV.height,\n                unit: 'm',\n                code: 'm',\n                system: 'http://unitsofmeasure.org'\n            }\n\n        }\n    return obs;\n}\n\n\nfunction createWeightObservation(){\n    let obs =     \n    {\n        resourceType: 'Observation',\n        active: true,\n        status: `final`,\n        category:[\n            {\n                \"coding\": [\n                {\n                    \"system\": \"http://terminology.hl7.org/CodeSystem/observation-category\",\n                    \"code\": \"vital-signs\",\n                    \"display\": \"Vital Signs\"\n                }\n                ]\n            }\n        ],\n        code: FHIR.fhirpath( ENV.resource, '%resource.item.where(linkId=\\'weight\\')' ),\n        derivedFrom: {\n            reference:  \"questionnaire-response\"\n        },       \n        subject: ENV.resource.subject,\n        issued: FHIR.fhirpath( ENV.resource, 'now()'),\n        performer: ENV.resource.author,\n        valueQuantity: {\n            value: ENV.height,\n            unit: 'kg',\n            code: 'kg',\n            system: 'http://unitsofmeasure.org'\n        }\n\n    }\n    return obs;\n}\n\nfunction createBmiObservation(){\n    let obs =         \n    {\n        resourceType: 'Observation',\n        active: true,\n        status: `final`,\n        category:[\n            {\n                \"coding\": [\n                {\n                    \"system\": \"http://terminology.hl7.org/CodeSystem/observation-category\",\n                    \"code\": \"vital-signs\",\n                    \"display\": \"Vital Signs\"\n                }\n                ]\n            }\n        ],\n        derivedFrom: [\n            { reference:  \"questionnaire-response\" },\n            { reference:  \"weight\" },\n            { reference:  \"height\" },\n        ],\n        code: {\n            \"coding\": [\n                {\n                \"system\": \"http://loinc.org\",\n                \"code\": \"39156-5\",\n                \"display\": \"Body mass index (BMI) [Ratio]\"\n                }\n            ],\n            \"text\": \"BMI\"\n            },\n        subject: ENV.resource.subject,\n        issued: FHIR.fhirpath( ENV.resource, 'now()'),\n        effectiveDateTime: FHIR.fhirpath( ENV.resource, 'now()')[0],\n        performer: ENV.resource.author,\n        valueQuantity: {\n            value: FHIR.fhirpath( ENV.resource, '%resource.item.where(linkId=\\'bmi\\').value'),\n            unit: 'kg/m^2',\n            code: 'kg/m^2',\n            system: 'http://unitsofmeasure.org'\n        }\n    }\n    return obs;\n}\n\n\nfunction createProvenance(){\n    let provenance =         {\n        resourceType: 'Provenance',\n        id: 'provenance',\n        occurredPeriod: {\n            start: ENV.resource.authored,\n            end: FHIR.fhirpath( ENV.resource, 'now()')[0]\n        },\n        recorded: FHIR.fhirpath( ENV.resource, 'now()')[0],\n        agent: [\n            {\n                type: {\n                    system: \"http://terminology.hl7.org/CodeSystem/provenance-participant-type\", \n                    code: \"enterer\", \n                    display: \"Enterer\"\n                },\n                who: ENV.resource.author\n            }\n        ],\n        target: [\n            {\n                extension:[\n                    {   url: 'http://hl7.org/fhir/StructureDefinition/resolve-as-version-specific',\n                        valueBoolean: true\n\n                    }\n                ],\n                reference: 'questionnaire-response'\n            },\n            {\n                extension:[\n                    {   url: 'http://hl7.org/fhir/StructureDefinition/resolve-as-version-specific',\n                        valueBoolean: true\n\n                    }\n                ],\n                reference: 'height'\n            },\n            {\n                extension:[\n                    {   url: 'http://hl7.org/fhir/StructureDefinition/resolve-as-version-specific',\n                        valueBoolean: true\n\n                    }\n                ],\n                reference: 'weight'\n            },\n            {\n                extension:[\n                    {   url: 'http://hl7.org/fhir/StructureDefinition/resolve-as-version-specific',\n                        valueBoolean: true\n\n                    }\n                ],\n                reference: 'bmi'\n            }    \n        ]   \n    }\n}"
      }
    }
  ],
  "url": "http://research.philips.com/fhirplayground/r4/sdc/Questionnaire/bmi-example",
  "version": "0.1.0",
  "title": "BMI example",
  "status": "active",
  "date": "2025-05-12T10:18:26+00:00",
  "publisher": "Hl7 International/ FHIR infrastructure",
  "contact": [
    {
      "name": "Hl7 International/ FHIR infrastructure",
      "telecom": [
        {
          "system": "url",
          "value": "http://www.hl7.org/Special/committees/"
        }
      ]
    }
  ],
  "description": "Prepopulates height and weight based on data in the repository\nbased on Observations in the repository. BMI is calculated and presented\n\nwhen weight and height are present. When stored, weight and height observations\n\nare created/updated and a BMI observation is added.",
  "item": [
    {
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-unit",
          "valueCoding": {
            "system": "http://unitsofmeasure.org",
            "code": "kg"
          }
        },
        {
          "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract",
          "valueBoolean": true
        },
        {
          "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod",
          "valueDuration": {
            "value": 1,
            "unit": "week",
            "system": "http://unitsofmeasure.org",
            "code": "wk"
          }
        }
      ],
      "linkId": "weight",
      "code": [
        {
          "system": "http://loinc.org",
          "code": "29463-7",
          "display": "Weight"
        }
      ],
      "text": "Body weight",
      "type": "decimal",
      "required": true
    },
    {
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-unit",
          "valueCoding": {
            "system": "http://unitsofmeasure.org",
            "code": "m"
          }
        },
        {
          "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract",
          "valueBoolean": true
        },
        {
          "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod",
          "valueDuration": {
            "value": 1,
            "unit": "year",
            "system": "http://unitsofmeasure.org",
            "code": "a"
          }
        }
      ],
      "linkId": "height",
      "code": [
        {
          "system": "http://loinc.org",
          "code": "8302-2",
          "display": "Height"
        }
      ],
      "text": "Body height",
      "type": "decimal",
      "required": true
    },
    {
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-unit",
          "valueCoding": {
            "system": "http://unitsofmeasure.org",
            "code": "kg/m2"
          }
        },
        {
          "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract",
          "valueBoolean": true
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/variable",
          "valueExpression": {
            "name": "height",
            "language": "text/fhirpath",
            "expression": "%resource.item.where(linkId='height').answer.value"
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/variable",
          "valueExpression": {
            "name": "weight",
            "language": "text/fhirpath",
            "expression": "%resource.item.where(linkId='weight').answer.value"
          }
        },
        {
          "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression",
          "valueExpression": {
            "language": "javascript",
            "expression": "Math.round(100*(ENV.weight/(ENV.height^2)))/100"
          }
        }
      ],
      "linkId": "bmi",
      "code": [
        {
          "system": "http://loinc.org",
          "code": "39156-5",
          "display": "BMI"
        }
      ],
      "text": "Body Mass index (BMI)",
      "type": "decimal",
      "required": true,
      "readOnly": true
    }
  ]
}