source: WorldVistAEHR/trunk/r/GEN_MED_REC_VITALS-GMRV/GMRVFIX.m@ 1474

Last change on this file since 1474 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.9 KB
Line 
1GMRVFIX ;HIOFO/FT-CONVERT C TEMPERATURES TO F, THEN REPLACE ;3/12/04 09:50
2 ;;4.0;Vitals/Measurements;**16**;Apr 25, 1997
3 ;
4 ; This routine uses the following IAs:
5 ; #2320 - ^%ZISH calls (supported)
6 ; #10063 - ^%ZTLOAD calls (supported)
7 ; #10070 - ^XMD calls (supported)
8 ; #10103 - ^XLFDT calls (supported)
9 ; #10104 - ^XLFSTR calls (supported)
10 ;
11EN ; Main entry point
12 D QUEUE
13 Q
14QUEUE ; Queue the clean-up
15 N ZTDESC,ZTDTH,ZTRTN,ZTIO,ZTSAVE,ZTSK
16 S ZTRTN="START^GMRVFIX",ZTIO=""
17 S ZTDTH=$$NOW^XLFDT(),ZTDESC="GMRV*4*16 DATA REPAIR"
18 D ^%ZTLOAD
19 I ZTSK>0 D
20 .D EN^DDIOL("Task "_ZTSK_" has started. I'll send you a MailMan message when I finish.","","!?5")
21 .Q
22 I ZTSK'>0 D
23 .S GMRVMSG="I couldn't start the task to repair the data."
24 .D EN^DDIOL(GMRVMSG,"","!?5")
25 .D ERRMAIL(GMRVMSG)
26 .Q
27 Q
28START ; Start looping through the database
29 I $D(ZTQUEUED) S ZTREQ="@"
30 N GMRVCNT,GMRVFILE,GMRVFIXD,GMRVIEN,GMRVLINE,GMRVLOOP,GMRVMSG,GMRVNEW,GMRVNODE,GMRVPATH,GMRVOLD,GMRVOUT,GMRVSTOP,GMRVTEMP,GMRVTMP,GMRVTOTL
31 N POP
32 ; get TEMPERATURE ien
33 S GMRVTEMP=$O(^GMRD(120.51,"C","T",0))
34 I GMRVTEMP'>0 D Q
35 .S GMRVMSG="Can't find TEMPERATURE in the VITAL types file (120.5). Please log a NOIS."
36 .D ERRMAIL(GMRVMSG)
37 .Q
38 ;
39 S GMRVTMP(1)="The following TEMPERATURE readings in the GMRV VITAL MEASUREMENT (#120.5)"
40 S GMRVTMP(2)="file were modified. The old value was a number less than 45. It was assumed"
41 S GMRVTMP(3)="that the reading was done in Celsius units but not converted to Fahrenheit"
42 S GMRVTMP(4)="before being stored in the database. These entries have now been converted"
43 S GMRVTMP(5)="to Fahrenheit and saved. IEN indicates the record number in FILE 120.5."
44 S GMRVTMP(6)="OLD indicates the previous value and NEW indicates the new value."
45 S GMRVTMP(7)=" "
46 ; set host file name and directory path
47 S GMRVFILE="GMRV_4_16.DAT"
48 S GMRVPATH=$$PWD^%ZISH ;current directory
49 ; Open up device to print to
50 D OPEN^%ZISH("VITAL",GMRVPATH,GMRVFILE,"A") ;'A' for append
51 I POP D Q ;send email if device cannot be opened
52 .S GMRVMSG="Could not open file "_GMRVFILE_" in path "_GMRVPATH_"."
53 .D ERRMAIL(GMRVMSG)
54 .Q
55 U IO
56 ; from this point on, the Write commands are writing to the host file.
57 F GMRVLOOP=1:1:7 W !,GMRVTMP(GMRVLOOP)
58 S (GMRVFIXD,GMRVIEN,GMRVOUT,GMRVSTOP,GMRVTOTL)=0,GMRVCNT=7
59 F S GMRVIEN=$O(^GMR(120.5,"T",GMRVTEMP,GMRVIEN)) Q:'GMRVIEN!(GMRVOUT=1) D
60 .S GMRVSTOP=GMRVSTOP+1,GMRVTOTL=GMRVTOTL+1
61 .I GMRVSTOP=1000 D Q:GMRVOUT=1 ;check if the user stopped the task
62 ..S GMRVSTOP=0
63 ..I $$S^%ZTLOAD D
64 ...S GMRVOUT=1
65 ...S GMRVMSG="Job stopped by user while checking entry # "_GMRVIEN
66 ...W !,GMRVMSG
67 ...D ERRMAIL(GMRVMSG)
68 ...Q
69 ..Q
70 .Q:$P($G(^GMR(120.5,GMRVIEN,2)),U,1)=1 ;entered-in-error
71 .S GMRVNODE=$G(^GMR(120.5,GMRVIEN,0))
72 .Q:GMRVNODE=""
73 .Q:$P(GMRVNODE,U,3)'=GMRVTEMP ;not a temperature
74 .Q:+$P(GMRVNODE,U,8)'>0 ;not a numeric reading
75 .I +$P(GMRVNODE,U,8)>45!(+$P(GMRVNODE,U,8)=45) Q ;not celsius value
76 .S GMRVOLD=$P(GMRVNODE,U,8)
77 .S GMRVNEW=(+$P(GMRVNODE,U,8)*1.8)+32
78 .S GMRVNEW=$$ROUND(GMRVNEW) ;round to 2 decimal places
79 .S $P(^GMR(120.5,GMRVIEN,0),U,8)=GMRVNEW
80 .S GMRVFIXD=GMRVFIXD+1
81 .S GMRVLINE="IEN="_GMRVIEN_" "_"OLD="_GMRVOLD_" / "_"NEW="_GMRVNEW
82 .W !,GMRVLINE
83 .Q
84 I GMRVFIXD'>0 D
85 .S GMRVCNT=GMRVCNT+1
86 .S GMRVTMP(GMRVCNT)="No entries needed to be changed."
87 .W !,GMRVTMP(GMRVCNT)
88 .Q
89 S GMRVCNT=GMRVCNT+1
90 S GMRVTMP(GMRVCNT)=" "
91 W !,GMRVTMP(GMRVCNT)
92 S GMRVCNT=GMRVCNT+1
93 S GMRVTMP(GMRVCNT)="Total number of entries checked: "_GMRVTOTL
94 W !,GMRVTMP(GMRVCNT)
95 S GMRVCNT=GMRVCNT+1
96 S GMRVTMP(GMRVCNT)="Number of entries fixed: "_GMRVFIXD
97 W !,GMRVTMP(GMRVCNT)
98 S GMRVCNT=GMRVCNT+1
99 S GMRVTMP(GMRVCNT)=GMRVFILE_" in path "_GMRVPATH_" contains a listing of entries changed."
100 W !,GMRVTMP(GMRVCNT)
101 D CLOSE^%ZISH("VITAL")
102 K GMRVTMP
103 S GMRVTMP(1)="The GMRV*4*16 data repair is finished."
104 S GMRVTMP(2)=" "
105 S GMRVTMP(3)="Total number of entries checked: "_GMRVTOTL
106 S GMRVTMP(4)=" Number of entries fixed: "_GMRVFIXD
107 S GMRVTMP(5)=" "
108 S GMRVTMP(6)="The "_GMRVFILE_" file in the "_GMRVPATH_" directory"
109 S GMRVTMP(7)="contains a listing of entries changed."
110 D EMAIL(.GMRVTMP)
111 K GMRVFILE,GMRVPATH
112 Q
113EMAIL(GMRVTMP) ; send Mailman message when job is done
114 ; Input
115 ; GMRVTMP is message text
116 N DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
117 S XMSUB="GMRV*4*16 DATA REPAIR"
118 S XMY(DUZ)="",XMDUZ=.5
119 S XMTEXT="GMRVTMP("
120 D ^XMD
121 Q
122ERRMAIL(GMRVMSG) ; Send email with error message
123 ; Input
124 ; GMRVMSG is error message text
125 N DIFROM,GMRVTEXT,XMDUZ,XMSUB,XMTEXT,XMY
126 S XMSUB="Error with GMRV*4*16 Post-Installation"
127 S XMY(DUZ)="",XMDUZ=.5
128 S GMRVTEXT(1)="The following error occurred:"
129 S GMRVTEXT(2)=GMRVMSG
130 S GMRVTEXT(3)=" "
131 S GMRVTEXT(4)="When the error is fixed, please D EN^GMRVFIX to complete the"
132 S GMRVTEXT(5)="database repair."
133 S XMTEXT="GMRVTEXT("
134 D ^XMD
135 Q
136ROUND(X) ; Round off a number
137 N Y
138 S X=+$G(X)
139 S Y=$J(X,6,2)
140 S Y=$$STRIP^XLFSTR(Y," ")
141 S Y=+Y
142 Q Y
143 ;
Note: See TracBrowser for help on using the repository browser.