PSBVDLUD ;BIRMINGHAM/EFC-BCMA UNIT DOSE VIRTUAL DUE LIST FUNCTIONS ;Mar 2004
;;3.0;BAR CODE MED ADMIN;**11,13,38,32**;Mar 2004;Build 32
;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
;
; Reference/IA
; EN^PSJBCMA/2828
; $$GET^XPAR/2263
;
EN(DFN,PSBDT) ;
;
;
; Description:
; Returns the current unit dose order set for today to display
; on the client VDL
;
N PSBDATA,PSBTBOUT
S PSBTBOUT=0
;
;This routine now re-uses the ^TMP("PSJ",$J global built in PSBVDLTB
;
G:$G(^TMP("PSJ",$J,1,0))=-1 1
F PSBX=0:0 S PSBX=$O(^TMP("PSJ",$J,PSBX)) Q:('PSBX)!(PSBTBOUT) D
.S:(PSBTAB'="UDTAB")&($G(^TMP("PSB",$J,"UDTAB",2))>0) PSBTBOUT=1
.D CLEAN^PSBVT,PSJ^PSBVT(PSBX)
.;
.; << Standard checks for ALL orders >>
.;
.Q:PSBONX["V" ;No IVs on UD tab
.Q:PSBONX["P" ; No Pending Orders
.Q:PSBOST>PSBWADM ; Order Start Date/Time > admin window
.Q:PSBOSP<PSBWBEG ; For Non one-times Order Stop Date/Time < vdl window
.Q:PSBOSTS["D" ; Is it DC'd
.Q:PSBNGF ; Is it marked DO NOT GIVE!
.Q:PSBIVPSH
.;
.; Non One-Times with stop date/time < now
.;
.D NOW^%DTC
.Q:PSBOSP<%
.;
.; include Active, Renewed, ReInstated and On Call
.; (Is it not one time)&(Is it not active or renewed or On Call)
.I PSBSCHT'="O",PSBOSTS'="A",PSBOSTS'="H",PSBOSTS'="R",PSBOSTS'="RE",PSBOSTS'="O" Q
.;
.; Is One Time Given
.;
.I PSBSCHT="O" D Q:PSBGVN
..S (PSBGVN,X,Y)=""
..F S X=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X),-1) Q:'X D
...F S Y=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X,Y),-1) Q:'Y D
....I $P(^PSB(53.79,Y,.1),U)=PSBONX,$P(^PSB(53.79,Y,0),U,9)="G" S PSBGVN=1,(X,Y)=0
.;
.; How long does One Time remain on VDL ??
.S PSBRMN=1
.I PSBSCHT="O",PSBOSP'=PSBOST&(%>PSBOSP) S PSBRMN=0
.Q:'PSBRMN
.; Is On-Call Given, Can it be given more than once
.;
.I PSBSCHT="OC" D Q:PSBGVN&('$$GET^XPAR("DIV","PSB ADMIN MULTIPLE ONCALL"))
..S (PSBGVN,X,Y)=""
..F S X=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X),-1) Q:'X D
...F S Y=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X,Y),-1) Q:'Y D
....I $P(^PSB(53.79,Y,.1),U)=PSBONX,$P(^PSB(53.79,Y,0),U,9)="G" S PSBGVN=1,(X,Y)=0
.;
.S PSBREC=""
.S $P(PSBREC,U,1)=DFN ; dfn
.S $P(PSBREC,U,2)=PSBONX ; order
.S $P(PSBREC,U,3)=PSBON ; order ien
.S $P(PSBREC,U,4)=PSBOTYP ; iv/ud/pending
.S $P(PSBREC,U,5)=PSBSCHT ; schedule type
.S $P(PSBREC,U,6)=PSBSCH ; schedule
.S $P(PSBREC,U,7)=$S(PSBHSM:"HSM",PSBSM:"SM",1:"") ; self med
.S $P(PSBREC,U,8)=PSBOITX ; drugname
.S $P(PSBREC,U,9)=PSBDOSE_" "_PSBIFR ; dosage
.S $P(PSBREC,U,10)=PSBMR ; med route
.; Last Given from the AOIP X-Ref - not given status not excepted
.S (PSBCNT,PSBFLAG)=0,(YZ,PSBSTUS,PSBADMER)="" K PSBHSTA,PSBHSTAX
.F XZ=1:1:20 S YZ=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,YZ),-1),(PSBCNT,PSBFLAG)=0 Q:YZ="" D
..S:YZ>0 $P(PSBREC,U,11)=YZ
..S X="" F S X=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,YZ,X),-1) Q:X="" D
...K PSBLCK L +^PSB(53.79,X):1 I L -^PSB(53.79,X) S PSBLCK=1
...S PSBSTUS=$P(^PSB(53.79,X,0),U,9)
...I $G(PSBSTUS)="" S:'$G(PSBLCK) PSBSTUS="X" I $G(PSBLCK) S PSBADMER=1 D
....K PSBPARM3,PSBPARM5,PSBPARM6,PSBPARM7
....S PSBPARM6=X,Y=$P(^PSB(53.79,X,.1),U,3) D DD^%DT S PSBPARM3=Y,Y=$P(^PSB(53.79,X,0),U,6) D DD^%DT S PSBPARM5=Y
....S PSBPARM7=$P(^PSB(53.79,X,0),U,7) S PSBPARM7="( # "_PSBPARM7_" ) "_$$GET1^DIQ(200,PSBPARM7_",",.01)
....K PSBXTMP S PSBXTMP=PSBONX
....D CLEAN^PSBVT,PSJ1^PSBVT(DFN,$$GET1^DIQ(53.79,PSBPARM6_",",.11))
....D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,PSBPARM3_" admin's ACTION STATUS is ""UNKNOWN"".",PSBSCH,PSBPARM5,PSBPARM6,PSBPARM7) ; SEND AN E-MAIL
....D CLEAN^PSBVT,PSJ1^PSBVT(DFN,PSBXTMP) ;Reset Variables
....S X=PSBPARM6 K PSBPARM3,PSBPARM5,PSBPARM6,PSBPARM7
...K PSBLCK S:(PSBSTUS']"") PSBSTUS="U" I PSBSTUS'="N",($G(PSBSTUS)'="X") S PSBFLAG=1,PSBHSTA(YZ,$G(PSBSTUS))="ORIG"_U_X
...D:PSBSTUS="N"
....S $P(PSBREC,U,11)=""
....S Z="" F S Z=$O(^PSB(53.79,X,.9,Z),-1) Q:'Z Q:PSBFLAG=1 S PSBDATA=$G(^(Z,0)) D
.....I (PSBDATA["Set to 'NOT GIVEN'")!(PSBDATA["Set to 'GIVEN'")!(PSBDATA["Set to 'REFUSED'")!(PSBDATA["Set to 'HELD'")!(PSBDATA["Set to 'MISSING DOSE'")!(PSBDATA["Set to 'REMOVED'") S PSBCNT=PSBCNT+1
.....I (PSBDATA["STATUS 'HELD'")!(PSBDATA["STATUS 'GIVEN'")!(PSBDATA["STATUS 'REFUSED'")!(PSBDATA["STATUS 'MISSING DOSE'")!(PSBDATA["STATUS 'REMOVED'") S PSBCNT=PSBCNT+1
.....I PSBCNT#2=0,PSBDATA["'REFUSED'" S PSBSTUS="R" D LAST^PSBVDLU1
.....I PSBCNT#2=0,PSBDATA["'HELD'" S PSBSTUS="H" D LAST^PSBVDLU1
.....I PSBCNT#2=0,PSBDATA["'MISSING DOSE'" S PSBSTUS="M" D LAST^PSBVDLU1
.....I PSBCNT#2=0,PSBDATA["'REMOVED'" S PSBSTUS="RM" D LAST^PSBVDLU1
.....I PSBFLAG=1,'$D(PSBHSTA($P(PSBREC,U,11),$G(PSBSTUS))) S PSBHSTA($P(PSBREC,U,11),$G(PSBSTUS))=Z_U_X
.I $D(PSBHSTA) S $P(PSBREC,U,11)=$O(PSBHSTA(""),-1),PSBSTUS=$O(PSBHSTA($P(PSBREC,U,11),""),-1) M PSBHSTAX(PSBOIT)=PSBHSTA K PSBHSTA ;last action date/time
.S $P(PSBREC,U,12)="" ;med log ien inserted below for actual date
.S $P(PSBREC,U,13)="" ;med log status inserted below for actual date
.S $P(PSBREC,U,14)="" ; admin date inserted below
.S $P(PSBREC,U,15)=PSBOIT ; OI Pointer
.S $P(PSBREC,U,16)=PSBNJECT ;med route injectable flag
.; Variable dosage entered as ####-####?
.I $P(PSBREC,U,9)?1.4N1"-"1.4N.E S $P(PSBREC,U,17)=1
.E S $P(PSBREC,U,17)=0
.S:PSBDOSEF?1"CAP".E!(PSBDOSEF?1"TAB".E)!(PSBDOSEF="PATCH") $P(PSBREC,U,18)=PSBDOSEF ; dosage form
.S $P(PSBREC,U,20)=$S((PSBSTUS="X")!(PSBSTUS="N"):"",1:PSBSTUS) ; last action status
.S $P(PSBREC,U,21)=PSBOST
.S $P(PSBREC,U,22)=PSBOSTS
.S $P(PSBREC,U,26)=PSBOSP
.S $P(PSBREC,U,27)=$$LASTG^PSBCSUTL(DFN,PSBOIT)
.;
.; Gather Dispense Drugs
.D NOW^%DTC
.S (PSBDDS,PSBSOLS,PSBADDS,PSBFLAG)="0"
.F Y=0:0 S Y=$O(PSBDDA(Y)) Q:'Y D
..I $P(PSBDDA(Y),U,5)=$P(%,".") S PSBFLAG=1 ;If drug was inactivated
..Q:$P(PSBDDA(Y),U,5)&($P(PSBDDA(Y),U,5)<%) ; Inactive
..S:$P(PSBDDA(Y),U,4)="" $P(PSBDDA(Y),U,4)=1
..S PSBDDS=PSBDDS_U_$P(PSBDDA(Y),U,1,4)
..S $P(PSBDDS,U,1)=PSBDDS+1
.;
.; On-Call One Time PRN orders
.S PSBQRR=0
.I "^O^OC^P^"[(U_PSBSCHT_U) D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSBNOW\1,PSBDDS,PSBSOLS,PSBADDS,"UDTAB") Q
.;
.; Now we deal with only continuous
.; process admintimes
.; Display an order on the VDL based on the frequency received from IPM **PSB*2.0*3
.S (PSBYES,PSBODD,PSBYTF)=0
.I PSBSCH="" D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"No Schedule on this order")
.S:$$PSBDCHK1^PSBVT1(PSBSCH) PSBYES=1
.I PSBYES,PSBADST="" D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Admin times required",PSBSCH) Q
.F I=1:1 Q:$P(PSBSCH,"-",I)="" I $P(PSBSCH,"-",I)?2N!($P(PSBSCH,"-",I)?4N) S PSBYES=1,PSBYTF=1
.I PSBSCHT="C",PSBYTF="1",PSBADST="" D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Admin times required",PSBSCH) Q
.S PSBFREQ=$$GETFREQ^PSBVDLU1(DFN,PSBONX)
.I PSBFREQ="O" S PSBFREQ=1440
.I PSBFREQ="D" S PSBFREQ=""
.I 'PSBYES,PSBFREQ<1 D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid frequency received from order",PSBSCH) Q
.I (PSBADST="")&(+PSBFREQ>0) D ODDSCH^PSBVDLU1("UDTAB") Q ;calculate admin times based on frequency
.; No admin times, MAYDAY MAYDAY!!
.I +PSBFREQ>0 I (PSBFREQ#1440'=0),(1440#PSBFREQ'=0) S PSBODD=1
.I PSBODD,PSBADST'="" D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Administration Times on ODD SCHEDULE",PSBSCH) Q
.; process admin times against beginning and ending date
.; build all orders for both days.
.F PSBY=1:1 Q:$P(PSBADST,"-",PSBY)="" D
..;For invalid admin times
..I ($P(PSBADST,"-",PSBY)'?2N)&($P(PSBADST,"-",PSBY)'?4N) D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid Admin times",PSBSCH)
..; apply this time to the beginning window date
..S PSB=+(PSBWBEG\1_"."_$P(PSBADST,"-",PSBY))
..D:(PSB'<PSBWBEG)&(PSB'>PSBWEND) ; Make sure it is in the window
...D:(PSB'<PSBOST)&(PSB<PSBOSP) ; Make sure this time is active
....D:$$OKAY^PSBVDLU1(PSBOST,PSB,PSBSCH,PSBONX,PSBOITX,PSBFREQ,PSBOSTS) ; Okay on this date?
.....D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSB,PSBDDS,PSBSOLS,PSBADDS,"UDTAB")
..;
..Q:(PSBWBEG\1)=(PSBWEND\1) ; Window only has one day rare but possible
..;
..; apply this time to the ending window date
..S PSB=+(PSBWEND\1_"."_$P(PSBADST,"-",PSBY))
..D:(PSB'<PSBWBEG)&(PSB'>PSBWEND) ; Make sure it is in the window
...D:(PSB'<PSBOST)&(PSB<PSBOSP) ; Make sure this time is active
....D:$$OKAY^PSBVDLU1(PSBOST,PSB,PSBSCH,PSBONX,PSBOITX,PSBFREQ,PSBOSTS) ; Okay on this date?
.....D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSB,PSBDDS,PSBSOLS,PSBADDS,"UDTAB")
.K PSBSTUS
1 K PSBREC D EN^PSBVDLPA
;add initials of verifying pharmacist/verifying nurse
D:PSBTAB="UDTAB" VNURSE^PSBVDLU1("UDTAB")
D CLEAN^PSBVT
Q
;
PSBVDLUD ;BIRMINGHAM/EFC-BCMA UNIT DOSE VIRTUAL DUE LIST FUNCTIONS ;Mar 2004
+1 ;;3.0;BAR CODE MED ADMIN;**11,13,38,32**;Mar 2004;Build 32
+2 ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
+3 ;
+4 ; Reference/IA
+5 ; EN^PSJBCMA/2828
+6 ; $$GET^XPAR/2263
+7 ;
EN(DFN,PSBDT) ;
+1 ;
+2 ;
+3 ; Description:
+4 ; Returns the current unit dose order set for today to display
+5 ; on the client VDL
+6 ;
+7 NEW PSBDATA,PSBTBOUT
+8 SET PSBTBOUT=0
+9 ;
+10 ;This routine now re-uses the ^TMP("PSJ",$J global built in PSBVDLTB
+11 ;
+12 IF $GET(^TMP("PSJ",$JOB,1,0))=-1
GOTO 1
+13 FOR PSBX=0:0
SET PSBX=$ORDER(^TMP("PSJ",$JOB,PSBX))
IF ('PSBX)!(PSBTBOUT)
QUIT
Begin DoDot:1
+14 IF (PSBTAB'="UDTAB")&($GET(^TMP("PSB",$JOB,"UDTAB",2))>0)
SET PSBTBOUT=1
+15 DO CLEAN^PSBVT
DO PSJ^PSBVT(PSBX)
+16 ;
+17 ; << Standard checks for ALL orders >>
+18 ;
+19 ;No IVs on UD tab
IF PSBONX["V"
QUIT
+20 ; No Pending Orders
IF PSBONX["P"
QUIT
+21 ; Order Start Date/Time > admin window
IF PSBOST>PSBWADM
QUIT
+22 ; For Non one-times Order Stop Date/Time < vdl window
IF PSBOSP<PSBWBEG
QUIT
+23 ; Is it DC'd
IF PSBOSTS["D"
QUIT
+24 ; Is it marked DO NOT GIVE!
IF PSBNGF
QUIT
+25 IF PSBIVPSH
QUIT
+26 ;
+27 ; Non One-Times with stop date/time < now
+28 ;
+29 DO NOW^%DTC
+30 IF PSBOSP<%
QUIT
+31 ;
+32 ; include Active, Renewed, ReInstated and On Call
+33 ; (Is it not one time)&(Is it not active or renewed or On Call)
+34 IF PSBSCHT'="O"
IF PSBOSTS'="A"
IF PSBOSTS'="H"
IF PSBOSTS'="R"
IF PSBOSTS'="RE"
IF PSBOSTS'="O"
QUIT
+35 ;
+36 ; Is One Time Given
+37 ;
+38 IF PSBSCHT="O"
Begin DoDot:2
+39 SET (PSBGVN,X,Y)=""
+40 FOR
SET X=$ORDER(^PSB(53.79,"AOIP",DFN,PSBOIT,X),-1)
IF 'X
QUIT
Begin DoDot:3
+41 FOR
SET Y=$ORDER(^PSB(53.79,"AOIP",DFN,PSBOIT,X,Y),-1)
IF 'Y
QUIT
Begin DoDot:4
+42 IF $PIECE(^PSB(53.79,Y,.1),U)=PSBONX
IF $PIECE(^PSB(53.79,Y,0),U,9)="G"
SET PSBGVN=1
SET (X,Y)=0
End DoDot:4
End DoDot:3
End DoDot:2
IF PSBGVN
QUIT
+43 ;
+44 ; How long does One Time remain on VDL ??
+45 SET PSBRMN=1
+46 IF PSBSCHT="O"
IF PSBOSP'=PSBOST&(%>PSBOSP)
SET PSBRMN=0
+47 IF 'PSBRMN
QUIT
+48 ; Is On-Call Given, Can it be given more than once
+49 ;
+50 IF PSBSCHT="OC"
Begin DoDot:2
+51 SET (PSBGVN,X,Y)=""
+52 FOR
SET X=$ORDER(^PSB(53.79,"AOIP",DFN,PSBOIT,X),-1)
IF 'X
QUIT
Begin DoDot:3
+53 FOR
SET Y=$ORDER(^PSB(53.79,"AOIP",DFN,PSBOIT,X,Y),-1)
IF 'Y
QUIT
Begin DoDot:4
+54 IF $PIECE(^PSB(53.79,Y,.1),U)=PSBONX
IF $PIECE(^PSB(53.79,Y,0),U,9)="G"
SET PSBGVN=1
SET (X,Y)=0
End DoDot:4
End DoDot:3
End DoDot:2
IF PSBGVN&('$$GET^XPAR("DIV","PSB ADMIN MULTIPLE ONCALL"))
QUIT
+55 ;
+56 SET PSBREC=""
+57 ; dfn
SET $PIECE(PSBREC,U,1)=DFN
+58 ; order
SET $PIECE(PSBREC,U,2)=PSBONX
+59 ; order ien
SET $PIECE(PSBREC,U,3)=PSBON
+60 ; iv/ud/pending
SET $PIECE(PSBREC,U,4)=PSBOTYP
+61 ; schedule type
SET $PIECE(PSBREC,U,5)=PSBSCHT
+62 ; schedule
SET $PIECE(PSBREC,U,6)=PSBSCH
+63 ; self med
SET $PIECE(PSBREC,U,7)=$SELECT(PSBHSM:"HSM",PSBSM:"SM",1:"")
+64 ; drugname
SET $PIECE(PSBREC,U,8)=PSBOITX
+65 ; dosage
SET $PIECE(PSBREC,U,9)=PSBDOSE_" "_PSBIFR
+66 ; med route
SET $PIECE(PSBREC,U,10)=PSBMR
+67 ; Last Given from the AOIP X-Ref - not given status not excepted
+68 SET (PSBCNT,PSBFLAG)=0
SET (YZ,PSBSTUS,PSBADMER)=""
KILL PSBHSTA,PSBHSTAX
+69 FOR XZ=1:1:20
SET YZ=$ORDER(^PSB(53.79,"AOIP",DFN,PSBOIT,YZ),-1)
SET (PSBCNT,PSBFLAG)=0
IF YZ=""
QUIT
Begin DoDot:2
+70 IF YZ>0
SET $PIECE(PSBREC,U,11)=YZ
+71 SET X=""
FOR
SET X=$ORDER(^PSB(53.79,"AOIP",DFN,PSBOIT,YZ,X),-1)
IF X=""
QUIT
Begin DoDot:3
+72 KILL PSBLCK
LOCK +^PSB(53.79,X):1
IF $TEST
LOCK -^PSB(53.79,X)
SET PSBLCK=1
+73 SET PSBSTUS=$PIECE(^PSB(53.79,X,0),U,9)
+74 IF $GET(PSBSTUS)=""
IF '$GET(PSBLCK)
SET PSBSTUS="X"
IF $GET(PSBLCK)
SET PSBADMER=1
Begin DoDot:4
+75 KILL PSBPARM3,PSBPARM5,PSBPARM6,PSBPARM7
+76 SET PSBPARM6=X
SET Y=$PIECE(^PSB(53.79,X,.1),U,3)
DO DD^%DT
SET PSBPARM3=Y
SET Y=$PIECE(^PSB(53.79,X,0),U,6)
DO DD^%DT
SET PSBPARM5=Y
+77 SET PSBPARM7=$PIECE(^PSB(53.79,X,0),U,7)
SET PSBPARM7="( # "_PSBPARM7_" ) "_$$GET1^DIQ(200,PSBPARM7_",",.01)
+78 KILL PSBXTMP
SET PSBXTMP=PSBONX
+79 DO CLEAN^PSBVT
DO PSJ1^PSBVT(DFN,$$GET1^DIQ(53.79,PSBPARM6_",",.11))
+80 ; SEND AN E-MAIL
DO ERROR^PSBMLU(PSBONX,PSBOITX,DFN,PSBPARM3_" admin's ACTION STATUS is ""UNKNOWN"".",PSBSCH,PSBPARM5,PSBPARM6,PSBPARM7)
+81 ;Reset Variables
DO CLEAN^PSBVT
DO PSJ1^PSBVT(DFN,PSBXTMP)
+82 SET X=PSBPARM6
KILL PSBPARM3,PSBPARM5,PSBPARM6,PSBPARM7
End DoDot:4
+83 KILL PSBLCK
IF (PSBSTUS']"")
SET PSBSTUS="U"
IF PSBSTUS'="N"
IF ($GET(PSBSTUS)'="X")
SET PSBFLAG=1
SET PSBHSTA(YZ,$GET(PSBSTUS))="ORIG"_U_X
+84 IF PSBSTUS="N"
Begin DoDot:4
+85 SET $PIECE(PSBREC,U,11)=""
+86 SET Z=""
FOR
SET Z=$ORDER(^PSB(53.79,X,.9,Z),-1)
IF 'Z
QUIT
IF PSBFLAG=1
QUIT
SET PSBDATA=$GET(^(Z,0))
Begin DoDot:5
+87 IF (PSBDATA["Set to 'NOT GIVEN'")!(PSBDATA["Set to 'GIVEN'")!(PSBDATA["Set to 'REFUSED'")!(PSBDATA["Set to 'HELD'")!(PSBDATA["Set to 'MISSING DOSE'")!(PSBDATA["Set to 'REMOVED'")
SET PSBCNT=PSBCNT+1
+88 IF (PSBDATA["STATUS 'HELD'")!(PSBDATA["STATUS 'GIVEN'")!(PSBDATA["STATUS 'REFUSED'")!(PSBDATA["STATUS 'MISSING DOSE'")!(PSBDATA["STATUS 'REMOVED'")
SET PSBCNT=PSBCNT+1
+89 IF PSBCNT#2=0
IF PSBDATA["'REFUSED'"
SET PSBSTUS="R"
DO LAST^PSBVDLU1
+90 IF PSBCNT#2=0
IF PSBDATA["'HELD'"
SET PSBSTUS="H"
DO LAST^PSBVDLU1
+91 IF PSBCNT#2=0
IF PSBDATA["'MISSING DOSE'"
SET PSBSTUS="M"
DO LAST^PSBVDLU1
+92 IF PSBCNT#2=0
IF PSBDATA["'REMOVED'"
SET PSBSTUS="RM"
DO LAST^PSBVDLU1
+93 IF PSBFLAG=1
IF '$DATA(PSBHSTA($PIECE(PSBREC,U,11),$GET(PSBSTUS)))
SET PSBHSTA($PIECE(PSBREC,U,11),$GET(PSBSTUS))=Z_U_X
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
+94 ;last action date/time
IF $DATA(PSBHSTA)
SET $PIECE(PSBREC,U,11)=$ORDER(PSBHSTA(""),-1)
SET PSBSTUS=$ORDER(PSBHSTA($PIECE(PSBREC,U,11),""),-1)
MERGE PSBHSTAX(PSBOIT)=PSBHSTA
KILL PSBHSTA
+95 ;med log ien inserted below for actual date
SET $PIECE(PSBREC,U,12)=""
+96 ;med log status inserted below for actual date
SET $PIECE(PSBREC,U,13)=""
+97 ; admin date inserted below
SET $PIECE(PSBREC,U,14)=""
+98 ; OI Pointer
SET $PIECE(PSBREC,U,15)=PSBOIT
+99 ;med route injectable flag
SET $PIECE(PSBREC,U,16)=PSBNJECT
+100 ; Variable dosage entered as ####-####?
+101 IF $PIECE(PSBREC,U,9)?1.4N1"-"1.4N.E
SET $PIECE(PSBREC,U,17)=1
+102 IF '$TEST
SET $PIECE(PSBREC,U,17)=0
+103 ; dosage form
IF PSBDOSEF?1"CAP".E!(PSBDOSEF?1"TAB".E)!(PSBDOSEF="PATCH")
SET $PIECE(PSBREC,U,18)=PSBDOSEF
+104 ; last action status
SET $PIECE(PSBREC,U,20)=$SELECT((PSBSTUS="X")!(PSBSTUS="N"):"",1:PSBSTUS)
+105 SET $PIECE(PSBREC,U,21)=PSBOST
+106 SET $PIECE(PSBREC,U,22)=PSBOSTS
+107 SET $PIECE(PSBREC,U,26)=PSBOSP
+108 SET $PIECE(PSBREC,U,27)=$$LASTG^PSBCSUTL(DFN,PSBOIT)
+109 ;
+110 ; Gather Dispense Drugs
+111 DO NOW^%DTC
+112 SET (PSBDDS,PSBSOLS,PSBADDS,PSBFLAG)="0"
+113 FOR Y=0:0
SET Y=$ORDER(PSBDDA(Y))
IF 'Y
QUIT
Begin DoDot:2
+114 ;If drug was inactivated
IF $PIECE(PSBDDA(Y),U,5)=$PIECE(%,".")
SET PSBFLAG=1
+115 ; Inactive
IF $PIECE(PSBDDA(Y),U,5)&($PIECE(PSBDDA(Y),U,5)<%)
QUIT
+116 IF $PIECE(PSBDDA(Y),U,4)=""
SET $PIECE(PSBDDA(Y),U,4)=1
+117 SET PSBDDS=PSBDDS_U_$PIECE(PSBDDA(Y),U,1,4)
+118 SET $PIECE(PSBDDS,U,1)=PSBDDS+1
End DoDot:2
+119 ;
+120 ; On-Call One Time PRN orders
+121 SET PSBQRR=0
+122 IF "^O^OC^P^"[(U_PSBSCHT_U)
DO ADD^PSBVDLU1(PSBREC,PSBOTXT,PSBNOW\1,PSBDDS,PSBSOLS,PSBADDS,"UDTAB")
QUIT
+123 ;
+124 ; Now we deal with only continuous
+125 ; process admintimes
+126 ; Display an order on the VDL based on the frequency received from IPM **PSB*2.0*3
+127 SET (PSBYES,PSBODD,PSBYTF)=0
+128 IF PSBSCH=""
DO ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"No Schedule on this order")
+129 IF $$PSBDCHK1^PSBVT1(PSBSCH)
SET PSBYES=1
+130 IF PSBYES
IF PSBADST=""
DO ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Admin times required",PSBSCH)
QUIT
+131 FOR I=1:1
IF $PIECE(PSBSCH,"-",I)=""
QUIT
IF $PIECE(PSBSCH,"-",I)?2N!($PIECE(PSBSCH,"-",I)?4N)
SET PSBYES=1
SET PSBYTF=1
+132 IF PSBSCHT="C"
IF PSBYTF="1"
IF PSBADST=""
DO ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Admin times required",PSBSCH)
QUIT
+133 SET PSBFREQ=$$GETFREQ^PSBVDLU1(DFN,PSBONX)
+134 IF PSBFREQ="O"
SET PSBFREQ=1440
+135 IF PSBFREQ="D"
SET PSBFREQ=""
+136 IF 'PSBYES
IF PSBFREQ<1
DO ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid frequency received from order",PSBSCH)
QUIT
+137 ;calculate admin times based on frequency
IF (PSBADST="")&(+PSBFREQ>0)
DO ODDSCH^PSBVDLU1("UDTAB")
QUIT
+138 ; No admin times, MAYDAY MAYDAY!!
+139 IF +PSBFREQ>0
IF (PSBFREQ#1440'=0)
IF (1440#PSBFREQ'=0)
SET PSBODD=1
+140 IF PSBODD
IF PSBADST'=""
DO ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Administration Times on ODD SCHEDULE",PSBSCH)
QUIT
+141 ; process admin times against beginning and ending date
+142 ; build all orders for both days.
+143 FOR PSBY=1:1
IF $PIECE(PSBADST,"-",PSBY)=""
QUIT
Begin DoDot:2
+144 ;For invalid admin times
+145 IF ($PIECE(PSBADST,"-",PSBY)'?2N)&($PIECE(PSBADST,"-",PSBY)'?4N)
DO ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid Admin times",PSBSCH)
+146 ; apply this time to the beginning window date
+147 SET PSB=+(PSBWBEG\1_"."_$PIECE(PSBADST,"-",PSBY))
+148 ; Make sure it is in the window
IF (PSB'<PSBWBEG)&(PSB'>PSBWEND)
Begin DoDot:3
+149 ; Make sure this time is active
IF (PSB'<PSBOST)&(PSB<PSBOSP)
Begin DoDot:4
+150 ; Okay on this date?
IF $$OKAY^PSBVDLU1(PSBOST,PSB,PSBSCH,PSBONX,PSBOITX,PSBFREQ,PSBOSTS)
Begin DoDot:5
+151 DO ADD^PSBVDLU1(PSBREC,PSBOTXT,PSB,PSBDDS,PSBSOLS,PSBADDS,"UDTAB")
End DoDot:5
End DoDot:4
End DoDot:3
+152 ;
+153 ; Window only has one day rare but possible
IF (PSBWBEG\1)=(PSBWEND\1)
QUIT
+154 ;
+155 ; apply this time to the ending window date
+156 SET PSB=+(PSBWEND\1_"."_$PIECE(PSBADST,"-",PSBY))
+157 ; Make sure it is in the window
IF (PSB'<PSBWBEG)&(PSB'>PSBWEND)
Begin DoDot:3
+158 ; Make sure this time is active
IF (PSB'<PSBOST)&(PSB<PSBOSP)
Begin DoDot:4
+159 ; Okay on this date?
IF $$OKAY^PSBVDLU1(PSBOST,PSB,PSBSCH,PSBONX,PSBOITX,PSBFREQ,PSBOSTS)
Begin DoDot:5
+160 DO ADD^PSBVDLU1(PSBREC,PSBOTXT,PSB,PSBDDS,PSBSOLS,PSBADDS,"UDTAB")
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
+161 KILL PSBSTUS
End DoDot:1
1 KILL PSBREC
DO EN^PSBVDLPA
+1 ;add initials of verifying pharmacist/verifying nurse
+2 IF PSBTAB="UDTAB"
DO VNURSE^PSBVDLU1("UDTAB")
+3 DO CLEAN^PSBVT
+4 QUIT
+5 ;