source: PGC/trunk/p/GMRVPGC.m@ 1081

Last change on this file since 1081 was 958, checked in by George Lilly, 14 years ago

Pediatric Growth Charts initial release

File size: 5.3 KB
Line 
1GMRVPGC ;DBA/CJS - Pediatric Growth Chart HTML generator ;9/26/10 21:59
2 ;;5.0;GEN. MED. REC. - VITALS;**[patch list]**;Oct 31, 2002;Build 15
3 ;
4EN(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 meters
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,8)**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 kilograms</a></P>"
44 S LABEL(1)=$S(SEX=1:"Male",1:"Female")_" Age in months vs. Length centimeters 0-36 months</a></P>"
45 S LABEL(2)=$S(SEX=1:"Male",1:"Female")_" Age in months vs Head Circumference in centimeters 0-36 months</a></p>"
46 S LABEL(4)=$S(SEX=1:"Male",1:"Female")_" Age in months vs. Height centimeters 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 S TITLE(0)=$S(SEX=1:"Male",1:"Female")_" Age in months vs. Weight in kilograms"
51 S TITLE(1)=$S(SEX=1:"Male",1:"Female")_" Age in months vs. Length centimeters for 0-36 months"
52 S TITLE(2)=$S(SEX=1:"Male",1:"Female")_" Age in months vs Head Circumference in centimeters for 0-36 months"
53 S TITLE(4)=$S(SEX=1:"Male",1:"Female")_" Age in months vs. Height centimeters over 36 months"
54 S TITLE(5)=$S(SEX=1:"Male",1:"Female")_" Body Mass Index vs. Age in Months from 24-240 Months"
55 S TITLE(6)=$S(SEX=1:"Male",1:"Female")_" Weight in Kilograms vs. Height in centimeters"
56 S TITLE(7)=$S(SEX=1:"Male",1:"Female")_" Weight in Kilograms vs. Length in centimeters"
57 F STYLE=0,1,2,4,5,6,7 S TYPE=$$TYPE(STYLE) D:$L(XVALS(TYPE))
58 . Q:("456"[STYLE)&(MAXAGE<36)
59 . S TMP(LINE)=REF_SERVER_"?style="_$$STRING(STYLE)_"&title="_TITLE(STYLE)_"&sex="_SEX_"&maxage="_$$AGE(MAXAGE,STYLE)_"&xvals="_$P(XVALS(TYPE),",",2,99)_"&yvals="_$P(YVALS(TYPE),",",2,99)_""">"_LABEL(STYLE)
60 . S LINE=LINE+1
61 . Q
62 ;
63 S:NONE TMP(LINE)="<P>THERE ARE NO GROWTH VITALS TO PLOT.</P>",LINE=LINE+1
64 ; last of the labels
65 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
66 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
67 S TMP(LINE)="</body>"
68 S TMP(LINE+1)="</html>"
69 ;
70 ; Write out the file
71 D OPEN^%ZISH("OUTFILE",ROOT,DFN_".html","W") S:POP GMRVPGC="ERROR"
72 Q:POP
73 U IO
74 S LINE=0 F S LINE=$O(TMP(LINE)) Q:LINE'>0 W TMP(LINE),!
75 D CLOSE^%ZISH("OUTFILE")
76 Q
77 ;
78 ; convert age to months
79MNTHSOLD(DATE,DOB) ;
80 S X1=DATE,X2=DOB D ^%DTC S X=X/30.42,X=$$ROUND(X)
81 Q X
82 ;
83ROUND(X) ;
84 Q $P(X,".")_"."_$E($P(X,".",2),1,2)
85 ;
86TYPE(STYLE) ;
87 Q $S(STYLE=0:9,STYLE=1:8,STYLE=2:20,STYLE=4:8,STYLE=5:"BMI",1:"WTHT")
88 ;
89AGE(MAXAGE,STYLE) ;
90 I MAXAGE<36 Q MAXAGE
91 I "0456"[STYLE Q MAXAGE
92 Q 36
93 ;
94STRING(STYLE) ;
95 I STYLE=0 Q "weight-age"
96 I STYLE=1 Q "length-age"
97 I STYLE=2 Q "head-age"
98 I STYLE=4 Q "stature-age"
99 I STYLE=5 Q "bmi-age"
100 I STYLE=6 Q "weight-stature"
101 I STYLE=7 Q "weight-length"
102 Q 0 ;oops!
103 ;
104HEAD ;;
105 ;;<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
106 ;; "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
107 ;;<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
108 ;;<head>
109 ;; <title>Growth Chart Example</title>
110 ;; <meta http-equiv="Content-Type" CONTENT="text/html; charset=UTF-8">
111 ;; <meta http-equiv="Expires" CONTENT="0">
112 ;; <meta http-equiv="Cache-Control" CONTENT="no-cache">
113 ;; <meta http-equiv="PRAGMA" CONTENT="NO-CACHE">
114 ;;</head>
115 ;;<body>
116 ;;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.
117 ;;
Note: See TracBrowser for help on using the repository browser.