180 lines
9.4 KiB
Mathematica
180 lines
9.4 KiB
Mathematica
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
|
|
;
|