WHO Clinical Care in Crisis Implementation Guide for Children
0.1.0 - ci-build

WHO Clinical Care in Crisis Implementation Guide for Children - Local Development build (v0.1.0). See the Directory of published versions

Library: BMIForAge

Official URL: https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/BMIForAge Version: 0.1.0
Active as of 2023-10-04 Computable Name: BMIForAge

Related Artifacts

depends-onanthrobase
depends-onhttp://fhir.org/guides/who/anc-cds/Library/FHIRHelpers

Parameters

zscoreindecimal
Ageindecimal
sexindecimal
generateBMIFromAgeoutdecimal
generateZScoreBMIForAgeoutdecimal
ZscoreBMIForAgetables_soutdecimal
ZscoreBMIForAgetables_moutdecimal
ZscoreBMIForAgetables_loutdecimal

Data Requirements

Type: Patient (Patient)

Contents

text/cql


library BMIForAge version '1.0.4'
using FHIR version '4.0.1'
include anthrobase version '1.0.4' called base
include FHIRHelpers version '4.0.1' called FHIRHelpers

// Antrho library for BMIForAge  Z-Score from the bmianthro files
codesystem "administrative-gender": 'http://hl7.org/fhir/administrative-gender'
//code "Female" : 'female' from "administrative-gender"  display 'Female'


define BMIForAgeFemale:
{
	{y:0.0,l:-0.0631,s:0.09272,m:13.3363},
	{y:1.0,l:0.0362,s:0.0936,m:13.3185},
	{y:2.0,l:0.1355,s:0.09448,m:13.3006},
	{y:3.0,l:0.2347,s:0.09535,m:13.2828},
	{y:4.0,l:0.334,s:0.09623,m:13.2649},
	{y:5.0,l:0.4333,s:0.09711,m:13.247},
	{y:6.0,l:0.5326,s:0.09799,m:13.2292},
	{y:7.0,l:0.6319,s:0.09887,m:13.2113},
	{y:8.0,l:0.6142,s:0.09866,m:13.2455},
	{y:9.0,l:0.5965,s:0.09845,m:13.2796},
	{y:10.0,l:0.5789,s:0.09824,m:13.3137},
	{y:11.0,l:0.5612,s:0.09804,m:13.3478},
	{y:12.0,l:0.5435,s:0.09783,m:13.3819},
	{y:13.0,l:0.5258,s:0.09762,m:13.416},
	{y:14.0,l:0.5082,s:0.09741,m:13.4501},
	{y:15.0,l:0.4947,s:0.09726,m:13.5169},
	{y:16.0,l:0.482,s:0.09711,m:13.5873},
	{y:17.0,l:0.4699,s:0.09697,m:13.6595},
	{y:18.0,l:0.4583,s:0.09684,m:13.7325},
	{y:19.0,l:0.4472,s:0.09671,m:13.8056},
	{y:20.0,l:0.4365,s:0.09659,m:13.8784},
	{y:21.0,l:0.4263,s:0.09647,m:13.9505},
	{y:22.0,l:0.4164,s:0.09636,m:14.0216},
	{y:23.0,l:0.4069,s:0.09625,m:14.0916},
	{y:24.0,l:0.3977,s:0.09615,m:14.1603},
	{y:25.0,l:0.3888,s:0.09605,m:14.2276},
	{y:26.0,l:0.3802,s:0.09595,m:14.2935},
	{y:27.0,l:0.3718,s:0.09586,m:14.3579},
	{y:28.0,l:0.3637,s:0.09577,m:14.4208},
	{y:29.0,l:0.3558,s:0.09568,m:14.4824},
	{y:30.0,l:0.3481,s:0.09559,m:14.5422},
	{y:31.0,l:0.3406,s:0.09551,m:14.6003},
	{y:32.0,l:0.3333,s:0.09543,m:14.6566},
	{y:33.0,l:0.3262,s:0.09535,m:14.7112},
	{y:34.0,l:0.3192,s:0.09527,m:14.7642},
	{y:35.0,l:0.3124,s:0.0952,m:14.8157},
	{y:36.0,l:0.3058,s:0.09513,m:14.8657},
	{y:37.0,l:0.2993,s:0.09506,m:14.9142},
	{y:38.0,l:0.2929,s:0.09499,m:14.9614},
	{y:39.0,l:0.2867,s:0.09492,m:15.0073},
	{y:40.0,l:0.2806,s:0.09485,m:15.052},
	{y:41.0,l:0.2747,s:0.09479,m:15.0955},
	{y:42.0,l:0.2688,s:0.09472,m:15.138},
	{y:43.0,l:0.263,s:0.09466,m:15.1794},
	{y:44.0,l:0.2574,s:0.0946,m:15.2198},
	{y:45.0,l:0.2519,s:0.09454,m:15.2591},
	{y:46.0,l:0.2464,s:0.09448,m:15.2974},
	{y:47.0,l:0.2411,s:0.09442,m:15.3347},
	{y:48.0,l:0.2358,s:0.09436,m:15.3709},
	{y:49.0,l:0.2306,s:0.09431,m:15.4063},
	{y:50.0,l:0.2255,s:0.09425,m:15.4408},
	{y:51.0,l:0.2205,s:0.0942,m:15.4744},
	{y:52.0,l:0.2156,s:0.09415,m:15.5072},
	{y:53.0,l:0.2107,s:0.0941,m:15.5393},
	{y:54.0,l:0.2059,s:0.09404,m:15.5706},
	{y:55.0,l:0.2012,s:0.09399,m:15.6012},
	{y:56.0,l:0.1966,s:0.09394,m:15.6311},
	{y:57.0,l:0.192,s:0.09389,m:15.6604},
	{y:58.0,l:0.1875,s:0.09385,m:15.689},
	{y:59.0,l:0.183,s:0.0938,m:15.717},
	{y:60.0,l:0.1787,s:0.09375,m:15.7444},
	{y:63.0,l:0.1658,s:0.09361,m:15.8232},
	{y:70.0,l:0.1377,s:0.09332,m:15.9874},
	{y:77.0,l:0.1118,s:0.09304,m:16.1277},
	{y:84.0,l:0.0877,s:0.09279,m:16.2485},
	{y:91.0,l:0.0652,s:0.09255,m:16.3531},
	{y:98.0,l:0.0442,s:0.09233,m:16.4438},
	{y:105.0,l:0.0243,s:0.09212,m:16.5222},
	{y:112.0,l:0.0055,s:0.09192,m:16.5901},
	{y:119.0,l:-0.0124,s:0.09173,m:16.6492},
	{y:126.0,l:-0.0293,s:0.09156,m:16.7009},
	{y:133.0,l:-0.0455,s:0.09139,m:16.746},
	{y:140.0,l:-0.061,s:0.09122,m:16.7848},
	{y:147.0,l:-0.0758,s:0.09107,m:16.8178},
	{y:154.0,l:-0.0901,s:0.09092,m:16.8452},
	{y:161.0,l:-0.1037,s:0.09077,m:16.8677},
	{y:168.0,l:-0.1169,s:0.09063,m:16.8854},
	{y:175.0,l:-0.1296,s:0.0905,m:16.8987},
	{y:182.0,l:-0.1418,s:0.09037,m:16.9077},
	{y:197.0,l:-0.1668,s:0.09011,m:16.9135},
	{y:227.0,l:-0.2119,s:0.08963,m:16.8795},
	{y:257.0,l:-0.2518,s:0.0892,m:16.7999},
	{y:287.0,l:-0.2876,s:0.08882,m:16.69},
	{y:317.0,l:-0.3201,s:0.08847,m:16.5645},
	{y:347.0,l:-0.3498,s:0.08815,m:16.4347},
	{y:377.0,l:-0.3772,s:0.08785,m:16.3075},
	{y:407.0,l:-0.4025,s:0.08758,m:16.1862},
	{y:437.0,l:-0.4261,s:0.08732,m:16.0725},
	{y:467.0,l:-0.4482,s:0.08708,m:15.9671},
	{y:497.0,l:-0.469,s:0.08686,m:15.8704},
	{y:527.0,l:-0.4887,s:0.08664,m:15.7825},
	{y:557.0,l:-0.5073,s:0.08644,m:15.703},
	{y:587.0,l:-0.525,s:0.08625,m:15.6319},
	{y:617.0,l:-0.5418,s:0.08607,m:15.569},
	{y:647.0,l:-0.5578,s:0.08589,m:15.5144},
	{y:677.0,l:-0.5732,s:0.08573,m:15.4681},
	{y:707.0,l:-0.588,s:0.08556,m:15.4298},
	{y:737.0,l:-0.5684,s:0.08454,m:15.6822},
	{y:767.0,l:-0.5684,s:0.08451,m:15.6532},
	{y:797.0,l:-0.5684,s:0.08449,m:15.6257},
	{y:827.0,l:-0.5684,s:0.08446,m:15.5992},
	{y:857.0,l:-0.5684,s:0.08444,m:15.5737},
	{y:887.0,l:-0.5684,s:0.08443,m:15.5488},
	{y:917.0,l:-0.5684,s:0.08444,m:15.5245},
	{y:947.0,l:-0.5684,s:0.08448,m:15.5007},
	{y:977.0,l:-0.5684,s:0.08456,m:15.4776},
	{y:1007.0,l:-0.5684,s:0.08468,m:15.4553},
	{y:1037.0,l:-0.5684,s:0.08485,m:15.4342},
	{y:1067.0,l:-0.5684,s:0.08508,m:15.4144},
	{y:1097.0,l:-0.5684,s:0.08536,m:15.396},
	{y:1127.0,l:-0.5684,s:0.0857,m:15.3791},
	{y:1157.0,l:-0.5684,s:0.08609,m:15.3636},
	{y:1187.0,l:-0.5684,s:0.08654,m:15.3493},
	{y:1217.0,l:-0.5684,s:0.08703,m:15.336},
	{y:1247.0,l:-0.5684,s:0.08755,m:15.3236},
	{y:1277.0,l:-0.5684,s:0.08811,m:15.3121},
	{y:1307.0,l:-0.5684,s:0.08868,m:15.3013},
	{y:1337.0,l:-0.5684,s:0.08927,m:15.2913},
	{y:1367.0,l:-0.5684,s:0.08986,m:15.2821},
	{y:1397.0,l:-0.5684,s:0.09045,m:15.274},
	{y:1427.0,l:-0.5684,s:0.09103,m:15.2669},
	{y:1457.0,l:-0.5684,s:0.09161,m:15.2609},
	{y:1487.0,l:-0.5684,s:0.09219,m:15.2562},
	{y:1517.0,l:-0.5684,s:0.09277,m:15.2527},
	{y:1547.0,l:-0.5684,s:0.09335,m:15.2506},
	{y:1577.0,l:-0.5684,s:0.09392,m:15.2497},
	{y:1607.0,l:-0.5684,s:0.09449,m:15.25},
	{y:1637.0,l:-0.5684,s:0.09503,m:15.2514},
	{y:1667.0,l:-0.5684,s:0.09556,m:15.2537},
	{y:1697.0,l:-0.5684,s:0.09606,m:15.2567},
	{y:1727.0,l:-0.5684,s:0.09653,m:15.2602},
	{y:1757.0,l:-0.5684,s:0.09697,m:15.2641},
	{y:1787.0,l:-0.5684,s:0.09739,m:15.2685},
	{y:1817.0,l:-0.5684,s:0.09777,m:15.2732},
	{y:1847.0,l:-0.5684,s:0.09814,m:15.2782}
}

define BMIForAgeMale:
{
	{y:0.0,l:-0.3053,s:0.0956,m:13.4069},
	{y:1.0,l:-0.1867,s:0.09597,m:13.3976},
	{y:2.0,l:-0.0681,s:0.09634,m:13.3883},
	{y:3.0,l:0.0505,s:0.09672,m:13.3791},
	{y:4.0,l:0.169,s:0.09709,m:13.3698},
	{y:5.0,l:0.2876,s:0.09746,m:13.3606},
	{y:6.0,l:0.4062,s:0.09784,m:13.3513},
	{y:7.0,l:0.5247,s:0.09821,m:13.3421},
	{y:8.0,l:0.5094,s:0.09769,m:13.3843},
	{y:9.0,l:0.4941,s:0.09716,m:13.4265},
	{y:10.0,l:0.4789,s:0.09664,m:13.4687},
	{y:11.0,l:0.4636,s:0.09611,m:13.511},
	{y:12.0,l:0.4483,s:0.09559,m:13.5532},
	{y:13.0,l:0.433,s:0.09507,m:13.5954},
	{y:14.0,l:0.4177,s:0.09454,m:13.6377},
	{y:15.0,l:0.4059,s:0.09416,m:13.7174},
	{y:16.0,l:0.3946,s:0.0938,m:13.8006},
	{y:17.0,l:0.3839,s:0.09347,m:13.8854},
	{y:18.0,l:0.3735,s:0.09315,m:13.9707},
	{y:19.0,l:0.3636,s:0.09285,m:14.0558},
	{y:20.0,l:0.3541,s:0.09257,m:14.1404},
	{y:21.0,l:0.3449,s:0.0923,m:14.2241},
	{y:22.0,l:0.336,s:0.09204,m:14.3065},
	{y:23.0,l:0.3274,s:0.0918,m:14.3877},
	{y:24.0,l:0.3191,s:0.09156,m:14.4675},
	{y:25.0,l:0.311,s:0.09134,m:14.5457},
	{y:26.0,l:0.3032,s:0.09112,m:14.6225},
	{y:27.0,l:0.2955,s:0.09092,m:14.6977},
	{y:28.0,l:0.2881,s:0.09072,m:14.7714},
	{y:29.0,l:0.2809,s:0.09053,m:14.8436},
	{y:30.0,l:0.2738,s:0.09035,m:14.914},
	{y:31.0,l:0.2669,s:0.09017,m:14.9822},
	{y:32.0,l:0.2602,s:0.09,m:15.0485},
	{y:33.0,l:0.2536,s:0.08984,m:15.1127},
	{y:34.0,l:0.2472,s:0.08968,m:15.175},
	{y:35.0,l:0.2409,s:0.08953,m:15.2355},
	{y:36.0,l:0.2348,s:0.08938,m:15.2942},
	{y:37.0,l:0.2287,s:0.08924,m:15.3511},
	{y:38.0,l:0.2228,s:0.0891,m:15.4062},
	{y:39.0,l:0.217,s:0.08897,m:15.4597},
	{y:40.0,l:0.2113,s:0.08884,m:15.5115},
	{y:41.0,l:0.2058,s:0.08871,m:15.5618},
	{y:42.0,l:0.2003,s:0.08859,m:15.6107},
	{y:43.0,l:0.1949,s:0.08847,m:15.6582},
	{y:44.0,l:0.1896,s:0.08835,m:15.7043},
	{y:45.0,l:0.1844,s:0.08824,m:15.7492},
	{y:46.0,l:0.1793,s:0.08813,m:15.7929},
	{y:47.0,l:0.1743,s:0.08802,m:15.8353},
	{y:48.0,l:0.1693,s:0.08792,m:15.8767},
	{y:49.0,l:0.1645,s:0.08782,m:15.9169},
	{y:50.0,l:0.1597,s:0.08772,m:15.956},
	{y:51.0,l:0.155,s:0.08762,m:15.9941},
	{y:52.0,l:0.1503,s:0.08753,m:16.0311},
	{y:53.0,l:0.1457,s:0.08743,m:16.0672},
	{y:54.0,l:0.1412,s:0.08734,m:16.1023},
	{y:55.0,l:0.1368,s:0.08725,m:16.1365},
	{y:56.0,l:0.1324,s:0.08717,m:16.1698},
	{y:57.0,l:0.128,s:0.08708,m:16.2021},
	{y:58.0,l:0.1238,s:0.087,m:16.2336},
	{y:59.0,l:0.1196,s:0.08692,m:16.2642},
	{y:60.0,l:0.1154,s:0.08684,m:16.2941},
	{y:63.0,l:0.1032,s:0.08661,m:16.3787},
	{y:70.0,l:0.0766,s:0.08612,m:16.5494},
	{y:77.0,l:0.052,s:0.08569,m:16.6882},
	{y:84.0,l:0.0291,s:0.08531,m:16.8016},
	{y:91.0,l:0.0077,s:0.08496,m:16.895},
	{y:98.0,l:-0.0124,s:0.08465,m:16.9725},
	{y:105.0,l:-0.0313,s:0.08437,m:17.0376},
	{y:112.0,l:-0.0492,s:0.08411,m:17.0931},
	{y:119.0,l:-0.0662,s:0.08387,m:17.1409},
	{y:126.0,l:-0.0824,s:0.08365,m:17.1825},
	{y:133.0,l:-0.0979,s:0.08345,m:17.2187},
	{y:140.0,l:-0.1127,s:0.08326,m:17.2497},
	{y:147.0,l:-0.1269,s:0.08309,m:17.2757},
	{y:154.0,l:-0.1405,s:0.08292,m:17.297},
	{y:161.0,l:-0.1536,s:0.08277,m:17.3139},
	{y:168.0,l:-0.1663,s:0.08262,m:17.3268},
	{y:175.0,l:-0.1785,s:0.08248,m:17.3361},
	{y:182.0,l:-0.1903,s:0.08235,m:17.3419},
	{y:197.0,l:-0.2144,s:0.08209,m:17.3431},
	{y:227.0,l:-0.2581,s:0.08163,m:17.3048},
	{y:257.0,l:-0.2972,s:0.08122,m:17.2242},
	{y:287.0,l:-0.3326,s:0.08087,m:17.1174},
	{y:317.0,l:-0.3649,s:0.08055,m:16.9974},
	{y:347.0,l:-0.3945,s:0.08025,m:16.8735},
	{y:377.0,l:-0.422,s:0.07998,m:16.75},
	{y:407.0,l:-0.4476,s:0.07973,m:16.6293},
	{y:437.0,l:-0.4715,s:0.07949,m:16.5134},
	{y:467.0,l:-0.494,s:0.07927,m:16.4033},
	{y:497.0,l:-0.5151,s:0.07906,m:16.2997},
	{y:527.0,l:-0.5351,s:0.07886,m:16.2027},
	{y:557.0,l:-0.5541,s:0.07867,m:16.1125},
	{y:587.0,l:-0.5721,s:0.07849,m:16.0296},
	{y:617.0,l:-0.5892,s:0.07831,m:15.9544},
	{y:647.0,l:-0.6056,s:0.07814,m:15.8871},
	{y:677.0,l:-0.6212,s:0.07798,m:15.8271},
	{y:707.0,l:-0.6362,s:0.07782,m:15.7733},
	{y:737.0,l:-0.6117,s:0.07786,m:16.011},
	{y:767.0,l:-0.5771,s:0.07793,m:15.9722},
	{y:797.0,l:-0.5435,s:0.07801,m:15.9343},
	{y:827.0,l:-0.5111,s:0.0781,m:15.8973},
	{y:857.0,l:-0.4803,s:0.0782,m:15.8611},
	{y:887.0,l:-0.4512,s:0.07831,m:15.8256},
	{y:917.0,l:-0.424,s:0.07843,m:15.7908},
	{y:947.0,l:-0.3988,s:0.07855,m:15.7567},
	{y:977.0,l:-0.376,s:0.07869,m:15.7234},
	{y:1007.0,l:-0.3556,s:0.07883,m:15.6907},
	{y:1037.0,l:-0.3376,s:0.07898,m:15.6588},
	{y:1067.0,l:-0.3223,s:0.07915,m:15.6277},
	{y:1097.0,l:-0.3097,s:0.07932,m:15.5976},
	{y:1127.0,l:-0.2997,s:0.0795,m:15.5685},
	{y:1157.0,l:-0.2927,s:0.07969,m:15.5406},
	{y:1187.0,l:-0.2884,s:0.0799,m:15.5141},
	{y:1217.0,l:-0.2869,s:0.08012,m:15.4889},
	{y:1247.0,l:-0.288,s:0.08035,m:15.4652},
	{y:1277.0,l:-0.2917,s:0.0806,m:15.443},
	{y:1307.0,l:-0.2977,s:0.08085,m:15.4222},
	{y:1337.0,l:-0.306,s:0.08113,m:15.4027},
	{y:1367.0,l:-0.3164,s:0.08141,m:15.3843},
	{y:1397.0,l:-0.3289,s:0.08171,m:15.3669},
	{y:1427.0,l:-0.3434,s:0.08202,m:15.3504},
	{y:1457.0,l:-0.3598,s:0.08234,m:15.3346},
	{y:1487.0,l:-0.3782,s:0.08267,m:15.3196},
	{y:1517.0,l:-0.3984,s:0.08302,m:15.3052},
	{y:1547.0,l:-0.4204,s:0.08337,m:15.2914},
	{y:1577.0,l:-0.4441,s:0.08373,m:15.2783},
	{y:1607.0,l:-0.4693,s:0.0841,m:15.2658},
	{y:1637.0,l:-0.4958,s:0.08448,m:15.254},
	{y:1667.0,l:-0.5236,s:0.08487,m:15.2426},
	{y:1697.0,l:-0.5525,s:0.08526,m:15.2318},
	{y:1727.0,l:-0.5824,s:0.08566,m:15.2214},
	{y:1757.0,l:-0.6135,s:0.08606,m:15.2117},
	{y:1787.0,l:-0.6456,s:0.08647,m:15.2026},
	{y:1817.0,l:-0.6787,s:0.08687,m:15.1941},
	{y:1847.0,l:-0.713,s:0.08728,m:15.1863}
}




define function ZscoreBMIForAgetables(sex String, age Decimal):
	if sex = 'female' then  
        First(BMIForAgeFemale c where c.y = base.AgeToMini(age) )
	else 
        First(BMIForAgeMale c where  c.y = base.AgeToMini(age))
            
define function generateZScoreBMIForAge(sex System.String, age System.Decimal, weight  System.Decimal)  : 
	 generateZScoreBMIForAgedet(ZscoreBMIForAgetables(sex,age), weight )

define function generateZScoreBMIForAgedet(row Tuple {y System.Decimal,l System.Decimal,s System.Decimal,m System.Decimal}, weight  System.Decimal):
    if row is not null then 
        base.computeZScore(
            weight,
            row.m , 
            row.l ,
            row.s 
        )
    else null


define function generateBMIFromAge(sex System.String, age System.Decimal, zscore  System.Decimal) : 
	 generateBMIFromAgedet(ZscoreBMIForAgetables(sex,age),zscore  )

define function generateBMIFromAgedet(row Tuple {y System.Decimal,l System.Decimal,s System.Decimal,m System.Decimal},zscore  System.Decimal) : 
    if row is not null then 
        base.computeReverseZScore(
            zscore,
            row.m , 
            row.l ,
            row.s 
        )
    else null