PSBOMH ;BIRMINGHAM/EFC-MAH ;Mar 2004
;;3.0;BAR CODE MED ADMIN;**5,9,38**;Mar 2004;Build 8
;Per VHA Directive 2004-038, this routine should not be modified.
;
; Reference/IA
; EN^PSJBCMA/2828
; EN^PSJBCMA2/2830
; File 200/10060
; ^DIWP/10011
;
EN ; Called from DQ^PSBO
N PSBGBL,DFN
S PSBGBL=$NAME(^TMP("PSBO",$J,"B"))
F S PSBGBL=$Q(@PSBGBL) Q:PSBGBL="" Q:$QS(PSBGBL,2)'=$J Q:$QS(PSBGBL,1)'["PSBO" D
.S DFN=$QS(PSBGBL,5)
.S (PSBSTRT,X)=$P(PSBRPT(.1),U,6) D H^%DTC S PSBSTH=%H
.S (PSBSTOP,X)=$P(PSBRPT(.1),U,8)+.235959 D H^%DTC S PSBSPH=%H
.S PSBCNT=0 F I=PSBSTH:1:PSBSPH S PSBAR(I)=PSBSTH+((PSBCNT\7)*7),PSBCNT=PSBCNT+1
.D EN1
K PSBCNT,PSBAR Q
EN1 ; Expects DFN,STRT,STOP
N PSBGBL,PSBHDR,PSBX,PSBFLAG
K ^TMP("PSJ",$J),^TMP("PSB",$J)
S PSBEVDT=PSBSTRT
D EN^PSJBCMA(DFN,PSBSTRT)
I $G(^TMP("PSJ",$J,1,0))=-1 D PT^PSBOHDR(DFN,.PSBHDR) W !!,"****NO MEDICATIONS FOUND****" Q ; No Ord
S PSBX=""
F S PSBX=$O(^TMP("PSJ",$J,PSBX)) Q:PSBX="" D
.Q:$P(^TMP("PSJ",$J,PSBX,0),U,3)?.N1"P" ; No Pnd
.Q:$P(^TMP("PSJ",$J,PSBX,1),U,5)<PSBSTRT!($P(^TMP("PSJ",$J,PSBX,1),U,4)>PSBSTOP) ;display orders active in date range of report
.S X=$P(^TMP("PSJ",$J,PSBX,1),U,2)
.S ^TMP("PSB",$J,"ORDERS",$P(^TMP("PSJ",$J,PSBX,0),U,3))=X
I '$D(^TMP("PSB",$J,"ORDERS")) D PT^PSBOHDR(DFN,.PSBHDR) W !!,"****NO MEDICATIONS FOUND****" Q ; No Orders
S PSBMHND="PSBOMH"
; Act on Orders
S PSBX="" F S PSBX=$O(^TMP("PSB",$J,"ORDERS",PSBX)) Q:PSBX="" S PSBTYPE=^(PSBX) D
.S:PSBTYPE'="C" PSBTYPE="P"
.D CLEAN^PSBVT
.D PSJ1^PSBVT(DFN,PSBX)
.S X1=((PSBEVDT)\1) S X2=-1 D C^%DTC S PSBCNTST=X
.S X1=((PSBSTOP)\1) S X2=1 D C^%DTC S PSBXSTOP=X
.S PSBVALB=""
.S PSBVALB=$$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,PSBIVPSH)
.S PSBZ=""
.S X1=PSBXSTOP,X2=PSBCNTST D ^%DTC S PSBNCT=X
.F PSBZ=1:1:PSBNCT S X1=PSBCNTST S X2=1 D C^%DTC S PSBCNTST=X D
..I (PSBX["V")!(PSBX'["V") D
...I PSBCNTST'>(PSBOST\1) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
...I PSBCNTST=(PSBOST\1)!($G(^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST))) K ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)
...I PSBCNTST>(PSBOSP\1) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
...I PSBCNTST=(PSBOSP\1)&($G(^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST))) K ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
..S PSBDODD=""
..I (PSBFREQ#1440'=0),(1440#PSBFREQ'=0) S PSBDODD=1
..I ((PSBX'["V")!(PSBVALB="1")),((PSBDODD="1")&(PSBADST'="")) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
..I ((PSBX'["V")!(PSBVALB="1")),('$$OKAY^PSBVDLU1(PSBOST,PSBCNTST,PSBSCH,PSBON,PSBOITX,PSBFREQ,PSBOSTS)) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)="" ;W t TMP
.S (PSBYES,PSBODD,PSBFLAG,PSBYTFN,PSBDAYN)=0
.S:$$PSBDCHK1^PSBVT1(PSBSCH) PSBYES=1,PSBDAYN=1
.I PSBYES,PSBADST="",PSBSCHT'="O",PSBSCHT'="OC",PSBSCHT'="P" Q
.F I=1:1 Q:$P(PSBSCH,"-",I)="" I $P(PSBSCH,"-",I)?2N!($P(PSBSCH,"-",I)?4N) S PSBYES=1,PSBYTFN=1
.I (PSBFREQ="O")!(PSBTYPE="P") S PSBYES=1
.I (PSBFREQ#1440'=0),(1440#PSBFREQ'=0) S PSBODD=1
.;flg / admn t
.S:PSBONX["U" PSBFLAG=1
.I PSBIVT="A" S PSBADST="0000"
.I PSBIVT="H" S PSBADST="0000"
.I PSBIVT="C",PSBCHEMT="P" S:PSBADST="" PSBFLAG=1
.I PSBIVT="C",PSBISYR=1 S:PSBADST="" PSBFLAG=1
.I PSBIVT="C",PSBCHEMT="A" S PSBADST="0000"
.I PSBIVT="C",PSBISYR=0 S PSBADST="0000"
.I PSBIVT="P",($G(PSBADST)=0) S:PSBADST="" PSBFLAG=1
.I PSBIVT="P" S:PSBADST="" PSBFLAG=1
.I PSBIVT="S",PSBISYR=0 S PSBADST="0000"
.I PSBIVT="S",PSBISYR=1 S:PSBADST="" PSBFLAG=1
.I PSBFREQ="D" S PSBFREQ=""
.I 'PSBYES,PSBADST="",PSBFREQ<1 Q
.S (PSBEE,PSBZZ)=0
.I (PSBVALB="1")!(PSBX'["V") D Q:(PSBEE!PSBZZ)=1
..I PSBSCHT="C",PSBYTFN="1",PSBADST="" S PSBEE=1
..I PSBSCHT="C",PSBDAYN'="1",PSBYTFN'="1",PSBADST'="",PSBFREQ<1 S PSBZZ=1
.I 'PSBODD,PSBFLAG,PSBTYPE="C",PSBADST="" S PSBADST=$$GETADMIN^PSBVDLU1(DFN,PSBONX,PSBOST,PSBFREQ,PSBSTOP)
.E I PSBADST'="" K ^TMP("PSB",$J,"GETADMIN") S ^TMP("PSB",$J,"GETADMIN",0)=PSBADST
.;Calc adm/frq
.S PSBDT=PSBSTRT
.K PSBO,^UTILITY($J)
.F X=1:1:8 S PSBO(X)=""
.S DIWL=0,DIWR=32,DIWF="C32"
.S X=$P(PSBOSTX," ")_" "_$P(PSBOSPX," ") D ^DIWP
.S X="@"_$P(PSBOSTX," ",3)_" @"_$P(PSBOSPX," ",3)_" " D ^DIWP
.S X="" D ^DIWP
.S X=PSBOITX D ^DIWP
.; DD,SOL,ADD
.S X=""
.F Y=0:0 S Y=$O(PSBDDA(Y)) Q:'Y S X=X_$S(X]"":", ",1:"")_$P(PSBDDA(Y),U,3)
.F Y=0:0 S Y=$O(PSBADA(Y)) Q:'Y S X=X_$S(X]"":", ",1:"")_$P(PSBADA(Y),U,3)_" "_$P(PSBADA(Y),U,4)_$P(PSBADA(Y),U,5)
.F Y=0:0 S Y=$O(PSBSOLA(Y)) Q:'Y S X=X_$S(X]"":", ",1:"")_$P(PSBSOLA(Y),U,3)_" "_$P(PSBSOLA(Y),U,4)
.S X=" "_X,DIWF="I2C32" D ^DIWP S DIWF="C32"
.S PSBTXT=" Give: "_PSBDOSE_" "_PSBMRAB_" "_PSBSCH_" "_PSBIFR
.F S PSBWORD=$P(PSBTXT," ",1),PSBTXT=$P(PSBTXT," ",2,250) D Q:PSBTXT=""
..F Q:'$L(PSBWORD) S X=$E(PSBWORD,1,30),PSBWORD=$E(PSBWORD,30,250) D ^DIWP
.K ^TMP("PSJ",$J) D EN^PSJBCMA2(DFN,PSBX) I ^TMP("PSJ",$J,0)'=-1 D ;get activity log
..S (PSBDISX,PSBHLDX)=0 F I=1:1:$P(^TMP("PSJ",$J,0),U,4) S X=$G(^TMP("PSJ",$J,I,1)) D ;loop activities
...Q:X["EDITED"!(X["VERIF") ;
...S Z=0
...I X'["OFF HOLD",X'["UNHOLD",X'["REINSTATE" S Z=1 ; inc iv's
...S PSBHLDX=PSBHLDX+$S(Z>0:1,1:0)
...S $P(PSBHLD(PSBHLDX),U,$S(Z>0:1,1:11))=^TMP("PSJ",$J,I,1) ;set up for multiple on hold entries save start & stop as pair if exists
..F PSBHLDX=1:1 S X=$G(PSBHLD(PSBHLDX)) Q:'X D ;if a hold index - process
...S PSBHLDN=$P(PSBHLD(PSBHLDX),U,1),PSBHLDF=$P(PSBHLD(PSBHLDX),U,11) ;get on/off hold, dates, IEN number(for UD orders) of person.
...Q:PSBHLDN>PSBSTOP Q:(PSBHLDF<PSBSTRT)&(PSBHLDF'="")
...F PSBHLDT=PSBSTRT\1:1:PSBSTOP\1 I (PSBHLDT'<(PSBHLDN\1)),(PSBHLDT'>PSBSTOP) D
....I X["DISCONTINUED" K ^TMP("PSB",$J,"ORDERS",PSBONX,"HOLD",PSBHLDT) S ^TMP("PSB",$J,"ORDERS",PSBONX,"DISC",PSBHLDT)=""
....I (X["HOLD")&((PSBHLDN\1)'>PSBHLDT)&((PSBHLDF'<PSBHLDT)!(PSBHLDF="")) S ^TMP("PSB",$J,"ORDERS",PSBONX,"HOLD",PSBHLDT)=""
....I X["REINSTATE" K ^TMP("PSB",$J,"ORDERS",PSBONX,"DISC",PSBHLDT) I PSBOSTS="H" S ^TMP("PSB",$J,"ORDERS",PSBONX,"HOLD",PSBHLDT)=""
...F PSBHLDXP=1:10:$P(PSBHLD(PSBHLDX),U,11)]""+10 D
....S PSBDESC=$P(PSBHLD(PSBHLDX),U,PSBHLDXP+3),X=$S(PSBDESC["DISCONTINUE":"***",1:"")
....S X=" "_X_PSBDESC D ^DIWP ;output activity text
....S X="",PSBHLDI=$P(PSBHLD(PSBHLDX),U,PSBHLDXP+4) I PSBHLDI'="" S X=$$GET1^DIQ(200,PSBHLDI,"INITIAL")
....S:X="" X="99" ;no init present
....I X'="99" S X=" "_X D ^DIWP ;get init & store
....S Y=$P(PSBHLD(PSBHLDX),U,PSBHLDXP) D DD^%DT S X=Y D ^DIWP ;format hold date / write
..K PSBHLD,PSBHLDF,PSBHLDN,PSBHLDT,PSBHLDX,PSBHLDXP,PSBHLDI,PSBDISX,PSBDISC,PSBDISXP,PSBDISI,PSBDIST,PSBDISN,PSBDESC
.I PSBOTXT]"" D
..I $E(PSBOTXT,1)="!" S $E(PSBOTXT,1)=""
..S PSBOTXT=" Spec Inst: "_PSBOTXT
..F S PSBWORD=$P(PSBOTXT," ",1),PSBOTXT=$P(PSBOTXT," ",2,250) D Q:PSBOTXT=""
...F Q:'$L(PSBWORD) S X=$E(PSBWORD,1,30),PSBWORD=$E(PSBWORD,30,250) D ^DIWP
.F X=0:0 S X=$O(^UTILITY($J,"W",0,X)) Q:'X S PSBO(X)=$G(^(X,0)) D
.S X=$O(PSBO(""),-1) S X=$S(X<8:8,1:X+1)
.S PSBO(X)=" RPH: "_PSBVPHI_" RN: "_PSBVNI
.S PSBVAL=$$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,PSBIVPSH)
.I PSBODD="1",PSBADST'="" D
..I (PSBVAL="1")!(PSBX'["V") D ;checks iv/pb and u dose
...S PSBO(X+1)=""
...S PSBO(X+2)="NOTE - ODD SCHEDULE NO LONGER",PSBO(X+3)=" ALLOWS ADMIN TIMES."
.K ^UTILITY($J)
.M ^TMP("PSB",$J,"ORDERS",PSBX,"INST")=PSBO
.D:PSBTYPE="C"
..F D Q:PSBDT>PSBSTOP
...S X=PSBDT D H^%DTC S PSBWEEK=%H
...S ^TMP("PSB",$J,PSBWEEK,PSBONX)=""
...; Odd schd - msg
...S PSBIDOW=0 I PSBONX["U"!("PCS"[PSBIVT) S PSBIDOW=1
...I PSBADST="",PSBIDOW,(PSBODD) D
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",0)=7
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",1)="odd"
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",2)="sched"
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",3)=$E(PSBSCH,1,5)
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",4)="no"
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",5)="fixed"
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",6)="admin"
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",7)="times"
...I PSBADST'="",PSBADST'="0000",+$G(PSBFREQ)>0,+$G(PSBFREQ)<45 D
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",0)=5
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",1)="Due"
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",2)="every"
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",3)=$E(PSBFREQ,1,5)
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",4)="mins."
....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",5)=" "
...S PSBATCNT=0 ; # times to print...
...I PSBADST'="",((+$G(PSBFREQ)>44)!(PSBFREQ="")!(PSBADST="0000")) F PSBXX=0:1 Q:$G(^TMP("PSB",$J,"GETADMIN",PSBXX))="" D
....S PSBADST2=$G(^TMP("PSB",$J,"GETADMIN",PSBXX))
....F Y=1:1:$L(PSBADST2,"-") D
.....Q:($P(PSBADST2,"-",Y)'?2N)&($P(PSBADST2,"-",Y)'?4N) S PSBATCNT=PSBATCNT+1,^TMP("PSB",$J,"ORDERS",PSBONX,"AT",PSBATCNT)=$P(PSBADST2,"-",Y)
...I PSBADST'="",PSBFREQ>44 S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",0)=PSBATCNT
...S ^TMP("PSB",$J,PSBWEEK,"SORT",PSBTYPE,PSBOITX,PSBX)=""
...F PSBDOW=0:1:6 D Q:X>(PSBSTOP-1)
....S %H=PSBWEEK+PSBDOW D YMD^%DTC
....S ^TMP("PSB",$J,PSBWEEK,PSBONX,X,0)=0
....I '$D(^TMP("PSB",$J,PSBWEEK,"HDR",X)) S ^TMP("PSB",$J,PSBWEEK,"HDR",X)=$E(X,4,5)_"/"_$E(X,6,7)_"/"_(1700+$E(X,1,3))
...S %H=PSBWEEK+7 D YMD^%DTC S PSBDT=X
.D:PSBTYPE'="C"
..S X=PSBDT D H^%DTC S PSBWEEK=%H
..S (^TMP("PSB",$J,PSBWEEK,PSBONX),^TMP("PSB",$J,PSBWEEK,PSBONX,"AT",0))="",^TMP("PSB",$J,PSBWEEK,"SORT",PSBTYPE,PSBOITX,PSBX)=""
D EN^PSBOMH1,EN^PSBOMH2
Q
INSTR S PSBINIT=PSBINIT_"*"
S PSBNAME=PSBNAME_"/"_$P(^PSB(53.79,PSBIEN,.9,$P(PSBDT,"."),0),U,3)_" "_$$GET1^DIQ(53.79,PSBIEN_",",.06)
Q
;
PSBOMH ;BIRMINGHAM/EFC-MAH ;Mar 2004
+1 ;;3.0;BAR CODE MED ADMIN;**5,9,38**;Mar 2004;Build 8
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 ; Reference/IA
+5 ; EN^PSJBCMA/2828
+6 ; EN^PSJBCMA2/2830
+7 ; File 200/10060
+8 ; ^DIWP/10011
+9 ;
EN ; Called from DQ^PSBO
+1 NEW PSBGBL,DFN
+2 SET PSBGBL=$NAME(^TMP("PSBO",$JOB,"B"))
+3 FOR
SET PSBGBL=$QUERY(@PSBGBL)
IF PSBGBL=""
QUIT
IF $QSUBSCRIPT(PSBGBL,2)'=$JOB
QUIT
IF $QSUBSCRIPT(PSBGBL,1)'["PSBO"
QUIT
Begin DoDot:1
+4 SET DFN=$QSUBSCRIPT(PSBGBL,5)
+5 SET (PSBSTRT,X)=$PIECE(PSBRPT(.1),U,6)
DO H^%DTC
SET PSBSTH=%H
+6 SET (PSBSTOP,X)=$PIECE(PSBRPT(.1),U,8)+.235959
DO H^%DTC
SET PSBSPH=%H
+7 SET PSBCNT=0
FOR I=PSBSTH:1:PSBSPH
SET PSBAR(I)=PSBSTH+((PSBCNT\7)*7)
SET PSBCNT=PSBCNT+1
+8 DO EN1
End DoDot:1
+9 KILL PSBCNT,PSBAR
QUIT
EN1 ; Expects DFN,STRT,STOP
+1 NEW PSBGBL,PSBHDR,PSBX,PSBFLAG
+2 KILL ^TMP("PSJ",$JOB),^TMP("PSB",$JOB)
+3 SET PSBEVDT=PSBSTRT
+4 DO EN^PSJBCMA(DFN,PSBSTRT)
+5 ; No Ord
IF $GET(^TMP("PSJ",$JOB,1,0))=-1
DO PT^PSBOHDR(DFN,.PSBHDR)
WRITE !!,"****NO MEDICATIONS FOUND****"
QUIT
+6 SET PSBX=""
+7 FOR
SET PSBX=$ORDER(^TMP("PSJ",$JOB,PSBX))
IF PSBX=""
QUIT
Begin DoDot:1
+8 ; No Pnd
IF $PIECE(^TMP("PSJ",$JOB,PSBX,0),U,3)?.N1"P"
QUIT
+9 ;display orders active in date range of report
IF $PIECE(^TMP("PSJ",$JOB,PSBX,1),U,5)<PSBSTRT!($PIECE(^TMP("PSJ",$JOB,PSBX,1),U,4)>PSBSTOP)
QUIT
+10 SET X=$PIECE(^TMP("PSJ",$JOB,PSBX,1),U,2)
+11 SET ^TMP("PSB",$JOB,"ORDERS",$PIECE(^TMP("PSJ",$JOB,PSBX,0),U,3))=X
End DoDot:1
+12 ; No Orders
IF '$DATA(^TMP("PSB",$JOB,"ORDERS"))
DO PT^PSBOHDR(DFN,.PSBHDR)
WRITE !!,"****NO MEDICATIONS FOUND****"
QUIT
+13 SET PSBMHND="PSBOMH"
+14 ; Act on Orders
+15 SET PSBX=""
FOR
SET PSBX=$ORDER(^TMP("PSB",$JOB,"ORDERS",PSBX))
IF PSBX=""
QUIT
SET PSBTYPE=^(PSBX)
Begin DoDot:1
+16 IF PSBTYPE'="C"
SET PSBTYPE="P"
+17 DO CLEAN^PSBVT
+18 DO PSJ1^PSBVT(DFN,PSBX)
+19 SET X1=((PSBEVDT)\1)
SET X2=-1
DO C^%DTC
SET PSBCNTST=X
+20 SET X1=((PSBSTOP)\1)
SET X2=1
DO C^%DTC
SET PSBXSTOP=X
+21 SET PSBVALB=""
+22 SET PSBVALB=$$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,PSBIVPSH)
+23 SET PSBZ=""
+24 SET X1=PSBXSTOP
SET X2=PSBCNTST
DO ^%DTC
SET PSBNCT=X
+25 FOR PSBZ=1:1:PSBNCT
SET X1=PSBCNTST
SET X2=1
DO C^%DTC
SET PSBCNTST=X
Begin DoDot:2
+26 IF (PSBX["V")!(PSBX'["V")
Begin DoDot:3
+27 IF PSBCNTST'>(PSBOST\1)
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
+28 IF PSBCNTST=(PSBOST\1)!($GET(^TMP("PSB",$JOB,"ORDERS",PSBONX,"NTDUE",PSBCNTST)))
KILL ^TMP("PSB",$JOB,"ORDERS",PSBONX,"NTDUE",PSBCNTST)
+29 IF PSBCNTST>(PSBOSP\1)
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
+30 IF PSBCNTST=(PSBOSP\1)&($GET(^TMP("PSB",$JOB,"ORDERS",PSBONX,"NTDUE",PSBCNTST)))
KILL ^TMP("PSB",$JOB,"ORDERS",PSBONX,"NTDUE",PSBCNTST)
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
End DoDot:3
+31 SET PSBDODD=""
+32 IF (PSBFREQ#1440'=0)
IF (1440#PSBFREQ'=0)
SET PSBDODD=1
+33 IF ((PSBX'["V")!(PSBVALB="1"))
IF ((PSBDODD="1")&(PSBADST'=""))
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
+34 ;W t TMP
IF ((PSBX'["V")!(PSBVALB="1"))
IF ('$$OKAY^PSBVDLU1(PSBOST,PSBCNTST,PSBSCH,PSBON,PSBOITX,PSBFREQ,PSBOSTS))
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
End DoDot:2
+35 SET (PSBYES,PSBODD,PSBFLAG,PSBYTFN,PSBDAYN)=0
+36 IF $$PSBDCHK1^PSBVT1(PSBSCH)
SET PSBYES=1
SET PSBDAYN=1
+37 IF PSBYES
IF PSBADST=""
IF PSBSCHT'="O"
IF PSBSCHT'="OC"
IF PSBSCHT'="P"
QUIT
+38 FOR I=1:1
IF $PIECE(PSBSCH,"-",I)=""
QUIT
IF $PIECE(PSBSCH,"-",I)?2N!($PIECE(PSBSCH,"-",I)?4N)
SET PSBYES=1
SET PSBYTFN=1
+39 IF (PSBFREQ="O")!(PSBTYPE="P")
SET PSBYES=1
+40 IF (PSBFREQ#1440'=0)
IF (1440#PSBFREQ'=0)
SET PSBODD=1
+41 ;flg / admn t
+42 IF PSBONX["U"
SET PSBFLAG=1
+43 IF PSBIVT="A"
SET PSBADST="0000"
+44 IF PSBIVT="H"
SET PSBADST="0000"
+45 IF PSBIVT="C"
IF PSBCHEMT="P"
IF PSBADST=""
SET PSBFLAG=1
+46 IF PSBIVT="C"
IF PSBISYR=1
IF PSBADST=""
SET PSBFLAG=1
+47 IF PSBIVT="C"
IF PSBCHEMT="A"
SET PSBADST="0000"
+48 IF PSBIVT="C"
IF PSBISYR=0
SET PSBADST="0000"
+49 IF PSBIVT="P"
IF ($GET(PSBADST)=0)
IF PSBADST=""
SET PSBFLAG=1
+50 IF PSBIVT="P"
IF PSBADST=""
SET PSBFLAG=1
+51 IF PSBIVT="S"
IF PSBISYR=0
SET PSBADST="0000"
+52 IF PSBIVT="S"
IF PSBISYR=1
IF PSBADST=""
SET PSBFLAG=1
+53 IF PSBFREQ="D"
SET PSBFREQ=""
+54 IF 'PSBYES
IF PSBADST=""
IF PSBFREQ<1
QUIT
+55 SET (PSBEE,PSBZZ)=0
+56 IF (PSBVALB="1")!(PSBX'["V")
Begin DoDot:2
+57 IF PSBSCHT="C"
IF PSBYTFN="1"
IF PSBADST=""
SET PSBEE=1
+58 IF PSBSCHT="C"
IF PSBDAYN'="1"
IF PSBYTFN'="1"
IF PSBADST'=""
IF PSBFREQ<1
SET PSBZZ=1
End DoDot:2
IF (PSBEE!PSBZZ)=1
QUIT
+59 IF 'PSBODD
IF PSBFLAG
IF PSBTYPE="C"
IF PSBADST=""
SET PSBADST=$$GETADMIN^PSBVDLU1(DFN,PSBONX,PSBOST,PSBFREQ,PSBSTOP)
+60 IF '$TEST
IF PSBADST'=""
KILL ^TMP("PSB",$JOB,"GETADMIN")
SET ^TMP("PSB",$JOB,"GETADMIN",0)=PSBADST
+61 ;Calc adm/frq
+62 SET PSBDT=PSBSTRT
+63 KILL PSBO,^UTILITY($JOB)
+64 FOR X=1:1:8
SET PSBO(X)=""
+65 SET DIWL=0
SET DIWR=32
SET DIWF="C32"
+66 SET X=$PIECE(PSBOSTX," ")_" "_$PIECE(PSBOSPX," ")
DO ^DIWP
+67 SET X="@"_$PIECE(PSBOSTX," ",3)_" @"_$PIECE(PSBOSPX," ",3)_" "
DO ^DIWP
+68 SET X=""
DO ^DIWP
+69 SET X=PSBOITX
DO ^DIWP
+70 ; DD,SOL,ADD
+71 SET X=""
+72 FOR Y=0:0
SET Y=$ORDER(PSBDDA(Y))
IF 'Y
QUIT
SET X=X_$SELECT(X]"":", ",1:"")_$PIECE(PSBDDA(Y),U,3)
+73 FOR Y=0:0
SET Y=$ORDER(PSBADA(Y))
IF 'Y
QUIT
SET X=X_$SELECT(X]"":", ",1:"")_$PIECE(PSBADA(Y),U,3)_" "_$PIECE(PSBADA(Y),U,4)_$PIECE(PSBADA(Y),U,5)
+74 FOR Y=0:0
SET Y=$ORDER(PSBSOLA(Y))
IF 'Y
QUIT
SET X=X_$SELECT(X]"":", ",1:"")_$PIECE(PSBSOLA(Y),U,3)_" "_$PIECE(PSBSOLA(Y),U,4)
+75 SET X=" "_X
SET DIWF="I2C32"
DO ^DIWP
SET DIWF="C32"
+76 SET PSBTXT=" Give: "_PSBDOSE_" "_PSBMRAB_" "_PSBSCH_" "_PSBIFR
+77 FOR
SET PSBWORD=$PIECE(PSBTXT," ",1)
SET PSBTXT=$PIECE(PSBTXT," ",2,250)
Begin DoDot:2
+78 FOR
IF '$LENGTH(PSBWORD)
QUIT
SET X=$EXTRACT(PSBWORD,1,30)
SET PSBWORD=$EXTRACT(PSBWORD,30,250)
DO ^DIWP
End DoDot:2
IF PSBTXT=""
QUIT
+79 ;get activity log
KILL ^TMP("PSJ",$JOB)
DO EN^PSJBCMA2(DFN,PSBX)
IF ^TMP("PSJ",$JOB,0)'=-1
Begin DoDot:2
+80 ;loop activities
SET (PSBDISX,PSBHLDX)=0
FOR I=1:1:$PIECE(^TMP("PSJ",$JOB,0),U,4)
SET X=$GET(^TMP("PSJ",$JOB,I,1))
Begin DoDot:3
+81 ;
IF X["EDITED"!(X["VERIF")
QUIT
+82 SET Z=0
+83 ; inc iv's
IF X'["OFF HOLD"
IF X'["UNHOLD"
IF X'["REINSTATE"
SET Z=1
+84 SET PSBHLDX=PSBHLDX+$SELECT(Z>0:1,1:0)
+85 ;set up for multiple on hold entries save start & stop as pair if exists
SET $PIECE(PSBHLD(PSBHLDX),U,$SELECT(Z>0:1,1:11))=^TMP("PSJ",$JOB,I,1)
End DoDot:3
+86 ;if a hold index - process
FOR PSBHLDX=1:1
SET X=$GET(PSBHLD(PSBHLDX))
IF 'X
QUIT
Begin DoDot:3
+87 ;get on/off hold, dates, IEN number(for UD orders) of person.
SET PSBHLDN=$PIECE(PSBHLD(PSBHLDX),U,1)
SET PSBHLDF=$PIECE(PSBHLD(PSBHLDX),U,11)
+88 IF PSBHLDN>PSBSTOP
QUIT
IF (PSBHLDF<PSBSTRT)&(PSBHLDF'="")
QUIT
+89 FOR PSBHLDT=PSBSTRT\1:1:PSBSTOP\1
IF (PSBHLDT'<(PSBHLDN\1))
IF (PSBHLDT'>PSBSTOP)
Begin DoDot:4
+90 IF X["DISCONTINUED"
KILL ^TMP("PSB",$JOB,"ORDERS",PSBONX,"HOLD",PSBHLDT)
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"DISC",PSBHLDT)=""
+91 IF (X["HOLD")&((PSBHLDN\1)'>PSBHLDT)&((PSBHLDF'<PSBHLDT)!(PSBHLDF=""))
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"HOLD",PSBHLDT)=""
+92 IF X["REINSTATE"
KILL ^TMP("PSB",$JOB,"ORDERS",PSBONX,"DISC",PSBHLDT)
IF PSBOSTS="H"
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"HOLD",PSBHLDT)=""
End DoDot:4
+93 FOR PSBHLDXP=1:10:$PIECE(PSBHLD(PSBHLDX),U,11)]""+10
Begin DoDot:4
+94 SET PSBDESC=$PIECE(PSBHLD(PSBHLDX),U,PSBHLDXP+3)
SET X=$SELECT(PSBDESC["DISCONTINUE":"***",1:"")
+95 ;output activity text
SET X=" "_X_PSBDESC
DO ^DIWP
+96 SET X=""
SET PSBHLDI=$PIECE(PSBHLD(PSBHLDX),U,PSBHLDXP+4)
IF PSBHLDI'=""
SET X=$$GET1^DIQ(200,PSBHLDI,"INITIAL")
+97 ;no init present
IF X=""
SET X="99"
+98 ;get init & store
IF X'="99"
SET X=" "_X
DO ^DIWP
+99 ;format hold date / write
SET Y=$PIECE(PSBHLD(PSBHLDX),U,PSBHLDXP)
DO DD^%DT
SET X=Y
DO ^DIWP
End DoDot:4
End DoDot:3
+100 KILL PSBHLD,PSBHLDF,PSBHLDN,PSBHLDT,PSBHLDX,PSBHLDXP,PSBHLDI,PSBDISX,PSBDISC,PSBDISXP,PSBDISI,PSBDIST,PSBDISN,PSBDESC
End DoDot:2
+101 IF PSBOTXT]""
Begin DoDot:2
+102 IF $EXTRACT(PSBOTXT,1)="!"
SET $EXTRACT(PSBOTXT,1)=""
+103 SET PSBOTXT=" Spec Inst: "_PSBOTXT
+104 FOR
SET PSBWORD=$PIECE(PSBOTXT," ",1)
SET PSBOTXT=$PIECE(PSBOTXT," ",2,250)
Begin DoDot:3
+105 FOR
IF '$LENGTH(PSBWORD)
QUIT
SET X=$EXTRACT(PSBWORD,1,30)
SET PSBWORD=$EXTRACT(PSBWORD,30,250)
DO ^DIWP
End DoDot:3
IF PSBOTXT=""
QUIT
End DoDot:2
+106 FOR X=0:0
SET X=$ORDER(^UTILITY($JOB,"W",0,X))
IF 'X
QUIT
SET PSBO(X)=$GET(^(X,0))
Begin DoDot:2
End DoDot:2
+107 SET X=$ORDER(PSBO(""),-1)
SET X=$SELECT(X<8:8,1:X+1)
+108 SET PSBO(X)=" RPH: "_PSBVPHI_" RN: "_PSBVNI
+109 SET PSBVAL=$$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,PSBIVPSH)
+110 IF PSBODD="1"
IF PSBADST'=""
Begin DoDot:2
+111 ;checks iv/pb and u dose
IF (PSBVAL="1")!(PSBX'["V")
Begin DoDot:3
+112 SET PSBO(X+1)=""
+113 SET PSBO(X+2)="NOTE - ODD SCHEDULE NO LONGER"
SET PSBO(X+3)=" ALLOWS ADMIN TIMES."
End DoDot:3
End DoDot:2
+114 KILL ^UTILITY($JOB)
+115 MERGE ^TMP("PSB",$JOB,"ORDERS",PSBX,"INST")=PSBO
+116 IF PSBTYPE="C"
Begin DoDot:2
+117 FOR
Begin DoDot:3
+118 SET X=PSBDT
DO H^%DTC
SET PSBWEEK=%H
+119 SET ^TMP("PSB",$JOB,PSBWEEK,PSBONX)=""
+120 ; Odd schd - msg
+121 SET PSBIDOW=0
IF PSBONX["U"!("PCS"[PSBIVT)
SET PSBIDOW=1
+122 IF PSBADST=""
IF PSBIDOW
IF (PSBODD)
Begin DoDot:4
+123 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",0)=7
+124 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",1)="odd"
+125 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",2)="sched"
+126 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",3)=$EXTRACT(PSBSCH,1,5)
+127 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",4)="no"
+128 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",5)="fixed"
+129 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",6)="admin"
+130 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",7)="times"
End DoDot:4
+131 IF PSBADST'=""
IF PSBADST'="0000"
IF +$GET(PSBFREQ)>0
IF +$GET(PSBFREQ)<45
Begin DoDot:4
+132 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",0)=5
+133 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",1)="Due"
+134 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",2)="every"
+135 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",3)=$EXTRACT(PSBFREQ,1,5)
+136 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",4)="mins."
+137 SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",5)=" "
End DoDot:4
+138 ; # times to print...
SET PSBATCNT=0
+139 IF PSBADST'=""
IF ((+$GET(PSBFREQ)>44)!(PSBFREQ="")!(PSBADST="0000"))
FOR PSBXX=0:1
IF $GET(^TMP("PSB",$JOB,"GETADMIN",PSBXX))=""
QUIT
Begin DoDot:4
+140 SET PSBADST2=$GET(^TMP("PSB",$JOB,"GETADMIN",PSBXX))
+141 FOR Y=1:1:$LENGTH(PSBADST2,"-")
Begin DoDot:5
+142 IF ($PIECE(PSBADST2,"-",Y)'?2N)&($PIECE(PSBADST2,"-",Y)'?4N)
QUIT
SET PSBATCNT=PSBATCNT+1
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",PSBATCNT)=$PIECE(PSBADST2,"-",Y)
End DoDot:5
End DoDot:4
+143 IF PSBADST'=""
IF PSBFREQ>44
SET ^TMP("PSB",$JOB,"ORDERS",PSBONX,"AT",0)=PSBATCNT
+144 SET ^TMP("PSB",$JOB,PSBWEEK,"SORT",PSBTYPE,PSBOITX,PSBX)=""
+145 FOR PSBDOW=0:1:6
Begin DoDot:4
+146 SET %H=PSBWEEK+PSBDOW
DO YMD^%DTC
+147 SET ^TMP("PSB",$JOB,PSBWEEK,PSBONX,X,0)=0
+148 IF '$DATA(^TMP("PSB",$JOB,PSBWEEK,"HDR",X))
SET ^TMP("PSB",$JOB,PSBWEEK,"HDR",X)=$EXTRACT(X,4,5)_"/"_$EXTRACT(X,6,7)_"/"_(1700+$EXTRACT(X,1,3))
End DoDot:4
IF X>(PSBSTOP-1)
QUIT
+149 SET %H=PSBWEEK+7
DO YMD^%DTC
SET PSBDT=X
End DoDot:3
IF PSBDT>PSBSTOP
QUIT
End DoDot:2
+150 IF PSBTYPE'="C"
Begin DoDot:2
+151 SET X=PSBDT
DO H^%DTC
SET PSBWEEK=%H
+152 SET (^TMP("PSB",$JOB,PSBWEEK,PSBONX),^TMP("PSB",$JOB,PSBWEEK,PSBONX,"AT",0))=""
SET ^TMP("PSB",$JOB,PSBWEEK,"SORT",PSBTYPE,PSBOITX,PSBX)=""
End DoDot:2
End DoDot:1
+153 DO EN^PSBOMH1
DO EN^PSBOMH2
+154 QUIT
INSTR SET PSBINIT=PSBINIT_"*"
+1 SET PSBNAME=PSBNAME_"/"_$PIECE(^PSB(53.79,PSBIEN,.9,$PIECE(PSBDT,"."),0),U,3)_" "_$$GET1^DIQ(53.79,PSBIEN_",",.06)
+2 QUIT
+3 ;