PSBML ;BIRMINGHAM/EFC-BCMA MED LOG FUNCTIONS ; 1/7/09 9:57am
;;3.0;BAR CODE MED ADMIN;**6,3,4,9,11,13,25,45,33**;Mar 2004;Build 14
;;Per VHA Directive 2004-038, this routine should not be modified.
; Reference/IA
; ^DPT/10035
; DIC(42/10039
; DIC(42/2440
; File 200/10060
; EN^PSJBCMA3/3320
; $$SITE^VASITE/10112
; ^XUSEC(/10076
;
RPC(RESULTS,PSBHDR,PSBREC) ;BCMA MedLog Filing
S PSBEDTFL=0
N PSBORD,PSBTRAN,PSBFDA
K PSBIEN,PSBHL7
S PSBIEN=$P(PSBHDR,U,1)
S PSBTRAN=$P(PSBHDR,U,2),PSBHL7=PSBTRAN
S PSBINST=$P($G(PSBHDR),U,3)
;PSB*3*45 We should be recording the first entry in the audit log.
;S PSBAUDIT=$S(PSBIEN="+1":0,1:1)
S PSBAUDIT=1
D NOW^%DTC S PSBNOW=%
I $D(^XUSEC("PSB STUDENT",DUZ)),PSBINST="" S RESULTS(0)=1,RESULTS(1)="-1^Instructor not present" Q
I $D(^XUSEC("PSB STUDENT",DUZ)),'$D(^XUSEC("PSB INSTRUCTOR",PSBINST)) S RESULTS(0)=1,RESULTS(1)="-1^Instructor doesn't have authority" Q
S PSBINST(0)=$$GET1^DIQ(200,PSBINST_",",.01)
I PSBTRAN="ADD COMMENT" D COMMENT^PSBML1 Q
I PSBTRAN="PRN EFFECTIVENESS" D PRN^PSBML1 Q
I PSBTRAN="UPDATE STATUS" D Q
.I '$D(^PSB(53.79,PSBIEN)) S RESULTS(0)=1,RESULTS(1)="-1^Administration is at an UNKNOWN STATUS" Q
.D UPDATED^PSBML2
I PSBTRAN="EDIT" D EDIT^PSBML2 Q
;SAGG
N PSBWARD S PSBWARD=$G(^DPT(+$G(PSBREC(0)),.1),"UNKNOWN"),^PSB("SAGG",PSBWARD,DT)=$G(^PSB("SAGG",PSBWARD,DT))+1
I PSBREC(1)?1U1";"1.6N S PSBREC(1)=$P(PSBREC(1),";",1)_$E(PSBREC(1))
D PSJ1^PSBVT(PSBREC(0),$P(PSBREC(1),";",2)_$P(PSBREC(1),";",1))
S PSBTAB=$P(PSBREC(9),U,1),PSBUID=$P(PSBREC(9),U,2)
D:PSBTRAN="MEDPASS"
.I (PSBDOSEF["PATCH"),(PSBREC(3)="G") D Q:+$G(RESULTS(1))<0
..S PSBXDT="" F S PSBXDT=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXDT)) Q:PSBXDT="" D Q:+$G(RESULTS(1))<0
...S PSBYZ="" F S PSBYZ=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXDT,PSBYZ)) Q:'PSBYZ I ("G"[$$GET1^DIQ(53.79,PSBYZ,.09,"I")) D Q
....S:($$GET1^DIQ(53.79,PSBYZ,.09,"I")="G") RESULTS(0)=1,RESULTS(1)="-1^Previous Patch has not been removed. Administration canceled."
....S:($$GET1^DIQ(53.79,PSBYZ,.09,"I")="")&(($$GET1^DIQ(53.79,PSBYZ,.07,"I")'=DUZ)&('$D(^XUSEC("PSB MANAGER",DUZ)))) RESULTS(0)=1,RESULTS(1)="-1^Patch status ""*UNKNOWN*"". Administration canceled."
.I PSBREC(7)="BCMA/CPRS Interface Entry." S PSBNOW=PSBREC(5) ;MOB
.F X=0:1:9 S PSBREC(X)=$G(PSBREC(X))
.I PSBREC(1)?1U1";".N S PSBREC(1)=$P(PSBREC(1),";",2)_$P(PSBREC(1),";",1)
.I PSBREC(1)["V",+PSBREC(5)>0,+$P(PSBREC(5),".",2)=0,PSBIVT'["P" D NOW^%DTC S PSBREC(5)=$P(PSBREC(5),".",1)_"."_$P(%,".",2)
.I $P(PSBREC(9),U,1)="IVTAB",$P(PSBREC(9),U,2)="" S PSBUID=$$GETWSID^PSBVDLU2(PSBREC(0),PSBREC(1))
.I $P(PSBREC(9),U,1)="PBTAB",$P(PSBREC(9),U,2)="",PSBREC(1)'["U",PSBREC(3)'="M",PSBREC(3)'="R",PSBREC(3)'="H" S PSBUID=$$GETWSID^PSBVDLU2(PSBREC(0),PSBREC(1))
.;OnCal
.D:PSBREC(2)="OC"
..S X=$O(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),"")) Q:X=""
..S Y=$O(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),X,0))
..I $P(^PSB(53.79,Y,0),U,9)="G"&('$$GET^XPAR("DIV","PSB ADMIN MULTIPLE ONCALL")) D ERR(1,"On-Call already given")
.;1x
.D:PSBREC(2)="O"
..S X=$O(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),"")) Q:X=""
..S Y=$O(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),X,0))
..I $P(^PSB(53.79,Y,0),U,9)="G" D ERR(1,"One Time already Given")
.;PRN
.I PSBREC(2)="P",PSBREC(3)'="M",$P(PSBREC(9),U,1)'="IVTAB" D
..I PSBREC(6)="" D ERR(1,"PRN Medications MUST Have a PRN Reason")
..I PSBREC(5)]"" D ERR(1,"PRN Orders don't have scheduled times")
..I PSBREC(3)'="G" D ERR(1,"PRN Orders cannot be marked NOT Given")
.;Cnt
.I PSBREC(2)="C",PSBTAB'="IVTAB" D
..D:PSBREC(5)="" ERR(1,"Continuous Order needs admin time")
..D:PSBREC(6)]"" ERR(1,"No PRN Reason allowed on Continuous Orders")
.I PSBREC(2)="C",$D(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),+PSBREC(5))),PSBIEN="+1" D K PSBADMBY,PSBADMAT Q:PSBSIEN="" Q:$P(^PSB(53.79,PSBSIEN,0),U,9)'="N"
..S PSBSIEN=$O(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),PSBREC(5),""))
..I PSBSIEN]"" I '(($P(^PSB(53.79,PSBSIEN,0),U,7)=DUZ)!($D(^XUSEC("PSB MANAGER",DUZ)))) S PSBSIEN=""
..I PSBSIEN']"" S RESULTS(0)=2,RESULTS(1)="-2^Error Filing Transaction MEDPASS",RESULTS(2)="The PSB MANAGER key is required to modify this scheduled admin" Q
..D:$P(^PSB(53.79,PSBSIEN,0),U,9)'="N"
...K PSBINCX I $P(^PSB(53.79,PSBSIEN,0),U,9)="" S PSBINCX=PSBSIEN L +^PSB(53.79,PSBINCX):1 Q:'$T L -^PSB(53.79,PSBINCX)
...S Y=$P(^PSB(53.79,PSBSIEN,0),U,6) D DD^%DT S PSBADMAT=Y
...S PSBADMBY=$$GET1^DIQ(200,$P(^PSB(53.79,PSBSIEN,0),U,7),.01,)
...S RESULTS(0)=3,RESULTS(1)="-2^Error Filing Transaction MEDPASS"
...S RESULTS(2)="Continuous Administration Date/Time already on file."
...S RESULTS(3)="Administered by "_PSBADMBY_" at "_PSBADMAT_"."
...I $D(XWB) S RESULTS(0)=RESULTS(0)+2,RESULTS(4)=" ",RESULTS(5)=" VDL will now be updated."
.;NonGvn
.I PSBREC(3)'="G",PSBREC(3)'="M",PSBUID'["V",PSBUID'["W" D
..I PSBREC(7)="",PSBTAB'="IVTAB" D ERR(1,"Comment needed if Not Marked Given")
..I PSBREC(7)="",PSBTAB="IVTAB" D ERR(1,"Comment needed if Not Marked Completed")
.S:PSBREC(3)="H" PSBREC(7)="Held: "_PSBREC(7) ;.3
.S:PSBREC(3)="R" PSBREC(7)="Refused: "_PSBREC(7) ;.3
.S:PSBREC(3)="S" PSBREC(7)="Stopped: "_PSBREC(7) ;.3
.;Vald?
.I $G(PSBSIEN)'="" I $D(^PSB(53.79,PSBSIEN,0)) I $P(^PSB(53.79,PSBSIEN,0),U,9)="N" S PSBIEN=+PSBSIEN_",",$P(PSBHDR,U)=PSBIEN,PSBTRAN="UPDATE STATUS",PSBAUDIT=1 ;do UPDATE
.D:PSBIEN="+1" ;New?
..D VAL(53.79,PSBIEN,.01,"`"_PSBREC(0)) ;Pt
..S X=$G(^DPT(PSBREC(0),.1))_" "_$G(^(.101)) ;WrdRmBd
..D VAL(53.79,PSBIEN,.02,X) ;PtLoc
..D:$G(^DPT(PSBREC(0),.1))'=""
...S Y=$O(^DIC(42,"B",$G(^DPT(PSBREC(0),.1)),"")),Y=$$GET1^DIQ(42,Y,.015,"I"),PSBDIV=$$SITE^VASITE(DT,Y)
...D VAL(53.79,PSBIEN,.03,"`"_$P(PSBDIV,U,1)) ;Div
..D VAL(53.79,PSBIEN,.04,PSBNOW) ;EntDT
..D VAL(53.79,PSBIEN,.05,"`"_DUZ) ;Who
..D VAL(53.79,PSBIEN,.06,PSBNOW) ;AdmDT
..D VAL(53.79,PSBIEN,.07,"`"_DUZ) ;AdmBy
..D VAL(53.79,PSBIEN,.08,"`"_PSBREC(4)) ;OrdblItm
..D VAL(53.79,PSBIEN,.11,PSBREC(1)) ;OrdTpeIEN
..D VAL(53.79,PSBIEN,.12,PSBREC(2)) ;OrdSchdTpe
..D VAL(53.79,PSBIEN,.13,PSBREC(5)) ;SchdAdmDT
..D:PSBTAB'="UDTAB" VAL(53.79,PSBIEN,.26,PSBUID) ;Bag
..D:PSBTAB="IVTAB" VAL(53.79,PSBIEN,.13,"") ;no SchdAdm - lvIV
..D:PSBREC(1)?.N1"U" VAL(53.79,PSBIEN,.15,PSBDOSE) ;UDDsage
..D:PSBREC(1)?.N1"V" VAL(53.79,PSBIEN,.35,PSBIFR) ;IVInfRt
.;Ovrwrt if exsts
.I PSBREC(3)="G"!(PSBREC(3))="C" D ;Gvn/Cmpltd?
..D VAL(53.79,PSBIEN,.06,PSBNOW) ;AdmDT
..D VAL(53.79,PSBIEN,.07,"`"_DUZ) ;AdmBy
.D:PSBREC(8)]"" VAL(53.79,PSBIEN,.16,PSBREC(8)) ;InjctSte
.D:'$G(PSBMMEN) VAL(53.79,PSBIEN,.09,PSBREC(3)) ;AStats
.D:PSBREC(6)]"" VAL(53.79,PSBIEN,.21,$P(PSBREC(6),U)),VAL(53.79,PSBIEN,.27,$P(PSBREC(6),U,2)) ;PRNRsn
.D:PSBREC(7)]""
..D VAL(53.793,"+2,"_PSBIEN,.01,PSBREC(7)) ;Cmnt
..D VAL(53.793,"+2,"_PSBIEN,.02,"`"_DUZ) ;Who
..D VAL(53.793,"+2,"_PSBIEN,.03,PSBNOW)
.;DD/SOL/ADD
.I PSBREC(3)="G"!(PSBREC(3)="I")!(PSBREC(3)="H")!(PSBREC(3)="R")!(PSBREC(3)="M") D ;gvn/infs?
..I PSBTRAN="UPDATE STATUS" K ^PSB(53.79,+PSBIEN,.5),^PSB(53.79,+PSBIEN,.6),^PSB(53.79,+PSBIEN,.7)
..F PSBCNT=10:1 Q:'$D(PSBREC(PSBCNT)) D
...S Y=$P(PSBREC(PSBCNT),U)
...S PSBDD=$S(Y="DD":53.795,Y="ADD":53.796,Y="SOL":53.797,1:0)
...Q:'PSBDD
...S PSBIENS="+"_PSBCNT_","_PSBIEN
...D VAL(PSBDD,PSBIENS,.01,"`"_$P(PSBREC(PSBCNT),U,2))
...D VAL(PSBDD,PSBIENS,.02,$P(PSBREC(PSBCNT),U,3))
...D VAL(PSBDD,PSBIENS,.03,$P(PSBREC(PSBCNT),U,4))
...D:(PSBTAB="UDTAB")!(PSBTAB="PBTAB") VAL(PSBDD,PSBIENS,.04,$E($P(PSBREC(PSBCNT),U,5),1,40))
.I $O(RESULTS("")) S RESULTS(0)=1,RESULTS(1)="-1^Error(s) Filing Transaction MEDPASS" Q
.D FILEIT
.;PSB*3*33
.D:((PSBREC(2)="O")!($$ONE^PSJBCMA(PSBREC(0),PSBREC(1))="O"))&(PSBREC(3)="G") EXPIRE^PSBML1 ;1x exp?
.D:(PSBREC(2)="O")&(PSBREC(3)="G") EXPIRE^PSBML1 ;1x exp?
.I $P(RESULTS(0),U,1)=1,PSBTAB'="UDTAB",PSBUID]"",PSBUID'["WS" S PSBON=+PSBREC(1) D EN^PSJBCMA3(PSBREC(0),PSBON,PSBUID,PSBREC(3),PSBNOW)
Q
BCBU ;HL7,NatContng
Q:+$G(RESULTS(0))'>0
N PSBIEN1 S PSBIEN1=$S($P(PSBIEN,",",2)'="":+$P(PSBIEN,",",2),$G(PSBIEN)="+1":PSBIEN(1),1:+$G(PSBIEN))
I $G(PSBIEN1)="" S RESULTS(0)=1,RESULTS(1)="-1^Contingency NOT processed" Q
I $G(PSBIEN)="+1" S PSBHL7="MEDPASS"
E S:$G(PSBHL7)="" PSBHL7="UPDATE STATUS"
D:('$D(Y(0))!($G(Y(0))="SAVE")!($G(Y(0))="YES")) EN^PSBSVHL7(+PSBIEN1,PSBHL7),MEDL^ALPBCBU(+PSBIEN1) K PSBHL7
;<<HDR-VDEF(frm *3)
Q
VAL(PSBDD,PSBIEN,PSBFLD,PSBVAL) ;
K ^TMP("DIERR",$J),PSBRET
D VAL^DIE(PSBDD,PSBIEN,PSBFLD,"F",PSBVAL,.PSBRET,"PSBFDA")
I PSBRET="^" F X=0:0 S X=$O(^TMP("DIERR",$J,X)) Q:'X D ERR(2,^TMP("DIERR",$J,X)_": "_$G(^(X,"TEXT",1),"**"))
K ^TMP("DIERR",$J),PSBRET
Q
FILEIT ;Updt
N PSBMSG,PSBAUD
S (PSB1,PSB2)=""
D APATCH^PSBML3
D CLEAN^DILF
D RESETADM^PSBUTL
D UPDATE^DIE("","PSBFDA","PSBIEN","PSBMSG")
I '$G(PSBMMEN) S X=+PSBIEN I $F("HR",$P(^PSB(53.79,X,0),U,9))>1 F Y=.5,.6,.7 S Z=0 F S Z=$O(^PSB(53.79,+X,Y,Z)) Q:+Z=0 S $P(^PSB(53.79,+X,Y,Z,0),U,3)=0
I $D(PSBMSG("DIERR")) S RESULTS(0)=1,RESULTS(1)="-1^"_PSBMSG("DIERR",1)_": "_PSBMSG("DIERR",1,"TEXT",1) Q
I $G(PSB1)]"" X PSB1 I $G(PSB2)]"" X PSB2
I $D(PSBHDR) D:"NHMR"[$P(^PSB(53.79,$S($P(PSBHDR,"^",1)="+1":PSBIEN(1),1:+PSBIEN),0),U,9)
.N PSBINDX S PSBINDX=$S($P(PSBHDR,"^",1)="+1":PSBIEN(1),1:+PSBIEN)
.K ^PSB(53.79,"APATCH",$P(^PSB(53.79,PSBINDX,0),U),$P(^PSB(53.79,PSBINDX,0),U,6),PSBINDX)
S RESULTS(0)=1,RESULTS(1)="1^Data Successfully Filed^"_$S($G(PSBIEN(1))'="":$G(PSBIEN(1)),1:+$G(PSBIEN))
D BCBU ;NatContng
I $G(PSBINST,0) S PSBAUD=$S($P(PSBHDR,"^",1)="+1":PSBIEN(1),1:$P(PSBHDR,"^",1)) D AUDIT^PSBMLU(PSBAUD,"Instructor "_PSBINST(0)_" present.",PSBTRAN)
Q
ERR(X,Y) ;
S X=$P("Business Logic Error^Data Validation Error",U,X)
S RESULTS($O(RESULTS(""),-1)+1)=X_": "_Y
Q
N PSBFDA,PSBIEN,PSBNOW
S PSBIEN="+1,"_DA_","
D NOW^%DTC S PSBNOW=%
D VAL(53.793,PSBIEN,.01,PSBCMT)
S PSBFDA(53.793,PSBIEN,.02)=DUZ
S PSBFDA(53.793,PSBIEN,.03)=PSBNOW
D FILEIT
Q
PSBML ;BIRMINGHAM/EFC-BCMA MED LOG FUNCTIONS ; 1/7/09 9:57am
+1 ;;3.0;BAR CODE MED ADMIN;**6,3,4,9,11,13,25,45,33**;Mar 2004;Build 14
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ; Reference/IA
+4 ; ^DPT/10035
+5 ; DIC(42/10039
+6 ; DIC(42/2440
+7 ; File 200/10060
+8 ; EN^PSJBCMA3/3320
+9 ; $$SITE^VASITE/10112
+10 ; ^XUSEC(/10076
+11 ;
RPC(RESULTS,PSBHDR,PSBREC) ;BCMA MedLog Filing
+1 SET PSBEDTFL=0
+2 NEW PSBORD,PSBTRAN,PSBFDA
+3 KILL PSBIEN,PSBHL7
+4 SET PSBIEN=$PIECE(PSBHDR,U,1)
+5 SET PSBTRAN=$PIECE(PSBHDR,U,2)
SET PSBHL7=PSBTRAN
+6 SET PSBINST=$PIECE($GET(PSBHDR),U,3)
+7 ;PSB*3*45 We should be recording the first entry in the audit log.
+8 ;S PSBAUDIT=$S(PSBIEN="+1":0,1:1)
+9 SET PSBAUDIT=1
+10 DO NOW^%DTC
SET PSBNOW=%
+11 IF $DATA(^XUSEC("PSB STUDENT",DUZ))
IF PSBINST=""
SET RESULTS(0)=1
SET RESULTS(1)="-1^Instructor not present"
QUIT
+12 IF $DATA(^XUSEC("PSB STUDENT",DUZ))
IF '$DATA(^XUSEC("PSB INSTRUCTOR",PSBINST))
SET RESULTS(0)=1
SET RESULTS(1)="-1^Instructor doesn't have authority"
QUIT
+13 SET PSBINST(0)=$$GET1^DIQ(200,PSBINST_",",.01)
+14 IF PSBTRAN="ADD COMMENT"
DO COMMENT^PSBML1
QUIT
+15 IF PSBTRAN="PRN EFFECTIVENESS"
DO PRN^PSBML1
QUIT
+16 IF PSBTRAN="UPDATE STATUS"
Begin DoDot:1
+17 IF '$DATA(^PSB(53.79,PSBIEN))
SET RESULTS(0)=1
SET RESULTS(1)="-1^Administration is at an UNKNOWN STATUS"
QUIT
+18 DO UPDATED^PSBML2
End DoDot:1
QUIT
+19 IF PSBTRAN="EDIT"
DO EDIT^PSBML2
QUIT
+20 ;SAGG
+21 NEW PSBWARD
SET PSBWARD=$GET(^DPT(+$GET(PSBREC(0)),.1),"UNKNOWN")
SET ^PSB("SAGG",PSBWARD,DT)=$GET(^PSB("SAGG",PSBWARD,DT))+1
+22 IF PSBREC(1)?1U1";"1.6N
SET PSBREC(1)=$PIECE(PSBREC(1),";",1)_$EXTRACT(PSBREC(1))
+23 DO PSJ1^PSBVT(PSBREC(0),$PIECE(PSBREC(1),";",2)_$PIECE(PSBREC(1),";",1))
+24 SET PSBTAB=$PIECE(PSBREC(9),U,1)
SET PSBUID=$PIECE(PSBREC(9),U,2)
+25 IF PSBTRAN="MEDPASS"
Begin DoDot:1
+26 IF (PSBDOSEF["PATCH")
IF (PSBREC(3)="G")
Begin DoDot:2
+27 SET PSBXDT=""
FOR
SET PSBXDT=$ORDER(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXDT))
IF PSBXDT=""
QUIT
Begin DoDot:3
+28 SET PSBYZ=""
FOR
SET PSBYZ=$ORDER(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXDT,PSBYZ))
IF 'PSBYZ
QUIT
IF ("G"[$$GET1^DIQ(53.79,PSBYZ,.09,"I"))
Begin DoDot:4
+29 IF ($$GET1^DIQ(53.79,PSBYZ,.09,"I")="G")
SET RESULTS(0)=1
SET RESULTS(1)="-1^Previous Patch has not been removed. Administration canceled."
+30 IF ($$GET1^DIQ(53.79,PSBYZ,.09,"I")="")&(($$GET1^DIQ(53.79,PSBYZ,.07,"I")'=DUZ)&('$DATA(^XUSEC("PSB MANAGER",DUZ))))
SET RESULTS(0)=1
SET RESULTS(1)="-1^Patch status ""*UNKNOWN*"". Administration canceled."
End DoDot:4
QUIT
End DoDot:3
IF +$GET(RESULTS(1))<0
QUIT
End DoDot:2
IF +$GET(RESULTS(1))<0
QUIT
+31 ;MOB
IF PSBREC(7)="BCMA/CPRS Interface Entry."
SET PSBNOW=PSBREC(5)
+32 FOR X=0:1:9
SET PSBREC(X)=$GET(PSBREC(X))
+33 IF PSBREC(1)?1U1";".N
SET PSBREC(1)=$PIECE(PSBREC(1),";",2)_$PIECE(PSBREC(1),";",1)
+34 IF PSBREC(1)["V"
IF +PSBREC(5)>0
IF +$PIECE(PSBREC(5),".",2)=0
IF PSBIVT'["P"
DO NOW^%DTC
SET PSBREC(5)=$PIECE(PSBREC(5),".",1)_"."_$PIECE(%,".",2)
+35 IF $PIECE(PSBREC(9),U,1)="IVTAB"
IF $PIECE(PSBREC(9),U,2)=""
SET PSBUID=$$GETWSID^PSBVDLU2(PSBREC(0),PSBREC(1))
+36 IF $PIECE(PSBREC(9),U,1)="PBTAB"
IF $PIECE(PSBREC(9),U,2)=""
IF PSBREC(1)'["U"
IF PSBREC(3)'="M"
IF PSBREC(3)'="R"
IF PSBREC(3)'="H"
SET PSBUID=$$GETWSID^PSBVDLU2(PSBREC(0),PSBREC(1))
+37 ;OnCal
+38 IF PSBREC(2)="OC"
Begin DoDot:2
+39 SET X=$ORDER(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),""))
IF X=""
QUIT
+40 SET Y=$ORDER(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),X,0))
+41 IF $PIECE(^PSB(53.79,Y,0),U,9)="G"&('$$GET^XPAR("DIV","PSB ADMIN MULTIPLE ONCALL"))
DO ERR(1,"On-Call already given")
End DoDot:2
+42 ;1x
+43 IF PSBREC(2)="O"
Begin DoDot:2
+44 SET X=$ORDER(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),""))
IF X=""
QUIT
+45 SET Y=$ORDER(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),X,0))
+46 IF $PIECE(^PSB(53.79,Y,0),U,9)="G"
DO ERR(1,"One Time already Given")
End DoDot:2
+47 ;PRN
+48 IF PSBREC(2)="P"
IF PSBREC(3)'="M"
IF $PIECE(PSBREC(9),U,1)'="IVTAB"
Begin DoDot:2
+49 IF PSBREC(6)=""
DO ERR(1,"PRN Medications MUST Have a PRN Reason")
+50 IF PSBREC(5)]""
DO ERR(1,"PRN Orders don't have scheduled times")
+51 IF PSBREC(3)'="G"
DO ERR(1,"PRN Orders cannot be marked NOT Given")
End DoDot:2
+52 ;Cnt
+53 IF PSBREC(2)="C"
IF PSBTAB'="IVTAB"
Begin DoDot:2
+54 IF PSBREC(5)=""
DO ERR(1,"Continuous Order needs admin time")
+55 IF PSBREC(6)]""
DO ERR(1,"No PRN Reason allowed on Continuous Orders")
End DoDot:2
+56 IF PSBREC(2)="C"
IF $DATA(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),+PSBREC(5)))
IF PSBIEN="+1"
Begin DoDot:2
+57 SET PSBSIEN=$ORDER(^PSB(53.79,"AORD",PSBREC(0),PSBREC(1),PSBREC(5),""))
+58 IF PSBSIEN]""
IF '(($PIECE(^PSB(53.79,PSBSIEN,0),U,7)=DUZ)!($DATA(^XUSEC("PSB MANAGER",DUZ))))
SET PSBSIEN=""
+59 IF PSBSIEN']""
SET RESULTS(0)=2
SET RESULTS(1)="-2^Error Filing Transaction MEDPASS"
SET RESULTS(2)="The PSB MANAGER key is required to modify this scheduled admin"
QUIT
+60 IF $PIECE(^PSB(53.79,PSBSIEN,0),U,9)'="N"
Begin DoDot:3
+61 KILL PSBINCX
IF $PIECE(^PSB(53.79,PSBSIEN,0),U,9)=""
SET PSBINCX=PSBSIEN
LOCK +^PSB(53.79,PSBINCX):1
IF '$TEST
QUIT
LOCK -^PSB(53.79,PSBINCX)
+62 SET Y=$PIECE(^PSB(53.79,PSBSIEN,0),U,6)
DO DD^%DT
SET PSBADMAT=Y
+63 SET PSBADMBY=$$GET1^DIQ(200,$PIECE(^PSB(53.79,PSBSIEN,0),U,7),.01,)
+64 SET RESULTS(0)=3
SET RESULTS(1)="-2^Error Filing Transaction MEDPASS"
+65 SET RESULTS(2)="Continuous Administration Date/Time already on file."
+66 SET RESULTS(3)="Administered by "_PSBADMBY_" at "_PSBADMAT_"."
+67 IF $DATA(XWB)
SET RESULTS(0)=RESULTS(0)+2
SET RESULTS(4)=" "
SET RESULTS(5)=" VDL will now be updated."
End DoDot:3
End DoDot:2
KILL PSBADMBY,PSBADMAT
IF PSBSIEN=""
QUIT
IF $PIECE(^PSB(53.79,PSBSIEN,0),U,9)'="N"
QUIT
+68 ;NonGvn
+69 IF PSBREC(3)'="G"
IF PSBREC(3)'="M"
IF PSBUID'["V"
IF PSBUID'["W"
Begin DoDot:2
+70 IF PSBREC(7)=""
IF PSBTAB'="IVTAB"
DO ERR(1,"Comment needed if Not Marked Given")
+71 IF PSBREC(7)=""
IF PSBTAB="IVTAB"
DO ERR(1,"Comment needed if Not Marked Completed")
End DoDot:2
+72 ;.3
IF PSBREC(3)="H"
SET PSBREC(7)="Held: "_PSBREC(7)
+73 ;.3
IF PSBREC(3)="R"
SET PSBREC(7)="Refused: "_PSBREC(7)
+74 ;.3
IF PSBREC(3)="S"
SET PSBREC(7)="Stopped: "_PSBREC(7)
+75 ;Vald?
+76 ;do UPDATE
IF $GET(PSBSIEN)'=""
IF $DATA(^PSB(53.79,PSBSIEN,0))
IF $PIECE(^PSB(53.79,PSBSIEN,0),U,9)="N"
SET PSBIEN=+PSBSIEN_","
SET $PIECE(PSBHDR,U)=PSBIEN
SET PSBTRAN="UPDATE STATUS"
SET PSBAUDIT=1
+77 ;New?
IF PSBIEN="+1"
Begin DoDot:2
+78 ;Pt
DO VAL(53.79,PSBIEN,.01,"`"_PSBREC(0))
+79 ;WrdRmBd
SET X=$GET(^DPT(PSBREC(0),.1))_" "_$GET(^(.101))
+80 ;PtLoc
DO VAL(53.79,PSBIEN,.02,X)
+81 IF $GET(^DPT(PSBREC(0),.1))'=""
Begin DoDot:3
+82 SET Y=$ORDER(^DIC(42,"B",$GET(^DPT(PSBREC(0),.1)),""))
SET Y=$$GET1^DIQ(42,Y,.015,"I")
SET PSBDIV=$$SITE^VASITE(DT,Y)
+83 ;Div
DO VAL(53.79,PSBIEN,.03,"`"_$PIECE(PSBDIV,U,1))
End DoDot:3
+84 ;EntDT
DO VAL(53.79,PSBIEN,.04,PSBNOW)
+85 ;Who
DO VAL(53.79,PSBIEN,.05,"`"_DUZ)
+86 ;AdmDT
DO VAL(53.79,PSBIEN,.06,PSBNOW)
+87 ;AdmBy
DO VAL(53.79,PSBIEN,.07,"`"_DUZ)
+88 ;OrdblItm
DO VAL(53.79,PSBIEN,.08,"`"_PSBREC(4))
+89 ;OrdTpeIEN
DO VAL(53.79,PSBIEN,.11,PSBREC(1))
+90 ;OrdSchdTpe
DO VAL(53.79,PSBIEN,.12,PSBREC(2))
+91 ;SchdAdmDT
DO VAL(53.79,PSBIEN,.13,PSBREC(5))
+92 ;Bag
IF PSBTAB'="UDTAB"
DO VAL(53.79,PSBIEN,.26,PSBUID)
+93 ;no SchdAdm - lvIV
IF PSBTAB="IVTAB"
DO VAL(53.79,PSBIEN,.13,"")
+94 ;UDDsage
IF PSBREC(1)?.N1"U"
DO VAL(53.79,PSBIEN,.15,PSBDOSE)
+95 ;IVInfRt
IF PSBREC(1)?.N1"V"
DO VAL(53.79,PSBIEN,.35,PSBIFR)
End DoDot:2
+96 ;Ovrwrt if exsts
+97 ;Gvn/Cmpltd?
IF PSBREC(3)="G"!(PSBREC(3))="C"
Begin DoDot:2
+98 ;AdmDT
DO VAL(53.79,PSBIEN,.06,PSBNOW)
+99 ;AdmBy
DO VAL(53.79,PSBIEN,.07,"`"_DUZ)
End DoDot:2
+100 ;InjctSte
IF PSBREC(8)]""
DO VAL(53.79,PSBIEN,.16,PSBREC(8))
+101 ;AStats
IF '$GET(PSBMMEN)
DO VAL(53.79,PSBIEN,.09,PSBREC(3))
+102 ;PRNRsn
IF PSBREC(6)]""
DO VAL(53.79,PSBIEN,.21,$PIECE(PSBREC(6),U))
DO VAL(53.79,PSBIEN,.27,$PIECE(PSBREC(6),U,2))
+103 IF PSBREC(7)]""
Begin DoDot:2
+104 ;Cmnt
DO VAL(53.793,"+2,"_PSBIEN,.01,PSBREC(7))
+105 ;Who
DO VAL(53.793,"+2,"_PSBIEN,.02,"`"_DUZ)
+106 DO VAL(53.793,"+2,"_PSBIEN,.03,PSBNOW)
End DoDot:2
+107 ;DD/SOL/ADD
+108 ;gvn/infs?
IF PSBREC(3)="G"!(PSBREC(3)="I")!(PSBREC(3)="H")!(PSBREC(3)="R")!(PSBREC(3)="M")
Begin DoDot:2
+109 IF PSBTRAN="UPDATE STATUS"
KILL ^PSB(53.79,+PSBIEN,.5),^PSB(53.79,+PSBIEN,.6),^PSB(53.79,+PSBIEN,.7)
+110 FOR PSBCNT=10:1
IF '$DATA(PSBREC(PSBCNT))
QUIT
Begin DoDot:3
+111 SET Y=$PIECE(PSBREC(PSBCNT),U)
+112 SET PSBDD=$SELECT(Y="DD":53.795,Y="ADD":53.796,Y="SOL":53.797,1:0)
+113 IF 'PSBDD
QUIT
+114 SET PSBIENS="+"_PSBCNT_","_PSBIEN
+115 DO VAL(PSBDD,PSBIENS,.01,"`"_$PIECE(PSBREC(PSBCNT),U,2))
+116 DO VAL(PSBDD,PSBIENS,.02,$PIECE(PSBREC(PSBCNT),U,3))
+117 DO VAL(PSBDD,PSBIENS,.03,$PIECE(PSBREC(PSBCNT),U,4))
+118 IF (PSBTAB="UDTAB")!(PSBTAB="PBTAB")
DO VAL(PSBDD,PSBIENS,.04,$EXTRACT($PIECE(PSBREC(PSBCNT),U,5),1,40))
End DoDot:3
End DoDot:2
+119 IF $ORDER(RESULTS(""))
SET RESULTS(0)=1
SET RESULTS(1)="-1^Error(s) Filing Transaction MEDPASS"
QUIT
+120 DO FILEIT
+121 ;PSB*3*33
+122 ;1x exp?
IF ((PSBREC(2)="O")!($$ONE^PSJBCMA(PSBREC(0),PSBREC(1))="O"))&(PSBREC(3)="G")
DO EXPIRE^PSBML1
+123 ;1x exp?
IF (PSBREC(2)="O")&(PSBREC(3)="G")
DO EXPIRE^PSBML1
+124 IF $PIECE(RESULTS(0),U,1)=1
IF PSBTAB'="UDTAB"
IF PSBUID]""
IF PSBUID'["WS"
SET PSBON=+PSBREC(1)
DO EN^PSJBCMA3(PSBREC(0),PSBON,PSBUID,PSBREC(3),PSBNOW)
End DoDot:1
+125 QUIT
BCBU ;HL7,NatContng
+1 IF +$GET(RESULTS(0))'>0
QUIT
+2 NEW PSBIEN1
SET PSBIEN1=$SELECT($PIECE(PSBIEN,",",2)'="":+$PIECE(PSBIEN,",",2),$GET(PSBIEN)="+1":PSBIEN(1),1:+$GET(PSBIEN))
+3 IF $GET(PSBIEN1)=""
SET RESULTS(0)=1
SET RESULTS(1)="-1^Contingency NOT processed"
QUIT
+4 IF $GET(PSBIEN)="+1"
SET PSBHL7="MEDPASS"
+5 IF '$TEST
IF $GET(PSBHL7)=""
SET PSBHL7="UPDATE STATUS"
+6 IF ('$DATA(Y(0))!($GET(Y(0))="SAVE")!($GET(Y(0))="YES"))
DO EN^PSBSVHL7(+PSBIEN1,PSBHL7)
DO MEDL^ALPBCBU(+PSBIEN1)
KILL PSBHL7
+7 ;<<HDR-VDEF(frm *3)
+8 QUIT
VAL(PSBDD,PSBIEN,PSBFLD,PSBVAL) ;
+1 KILL ^TMP("DIERR",$JOB),PSBRET
+2 DO VAL^DIE(PSBDD,PSBIEN,PSBFLD,"F",PSBVAL,.PSBRET,"PSBFDA")
+3 IF PSBRET="^"
FOR X=0:0
SET X=$ORDER(^TMP("DIERR",$JOB,X))
IF 'X
QUIT
DO ERR(2,^TMP("DIERR",$JOB,X)_": "_$GET(^(X,"TEXT",1),"**"))
+4 KILL ^TMP("DIERR",$JOB),PSBRET
+5 QUIT
FILEIT ;Updt
+1 NEW PSBMSG,PSBAUD
+2 SET (PSB1,PSB2)=""
+3 DO APATCH^PSBML3
+4 DO CLEAN^DILF
+5 DO RESETADM^PSBUTL
+6 DO UPDATE^DIE("","PSBFDA","PSBIEN","PSBMSG")
+7 IF '$GET(PSBMMEN)
SET X=+PSBIEN
IF $FIND("HR",$PIECE(^PSB(53.79,X,0),U,9))>1
FOR Y=.5,.6,.7
SET Z=0
FOR
SET Z=$ORDER(^PSB(53.79,+X,Y,Z))
IF +Z=0
QUIT
SET $PIECE(^PSB(53.79,+X,Y,Z,0),U,3)=0
+8 IF $DATA(PSBMSG("DIERR"))
SET RESULTS(0)=1
SET RESULTS(1)="-1^"_PSBMSG("DIERR",1)_": "_PSBMSG("DIERR",1,"TEXT",1)
QUIT
+9 IF $GET(PSB1)]""
XECUTE PSB1
IF $GET(PSB2)]""
XECUTE PSB2
+10 IF $DATA(PSBHDR)
IF "NHMR"[$PIECE(^PSB(53.79,$SELECT($PIECE(PSBHDR,"^",1)="+1"
Begin DoDot:1
+11 NEW PSBINDX
SET PSBINDX=$SELECT($PIECE(PSBHDR,"^",1)="+1":PSBIEN(1),1:+PSBIEN)
+12 KILL ^PSB(53.79,"APATCH",$PIECE(^PSB(53.79,PSBINDX,0),U),$PIECE(^PSB(53.79,PSBINDX,0),U,6),PSBINDX)
End DoDot:1
+13 SET RESULTS(0)=1
SET RESULTS(1)="1^Data Successfully Filed^"_$SELECT($GET(PSBIEN(1))'="":$GET(PSBIEN(1)),1:+$GET(PSBIEN))
+14 ;NatContng
DO BCBU
+15 IF $GET(PSBINST,0)
SET PSBAUD=$SELECT($PIECE(PSBHDR,"^",1)="+1":PSBIEN(1),1:$PIECE(PSBHDR,"^",1))
DO AUDIT^PSBMLU(PSBAUD,"Instructor "_PSBINST(0)_" present.",PSBTRAN)
+16 QUIT
ERR(X,Y) ;
+1 SET X=$PIECE("Business Logic Error^Data Validation Error",U,X)
+2 SET RESULTS($ORDER(RESULTS(""),-1)+1)=X_": "_Y
+3 QUIT
+1 NEW PSBFDA,PSBIEN,PSBNOW
+2 SET PSBIEN="+1,"_DA_","
+3 DO NOW^%DTC
SET PSBNOW=%
+4 DO VAL(53.793,PSBIEN,.01,PSBCMT)
+5 SET PSBFDA(53.793,PSBIEN,.02)=DUZ
+6 SET PSBFDA(53.793,PSBIEN,.03)=PSBNOW
+7 DO FILEIT
+8 QUIT