GMVZEROS ;HIOFO/FT - LOOK FOR TRAILING ZEROES IN FILE 120.5, FIELD .01 ;08/27/08 16:07
;;5.0;GEN. MED. REC. - VITALS;**25**;Oct 31, 2002;Build 4
;
; This routine uses the following IAs:
; #2320 - ^%ZISH calls (supported)
; #10063 - ^%ZTLOAD (supported)
; #10070 - ^XMD calls (supported)
; #10103 - ^XLFDT calls (supported)
;
QUEUE ;Queue job as a background task
N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSK
D EN^DDIOL("Starting FIX^GMVZEROS as a background task.","","!?5")
S ZTDESC="GMRV*5.0*25 D/T REPAIR UTILITY",ZTIO=""
S ZTRTN="FIX^GMVZEROS",ZTDTH=$$NOW^XLFDT()
D ^%ZTLOAD
D EN^DDIOL("Task "_ZTSK_" has started. I'll send you a MailMan message when I finish.","","!?5")
Q
;
FIX ;Search for string dates and repair them.
I $D(ZTQUEUED) S ZTREQ="@"
N DA,DIE,DR,X,Y,ZTSTOP
N GMVBAD,GMVCNT,GMVDATE,GMVEND,GMVIEN,GMVFILE,GMVFOUND,GMVLINE,GMVPATH,GMVSTART,GMVTEXT,GMVTOTAL
N POP
S DIE=120.5,GMVLINE=1
S GMVTEXT(GMVLINE)="Starting search for string dates in FILE 120.5 at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
S (GMVBAD,GMVCNT,GMVIEN,GMVFOUND,GMVTOTAL)=0
; set host file name and directory path
S GMVFILE="GMRV_5_25.DAT"
S GMVPATH=$$PWD^%ZISH ;current directory
; Open up device to print to
D OPEN^%ZISH("VITAL",GMVPATH,GMVFILE,"A") ;'A' for append
I POP D Q ;send email if device cannot be opened
.S GMVLINE=GMVLINE+1
.S GMVTEXT(GMVLINE)="Could not open file "_GMVFILE_" in path "_GMVPATH_"."
.S GMVLINE=GMVLINE+1
.S GMVTEXT(GMVLINE)="Stopping at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
.D EMAIL(.GMVTEXT)
.Q
U IO
; from this point on, the Write commands are writing to the host file.
F S GMVIEN=+$O(^GMR(120.5,GMVIEN)) Q:GMVIEN=0!($G(ZTSTOP)=1) D
.S GMVTOTAL=GMVTOTAL+1
.S GMVCNT=GMVCNT+1
.I GMVCNT>10000 D ;check if user wants to stop the job
..S GMVCNT=0
..Q:'$D(ZTQUEUED) ;not a background task
..I $$S^%ZTLOAD D
...S ZTSTOP=1 ;set TaskMan variable equal to 1 to stop task
...W !,"Task stopped at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
...W !,"Stopped at record "_GMVIEN
...K ZTREQ ;keep record of task in task log
.S GMVDATE=$P(^GMR(120.5,GMVIEN,0),U,1)
.I GMVDATE'=+GMVDATE D
..I $$DTCHECK(+GMVDATE,"TX")=0 D Q ;not a real date/time
...W !,"IEN="_GMVIEN,?15,GMVDATE_" is not a real date/time. No action taken."
...S GMVBAD=GMVBAD+1
..S GMVFOUND=GMVFOUND+1
..W !,"IEN="_GMVIEN,?15,GMVDATE_" changed to "_+GMVDATE
..S DR=".01///"_+GMVDATE,DA=GMVIEN
..D ^DIE
W !!,"# of Records changed: "_GMVFOUND
D CLOSE^%ZISH("VITAL")
S GMVLINE=GMVLINE+1
S GMVTEXT(GMVLINE)="Finished at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
S GMVLINE=GMVLINE+1
S GMVTEXT(GMVLINE)="Records checked: "_GMVTOTAL
S GMVLINE=GMVLINE+1
S GMVTEXT(GMVLINE)="Records changed: "_GMVFOUND
S GMVLINE=GMVLINE+1
S GMVTEXT(GMVLINE)="Records that could not be changed: "_GMVBAD
S GMVLINE=GMVLINE+1
S GMVTEXT(GMVLINE)="The "_GMVFILE_" file in the "_GMVPATH_" directory contains"
S GMVLINE=GMVLINE+1
S GMVTEXT(GMVLINE)="a list of entries changed and those that could not be changed."
D EMAIL(.GMVTEXT)
Q
;
DTCHECK(GMVDT,GMVPDT) ; Is GMVDT a real date/time?
; Input: GMVDT - date/time (FM internal format)(req)
; GMVPDT - %DT value (opt - default is 'TX')
; Output: 1 = Yes
; 0 = No
N %DT,X,Y
S GMVDT=$G(GMVDT),GMVPDT=$G(GMVPDT)
I $G(GMVDT)="" Q 0
I $G(GMVPDT)="" S GMVPDT="TX"
S X=GMVDT
S %DT=GMVPDT
D ^%DT
I Y=-1 Q 0
Q 1
;
EMAIL(GMVTXT) ; Send a MailMan message
N DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
S XMSUB="GMRV*5.0*25 D/T REPAIR UTILITY"
S XMY(DUZ)="",XMDUZ=.5
S XMTEXT="GMVTXT("
D ^XMD
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMVZEROS 3682 printed Dec 13, 2024@02:00:20 Page 2
GMVZEROS ;HIOFO/FT - LOOK FOR TRAILING ZEROES IN FILE 120.5, FIELD .01 ;08/27/08 16:07
+1 ;;5.0;GEN. MED. REC. - VITALS;**25**;Oct 31, 2002;Build 4
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #2320 - ^%ZISH calls (supported)
+5 ; #10063 - ^%ZTLOAD (supported)
+6 ; #10070 - ^XMD calls (supported)
+7 ; #10103 - ^XLFDT calls (supported)
+8 ;
QUEUE ;Queue job as a background task
+1 NEW ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSK
+2 DO EN^DDIOL("Starting FIX^GMVZEROS as a background task.","","!?5")
+3 SET ZTDESC="GMRV*5.0*25 D/T REPAIR UTILITY"
SET ZTIO=""
+4 SET ZTRTN="FIX^GMVZEROS"
SET ZTDTH=$$NOW^XLFDT()
+5 DO ^%ZTLOAD
+6 DO EN^DDIOL("Task "_ZTSK_" has started. I'll send you a MailMan message when I finish.","","!?5")
+7 QUIT
+8 ;
FIX ;Search for string dates and repair them.
+1 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+2 NEW DA,DIE,DR,X,Y,ZTSTOP
+3 NEW GMVBAD,GMVCNT,GMVDATE,GMVEND,GMVIEN,GMVFILE,GMVFOUND,GMVLINE,GMVPATH,GMVSTART,GMVTEXT,GMVTOTAL
+4 NEW POP
+5 SET DIE=120.5
SET GMVLINE=1
+6 SET GMVTEXT(GMVLINE)="Starting search for string dates in FILE 120.5 at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
+7 SET (GMVBAD,GMVCNT,GMVIEN,GMVFOUND,GMVTOTAL)=0
+8 ; set host file name and directory path
+9 SET GMVFILE="GMRV_5_25.DAT"
+10 ;current directory
SET GMVPATH=$$PWD^%ZISH
+11 ; Open up device to print to
+12 ;'A' for append
DO OPEN^%ZISH("VITAL",GMVPATH,GMVFILE,"A")
+13 ;send email if device cannot be opened
IF POP
Begin DoDot:1
+14 SET GMVLINE=GMVLINE+1
+15 SET GMVTEXT(GMVLINE)="Could not open file "_GMVFILE_" in path "_GMVPATH_"."
+16 SET GMVLINE=GMVLINE+1
+17 SET GMVTEXT(GMVLINE)="Stopping at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
+18 DO EMAIL(.GMVTEXT)
+19 QUIT
End DoDot:1
QUIT
+20 USE IO
+21 ; from this point on, the Write commands are writing to the host file.
+22 FOR
SET GMVIEN=+$ORDER(^GMR(120.5,GMVIEN))
if GMVIEN=0!($GET(ZTSTOP)=1)
QUIT
Begin DoDot:1
+23 SET GMVTOTAL=GMVTOTAL+1
+24 SET GMVCNT=GMVCNT+1
+25 ;check if user wants to stop the job
IF GMVCNT>10000
Begin DoDot:2
+26 SET GMVCNT=0
+27 ;not a background task
if '$DATA(ZTQUEUED)
QUIT
+28 IF $$S^%ZTLOAD
Begin DoDot:3
+29 ;set TaskMan variable equal to 1 to stop task
SET ZTSTOP=1
+30 WRITE !,"Task stopped at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
+31 WRITE !,"Stopped at record "_GMVIEN
+32 ;keep record of task in task log
KILL ZTREQ
End DoDot:3
End DoDot:2
+33 SET GMVDATE=$PIECE(^GMR(120.5,GMVIEN,0),U,1)
+34 IF GMVDATE'=+GMVDATE
Begin DoDot:2
+35 ;not a real date/time
IF $$DTCHECK(+GMVDATE,"TX")=0
Begin DoDot:3
+36 WRITE !,"IEN="_GMVIEN,?15,GMVDATE_" is not a real date/time. No action taken."
+37 SET GMVBAD=GMVBAD+1
End DoDot:3
QUIT
+38 SET GMVFOUND=GMVFOUND+1
+39 WRITE !,"IEN="_GMVIEN,?15,GMVDATE_" changed to "_+GMVDATE
+40 SET DR=".01///"_+GMVDATE
SET DA=GMVIEN
+41 DO ^DIE
End DoDot:2
End DoDot:1
+42 WRITE !!,"# of Records changed: "_GMVFOUND
+43 DO CLOSE^%ZISH("VITAL")
+44 SET GMVLINE=GMVLINE+1
+45 SET GMVTEXT(GMVLINE)="Finished at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
+46 SET GMVLINE=GMVLINE+1
+47 SET GMVTEXT(GMVLINE)="Records checked: "_GMVTOTAL
+48 SET GMVLINE=GMVLINE+1
+49 SET GMVTEXT(GMVLINE)="Records changed: "_GMVFOUND
+50 SET GMVLINE=GMVLINE+1
+51 SET GMVTEXT(GMVLINE)="Records that could not be changed: "_GMVBAD
+52 SET GMVLINE=GMVLINE+1
+53 SET GMVTEXT(GMVLINE)="The "_GMVFILE_" file in the "_GMVPATH_" directory contains"
+54 SET GMVLINE=GMVLINE+1
+55 SET GMVTEXT(GMVLINE)="a list of entries changed and those that could not be changed."
+56 DO EMAIL(.GMVTEXT)
+57 QUIT
+58 ;
DTCHECK(GMVDT,GMVPDT) ; Is GMVDT a real date/time?
+1 ; Input: GMVDT - date/time (FM internal format)(req)
+2 ; GMVPDT - %DT value (opt - default is 'TX')
+3 ; Output: 1 = Yes
+4 ; 0 = No
+5 NEW %DT,X,Y
+6 SET GMVDT=$GET(GMVDT)
SET GMVPDT=$GET(GMVPDT)
+7 IF $GET(GMVDT)=""
QUIT 0
+8 IF $GET(GMVPDT)=""
SET GMVPDT="TX"
+9 SET X=GMVDT
+10 SET %DT=GMVPDT
+11 DO ^%DT
+12 IF Y=-1
QUIT 0
+13 QUIT 1
+14 ;
EMAIL(GMVTXT) ; Send a MailMan message
+1 NEW DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
+2 SET XMSUB="GMRV*5.0*25 D/T REPAIR UTILITY"
+3 SET XMY(DUZ)=""
SET XMDUZ=.5
+4 SET XMTEXT="GMVTXT("
+5 DO ^XMD
+6 QUIT