PSIVCHK ;BIR/PR,MLM-CHECK ORDER FOR INTEGRITY ;12 DEC 97 / 10:16 AM
;;5.0; INPATIENT MEDICATIONS ;**54,58,81,111,213**;16 DEC 97;Build 8
;
; Reference to ^PS(51.1 supported by DBIA# 2177.
; Reference to ^DIE supported by DBIA# 2053.
;
;Need DFN and ON
W ! S ERR=0,P("TYP")=P(4) S:P("TYP")="C" P("TYP")=P(23) I P("TYP")="S" S P("TYP")=$S(+P(5):"P",1:"A")
I '+P("MR") W !,"*** You have not specified a med route! ",! S ERR=1
I P(11)]"" S X=P(11) D CHK^DIE(51.1,1,"",X,.PSJTIM) I PSJTIM="^" W !,"*** Your administration time(s) are in an invalid format !" S ERR=1
M I P(15)<0 S ERR=1 W !,"*** Time interval between doses is less than zero !"
NEW X S X=0 S:P(9)]"" X=$O(^PS(51.1,"APPSJ",P(9),0))
N XX F XX=2,3 I $P(P(XX),".",2)=""!($L(P(XX))>12) S ERR=1 W !,"*** ",$S(XX=2:"Start",1:"Stop")," date is in an invalid format or must contain time !"
I P(2)>P(3) S ERR=1 W !,"*** Start date/time CANNOT be greater than the stop date/time"
I $$SCHREQ^PSJLIVFD(.P),'X D
.N PSJXSTMP S PSJXSTMP=P(9) I PSJXSTMP="" S ERR=1 Q
.N X,Y,PSGS0XT,PSGS0Y,PSGOES S PSGOES=2,X=PSJXSTMP D ENOS^PSGS0 I $G(X)]""&($G(X)=$G(PSJXSTMP)) Q
.W !," *** WARNING -- Missing or Invalid Schedule ...",! S ERR=1
INF I P(8)="","AH"[P("TYP") S ERR=1 W !,"*** You have no infusion rate defined !"
I "AH"[P("TYP"),P(8)'?1N.N.1".".1N1" ml/hr",P(8)'?.E1"@"1N.N,P(8)'?1"0."1N1" ml/hr" S ERR=1 W !,"*** Your infusion rate is in an invalid format !"
I P(8)="",P("TYP")="P" S:'ERR ERR=2 W !,"*** WARNING -- You have not specified an infusion rate. "
I '$$CODES1^PSIVUTL(P("TYP"),55.01,.04)!(P("TYP")="") S ERR=1 W !,"*** Type of order is invalid !"
I '$$CODES1^PSIVUTL(P(17),55.01,100)!(P(17)="") S ERR=1 W !,"*** Status of order is invalid !"
AH ;
I "HA"[P("TYP"),(P(11)]""!(P(9)]"")) W !,$C(7),"Order type is an admixture, hyperal, or continuous syringe, and you have",!,"a schedule and/or administration times defined!"
I F Q=0:0 W !,"Ok to delete these fields" S %=1 D YN^DICN D NULSET Q:%
K % I P(6)="" S ERR=1 W !,"*** You have not entered a physician!"
I P(6)]"",'$D(^VA(200,+P(6),"PS")) S ERR=1 W !,"*** Physician entered does not exist or is not authorized to write",!,"medication orders"
I P(6)]"",$D(^VA(200,+P(6),"PS")),(+$P(^("PS"),U,4)),($P(^("PS"),U,4)'>DT) S ERR=1 W !,"*** Physician entered is no longer active."
D ^PSIVCHK1
Q
;
NULSET ;Delete admin/schedule fields for hyperals and/or admixtures
I '% W !!?2,"Enter 'YES' to delete the schedule and/or administration times fields from",!,"this order. Enter 'NO' (or '^') to leave the fields intact.",! Q
S:%=1 P(9)="",P(11)=""
Q
CKO S P16=0,PSIVEXAM=1,PSIVCT=1 D PSIVCHK S PSIVNOL=1 W ! D ^PSIVORLB K PSIVEXAM Q:'ERR
I ERR=2 F J=0:0 W !!,"Since there is a warning with this order.",!,"do you wish to re-edit this order" S %=1 D YN^DICN Q:% W !!,"Answer 'YES' to re-edit this order."
I ERR=2,%=1 S PSIVOK="57^58^59^26^39^63^64^62^10^25^1" D ^PSIVORV2,GSTRING^PSIVORE1,GTFLDS^PSIVORFE K DA,DIE,DR G CKO
Q
PSIVCHK ;BIR/PR,MLM-CHECK ORDER FOR INTEGRITY ;12 DEC 97 / 10:16 AM
+1 ;;5.0; INPATIENT MEDICATIONS ;**54,58,81,111,213**;16 DEC 97;Build 8
+2 ;
+3 ; Reference to ^PS(51.1 supported by DBIA# 2177.
+4 ; Reference to ^DIE supported by DBIA# 2053.
+5 ;
+6 ;Need DFN and ON
+7 WRITE !
SET ERR=0
SET P("TYP")=P(4)
IF P("TYP")="C"
SET P("TYP")=P(23)
IF P("TYP")="S"
SET P("TYP")=$SELECT(+P(5):"P",1:"A")
+8 IF '+P("MR")
WRITE !,"*** You have not specified a med route! ",!
SET ERR=1
+9 IF P(11)]""
SET X=P(11)
DO CHK^DIE(51.1,1,"",X,.PSJTIM)
IF PSJTIM="^"
WRITE !,"*** Your administration time(s) are in an invalid format !"
SET ERR=1
M IF P(15)<0
SET ERR=1
WRITE !,"*** Time interval between doses is less than zero !"
+1 NEW X
SET X=0
IF P(9)]""
SET X=$ORDER(^PS(51.1,"APPSJ",P(9),0))
+2 NEW XX
FOR XX=2,3
IF $PIECE(P(XX),".",2)=""!($LENGTH(P(XX))>12)
SET ERR=1
WRITE !,"*** ",$SELECT(XX=2:"Start",1:"Stop")," date is in an invalid format or must contain time !"
+3 IF P(2)>P(3)
SET ERR=1
WRITE !,"*** Start date/time CANNOT be greater than the stop date/time"
+4 IF $$SCHREQ^PSJLIVFD(.P)
IF 'X
Begin DoDot:1
+5 NEW PSJXSTMP
SET PSJXSTMP=P(9)
IF PSJXSTMP=""
SET ERR=1
QUIT
+6 NEW X,Y,PSGS0XT,PSGS0Y,PSGOES
SET PSGOES=2
SET X=PSJXSTMP
DO ENOS^PSGS0
IF $GET(X)]""&($GET(X)=$GET(PSJXSTMP))
QUIT
+7 WRITE !," *** WARNING -- Missing or Invalid Schedule ...",!
SET ERR=1
End DoDot:1
INF IF P(8)=""
IF "AH"[P("TYP")
SET ERR=1
WRITE !,"*** You have no infusion rate defined !"
+1 IF "AH"[P("TYP")
IF P(8)'?1N.N.1".".1N1" ml/hr"
IF P(8)'?.E1"@"1N.N
IF P(8)'?1"0."1N1" ml/hr"
SET ERR=1
WRITE !,"*** Your infusion rate is in an invalid format !"
+2 IF P(8)=""
IF P("TYP")="P"
IF 'ERR
SET ERR=2
WRITE !,"*** WARNING -- You have not specified an infusion rate. "
+3 IF '$$CODES1^PSIVUTL(P("TYP"),55.01,.04)!(P("TYP")="")
SET ERR=1
WRITE !,"*** Type of order is invalid !"
+4 IF '$$CODES1^PSIVUTL(P(17),55.01,100)!(P(17)="")
SET ERR=1
WRITE !,"*** Status of order is invalid !"
AH ;
+1 IF "HA"[P("TYP")
IF (P(11)]""!(P(9)]""))
WRITE !,$CHAR(7),"Order type is an admixture, hyperal, or continuous syringe, and you have",!,"a schedule and/or administration times defined!"
+2 IF $TEST
FOR Q=0:0
WRITE !,"Ok to delete these fields"
SET %=1
DO YN^DICN
DO NULSET
IF %
QUIT
+3 KILL %
IF P(6)=""
SET ERR=1
WRITE !,"*** You have not entered a physician!"
+4 IF P(6)]""
IF '$DATA(^VA(200,+P(6),"PS"))
SET ERR=1
WRITE !,"*** Physician entered does not exist or is not authorized to write",!,"medication orders"
+5 IF P(6)]""
IF $DATA(^VA(200,+P(6),"PS"))
IF (+$PIECE(^("PS"),U,4))
IF ($PIECE(^("PS"),U,4)'>DT)
SET ERR=1
WRITE !,"*** Physician entered is no longer active."
+6 DO ^PSIVCHK1
+7 QUIT
+8 ;
NULSET ;Delete admin/schedule fields for hyperals and/or admixtures
+1 IF '%
WRITE !!?2,"Enter 'YES' to delete the schedule and/or administration times fields from",!,"this order. Enter 'NO' (or '^') to leave the fields intact.",!
QUIT
+2 IF %=1
SET P(9)=""
SET P(11)=""
+3 QUIT
CKO SET P16=0
SET PSIVEXAM=1
SET PSIVCT=1
DO PSIVCHK
SET PSIVNOL=1
WRITE !
DO ^PSIVORLB
KILL PSIVEXAM
IF 'ERR
QUIT
+1 IF ERR=2
FOR J=0:0
WRITE !!,"Since there is a warning with this order.",!,"do you wish to re-edit this order"
SET %=1
DO YN^DICN
IF %
QUIT
WRITE !!,"Answer 'YES' to re-edit this order."
+2 IF ERR=2
IF %=1
SET PSIVOK="57^58^59^26^39^63^64^62^10^25^1"
DO ^PSIVORV2
DO GSTRING^PSIVORE1
DO GTFLDS^PSIVORFE
KILL DA,DIE,DR
GOTO CKO
+3 QUIT