GMVFIXHL ;HIOFO/FT - HOSPITAL LOCATION FIX ;10/20/09 11:42
;;5.0;GEN. MED. REC. - VITALS;**24**;Oct 31, 2002;Build 24
;
; This routine uses the following IAs:
; #2320 - ^%ZISH calls (supported)
; #4253 - ^VDEFQM calls (controlled)
; #10039 - FILE 42 references (supported)
; #10040 - FILE 44 references (supported)
; #10061 - ^VADPT calls (supported)
; #10063 - ^%ZTLOAD (supported)
; #10070 - ^XMD calls (supported)
; #10103 - ^XLFDT calls (supported)
; #10141 - ^XPDUTL calls (supported)
;
EN ;
N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK,ZTSTOP
S ZTDESC="GMRV*5.0*24 HOSPITAL LOCATION FIX",ZTIO=""
S ZTSAVE("DUZ")=""
S ZTRTN="QUEUE^GMVFIXHL",ZTDTH=$$NOW^XLFDT()
D ^%ZTLOAD
D EN^DDIOL("Task "_ZTSK_" has started. I'll send you a MailMan message when I finish.","","!?5")
Q
QUEUE ; The problem started when GMRV*5.0*3 was installed.
; a) Find date patch 3 was installed. Go back a little farther to be safe.
; b) Loop through FILE 120.5.
; c) Ignore if not inpatient.
; d) Check hospital location pointer of the Vitals record.
; e)Determine if pointer can/needs to be changed.
N GMVBEG,GMVCNT,GMVDFN,GMVECNT,GMVEDT,GMVEND,GMVFILE,GMVHL,GMVIEN,GMVMSG,GMVNODE,GMVODT,GMVPATH,GMVPIEN,GMVSDT,GMVTOT,GMVTOTAL
N POP
I $D(ZTQUEUED) S ZTREQ="@"
K ^TMP($J,"GMVHL")
S GMVBEG=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
;Get patch 3 installation date
D INSTALDT^XPDUTL("GMRV*5.0*3",.GMVDATES)
I $G(GMVDATES(0))=0 D Q
.K GMVTEXT
.S GMVTEXT(1)="I cannot find an installation date for GMRV*5.0*3."
.S GMVTEXT(2)="Please file a Remedy ticket."
.D EMAIL(.GMVTEXT)
.Q
S GMVSDT=0
S GMVSDT=$O(GMVDATES(GMVSDT)) ;get the earliest install date
I 'GMVSDT D Q
.K GMVTEXT
.S GMVTEXT(1)="I cannot find a valid installation date for GMRV*5.0*3."
.S GMVTEXT(2)="Please file a Remedy ticket."
.D EMAIL(.GMVTEXT)
.Q
;problem fixed with patch 22 installation
K GMVDATES
D INSTALDT^XPDUTL("GMRV*5.0*22",.GMVDATES)
I $G(GMVDATES(0))=0 D Q
.K GMVTEXT
.S GMVTEXT(1)="I cannot find an installation date for GMRV*5.0*22."
.S GMVTEXT(2)="Please file a Remedy ticket."
.D EMAIL(.GMVTEXT)
.Q
S GMVEDT=0
S GMVEDT=$O(GMVDATES(GMVEDT)) ;get the earliest install date
I 'GMVEDT D Q
.K GMVTEXT
.S GMVTEXT(1)="I cannot find a valid installation date for GMRV*5.0*22."
.S GMVTEXT(2)="Please file a Remedy ticket."
.D EMAIL(.GMVTEXT)
.Q
; set host file name and directory path
S GMVFILE="GMRV_5_24.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
.K GMVTEXT
.S GMVTEXT(1)="Could not open file "_GMVFILE_" in path "_GMVPATH_"."
.S GMVTEXT(2)="Please try again."
.D EMAIL(.GMVTEXT)
.Q
U IO
; from this point on, the Write commands are to the host file.
S GMVSDT=$$FMADD^XLFDT(GMVSDT,-7) ;go back additional 7 days to be certain
S (GMVCNT,GMVECNT,GMVPIEN,GMVTOT,GMVTOTAL)=0
F S GMVSDT=$O(^GMR(120.5,"B",GMVSDT)) Q:'GMVSDT!($G(ZTSTOP)=1)!(GMVSDT>GMVEDT) D
.S GMVIEN=0
.K GMVLOC
.F S GMVIEN=$O(^GMR(120.5,"B",GMVSDT,GMVIEN)) Q:'GMVIEN!($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. Last record processed was "_GMVPIEN
....K ZTREQ ;keep record of task in task log
..S GMVNODE=$G(^GMR(120.5,GMVIEN,0)),GMVPIEN=GMVIEN
..I ($P(GMVNODE,U,1)="")!($P(GMVNODE,U,2)="")!($P(GMVNODE,U,3)="")!($P(GMVNODE,U,8)="") Q
..S GMVHL=+$P(GMVNODE,U,5),GMVDFN=+$P(GMVNODE,U,2),GMVODT=+$P(GMVNODE,U,1)
..;get inpatient location for this dfn & d/t
..I '$D(GMVLOC(GMVDFN,GMVODT)) D INP
..I $G(GMVLOC(GMVDFN,GMVODT))'>0 Q ;not an inpatient
..I $G(GMVLOC(GMVDFN,GMVODT))=GMVHL Q ;no discrepancy
..Q:$D(^SC(+GMVHL,0)) ;quit if FILE 44 entry exists
..I $G(GMVLOC(GMVDFN,GMVODT))'=GMVHL D
...S GMVMSG=$$SETHL(GMVLOC(GMVDFN,GMVODT),GMVIEN,GMVHL)
...W !,GMVMSG
...D HDR(GMVIEN,GMVDFN) ;upload record to HDR
S GMVEND=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
W !," Start Date/time: "_GMVBEG
W !," Finish Date/time: "_GMVEND
W !," Number of records checked: "_GMVTOTAL
W !," Number of records changed: "_GMVTOT
W !,"Number of records that could not be changed: "_GMVECNT
D CLOSE^%ZISH("VITAL")
K GMVTEXT
S GMVTEXT(1)=" The repair utility started at: "_GMVBEG
S GMVTEXT(2)=" The repair utility finished at: "_GMVEND
S GMVTEXT(3)=" Number of records checked: "_GMVTOTAL
S GMVTEXT(4)=" Number of records changed: "_GMVTOT
S GMVTEXT(5)="Number of records that could not be changed: "_GMVECNT
S GMVTEXT(6)=" "
S GMVTEXT(7)="The "_GMVFILE_" file in the "_GMVPATH_" directory contains"
S GMVTEXT(8)="a listing of entries changed."
D EMAIL(.GMVTEXT)
Q
SETHL(NEWHL,IEN,OLDHL) ; Set hospital location pointer (.05) field in 120.5.
; Returns a line of text
; NEWHL = New File 44 pointer
; IEN = File 120.5 record ien
; OLDHL = Old File 44 pointer
N GMVERR,GMVFDA,GMVDA,GMVLINE
S GMVLINE=""
S GMVFDA(120.5,IEN_",",.05)=NEWHL
D UPDATE^DIE("","GMVFDA","GMVDA","GMVERR")
I +$P($G(GMVERR("DIERR")),U,1)>0 D
.S GMVLINE="RECORD: "_IEN_", not changed because: "_$G(GMVERR("DIERR",1,"TEXT",1))
.S GMVECNT=GMVECNT+1
I +$P($G(GMVERR("DIERR")),U,1)'>0 D
.S GMVLINE="RECORD: "_IEN_" OLD LOCATION: "_OLDHL_" NEW LOCATION: "_NEWHL
.S GMVTOT=GMVTOT+1
Q GMVLINE
;
INP ;get inpatient location
N DFN,GMVAIN,GMVHLPTR,GMVWPTR,VAINDT,VAROOT
S DFN=GMVDFN,VAINDT=GMVODT,VAROOT="GMVAIN",GMVLOC(GMVDFN,GMVODT)=""
D INP^VADPT
S GMVWPTR=+$P(GMVAIN(4),U,1)
D KVAR^VADPT
Q:'GMVWPTR
S GMVHLPTR=+$P($G(^DIC(42,GMVWPTR,44)),U,1)
Q:'GMVHLPTR
S GMVLOC(GMVDFN,GMVODT)=GMVHLPTR
Q
EMAIL(GMVTXT) ; Send a MailMan message
N DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
S XMSUB="GMRV*5.0*24 HOSPITAL LOCATION REPAIR"
S XMY(DUZ)="",XMDUZ=.5
S XMTEXT="GMVTXT("
D ^XMD
Q
HDR(GMVX,GMVY) ; Send record to Health Data Repository (HDR)
; Input: GMVX - FILE 120.5 IEN
; GMVY - DFN
; Output: none
N ERR,GMVFLAG
S GMVX=+$G(GMVX),GMVY=+$G(GMVY)
Q:'GMVX
Q:'GMVY
Q:$$TESTPAT^VADPT(GMVY) ;ignore test patients
I $T(QUEUE^VDEFQM)]"" D
.S GMVFLAG=$$QUEUE^VDEFQM("ORU^R01","SUBTYPE=VTLS^IEN="_GMVX,.ERR)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMVFIXHL 6684 printed Nov 22, 2024@17:08:51 Page 2
GMVFIXHL ;HIOFO/FT - HOSPITAL LOCATION FIX ;10/20/09 11:42
+1 ;;5.0;GEN. MED. REC. - VITALS;**24**;Oct 31, 2002;Build 24
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #2320 - ^%ZISH calls (supported)
+5 ; #4253 - ^VDEFQM calls (controlled)
+6 ; #10039 - FILE 42 references (supported)
+7 ; #10040 - FILE 44 references (supported)
+8 ; #10061 - ^VADPT calls (supported)
+9 ; #10063 - ^%ZTLOAD (supported)
+10 ; #10070 - ^XMD calls (supported)
+11 ; #10103 - ^XLFDT calls (supported)
+12 ; #10141 - ^XPDUTL calls (supported)
+13 ;
EN ;
+1 NEW ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK,ZTSTOP
+2 SET ZTDESC="GMRV*5.0*24 HOSPITAL LOCATION FIX"
SET ZTIO=""
+3 SET ZTSAVE("DUZ")=""
+4 SET ZTRTN="QUEUE^GMVFIXHL"
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
QUEUE ; The problem started when GMRV*5.0*3 was installed.
+1 ; a) Find date patch 3 was installed. Go back a little farther to be safe.
+2 ; b) Loop through FILE 120.5.
+3 ; c) Ignore if not inpatient.
+4 ; d) Check hospital location pointer of the Vitals record.
+5 ; e)Determine if pointer can/needs to be changed.
+6 NEW GMVBEG,GMVCNT,GMVDFN,GMVECNT,GMVEDT,GMVEND,GMVFILE,GMVHL,GMVIEN,GMVMSG,GMVNODE,GMVODT,GMVPATH,GMVPIEN,GMVSDT,GMVTOT,GMVTOTAL
+7 NEW POP
+8 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+9 KILL ^TMP($JOB,"GMVHL")
+10 SET GMVBEG=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
+11 ;Get patch 3 installation date
+12 DO INSTALDT^XPDUTL("GMRV*5.0*3",.GMVDATES)
+13 IF $GET(GMVDATES(0))=0
Begin DoDot:1
+14 KILL GMVTEXT
+15 SET GMVTEXT(1)="I cannot find an installation date for GMRV*5.0*3."
+16 SET GMVTEXT(2)="Please file a Remedy ticket."
+17 DO EMAIL(.GMVTEXT)
+18 QUIT
End DoDot:1
QUIT
+19 SET GMVSDT=0
+20 ;get the earliest install date
SET GMVSDT=$ORDER(GMVDATES(GMVSDT))
+21 IF 'GMVSDT
Begin DoDot:1
+22 KILL GMVTEXT
+23 SET GMVTEXT(1)="I cannot find a valid installation date for GMRV*5.0*3."
+24 SET GMVTEXT(2)="Please file a Remedy ticket."
+25 DO EMAIL(.GMVTEXT)
+26 QUIT
End DoDot:1
QUIT
+27 ;problem fixed with patch 22 installation
+28 KILL GMVDATES
+29 DO INSTALDT^XPDUTL("GMRV*5.0*22",.GMVDATES)
+30 IF $GET(GMVDATES(0))=0
Begin DoDot:1
+31 KILL GMVTEXT
+32 SET GMVTEXT(1)="I cannot find an installation date for GMRV*5.0*22."
+33 SET GMVTEXT(2)="Please file a Remedy ticket."
+34 DO EMAIL(.GMVTEXT)
+35 QUIT
End DoDot:1
QUIT
+36 SET GMVEDT=0
+37 ;get the earliest install date
SET GMVEDT=$ORDER(GMVDATES(GMVEDT))
+38 IF 'GMVEDT
Begin DoDot:1
+39 KILL GMVTEXT
+40 SET GMVTEXT(1)="I cannot find a valid installation date for GMRV*5.0*22."
+41 SET GMVTEXT(2)="Please file a Remedy ticket."
+42 DO EMAIL(.GMVTEXT)
+43 QUIT
End DoDot:1
QUIT
+44 ; set host file name and directory path
+45 SET GMVFILE="GMRV_5_24.DAT"
+46 ;current directory
SET GMVPATH=$$PWD^%ZISH
+47 ; Open up device to print to
+48 ;'A' for append
DO OPEN^%ZISH("VITAL",GMVPATH,GMVFILE,"A")
+49 ;send email if device cannot be opened
IF POP
Begin DoDot:1
+50 KILL GMVTEXT
+51 SET GMVTEXT(1)="Could not open file "_GMVFILE_" in path "_GMVPATH_"."
+52 SET GMVTEXT(2)="Please try again."
+53 DO EMAIL(.GMVTEXT)
+54 QUIT
End DoDot:1
QUIT
+55 USE IO
+56 ; from this point on, the Write commands are to the host file.
+57 ;go back additional 7 days to be certain
SET GMVSDT=$$FMADD^XLFDT(GMVSDT,-7)
+58 SET (GMVCNT,GMVECNT,GMVPIEN,GMVTOT,GMVTOTAL)=0
+59 FOR
SET GMVSDT=$ORDER(^GMR(120.5,"B",GMVSDT))
if 'GMVSDT!($GET(ZTSTOP)=1)!(GMVSDT>GMVEDT)
QUIT
Begin DoDot:1
+60 SET GMVIEN=0
+61 KILL GMVLOC
+62 FOR
SET GMVIEN=$ORDER(^GMR(120.5,"B",GMVSDT,GMVIEN))
if 'GMVIEN!($GET(ZTSTOP)=1)
QUIT
Begin DoDot:2
+63 SET GMVTOTAL=GMVTOTAL+1
+64 SET GMVCNT=GMVCNT+1
+65 ;check if user wants to stop the job
IF GMVCNT>10000
Begin DoDot:3
+66 SET GMVCNT=0
+67 ;not a background task
if '$DATA(ZTQUEUED)
QUIT
+68 IF $$S^%ZTLOAD
Begin DoDot:4
+69 ;set TaskMan variable equal to 1 to stop task
SET ZTSTOP=1
+70 WRITE !,"Task stopped. Last record processed was "_GMVPIEN
+71 ;keep record of task in task log
KILL ZTREQ
End DoDot:4
End DoDot:3
+72 SET GMVNODE=$GET(^GMR(120.5,GMVIEN,0))
SET GMVPIEN=GMVIEN
+73 IF ($PIECE(GMVNODE,U,1)="")!($PIECE(GMVNODE,U,2)="")!($PIECE(GMVNODE,U,3)="")!($PIECE(GMVNODE,U,8)="")
QUIT
+74 SET GMVHL=+$PIECE(GMVNODE,U,5)
SET GMVDFN=+$PIECE(GMVNODE,U,2)
SET GMVODT=+$PIECE(GMVNODE,U,1)
+75 ;get inpatient location for this dfn & d/t
+76 IF '$DATA(GMVLOC(GMVDFN,GMVODT))
DO INP
+77 ;not an inpatient
IF $GET(GMVLOC(GMVDFN,GMVODT))'>0
QUIT
+78 ;no discrepancy
IF $GET(GMVLOC(GMVDFN,GMVODT))=GMVHL
QUIT
+79 ;quit if FILE 44 entry exists
if $DATA(^SC(+GMVHL,0))
QUIT
+80 IF $GET(GMVLOC(GMVDFN,GMVODT))'=GMVHL
Begin DoDot:3
+81 SET GMVMSG=$$SETHL(GMVLOC(GMVDFN,GMVODT),GMVIEN,GMVHL)
+82 WRITE !,GMVMSG
+83 ;upload record to HDR
DO HDR(GMVIEN,GMVDFN)
End DoDot:3
End DoDot:2
End DoDot:1
+84 SET GMVEND=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
+85 WRITE !," Start Date/time: "_GMVBEG
+86 WRITE !," Finish Date/time: "_GMVEND
+87 WRITE !," Number of records checked: "_GMVTOTAL
+88 WRITE !," Number of records changed: "_GMVTOT
+89 WRITE !,"Number of records that could not be changed: "_GMVECNT
+90 DO CLOSE^%ZISH("VITAL")
+91 KILL GMVTEXT
+92 SET GMVTEXT(1)=" The repair utility started at: "_GMVBEG
+93 SET GMVTEXT(2)=" The repair utility finished at: "_GMVEND
+94 SET GMVTEXT(3)=" Number of records checked: "_GMVTOTAL
+95 SET GMVTEXT(4)=" Number of records changed: "_GMVTOT
+96 SET GMVTEXT(5)="Number of records that could not be changed: "_GMVECNT
+97 SET GMVTEXT(6)=" "
+98 SET GMVTEXT(7)="The "_GMVFILE_" file in the "_GMVPATH_" directory contains"
+99 SET GMVTEXT(8)="a listing of entries changed."
+100 DO EMAIL(.GMVTEXT)
+101 QUIT
SETHL(NEWHL,IEN,OLDHL) ; Set hospital location pointer (.05) field in 120.5.
+1 ; Returns a line of text
+2 ; NEWHL = New File 44 pointer
+3 ; IEN = File 120.5 record ien
+4 ; OLDHL = Old File 44 pointer
+5 NEW GMVERR,GMVFDA,GMVDA,GMVLINE
+6 SET GMVLINE=""
+7 SET GMVFDA(120.5,IEN_",",.05)=NEWHL
+8 DO UPDATE^DIE("","GMVFDA","GMVDA","GMVERR")
+9 IF +$PIECE($GET(GMVERR("DIERR")),U,1)>0
Begin DoDot:1
+10 SET GMVLINE="RECORD: "_IEN_", not changed because: "_$GET(GMVERR("DIERR",1,"TEXT",1))
+11 SET GMVECNT=GMVECNT+1
End DoDot:1
+12 IF +$PIECE($GET(GMVERR("DIERR")),U,1)'>0
Begin DoDot:1
+13 SET GMVLINE="RECORD: "_IEN_" OLD LOCATION: "_OLDHL_" NEW LOCATION: "_NEWHL
+14 SET GMVTOT=GMVTOT+1
End DoDot:1
+15 QUIT GMVLINE
+16 ;
INP ;get inpatient location
+1 NEW DFN,GMVAIN,GMVHLPTR,GMVWPTR,VAINDT,VAROOT
+2 SET DFN=GMVDFN
SET VAINDT=GMVODT
SET VAROOT="GMVAIN"
SET GMVLOC(GMVDFN,GMVODT)=""
+3 DO INP^VADPT
+4 SET GMVWPTR=+$PIECE(GMVAIN(4),U,1)
+5 DO KVAR^VADPT
+6 if 'GMVWPTR
QUIT
+7 SET GMVHLPTR=+$PIECE($GET(^DIC(42,GMVWPTR,44)),U,1)
+8 if 'GMVHLPTR
QUIT
+9 SET GMVLOC(GMVDFN,GMVODT)=GMVHLPTR
+10 QUIT
EMAIL(GMVTXT) ; Send a MailMan message
+1 NEW DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
+2 SET XMSUB="GMRV*5.0*24 HOSPITAL LOCATION REPAIR"
+3 SET XMY(DUZ)=""
SET XMDUZ=.5
+4 SET XMTEXT="GMVTXT("
+5 DO ^XMD
+6 QUIT
HDR(GMVX,GMVY) ; Send record to Health Data Repository (HDR)
+1 ; Input: GMVX - FILE 120.5 IEN
+2 ; GMVY - DFN
+3 ; Output: none
+4 NEW ERR,GMVFLAG
+5 SET GMVX=+$GET(GMVX)
SET GMVY=+$GET(GMVY)
+6 if 'GMVX
QUIT
+7 if 'GMVY
QUIT
+8 ;ignore test patients
if $$TESTPAT^VADPT(GMVY)
QUIT
+9 IF $TEXT(QUEUE^VDEFQM)]""
Begin DoDot:1
+10 SET GMVFLAG=$$QUEUE^VDEFQM("ORU^R01","SUBTYPE=VTLS^IEN="_GMVX,.ERR)
End DoDot:1
+11 QUIT