1 | GMRVPGC ;DBA/CJS - Pediatric Growth Chart HTML generator ;8/29/07 09:08
|
---|
2 | ;;5.0;GEN. MED. REC. - VITALS;**[patch list]**;Oct 31, 2002;Build 11
|
---|
3 | ;
|
---|
4 | EN(DFN) ;
|
---|
5 | N BMI,DIC,DIV,IO,LABEL,LINE,MAXAGE,NAME,NONE,POP,REF,ROOT,SERVER,SEX,STYLE,TMP,TYPE,VAL,VDT,XPARSYS,XQDIC,XQPSM,XQVOL,XVALS,YVALS
|
---|
6 | S SERVER=$$GET^XPAR("SYS","GMRV PED GROWTH CHART SERVER")
|
---|
7 | S ROOT=$$GET^XPAR("SYS","GMRV PED GROWTH CHART FOLDER")
|
---|
8 | ;
|
---|
9 | S D=^DPT(DFN,0),NAME=$P(D,U),SEX=$P(D,U,2),SEX=$S(SEX="M":1,SEX="F":2,1:0),DOB=$P(D,U,3),DOD=$P($G(^DPT(DFN,.35)),U),PID=$P($G(^DPT(DFN,.36)),U,3)
|
---|
10 | S Y=DOB D DD^%DT S BIRTH=Y,MAXAGE=$$MNTHSOLD($S(DOD="":DT,DOD'="":DOD),DOB)
|
---|
11 | ;
|
---|
12 | ; See if there are any pediatric vitals to be had
|
---|
13 | ; ^GMR(120.5,"AA",GMRVDFN,GMRVTYP,9999999-GMRVDT,DA)="" "rate" on 0 node piece 8
|
---|
14 | ; types: 8 = Height, 9 - Weight, 20 = Circumference/Girth, 73 - Head qualifier
|
---|
15 | S NONE=1 F TYPE=8,9,20 D
|
---|
16 | . S XVALS(TYPE)="",YVALS(TYPE)=""
|
---|
17 | . S VDT=0 F S VDT=$O(^GMR(120.5,"AA",DFN,TYPE,VDT)) Q:VDT'>0 D
|
---|
18 | . . S DA=+$O(^GMR(120.5,"AA",DFN,TYPE,VDT,0))
|
---|
19 | . . I TYPE=20 Q:'$D(^GMR(120.5,DA,5,"B",73)) ; Quit if not "HEAD"
|
---|
20 | . . Q:+$G(^GMR(120.5,DA,2)) ; Quit if Entered in Error
|
---|
21 | . . S AGE=$$MNTHSOLD(9999999-VDT,DOB),NONE=0
|
---|
22 | . . S XVALS(TYPE)=XVALS(TYPE)_","_AGE
|
---|
23 | . . S VAL=$P(^GMR(120.5,DA,0),U,8),VAL=$S("8,20"[TYPE:VAL*2.54,TYPE=9:VAL/2.2),VAL=$$ROUND(VAL)
|
---|
24 | . . I TYPE=8!(TYPE=9) S BMI(AGE,TYPE)=VAL
|
---|
25 | . . S YVALS(TYPE)=YVALS(TYPE)_","_VAL
|
---|
26 | . . Q
|
---|
27 | . Q
|
---|
28 | ;
|
---|
29 | ; BMI=WEIGHT/(HEIGHT**2) Weight in Kg, Height in cm
|
---|
30 | S AGE="",XVALS("BMI")="",YVALS("BMI")="",XVALS("WTHT")="",YVALS("WTHT")=""
|
---|
31 | F S AGE=$O(BMI(AGE)) Q:AGE'>0 I $D(BMI(AGE,8)),$D(BMI(AGE,9)) D
|
---|
32 | . S DIV=BMI(AGE,9)**2
|
---|
33 | . S:DIV'=0 XVALS("BMI")=XVALS("BMI")_","_AGE,YVALS("BMI")=YVALS("BMI")_","_$$ROUND(10000*BMI(AGE,9)/DIV)
|
---|
34 | . S XVALS("WTHT")=XVALS("WTHT")_","_BMI(AGE,8),YVALS("WTHT")=YVALS("WTHT")_","_BMI(AGE,9)
|
---|
35 | . Q
|
---|
36 | ;
|
---|
37 | ; Establish HTML doctype & head
|
---|
38 | S LINE=0 F S LINE=LINE+1,TMP(LINE)=$P($T(HEAD+LINE),";",3) Q:TMP(LINE)=""
|
---|
39 | ;
|
---|
40 | ; Set up the href links
|
---|
41 | S TMP(LINE)="<P>"_NAME_"</P><P>DOB: "_BIRTH_"</P>",LINE=LINE+1
|
---|
42 | S REF="<P><a href="""
|
---|
43 | S LABEL(0)=$S(SEX=1:"Male",1:"Female")_" Age in months vs. Weight kg.</a></P>"
|
---|
44 | S LABEL(1)=$S(SEX=1:"Male",1:"Female")_" Age in months vs. Height cm. 0-36 months</a></P>"
|
---|
45 | S LABEL(2)=$S(SEX=1:"Male",1:"Female")_" Age in months vs Head Circumference in cm. 0-36 months</a></p>"
|
---|
46 | S LABEL(4)=$S(SEX=1:"Male",1:"Female")_" Age in months vs. Height cm. over 36 months</a></P>"
|
---|
47 | S LABEL(5)=$S(SEX=1:"Male",1:"Female")_" Body Mass Index-for age</a></P>"
|
---|
48 | S LABEL(6)=$S(SEX=1:"Male",1:"Female")_" Weight vs Stature</a></P>"
|
---|
49 | S LABEL(7)=$S(SEX=1:"Male",1:"Female")_" Weight vs Length</a></P>"
|
---|
50 | F STYLE=0,1,2,4,5,6,7 S TYPE=$$TYPE(STYLE) D:$L(XVALS(TYPE))
|
---|
51 | . Q:("456"[STYLE)&(MAXAGE<36)
|
---|
52 | . S TMP(LINE)=REF_SERVER_"?style="_$$STRING(STYLE)_"&sex="_SEX_"&maxage="_$$AGE(MAXAGE,STYLE)_"&xvals="_$P(XVALS(TYPE),",",2,99)_"&yvals="_$P(YVALS(TYPE),",",2,99)_""">"_LABEL(STYLE)
|
---|
53 | . S LINE=LINE+1
|
---|
54 | . Q
|
---|
55 | ;
|
---|
56 | S:NONE TMP(LINE)="<P>THERE ARE NO GROWTH VITALS TO PLOT.</P>",LINE=LINE+1
|
---|
57 | ; last of the labels
|
---|
58 | S TMP(LINE)="<P>Note: should any xvals or yvals value be inappropriate, or there be an unequal number of values in both lists,",LINE=LINE+1
|
---|
59 | S TMP(LINE)="the patient plot will be ignored, and a ""blank"" growth chart with percentile values only will be shown.</P>",LINE=LINE+1
|
---|
60 | S TMP(LINE)="</body>"
|
---|
61 | S TMP(LINE+1)="</html>"
|
---|
62 | ;
|
---|
63 | ; Write out the file
|
---|
64 | D OPEN^%ZISH("OUTFILE",ROOT,DFN_".html","W") S:POP GMRVPGC="ERROR"
|
---|
65 | Q:POP
|
---|
66 | U IO
|
---|
67 | S LINE=0 F S LINE=$O(TMP(LINE)) Q:LINE'>0 W TMP(LINE),!
|
---|
68 | D CLOSE^%ZISH("OUTFILE")
|
---|
69 | Q
|
---|
70 | ;
|
---|
71 | ; convert age to months
|
---|
72 | MNTHSOLD(DATE,DOB) ;
|
---|
73 | S X1=DATE,X2=DOB D ^%DTC S X=X/30.42,X=$$ROUND(X)
|
---|
74 | Q X
|
---|
75 | ;
|
---|
76 | ROUND(X) ;
|
---|
77 | Q $P(X,".")_"."_$E($P(X,".",2),1,2)
|
---|
78 | ;
|
---|
79 | TYPE(STYLE) ;
|
---|
80 | Q $S(STYLE=0:9,STYLE=1:8,STYLE=2:20,STYLE=4:8,STYLE=5:"BMI",1:"WTHT")
|
---|
81 | ;
|
---|
82 | AGE(MAXAGE,STYLE) ;
|
---|
83 | I MAXAGE<36 Q MAXAGE
|
---|
84 | I "0456"[STYLE Q MAXAGE
|
---|
85 | Q 36
|
---|
86 | ;
|
---|
87 | STRING(STYLE) ;
|
---|
88 | I STYLE=0 Q "weight-age"
|
---|
89 | I STYLE=1 Q "length-age"
|
---|
90 | I STYLE=2 Q "head-age"
|
---|
91 | I STYLE=4 Q "stature-age"
|
---|
92 | I STYLE=5 Q "bmi-age"
|
---|
93 | I STYLE=6 Q "weight-stature"
|
---|
94 | I STYLE=7 Q "weight-length"
|
---|
95 | Q 0 ;oops!
|
---|
96 | ;
|
---|
97 | HEAD ;;
|
---|
98 | ;;<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
---|
99 | ;; "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
---|
100 | ;;<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
---|
101 | ;;<head>
|
---|
102 | ;; <title>Growth Chart Example</title>
|
---|
103 | ;; <meta http-equiv="Content-Type" CONTENT="text/html; charset=UTF-8">
|
---|
104 | ;; <meta http-equiv="Expires" CONTENT="0">
|
---|
105 | ;; <meta http-equiv="Cache-Control" CONTENT="no-cache">
|
---|
106 | ;; <meta http-equiv="PRAGMA" CONTENT="NO-CACHE">
|
---|
107 | ;;</head>
|
---|
108 | ;;<body>
|
---|
109 | ;;Click on any one of the following to display the available growth charts for your patient. Use the back button to return to the main page.
|
---|
110 | ;;
|
---|