GMRVFIX ;HIOFO/FT-CONVERT C TEMPERATURES TO F, THEN REPLACE ;3/12/04 09:50
;;4.0;Vitals/Measurements;**16**;Apr 25, 1997
;
; This routine uses the following IAs:
; #2320 - ^%ZISH calls (supported)
; #10063 - ^%ZTLOAD calls (supported)
; #10070 - ^XMD calls (supported)
; #10103 - ^XLFDT calls (supported)
; #10104 - ^XLFSTR calls (supported)
;
EN ; Main entry point
D QUEUE
Q
QUEUE ; Queue the clean-up
N ZTDESC,ZTDTH,ZTRTN,ZTIO,ZTSAVE,ZTSK
S ZTRTN="START^GMRVFIX",ZTIO=""
S ZTDTH=$$NOW^XLFDT(),ZTDESC="GMRV*4*16 DATA REPAIR"
D ^%ZTLOAD
I ZTSK>0 D
.D EN^DDIOL("Task "_ZTSK_" has started. I'll send you a MailMan message when I finish.","","!?5")
.Q
I ZTSK'>0 D
.S GMRVMSG="I couldn't start the task to repair the data."
.D EN^DDIOL(GMRVMSG,"","!?5")
.D ERRMAIL(GMRVMSG)
.Q
Q
START ; Start looping through the database
I $D(ZTQUEUED) S ZTREQ="@"
N GMRVCNT,GMRVFILE,GMRVFIXD,GMRVIEN,GMRVLINE,GMRVLOOP,GMRVMSG,GMRVNEW,GMRVNODE,GMRVPATH,GMRVOLD,GMRVOUT,GMRVSTOP,GMRVTEMP,GMRVTMP,GMRVTOTL
N POP
; get TEMPERATURE ien
S GMRVTEMP=$O(^GMRD(120.51,"C","T",0))
I GMRVTEMP'>0 D Q
.S GMRVMSG="Can't find TEMPERATURE in the VITAL types file (120.5). Please log a NOIS."
.D ERRMAIL(GMRVMSG)
.Q
;
S GMRVTMP(1)="The following TEMPERATURE readings in the GMRV VITAL MEASUREMENT (#120.5)"
S GMRVTMP(2)="file were modified. The old value was a number less than 45. It was assumed"
S GMRVTMP(3)="that the reading was done in Celsius units but not converted to Fahrenheit"
S GMRVTMP(4)="before being stored in the database. These entries have now been converted"
S GMRVTMP(5)="to Fahrenheit and saved. IEN indicates the record number in FILE 120.5."
S GMRVTMP(6)="OLD indicates the previous value and NEW indicates the new value."
S GMRVTMP(7)=" "
; set host file name and directory path
S GMRVFILE="GMRV_4_16.DAT"
S GMRVPATH=$$PWD^%ZISH ;current directory
; Open up device to print to
D OPEN^%ZISH("VITAL",GMRVPATH,GMRVFILE,"A") ;'A' for append
I POP D Q ;send email if device cannot be opened
.S GMRVMSG="Could not open file "_GMRVFILE_" in path "_GMRVPATH_"."
.D ERRMAIL(GMRVMSG)
.Q
U IO
; from this point on, the Write commands are writing to the host file.
F GMRVLOOP=1:1:7 W !,GMRVTMP(GMRVLOOP)
S (GMRVFIXD,GMRVIEN,GMRVOUT,GMRVSTOP,GMRVTOTL)=0,GMRVCNT=7
F S GMRVIEN=$O(^GMR(120.5,"T",GMRVTEMP,GMRVIEN)) Q:'GMRVIEN!(GMRVOUT=1) D
.S GMRVSTOP=GMRVSTOP+1,GMRVTOTL=GMRVTOTL+1
.I GMRVSTOP=1000 D Q:GMRVOUT=1 ;check if the user stopped the task
..S GMRVSTOP=0
..I $$S^%ZTLOAD D
...S GMRVOUT=1
...S GMRVMSG="Job stopped by user while checking entry # "_GMRVIEN
...W !,GMRVMSG
...D ERRMAIL(GMRVMSG)
...Q
..Q
.Q:$P($G(^GMR(120.5,GMRVIEN,2)),U,1)=1 ;entered-in-error
.S GMRVNODE=$G(^GMR(120.5,GMRVIEN,0))
.Q:GMRVNODE=""
.Q:$P(GMRVNODE,U,3)'=GMRVTEMP ;not a temperature
.Q:+$P(GMRVNODE,U,8)'>0 ;not a numeric reading
.I +$P(GMRVNODE,U,8)>45!(+$P(GMRVNODE,U,8)=45) Q ;not celsius value
.S GMRVOLD=$P(GMRVNODE,U,8)
.S GMRVNEW=(+$P(GMRVNODE,U,8)*1.8)+32
.S GMRVNEW=$$ROUND(GMRVNEW) ;round to 2 decimal places
.S $P(^GMR(120.5,GMRVIEN,0),U,8)=GMRVNEW
.S GMRVFIXD=GMRVFIXD+1
.S GMRVLINE="IEN="_GMRVIEN_" "_"OLD="_GMRVOLD_" / "_"NEW="_GMRVNEW
.W !,GMRVLINE
.Q
I GMRVFIXD'>0 D
.S GMRVCNT=GMRVCNT+1
.S GMRVTMP(GMRVCNT)="No entries needed to be changed."
.W !,GMRVTMP(GMRVCNT)
.Q
S GMRVCNT=GMRVCNT+1
S GMRVTMP(GMRVCNT)=" "
W !,GMRVTMP(GMRVCNT)
S GMRVCNT=GMRVCNT+1
S GMRVTMP(GMRVCNT)="Total number of entries checked: "_GMRVTOTL
W !,GMRVTMP(GMRVCNT)
S GMRVCNT=GMRVCNT+1
S GMRVTMP(GMRVCNT)="Number of entries fixed: "_GMRVFIXD
W !,GMRVTMP(GMRVCNT)
S GMRVCNT=GMRVCNT+1
S GMRVTMP(GMRVCNT)=GMRVFILE_" in path "_GMRVPATH_" contains a listing of entries changed."
W !,GMRVTMP(GMRVCNT)
D CLOSE^%ZISH("VITAL")
K GMRVTMP
S GMRVTMP(1)="The GMRV*4*16 data repair is finished."
S GMRVTMP(2)=" "
S GMRVTMP(3)="Total number of entries checked: "_GMRVTOTL
S GMRVTMP(4)=" Number of entries fixed: "_GMRVFIXD
S GMRVTMP(5)=" "
S GMRVTMP(6)="The "_GMRVFILE_" file in the "_GMRVPATH_" directory"
S GMRVTMP(7)="contains a listing of entries changed."
D EMAIL(.GMRVTMP)
K GMRVFILE,GMRVPATH
Q
EMAIL(GMRVTMP) ; send Mailman message when job is done
; Input
; GMRVTMP is message text
N DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
S XMSUB="GMRV*4*16 DATA REPAIR"
S XMY(DUZ)="",XMDUZ=.5
S XMTEXT="GMRVTMP("
D ^XMD
Q
ERRMAIL(GMRVMSG) ; Send email with error message
; Input
; GMRVMSG is error message text
N DIFROM,GMRVTEXT,XMDUZ,XMSUB,XMTEXT,XMY
S XMSUB="Error with GMRV*4*16 Post-Installation"
S XMY(DUZ)="",XMDUZ=.5
S GMRVTEXT(1)="The following error occurred:"
S GMRVTEXT(2)=GMRVMSG
S GMRVTEXT(3)=" "
S GMRVTEXT(4)="When the error is fixed, please D EN^GMRVFIX to complete the"
S GMRVTEXT(5)="database repair."
S XMTEXT="GMRVTEXT("
D ^XMD
Q
ROUND(X) ; Round off a number
N Y
S X=+$G(X)
S Y=$J(X,6,2)
S Y=$$STRIP^XLFSTR(Y," ")
S Y=+Y
Q Y
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMRVFIX 5120 printed Oct 16, 2024@17:57:07 Page 2
GMRVFIX ;HIOFO/FT-CONVERT C TEMPERATURES TO F, THEN REPLACE ;3/12/04 09:50
+1 ;;4.0;Vitals/Measurements;**16**;Apr 25, 1997
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #2320 - ^%ZISH calls (supported)
+5 ; #10063 - ^%ZTLOAD calls (supported)
+6 ; #10070 - ^XMD calls (supported)
+7 ; #10103 - ^XLFDT calls (supported)
+8 ; #10104 - ^XLFSTR calls (supported)
+9 ;
EN ; Main entry point
+1 DO QUEUE
+2 QUIT
QUEUE ; Queue the clean-up
+1 NEW ZTDESC,ZTDTH,ZTRTN,ZTIO,ZTSAVE,ZTSK
+2 SET ZTRTN="START^GMRVFIX"
SET ZTIO=""
+3 SET ZTDTH=$$NOW^XLFDT()
SET ZTDESC="GMRV*4*16 DATA REPAIR"
+4 DO ^%ZTLOAD
+5 IF ZTSK>0
Begin DoDot:1
+6 DO EN^DDIOL("Task "_ZTSK_" has started. I'll send you a MailMan message when I finish.","","!?5")
+7 QUIT
End DoDot:1
+8 IF ZTSK'>0
Begin DoDot:1
+9 SET GMRVMSG="I couldn't start the task to repair the data."
+10 DO EN^DDIOL(GMRVMSG,"","!?5")
+11 DO ERRMAIL(GMRVMSG)
+12 QUIT
End DoDot:1
+13 QUIT
START ; Start looping through the database
+1 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+2 NEW GMRVCNT,GMRVFILE,GMRVFIXD,GMRVIEN,GMRVLINE,GMRVLOOP,GMRVMSG,GMRVNEW,GMRVNODE,GMRVPATH,GMRVOLD,GMRVOUT,GMRVSTOP,GMRVTEMP,GMRVTMP,GMRVTOTL
+3 NEW POP
+4 ; get TEMPERATURE ien
+5 SET GMRVTEMP=$ORDER(^GMRD(120.51,"C","T",0))
+6 IF GMRVTEMP'>0
Begin DoDot:1
+7 SET GMRVMSG="Can't find TEMPERATURE in the VITAL types file (120.5). Please log a NOIS."
+8 DO ERRMAIL(GMRVMSG)
+9 QUIT
End DoDot:1
QUIT
+10 ;
+11 SET GMRVTMP(1)="The following TEMPERATURE readings in the GMRV VITAL MEASUREMENT (#120.5)"
+12 SET GMRVTMP(2)="file were modified. The old value was a number less than 45. It was assumed"
+13 SET GMRVTMP(3)="that the reading was done in Celsius units but not converted to Fahrenheit"
+14 SET GMRVTMP(4)="before being stored in the database. These entries have now been converted"
+15 SET GMRVTMP(5)="to Fahrenheit and saved. IEN indicates the record number in FILE 120.5."
+16 SET GMRVTMP(6)="OLD indicates the previous value and NEW indicates the new value."
+17 SET GMRVTMP(7)=" "
+18 ; set host file name and directory path
+19 SET GMRVFILE="GMRV_4_16.DAT"
+20 ;current directory
SET GMRVPATH=$$PWD^%ZISH
+21 ; Open up device to print to
+22 ;'A' for append
DO OPEN^%ZISH("VITAL",GMRVPATH,GMRVFILE,"A")
+23 ;send email if device cannot be opened
IF POP
Begin DoDot:1
+24 SET GMRVMSG="Could not open file "_GMRVFILE_" in path "_GMRVPATH_"."
+25 DO ERRMAIL(GMRVMSG)
+26 QUIT
End DoDot:1
QUIT
+27 USE IO
+28 ; from this point on, the Write commands are writing to the host file.
+29 FOR GMRVLOOP=1:1:7
WRITE !,GMRVTMP(GMRVLOOP)
+30 SET (GMRVFIXD,GMRVIEN,GMRVOUT,GMRVSTOP,GMRVTOTL)=0
SET GMRVCNT=7
+31 FOR
SET GMRVIEN=$ORDER(^GMR(120.5,"T",GMRVTEMP,GMRVIEN))
if 'GMRVIEN!(GMRVOUT=1)
QUIT
Begin DoDot:1
+32 SET GMRVSTOP=GMRVSTOP+1
SET GMRVTOTL=GMRVTOTL+1
+33 ;check if the user stopped the task
IF GMRVSTOP=1000
Begin DoDot:2
+34 SET GMRVSTOP=0
+35 IF $$S^%ZTLOAD
Begin DoDot:3
+36 SET GMRVOUT=1
+37 SET GMRVMSG="Job stopped by user while checking entry # "_GMRVIEN
+38 WRITE !,GMRVMSG
+39 DO ERRMAIL(GMRVMSG)
+40 QUIT
End DoDot:3
+41 QUIT
End DoDot:2
if GMRVOUT=1
QUIT
+42 ;entered-in-error
if $PIECE($GET(^GMR(120.5,GMRVIEN,2)),U,1)=1
QUIT
+43 SET GMRVNODE=$GET(^GMR(120.5,GMRVIEN,0))
+44 if GMRVNODE=""
QUIT
+45 ;not a temperature
if $PIECE(GMRVNODE,U,3)'=GMRVTEMP
QUIT
+46 ;not a numeric reading
if +$PIECE(GMRVNODE,U,8)'>0
QUIT
+47 ;not celsius value
IF +$PIECE(GMRVNODE,U,8)>45!(+$PIECE(GMRVNODE,U,8)=45)
QUIT
+48 SET GMRVOLD=$PIECE(GMRVNODE,U,8)
+49 SET GMRVNEW=(+$PIECE(GMRVNODE,U,8)*1.8)+32
+50 ;round to 2 decimal places
SET GMRVNEW=$$ROUND(GMRVNEW)
+51 SET $PIECE(^GMR(120.5,GMRVIEN,0),U,8)=GMRVNEW
+52 SET GMRVFIXD=GMRVFIXD+1
+53 SET GMRVLINE="IEN="_GMRVIEN_" "_"OLD="_GMRVOLD_" / "_"NEW="_GMRVNEW
+54 WRITE !,GMRVLINE
+55 QUIT
End DoDot:1
+56 IF GMRVFIXD'>0
Begin DoDot:1
+57 SET GMRVCNT=GMRVCNT+1
+58 SET GMRVTMP(GMRVCNT)="No entries needed to be changed."
+59 WRITE !,GMRVTMP(GMRVCNT)
+60 QUIT
End DoDot:1
+61 SET GMRVCNT=GMRVCNT+1
+62 SET GMRVTMP(GMRVCNT)=" "
+63 WRITE !,GMRVTMP(GMRVCNT)
+64 SET GMRVCNT=GMRVCNT+1
+65 SET GMRVTMP(GMRVCNT)="Total number of entries checked: "_GMRVTOTL
+66 WRITE !,GMRVTMP(GMRVCNT)
+67 SET GMRVCNT=GMRVCNT+1
+68 SET GMRVTMP(GMRVCNT)="Number of entries fixed: "_GMRVFIXD
+69 WRITE !,GMRVTMP(GMRVCNT)
+70 SET GMRVCNT=GMRVCNT+1
+71 SET GMRVTMP(GMRVCNT)=GMRVFILE_" in path "_GMRVPATH_" contains a listing of entries changed."
+72 WRITE !,GMRVTMP(GMRVCNT)
+73 DO CLOSE^%ZISH("VITAL")
+74 KILL GMRVTMP
+75 SET GMRVTMP(1)="The GMRV*4*16 data repair is finished."
+76 SET GMRVTMP(2)=" "
+77 SET GMRVTMP(3)="Total number of entries checked: "_GMRVTOTL
+78 SET GMRVTMP(4)=" Number of entries fixed: "_GMRVFIXD
+79 SET GMRVTMP(5)=" "
+80 SET GMRVTMP(6)="The "_GMRVFILE_" file in the "_GMRVPATH_" directory"
+81 SET GMRVTMP(7)="contains a listing of entries changed."
+82 DO EMAIL(.GMRVTMP)
+83 KILL GMRVFILE,GMRVPATH
+84 QUIT
EMAIL(GMRVTMP) ; send Mailman message when job is done
+1 ; Input
+2 ; GMRVTMP is message text
+3 NEW DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
+4 SET XMSUB="GMRV*4*16 DATA REPAIR"
+5 SET XMY(DUZ)=""
SET XMDUZ=.5
+6 SET XMTEXT="GMRVTMP("
+7 DO ^XMD
+8 QUIT
ERRMAIL(GMRVMSG) ; Send email with error message
+1 ; Input
+2 ; GMRVMSG is error message text
+3 NEW DIFROM,GMRVTEXT,XMDUZ,XMSUB,XMTEXT,XMY
+4 SET XMSUB="Error with GMRV*4*16 Post-Installation"
+5 SET XMY(DUZ)=""
SET XMDUZ=.5
+6 SET GMRVTEXT(1)="The following error occurred:"
+7 SET GMRVTEXT(2)=GMRVMSG
+8 SET GMRVTEXT(3)=" "
+9 SET GMRVTEXT(4)="When the error is fixed, please D EN^GMRVFIX to complete the"
+10 SET GMRVTEXT(5)="database repair."
+11 SET XMTEXT="GMRVTEXT("
+12 DO ^XMD
+13 QUIT
ROUND(X) ; Round off a number
+1 NEW Y
+2 SET X=+$GET(X)
+3 SET Y=$JUSTIFY(X,6,2)
+4 SET Y=$$STRIP^XLFSTR(Y," ")
+5 SET Y=+Y
+6 QUIT Y
+7 ;