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: ArmCircumferenceForAge

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

Related Artifacts

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

Parameters

zscoreindecimal
Ageindecimal
sexindecimal
generateArmCircumferenceFromAgeoutdecimal
generateZScoreArmCircumferenceForAgeoutdecimal
ZscoreArmCircumferenceForAgetables_soutdecimal
ZscoreArmCircumferenceForAgetables_moutdecimal
ZscoreArmCircumferenceForAgetables_loutdecimal

Data Requirements

Type: Patient (Patient)

Contents

text/cql


library ArmCircumferenceForAge 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 ArmCircumferenceForAge  Z-Score from the acanthro files
codesystem "administrative-gender": 'http://hl7.org/fhir/administrative-gender'
//code "Female" : 'female' from "administrative-gender"  display 'Female'


define ArmCircumferenceForAgeFemale:
{
	{y:91.0,l:-0.1733,s:0.08262,m:13.0245},
	{y:98.0,l:-0.1733,s:0.08271,m:13.1107},
	{y:105.0,l:-0.1733,s:0.0828,m:13.1919},
	{y:112.0,l:-0.1733,s:0.08288,m:13.2679},
	{y:119.0,l:-0.1733,s:0.08296,m:13.3386},
	{y:126.0,l:-0.1733,s:0.08303,m:13.4039},
	{y:133.0,l:-0.1733,s:0.08309,m:13.4642},
	{y:140.0,l:-0.1733,s:0.08316,m:13.5197},
	{y:147.0,l:-0.1733,s:0.08321,m:13.5709},
	{y:154.0,l:-0.1733,s:0.08327,m:13.618},
	{y:161.0,l:-0.1733,s:0.08331,m:13.6616},
	{y:168.0,l:-0.1733,s:0.08336,m:13.7019},
	{y:175.0,l:-0.1733,s:0.0834,m:13.7394},
	{y:182.0,l:-0.1733,s:0.08343,m:13.7741},
	{y:197.0,l:-0.1733,s:0.08348,m:13.8407},
	{y:227.0,l:-0.1733,s:0.08352,m:13.9477},
	{y:257.0,l:-0.1733,s:0.08348,m:14.0292},
	{y:287.0,l:-0.1733,s:0.08335,m:14.0918},
	{y:317.0,l:-0.1733,s:0.08317,m:14.1413},
	{y:347.0,l:-0.1733,s:0.08295,m:14.1829},
	{y:377.0,l:-0.1733,s:0.0827,m:14.2215},
	{y:407.0,l:-0.1733,s:0.08244,m:14.2602},
	{y:437.0,l:-0.1733,s:0.08218,m:14.3009},
	{y:467.0,l:-0.1733,s:0.08194,m:14.3444},
	{y:497.0,l:-0.1733,s:0.08173,m:14.3913},
	{y:527.0,l:-0.1733,s:0.08154,m:14.442},
	{y:557.0,l:-0.1733,s:0.08139,m:14.4964},
	{y:587.0,l:-0.1733,s:0.08128,m:14.5544},
	{y:617.0,l:-0.1733,s:0.08121,m:14.616},
	{y:647.0,l:-0.1733,s:0.08118,m:14.6813},
	{y:677.0,l:-0.1733,s:0.08118,m:14.7501},
	{y:707.0,l:-0.1733,s:0.08122,m:14.8217},
	{y:737.0,l:-0.1733,s:0.08129,m:14.8957},
	{y:767.0,l:-0.1733,s:0.08138,m:14.9712},
	{y:797.0,l:-0.1733,s:0.0815,m:15.0468},
	{y:827.0,l:-0.1733,s:0.08164,m:15.1212},
	{y:857.0,l:-0.1733,s:0.08181,m:15.1928},
	{y:887.0,l:-0.1733,s:0.08199,m:15.2609},
	{y:917.0,l:-0.1733,s:0.0822,m:15.3248},
	{y:947.0,l:-0.1733,s:0.08243,m:15.3845},
	{y:977.0,l:-0.1733,s:0.08268,m:15.4405},
	{y:1007.0,l:-0.1733,s:0.08294,m:15.494},
	{y:1037.0,l:-0.1733,s:0.08323,m:15.5459},
	{y:1067.0,l:-0.1733,s:0.08353,m:15.597},
	{y:1097.0,l:-0.1733,s:0.08384,m:15.6477},
	{y:1127.0,l:-0.1733,s:0.08417,m:15.6983},
	{y:1157.0,l:-0.1733,s:0.08452,m:15.749},
	{y:1187.0,l:-0.1733,s:0.08487,m:15.7996},
	{y:1217.0,l:-0.1733,s:0.08524,m:15.85},
	{y:1247.0,l:-0.1733,s:0.08562,m:15.9001},
	{y:1277.0,l:-0.1733,s:0.086,m:15.9496},
	{y:1307.0,l:-0.1733,s:0.0864,m:15.9986},
	{y:1337.0,l:-0.1733,s:0.0868,m:16.0473},
	{y:1367.0,l:-0.1733,s:0.0872,m:16.0957},
	{y:1397.0,l:-0.1733,s:0.0876,m:16.1441},
	{y:1427.0,l:-0.1733,s:0.08801,m:16.1925},
	{y:1457.0,l:-0.1733,s:0.08842,m:16.2412},
	{y:1487.0,l:-0.1733,s:0.08884,m:16.2901},
	{y:1517.0,l:-0.1733,s:0.08925,m:16.3395},
	{y:1547.0,l:-0.1733,s:0.08966,m:16.3892},
	{y:1577.0,l:-0.1733,s:0.09008,m:16.4393},
	{y:1607.0,l:-0.1733,s:0.09049,m:16.4897},
	{y:1637.0,l:-0.1733,s:0.0909,m:16.5403},
	{y:1667.0,l:-0.1733,s:0.0913,m:16.5907},
	{y:1697.0,l:-0.1733,s:0.09171,m:16.641},
	{y:1727.0,l:-0.1733,s:0.09211,m:16.6908},
	{y:1757.0,l:-0.1733,s:0.09251,m:16.7402},
	{y:1787.0,l:-0.1733,s:0.0929,m:16.7891},
	{y:1817.0,l:-0.1733,s:0.09329,m:16.8377},
	{y:1847.0,l:-0.1733,s:0.09368,m:16.886}
}

define ArmCircumferenceForAgeMale:
{
	{y:91.0,l:0.3933,s:0.07474,m:13.4779},
	{y:98.0,l:0.3821,s:0.07486,m:13.5607},
	{y:105.0,l:0.3714,s:0.07498,m:13.6392},
	{y:112.0,l:0.3611,s:0.07509,m:13.7134},
	{y:119.0,l:0.3513,s:0.07519,m:13.7834},
	{y:126.0,l:0.3418,s:0.0753,m:13.849},
	{y:133.0,l:0.3327,s:0.0754,m:13.9105},
	{y:140.0,l:0.3239,s:0.07549,m:13.9679},
	{y:147.0,l:0.3153,s:0.07559,m:14.0214},
	{y:154.0,l:0.307,s:0.07568,m:14.071},
	{y:161.0,l:0.299,s:0.07577,m:14.117},
	{y:168.0,l:0.2912,s:0.07585,m:14.1597},
	{y:175.0,l:0.2836,s:0.07593,m:14.1992},
	{y:182.0,l:0.2762,s:0.076,m:14.2358},
	{y:197.0,l:0.2609,s:0.07615,m:14.3053},
	{y:227.0,l:0.2325,s:0.0764,m:14.4135},
	{y:257.0,l:0.2064,s:0.07657,m:14.4907},
	{y:287.0,l:0.1822,s:0.0767,m:14.5471},
	{y:317.0,l:0.1596,s:0.07679,m:14.5902},
	{y:347.0,l:0.1384,s:0.07686,m:14.6256},
	{y:377.0,l:0.1184,s:0.07691,m:14.657},
	{y:407.0,l:0.0993,s:0.07696,m:14.687},
	{y:437.0,l:0.0812,s:0.077,m:14.7174},
	{y:467.0,l:0.0638,s:0.07704,m:14.7495},
	{y:497.0,l:0.0471,s:0.07708,m:14.7842},
	{y:527.0,l:0.0311,s:0.07711,m:14.8218},
	{y:557.0,l:0.0157,s:0.07714,m:14.8622},
	{y:587.0,l:0.0008,s:0.07718,m:14.9054},
	{y:617.0,l:-0.0136,s:0.07722,m:14.9519},
	{y:647.0,l:-0.0275,s:0.07727,m:15.0016},
	{y:677.0,l:-0.0411,s:0.07732,m:15.0542},
	{y:707.0,l:-0.0542,s:0.07739,m:15.1093},
	{y:737.0,l:-0.067,s:0.07748,m:15.1659},
	{y:767.0,l:-0.0795,s:0.07758,m:15.2231},
	{y:797.0,l:-0.0916,s:0.07769,m:15.2799},
	{y:827.0,l:-0.1035,s:0.07782,m:15.3354},
	{y:857.0,l:-0.115,s:0.07796,m:15.3892},
	{y:887.0,l:-0.1264,s:0.07812,m:15.4408},
	{y:917.0,l:-0.1374,s:0.0783,m:15.4901},
	{y:947.0,l:-0.1483,s:0.07848,m:15.537},
	{y:977.0,l:-0.1589,s:0.07868,m:15.5814},
	{y:1007.0,l:-0.1693,s:0.07889,m:15.6236},
	{y:1037.0,l:-0.1795,s:0.07911,m:15.6639},
	{y:1067.0,l:-0.1895,s:0.07934,m:15.7024},
	{y:1097.0,l:-0.1993,s:0.07957,m:15.7395},
	{y:1127.0,l:-0.209,s:0.07982,m:15.7755},
	{y:1157.0,l:-0.2185,s:0.08007,m:15.8105},
	{y:1187.0,l:-0.2278,s:0.08032,m:15.8449},
	{y:1217.0,l:-0.237,s:0.08058,m:15.8788},
	{y:1247.0,l:-0.246,s:0.08084,m:15.9122},
	{y:1277.0,l:-0.2549,s:0.0811,m:15.9451},
	{y:1307.0,l:-0.2637,s:0.08137,m:15.9778},
	{y:1337.0,l:-0.2723,s:0.08164,m:16.01},
	{y:1367.0,l:-0.2808,s:0.08192,m:16.0419},
	{y:1397.0,l:-0.2892,s:0.08219,m:16.0735},
	{y:1427.0,l:-0.2975,s:0.08247,m:16.1048},
	{y:1457.0,l:-0.3056,s:0.08275,m:16.1359},
	{y:1487.0,l:-0.3137,s:0.08303,m:16.1668},
	{y:1517.0,l:-0.3216,s:0.08331,m:16.1977},
	{y:1547.0,l:-0.3295,s:0.08359,m:16.2285},
	{y:1577.0,l:-0.3372,s:0.08387,m:16.2594},
	{y:1607.0,l:-0.3449,s:0.08415,m:16.2904},
	{y:1637.0,l:-0.3524,s:0.08444,m:16.3215},
	{y:1667.0,l:-0.3599,s:0.08472,m:16.3526},
	{y:1697.0,l:-0.3673,s:0.08501,m:16.3838},
	{y:1727.0,l:-0.3746,s:0.08529,m:16.415},
	{y:1757.0,l:-0.3818,s:0.08558,m:16.4463},
	{y:1787.0,l:-0.3889,s:0.08587,m:16.4778},
	{y:1817.0,l:-0.396,s:0.08615,m:16.5094},
	{y:1847.0,l:-0.4029,s:0.08644,m:16.541}
}




define function ZscoreArmCircumferenceForAgetables(sex String, age Decimal):
	if sex = 'female' then  
        First(ArmCircumferenceForAgeFemale c where c.y = base.AgeToMini(age) )
	else 
        First(ArmCircumferenceForAgeMale c where  c.y = base.AgeToMini(age))
            
define function generateZScoreArmCircumferenceForAge(sex System.String, age System.Decimal, weight  System.Decimal)  : 
	 generateZScoreArmCircumferenceForAgedet(ZscoreArmCircumferenceForAgetables(sex,age), weight )

define function generateZScoreArmCircumferenceForAgedet(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 generateArmCircumferenceFromAge(sex System.String, age System.Decimal, zscore  System.Decimal) : 
	 generateArmCircumferenceFromAgedet(ZscoreArmCircumferenceForAgetables(sex,age),zscore  )

define function generateArmCircumferenceFromAgedet(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