- Timestamp:
- Dec 4, 2009, 12:11:15 AM (15 years ago)
- Location:
- WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW
- Files:
-
- 55 edited
Legend:
- Unmodified
- Added
- Removed
-
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGOE1.m
r613 r623 1 PSGOE1 ;BIR/CML3-ACTION ON INPATIENT ORDERS ;10 Mar 99 / 10:54 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**7,19,26,39,58,85,80,110,127,133,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 is supported by DBIA #2191. 5 ; Reference to ^PSDRUG( is supported by DBIA #2192. 6 ; Reference to EN1^ORCFLAG is supported by DBIA #3620. 7 ; Reference to AND^ORX8 is supported by DBIA #3632. 8 EN ; 9 K PSGDFLG,PSGPFLG S PSGOEA="^",PSGACT="",(PSGDI,PSGOENG,PSGPI,PSGRRF)=0 10 Q:'$G(DUZ) 11 D @$S(PSGORD["P":"NON",1:"ACT") 12 GO ; 13 K A,ND,PSGE,PSGR,ST,X,X1,X2,Y I $D(ORACTION) K PSGDI,PSGOENG,PSGPI Q 14 Q 15 ENACTION(PSGP,PSGORD) ; 16 ;Returns string identifying the actions allowed on this order. 17 D EN 18 Q PSGACT 19 DONE ; 20 I PSGORD["U"!(PSGORD["O") L -^PS(55,PSGP,5,+PSGORD) 21 E L -^PS(53.1,+PSGORD) 22 K C,PSGACT,PSGDFLG,PSGPFLG,PSGDI,PSGOENG,PSGPI,PSGRRF Q 23 B ; bypass 24 S PSGCANFL=1 25 Q 26 C ; copy an order (does NOT discontinue original order) 27 D ^PSGOD Q 28 D ; discontinue (or delete) an order 29 I PSGOEAV,'$D(PSGODF) D ENDS^PSGPO Q 30 D ENO^PSGOEC(PSGP,PSGORD) Q 31 E ; edit orders 32 D ^PSGOEE Q 33 F ; finish released orders 34 D ^PSGOEF Q 35 H(PSGP,PSGORD) ; hold 36 S X=$G(^PS(55,PSGP,5,+PSGORD,4)) I $P(X,U,12),$P(X,U,13) W $C(7),!!,"WARNING! THIS ORDER HAS BEEN MARKED FOR CANCELLATION." 37 I $P($G(^PS(55,PSGP,5,+PSGORD,0)),"^",9)="H" D ^PSGOEH0 Q 38 D ^PSGOEH1 Q 39 I ; mark (or unmark) a non-verified order as 'incomplete' 40 D ^PSGOEI Q 41 L ; display logs 42 D ^PSGOEL Q 43 N ; mark order as 'not to be given' 44 D ^PSGOENG Q 45 O ; Outpatient (discharge) med 46 W !!,"UNDER DEVELOPMENT, NOT CURRENTLY AVAILABLE." 47 Q 48 P ; print expanded view 49 D ^PSGVWP Q 50 R ; renew an order 51 I 'PSJSYSU,$D(^PS(55,PSGP,5,+PSGORD,4)),$P(^(4),"^",15),$P(^(4),"^",16) W !!,"THIS ORDER IS ALREADY MARKED FOR RENEWAL!" Q 52 I 'PSGRRF D ^PSGOER Q 53 D ^PSGOERI Q 54 S ; show the order again 55 D EN2^PSGVW Q 56 V ; verify an order 57 D EN^PSGOEV Q 58 ACT ; 59 S X=$G(^PS(55,PSGP,5,+PSGORD,0)),ND0=X,ND=$G(^(4)),ND2=$G(^(2)),PSGOENG=$P(X,"^",22),PSGR=$E("R",'PSGOENG),PSJCOM=$P($G(^PS(55,PSGP,5,+PSGORD,.2)),U,8) 60 I 'PSGOENG,PSJCOM S PSGR=$E("R",$$AND^ORX8(PSJCOM)) S:PSGR="R" PSGR=$E("R",$$RNEWOK^PSJUTL2(PSJCOM,PSGP)) 61 S PSGR=$E("R",'$$EXPIRED^PSGOER(PSGP,PSGORD)) S PSGR=$E("R",$P(ND0,"^",7)'="O") 62 I $P(ND2,U,4)'>PSGDT D OLD Q 63 S PSGE="E" I '$D(PSGOETOF) S (PSGDFLG,PSGDI)='$$DDOK^PSGOE2("^PS(55,"_PSGP_",5,"_+PSGORD_",1,",+$G(^PS(55,PSGP,5,+PSGORD,.2))),PSGPFLG='$$OIOK^PSGOE2(+$G(^PS(55,PSGP,5,+PSGORD,.2))) 64 S:$P(X,"^",26) (PSGE,PSGR)="" 65 I '$D(PSGOETOF) S PSGPI=$P(X,"^",2) I PSGPI S PSGPI=$P($G(^VA(200,PSGPI,"PS")),"^",4) S:PSGPI PSGPI=PSGPI'>DT 66 S ST=$P(X,"^",9)="H"*4 S:ST (PSGE,PSGR)="" 67 N CMPOK S CMPOK=1 I $$COMPLEX^PSJOE(PSGP,PSGORD) S CMPOK=+$P(^PS(55,PSGP,5,+PSGORD,.2),"^",8) 68 S PSGACT="D"_$S('$G(CMPOK):"",1:PSGE)_$S($P(ND,"^",18+ST)&'$P(ND,"^",19+ST)&'$P(ND,"^",PSJSYSU):"",1:"H")_"L"_$S(ST:"",1:PSGR) 69 I PSJSYSU,'$P(ND,"^",+PSJSYSU) S PSGACT=PSGACT_"V" 70 I +PSJSYSU=3,$L($T(EN1^ORCFLAG)) S PSGACT=PSGACT_"G" 71 Q 72 OLD ; 73 S A=$P(ND0,"^",9),PSGACT=$E("H",A="H")_"L" I A'["D",A'["E" Q 74 I 'PSGOENG,($D(^XUSEC("PSJU MGR",DUZ))!$D(^XUSEC("PSJ RPHARM",DUZ))) S PSGACT="LN" 75 I PSJSYSU,'$P(ND,"^",+PSJSYSU) S:(A'["D")&($G(PSGPRIO)'="DONE") PSGACT="D"_PSGACT S PSGACT=PSGACT_"V" Q 76 Q:PSGR=""!'PSJPCAF D NOW^%DTC S (PSGDT,X1)=+$E(%,1,12),X2=-4 D C^%DTC I $S('$P(ND2,"^",4):1,1:$P(ND2,"^",4)'>X) Q 77 I A="E",$G(PSJPRI)'="D" S PSGACT=PSGACT_PSGR Q 78 I PSJSYSU,$P(ND,"^",11) S PSGACT=PSGACT_PSGR,PSGRRF=1 79 Q 80 NON ; 81 N XND,DRGPT,XND2 82 S (X,XND)=$G(^PS(53.1,+PSGORD,0)) I $P(X,"^",19),$D(^PS(55,PSGP,5,$P(X,"^",19))) L -^PS(53.1,+PSGORD) S PSGORD=$P(X,"^",19)_"U" G ACT 83 I $S($P(X,"^",26):1,$P(X,"^",9)["D":1,1:$P(X,"^",9)["E") S:$P(X,U,9)="P"&($P(X,U,26)) PSGACT="D" S:(+PSJSYSU=3)&($L($T(EN1^ORCFLAG))) PSGACT=PSGACT_"G" Q 84 I PSGORD["U" S PSGACT="DE" S:(+PSJSYSU=3)&($L($T(EN1^ORCFLAG))) PSGACT=PSGACT_"G" Q 85 I '$D(PSGOETOF) S (PSGDFLG,PSGDI)='$$DDOK^PSGOE2("^PS(53.1,"_+PSGORD_",1,",+$G(^PS(53.1,+PSGORD,.2))),PSGPFLG='$$OIOK^PSGOE2(+$G(^PS(53.1,+PSGORD,.2))) 86 S DRG=$$STUFFDD^PSGOE2 S:DRG ^PS(53.1,+PSGORD,1,0)="^53.11P^1^1",^PS(53.1,+PSGORD,1,1,0)=DRG,^PS(53.1,+PSGORD,1,"B",DRG,1)="" 87 F DRG=0:0 S DRG=$O(^PS(53.1,+PSGORD,1,DRG)) Q:'DRG S DRGPT=^(DRG,0) S INACTDT=$G(^PSDRUG(+DRGPT,"I")) I INACTDT,(INACTDT'>DT) S PSGDFLG=1 88 I $P(XND,U,9)="P" S PSGACT=$S(+PSJSYSU=3:"BDEF",$G(PSJRNF):"BDEF",1:"") S:(+PSJSYSU=3)&($L($T(EN1^ORCFLAG))) PSGACT=PSGACT_"G" Q 89 I '$D(PSGOETOF) S PSGPI=$P(XND,"^",2) I PSGPI S PSGPI=$P($G(^VA(200,PSGPI,"PS")),"^",4) S:PSGPI PSGPI=PSGPI'>DT 90 S PSGACT="DEI" I PSJSYSU,'PSGPI,$P(XND,"^",9)'="I" S PSGACT=PSGACT_"V" 91 S XND2=$G(^PS(53.1,+PSGORD,.2)) I $P(XND2,"^",8),$P(XND,"^",9)="P" S PSGACT=$TR(PSGACT,"V") 92 I +PSJSYSU=3,$L($T(EN1^ORCFLAG)) S PSGACT=PSGACT_"G" 93 I $P($G(PSGRDTX),U,2)]"",'$P($G(^PS(53.1,+PSGORD,2.5)),"^",2) S $P(^PS(53.1,+PSGORD,2.5),U,2)=$P(PSGRDTX,U,2) 94 Q 95 ACTO ; 96 S PSGACTO="" I $G(PSGACT)]"" F X=1:1:$L(PSGACT) S PSGACTO=PSGACTO_$S($E(PSGACT,X)="D":"DC",1:$E(PSGACT,X))_" " 97 S:PSGACTO]"" PSGACTO=$E(PSGACTO,1,$L(PSGACTO)-1) Q 1 PSGOE1 ;BIR/CML3-ACTION ON INPATIENT ORDERS ;10 Mar 99 / 10:54 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**7,19,26,39,58,85,80,110,127,133**;16 DEC 97 3 ; 4 ; Reference to ^PS(55 is supported by DBIA #2191. 5 ; Reference to ^PSDRUG( is supported by DBIA #2192. 6 ; Reference to EN1^ORCFLAG is supported by DBIA #3620. 7 ; Reference to AND^ORX8 is supported by DBIA #3632. 8 EN ; 9 K PSGDFLG,PSGPFLG S PSGOEA="^",PSGACT="",(PSGDI,PSGOENG,PSGPI,PSGRRF)=0 10 Q:'$G(DUZ) 11 D @$S(PSGORD["P":"NON",1:"ACT") 12 GO ; 13 K A,ND,PSGE,PSGR,ST,X,X1,X2,Y I $D(ORACTION) K PSGDI,PSGOENG,PSGPI Q 14 ;W:$G(PSGPFLG) !!?3,"(THE ORDERABLE ITEM IS CURRENTLY LISTED AS INACTIVE.)" W:$G(PSGDFLG) !!?3,"(ONE OR ALL DISPENSE DRUGS ARE CURRENTLY LISTED AS INACTIVE OR DO NOT MATCH",!?3,"THE ORDERABLE ITEM FOR THIS ORDER.)" 15 ;I $G(PSGPFLG)!$G(PSGDFLG) K DIR S DIR(0)="E" D ^DIR K DIR 16 ;S PSGCANFL=0 ;F D ACTO W !!,"ACTION"_$S(PSGACTO]"":" ("_PSGACTO_")",1:"")_"? " R PSGOEA:DTIME W:'$T $C(7) S:'$T PSGOEA="^" Q:"^"[PSGOEA D CHK D:C @PSGOEA Q:PSGCANFL 17 Q 18 ENACTION(PSGP,PSGORD) ; 19 ;Returns string identifying the actions allowed on this order. 20 D EN 21 Q PSGACT 22 DONE ; 23 I PSGORD["U"!(PSGORD["O") L -^PS(55,PSGP,5,+PSGORD) 24 E L -^PS(53.1,+PSGORD) 25 K C,PSGACT,PSGDFLG,PSGPFLG,PSGDI,PSGOENG,PSGPI,PSGRRF Q 26 B ; bypass 27 S PSGCANFL=1 28 Q 29 C ; copy an order (does NOT discontinue original order) 30 D ^PSGOD Q 31 D ; discontinue (or delete) an order 32 I PSGOEAV,'$D(PSGODF) D ENDS^PSGPO Q 33 D ENO^PSGOEC(PSGP,PSGORD) Q 34 E ; edit orders 35 D ^PSGOEE Q 36 F ; finish released orders 37 D ^PSGOEF Q 38 H(PSGP,PSGORD) ; hold 39 S X=$G(^PS(55,PSGP,5,+PSGORD,4)) I $P(X,U,12),$P(X,U,13) W $C(7),!!,"WARNING! THIS ORDER HAS BEEN MARKED FOR CANCELLATION." 40 I $P($G(^PS(55,PSGP,5,+PSGORD,0)),"^",9)="H" D ^PSGOEH0 Q 41 D ^PSGOEH1 Q 42 I ; mark (or unmark) a non-verified order as 'incomplete' 43 D ^PSGOEI Q 44 L ; display logs 45 D ^PSGOEL Q 46 N ; mark order as 'not to be given' 47 D ^PSGOENG Q 48 O ; Outpatient (discharge) med 49 W !!,"UNDER DEVELOPMENT, NOT CURRENTLY AVAILABLE." 50 Q 51 P ; print expanded view 52 D ^PSGVWP Q 53 R ; renew an order 54 I 'PSJSYSU,$D(^PS(55,PSGP,5,+PSGORD,4)),$P(^(4),"^",15),$P(^(4),"^",16) W !!,"THIS ORDER IS ALREADY MARKED FOR RENEWAL!" Q 55 I 'PSGRRF D ^PSGOER Q 56 D ^PSGOERI Q 57 S ; show the order again 58 D EN2^PSGVW Q 59 V ; verify an order 60 D EN^PSGOEV Q 61 ACT ; 62 S X=$G(^PS(55,PSGP,5,+PSGORD,0)),ND0=X,ND=$G(^(4)),ND2=$G(^(2)),PSGOENG=$P(X,"^",22),PSGR=$E("R",'PSGOENG),PSJCOM=$P($G(^PS(55,PSGP,5,+PSGORD,.2)),U,8) 63 I 'PSGOENG,PSJCOM S PSGR=$E("R",$$AND^ORX8(PSJCOM)) S:PSGR="R" PSGR=$E("R",$$RNEWOK^PSJUTL2(PSJCOM,PSGP)) 64 S PSGR=$E("R",'$$EXPIRED^PSGOER(PSGP,PSGORD)) S PSGR=$E("R",$P(ND0,"^",7)'="O") 65 I $P(ND2,U,4)'>PSGDT D OLD Q 66 S PSGE="E" I '$D(PSGOETOF) S (PSGDFLG,PSGDI)='$$DDOK^PSGOE2("^PS(55,"_PSGP_",5,"_+PSGORD_",1,",+$G(^PS(55,PSGP,5,+PSGORD,.2))),PSGPFLG='$$OIOK^PSGOE2(+$G(^PS(55,PSGP,5,+PSGORD,.2))) 67 S:$P(X,"^",26) (PSGE,PSGR)="" 68 I '$D(PSGOETOF) S PSGPI=$P(X,"^",2) I PSGPI S PSGPI=$P($G(^VA(200,PSGPI,"PS")),"^",4) S:PSGPI PSGPI=PSGPI'>DT 69 S ST=$P(X,"^",9)="H"*4 S:ST (PSGE,PSGR)="" 70 ;S PSGACT="D"_$S(+$P(^PS(55,PSGP,5,+PSGORD,.2),"^",8):"",1:PSGE)_$S($P(ND,"^",18+ST)&'$P(ND,"^",19+ST)&'$P(ND,"^",PSJSYSU):"",1:"H")_"L"_$S(ST:"",1:PSGR) 71 N CMPOK S CMPOK=1 I $$COMPLEX^PSJOE(PSGP,PSGORD) S CMPOK=+$P(^PS(55,PSGP,5,+PSGORD,.2),"^",8) 72 S PSGACT="D"_$S('$G(CMPOK):"",1:PSGE)_$S($P(ND,"^",18+ST)&'$P(ND,"^",19+ST)&'$P(ND,"^",PSJSYSU):"",1:"H")_"L"_$S(ST:"",1:PSGR) 73 I PSJSYSU,'$P(ND,"^",+PSJSYSU) S PSGACT=PSGACT_"V" 74 I +PSJSYSU=3,$L($T(EN1^ORCFLAG)) S PSGACT=PSGACT_"G" 75 Q 76 OLD ; 77 S A=$P(ND0,"^",9),PSGACT=$E("H",A="H")_"L" I A'["D",A'["E" Q 78 I 'PSGOENG,($D(^XUSEC("PSJU MGR",DUZ))!$D(^XUSEC("PSJ RPHARM",DUZ))) S PSGACT="LN" 79 I PSJSYSU,'$P(ND,"^",+PSJSYSU) S:(A'["D")&($G(PSGPRIO)'="DONE") PSGACT="D"_PSGACT S PSGACT=PSGACT_"V" Q 80 Q:PSGR=""!'PSJPCAF D NOW^%DTC S (PSGDT,X1)=+$E(%,1,12),X2=-4 D C^%DTC I $S('$P(ND2,"^",4):1,1:$P(ND2,"^",4)'>X) Q 81 I A="E",$G(PSJPRI)'="D" S PSGACT=PSGACT_PSGR Q 82 I PSJSYSU,$P(ND,"^",11) S PSGACT=PSGACT_PSGR,PSGRRF=1 83 Q 84 NON ; 85 N XND,DRGPT,XND2 86 S (X,XND)=$G(^PS(53.1,+PSGORD,0)) I $P(X,"^",19),$D(^PS(55,PSGP,5,$P(X,"^",19))) L -^PS(53.1,+PSGORD) S PSGORD=$P(X,"^",19)_"U" G ACT 87 I $S($P(X,"^",26):1,$P(X,"^",9)["D":1,1:$P(X,"^",9)["E") S:$P(X,U,9)="P"&($P(X,U,26)) PSGACT="D" S:(+PSJSYSU=3)&($L($T(EN1^ORCFLAG))) PSGACT=PSGACT_"G" Q 88 I PSGORD["U" S PSGACT="DE" S:(+PSJSYSU=3)&($L($T(EN1^ORCFLAG))) PSGACT=PSGACT_"G" Q 89 I '$D(PSGOETOF) S (PSGDFLG,PSGDI)='$$DDOK^PSGOE2("^PS(53.1,"_+PSGORD_",1,",+$G(^PS(53.1,+PSGORD,.2))),PSGPFLG='$$OIOK^PSGOE2(+$G(^PS(53.1,+PSGORD,.2))) 90 S DRG=$$STUFFDD^PSGOE2 S:DRG ^PS(53.1,+PSGORD,1,0)="^53.11P^1^1",^PS(53.1,+PSGORD,1,1,0)=DRG,^PS(53.1,+PSGORD,1,"B",DRG,1)="" 91 F DRG=0:0 S DRG=$O(^PS(53.1,+PSGORD,1,DRG)) Q:'DRG S DRGPT=^(DRG,0) S INACTDT=$G(^PSDRUG(+DRGPT,"I")) I INACTDT,(INACTDT'>DT) S PSGDFLG=1 92 I $P(XND,U,9)="P" S PSGACT=$S(+PSJSYSU=3:"BDEF",$G(PSJRNF):"BDEF",1:"") S:(+PSJSYSU=3)&($L($T(EN1^ORCFLAG))) PSGACT=PSGACT_"G" Q 93 I '$D(PSGOETOF) S PSGPI=$P(XND,"^",2) I PSGPI S PSGPI=$P($G(^VA(200,PSGPI,"PS")),"^",4) S:PSGPI PSGPI=PSGPI'>DT 94 S PSGACT="DEI" I PSJSYSU,'PSGPI,$P(XND,"^",9)'="I" S PSGACT=PSGACT_"V" 95 ;* S PSGACT="DEI" I PSJSYSU,'PSGDI,'PSGPI,$P(X,"^",9)'="I" S PSGACT=PSGACT_"V" 96 S XND2=$G(^PS(53.1,+PSGORD,.2)) I $P(XND2,"^",8),$P(XND,"^",9)="P" S PSGACT=$TR(PSGACT,"V") 97 I +PSJSYSU=3,$L($T(EN1^ORCFLAG)) S PSGACT=PSGACT_"G" 98 I $P($G(PSGRDTX),U,2)]"",'$D(^PS(53.1,+PSGORD,2.5)) S $P(^PS(53.1,+PSGORD,2.5),U,2)=$P(PSGRDTX,U,2) 99 Q 100 ACTO ; 101 S PSGACTO="" I $G(PSGACT)]"" F X=1:1:$L(PSGACT) S PSGACTO=PSGACTO_$S($E(PSGACT,X)="D":"DC",1:$E(PSGACT,X))_" " 102 S:PSGACTO]"" PSGACTO=$E(PSGACTO,1,$L(PSGACTO)-1) Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGOE6.m
r613 r623 1 PSGOE6 ;BIR/CML3-ORDER ENTRY THROUGH OE/RR ;10 Mar 98 / 2:35 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**3,7,39,45,65,58,81,156,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(50.7 supported by DBIA #2180. 5 ; Reference to ^PS(51.1 is supported by DBIA #2177. 6 ; Reference to ^PS(51.2 is supported by DBIA #2178. 7 ; Reference to ^PS(55 is supported by DBIA #2191. 8 ; Reference to ^DD(53.1 is supported by DBIA #2256. 9 ; Reference to ^VA(200 is supported by DBIA #10060. 10 ; Reference to ^DICN is supported by DBIA #10009. 11 ; 12 K PSGFOK S F1=53.1,PSGPR=$S($D(PSGOERR):PSJORPV,1:PSGOEPR),PSGMR=$S($P(PSGNEDFD,"^",2):$P(PSGNEDFD,"^",2),1:PSGOEDMR),PSGSCH=$P(PSGNEDFD,"^",4),(PSGOROE1,PSGSI,SDT,PSGMRN,PSGSM,PSGHSM,PSGUD,PSGSD,PSGFD,PSGSI,PSGNEFD,PSGNESD)="" 13 S:PSGMR PSGMRN=$S('$P(PSGNEDFD,"^",2):"ORAL",'$D(^PS(51.2,PSGMR,0)):PSGMR,$P(^(0),"^")]"":$P(^(0),"^"),1:PSGMR) I PSGPR S PSGPRN=$P($G(^VA(200,PSGPR,0)),"^") S:PSGPRN="" PSGPRN=PSGPR 14 S PSGST=$S($P(PSGNEDFD,"^",3)]"":$P(PSGNEDFD,"^",3),1:"C") 15 ; Naked references in line below refer to ^PS(53.45,PSJSYSP 16 K ^PS(53.45,PSJSYSP,1),^(2) I PSGDRG S ^(2,0)="^53.4502P^"_PSGDRG_"^1",^(1,0)=PSGDRG,^PS(53.45,PSJSYSP,2,"B",PSGDRG,1)="" 17 ; 18 109 ; dosage ordered 19 W !,"DOSAGE ORDERED: ",$S(PSGDO]"":PSGDO_"// ",1:"") R X:DTIME I X="^"!'$T W:'$T $C(7) S PSGOROE1=1 G DONE 20 I X="" S X=PSGDO I X="" W $C(7)," (Required)" G 109 21 S PSGF2=109 I X="@" W $C(7)," (Required)" G 109 22 I X?1."?" S F1=53.1 D ENHLP^PSGOEM(53.1,109) G 109 23 I $E(X)="^" D FF G:Y>0 @Y G 109 24 I $E(X,$L(X))=" " F S X=$E(X,1,$L(X)-1) Q:$E(X,$L(X))'=" " 25 I $S(X?.E1C.E:1,$L(X)>20:1,X="":1,X["^":1,X?1.P:1,1:X=+X) W $C(7)," ",$S(X?1.P!(X=""):"(Required)",1:"??") S X="?" D ENHLP^PSGOEM(53.1,109) G 109 26 S PSGDO=X,PSGFOK(109)="" 27 ; 28 3 ; med route 29 W !,"MED ROUTE: ",$S(PSGMR:PSGMRN_"// ",1:"") R X:DTIME I X="^"!'$T W:'$T $C(7) S PSGOROE1=1 G DONE 30 I X="",PSGMR S X=PSGMRN I PSGMR'=PSGMRN,$D(^PS(51.2,PSGMR,0)) W " "_$P(^(0),"^",3) S PSGFOK(3)="" G 26 31 S PSGF2=3 I $S(X="@":1,X]"":0,1:'PSGMR) W $C(7)," (Required)" S X="?" D ENHLP^PSGOEM(53.1,3) G 3 32 I X?1."?" D ENHLP^PSGOEM(53.1,3) 33 I $E(X)="^" D FF G:Y>0 @Y G 3 34 K DIC S DIC="^PS(51.2,",DIC(0)="EMQZ",DIC("S")="I $P(^(0),""^"",4)" D ^DIC K DIC I Y'>0 G 3 35 S PSGMR=+Y,PSGMRN=Y(0,0),PSGFOK(3)="" 36 ; 37 26 ; schedule 38 W !,"SCHEDULE: ",$S(PSGSCH]"":PSGSCH_"// ",1:"") R X:DTIME I X="^"!'$T W:'$T $C(7) S PSGOROE1=1 G DONE 39 S:X="" X=PSGSCH S PSGF2=26 ; I "@"[X W $C(7)," (Required)" S X="?" D ENHLP^PSGOEM(53.1,26) G 26 40 I X?1."?" D ENHLP^PSGOEM(53.1,26) G 26 41 I $E(X)="^" D FF G:Y>0 @Y G 26 42 I X="" S (PSGS0XT,PSGS0Y,PSGST)="" 43 E D EN^PSGS0 I '$D(X) W $C(7)," ??" S X="?" D ENHLP^PSGOEM(53.1,26) G 26 44 S PSGSCH=X,(PSGFOK(26),PSGST)="",PSGOES=1 S:PSGS0XT="O" $P(PSGNEDFD,"^",3)="O",PSGST="O" D ^PSGNE3 K PSGOES 45 ; 46 66 ; provider's comments 47 ; 48 ; 49 DONE ; 50 I PSGOROE1 K Y W $C(7)," ...order not entered..." 51 K F,F0,F1,PSGF2,F3,PSGFOK,SDT Q 52 ; 53 FF ; up-arrow to another field 54 S Y=-1 I '$D(PSGFOK) W $C(7)," ??" Q 55 S X=$E(X,2,99) I X=+X S Y=$S($D(PSGFOK(X)):X,1:-1) W " " W:Y>0 $$CODES2^PSIVUTL(53.1,X) W:Y'>0 $C(7),"??" Q 56 K DIC S DIC="^DD(53.1,",DIC(0)="QEM",DIC("S")="I $D(PSGFOK(+Y))" D ^DIC K DIC S Y=+Y 57 Q 58 ; 59 DEL ; 60 W !?3,"SURE YOU WANT TO DELETE" S %=0 D YN^DICN I %'=1 W " <NOTHING DELETED>" 61 Q 62 ; 63 GTST(ON) ; Find schedule type for pending order. 64 N PD,PDAP,ST,X,ST1 S ST="" 65 S ST=$P($G(^PS(53.1,+ON,0)),"^",7) 66 I $P($G(^PS(53.1,+ON,0)),U,24)="R" D 67 .; naked ref below is from line above, ^PS(53.1,ON,0) 68 .S X=$P(^(0),U,25) S ST=$S(X["N"!(X["P"):$P($G(^PS(53.1,+X,0)),U,7),X["V":"C",1:$P($G(^PS(55,PSGP,5,+X,0)),U,7)) 69 .I ST]"" S (PSGOST,PSGST)=ST,PSGSTN=$$ENSTN^PSGMI(ST) Q 70 I ST'="" D 71 . S ST1="" 72 . S PD=+$G(^PS(53.1,+ON,.2)) S X=$G(^PS(50.7,PD,0)),ST1=$P(X,U,7) 73 . I $G(ST1)="R" S ST="R" 74 . K ST1 75 I ST="" D 76 . ;PSJ*5*156 - Don't allow backdoor to override intended schedule type from CPRS unless the default 77 . ; schedule type (if any) is "Fill on Request". 78 . S PD=+$G(^PS(53.1,+ON,.2)) S X=$G(^PS(50.7,PD,0)),ST=$P(X,U,7) ;see if there is a default schedule type. 79 . I ST="R" Q ;Fill on Request default schedule type will override incoming schedule type from CPRS 80 . S ST="" ;Reset to null in case default schedule type other than Fill on Request is defined. 81 . D OTS I ST="O" Q 82 . I PSGSCH="ON CALL"!(PSGSCH="ONCALL")!(PSGSCH="ON-CALL") S ST="OC" Q 83 . I PSGSCH["PRN" S ST="P" Q 84 . S ST="C" 85 S (PSGOST,PSGST)=ST,PSGSTN=$$ENSTN^PSGMI(ST) 86 Q 87 OTS I PSGSCH]"" S X=+$O(^PS(51.1,"B",PSGSCH,0)) I $P($G(^PS(51.1,X,0)),"^",5)="O" S ST="O" Q 88 I PSGSCH="TODAY"!(PSGSCH="NOW")!(PSGSCH="STAT")!(PSGSCH="ONCE")!(PSGSCH="ONE TIME")!(PSGSCH="ONE-TIME")!(PSGSCH="ONETIME")!(PSGSCH="1TIME")!(PSGSCH="1 TIME")!(PSGSCH="1-TIME") S ST="O" 89 Q 1 PSGOE6 ;BIR/CML3-ORDER ENTRY THROUGH OE/RR ;10 Mar 98 / 2:35 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**3,7,39,45,65,58,81,156**;16 DEC 97 3 ; 4 ; Reference to ^PS(50.7 supported by DBIA #2180. 5 ; Reference to ^PS(51.1 is supported by DBIA #2177. 6 ; Reference to ^PS(51.2 is supported by DBIA #2178. 7 ; Reference to ^PS(55 is supported by DBIA #2191. 8 ; Reference to ^DD(53.1 is supported by DBIA #2256. 9 ; Reference to ^VA(200 is supported by DBIA #10060. 10 ; Reference to ^DICN is supported by DBIA #10009. 11 ; 12 K PSGFOK S F1=53.1,PSGPR=$S($D(PSGOERR):PSJORPV,1:PSGOEPR),PSGMR=$S($P(PSGNEDFD,"^",2):$P(PSGNEDFD,"^",2),1:PSGOEDMR),PSGSCH=$P(PSGNEDFD,"^",4),(PSGOROE1,PSGSI,SDT,PSGMRN,PSGSM,PSGHSM,PSGUD,PSGSD,PSGFD,PSGSI,PSGNEFD,PSGNESD)="" 13 S:PSGMR PSGMRN=$S('$P(PSGNEDFD,"^",2):"ORAL",'$D(^PS(51.2,PSGMR,0)):PSGMR,$P(^(0),"^")]"":$P(^(0),"^"),1:PSGMR) I PSGPR S PSGPRN=$P($G(^VA(200,PSGPR,0)),"^") S:PSGPRN="" PSGPRN=PSGPR 14 S PSGST=$S($P(PSGNEDFD,"^",3)]"":$P(PSGNEDFD,"^",3),1:"C") 15 K ^PS(53.45,PSJSYSP,1),^(2) I PSGDRG S ^(2,0)="^53.4502P^"_PSGDRG_"^1",^(1,0)=PSGDRG,^PS(53.45,PSJSYSP,2,"B",PSGDRG,1)="" 16 ; 17 109 ; dosage ordered 18 W !,"DOSAGE ORDERED: ",$S(PSGDO]"":PSGDO_"// ",1:"") R X:DTIME I X="^"!'$T W:'$T $C(7) S PSGOROE1=1 G DONE 19 I X="" S X=PSGDO I X="" W $C(7)," (Required)" G 109 20 S PSGF2=109 I X="@" W $C(7)," (Required)" G 109 21 I X?1."?" S F1=53.1 D ENHLP^PSGOEM(53.1,109) G 109 22 I $E(X)="^" D FF G:Y>0 @Y G 109 23 I $E(X,$L(X))=" " F S X=$E(X,1,$L(X)-1) Q:$E(X,$L(X))'=" " 24 I $S(X?.E1C.E:1,$L(X)>20:1,X="":1,X["^":1,X?1.P:1,1:X=+X) W $C(7)," ",$S(X?1.P!(X=""):"(Required)",1:"??") S X="?" D ENHLP^PSGOEM(53.1,109) G 109 25 S PSGDO=X,PSGFOK(109)="" 26 ; 27 3 ; med route 28 W !,"MED ROUTE: ",$S(PSGMR:PSGMRN_"// ",1:"") R X:DTIME I X="^"!'$T W:'$T $C(7) S PSGOROE1=1 G DONE 29 I X="",PSGMR S X=PSGMRN I PSGMR'=PSGMRN,$D(^PS(51.2,PSGMR,0)) W " "_$P(^(0),"^",3) S PSGFOK(3)="" G 26 30 S PSGF2=3 I $S(X="@":1,X]"":0,1:'PSGMR) W $C(7)," (Required)" S X="?" D ENHLP^PSGOEM(53.1,3) G 3 31 I X?1."?" D ENHLP^PSGOEM(53.1,3) 32 I $E(X)="^" D FF G:Y>0 @Y G 3 33 K DIC S DIC="^PS(51.2,",DIC(0)="EMQZ",DIC("S")="I $P(^(0),""^"",4)" D ^DIC K DIC I Y'>0 G 3 34 S PSGMR=+Y,PSGMRN=Y(0,0),PSGFOK(3)="" 35 ; 36 26 ; schedule 37 W !,"SCHEDULE: ",$S(PSGSCH]"":PSGSCH_"// ",1:"") R X:DTIME I X="^"!'$T W:'$T $C(7) S PSGOROE1=1 G DONE 38 S:X="" X=PSGSCH S PSGF2=26 ; I "@"[X W $C(7)," (Required)" S X="?" D ENHLP^PSGOEM(53.1,26) G 26 39 I X?1."?" D ENHLP^PSGOEM(53.1,26) G 26 40 I $E(X)="^" D FF G:Y>0 @Y G 26 41 I X="" S (PSGS0XT,PSGS0Y,PSGST)="" 42 E D EN^PSGS0 I '$D(X) W $C(7)," ??" S X="?" D ENHLP^PSGOEM(53.1,26) G 26 43 S PSGSCH=X,(PSGFOK(26),PSGST)="",PSGOES=1 S:PSGS0XT="O" $P(PSGNEDFD,"^",3)="O",PSGST="O" D ^PSGNE3 K PSGOES 44 ; 45 66 ; provider's comments 46 ;S DA=PSJSYSP,DIE="^PS(53.45,",DR=4 D ^DIE K DA,DIE,DR 47 ;S PSGFOK(66)="",Y=1 48 ; 49 ; 50 DONE ; 51 I PSGOROE1 K Y W $C(7)," ...order not entered..." 52 K F,F0,F1,PSGF2,F3,PSGFOK,SDT Q 53 ; 54 FF ; up-arrow to another field 55 S Y=-1 I '$D(PSGFOK) W $C(7)," ??" Q 56 S X=$E(X,2,99) I X=+X S Y=$S($D(PSGFOK(X)):X,1:-1) W " " W:Y>0 $$CODES2^PSIVUTL(53.1,X) W:Y'>0 $C(7),"??" Q 57 K DIC S DIC="^DD(53.1,",DIC(0)="QEM",DIC("S")="I $D(PSGFOK(+Y))" D ^DIC K DIC S Y=+Y 58 Q 59 ; 60 DEL ; 61 W !?3,"SURE YOU WANT TO DELETE" S %=0 D YN^DICN I %'=1 W " <NOTHING DELETED>" 62 Q 63 ; 64 GTST(ON) ; Find schedule type for pending order. 65 N PD,PDAP,ST,X S ST="" I $P($G(^PS(53.1,+ON,0)),U,24)="R" D 66 .; naked ref below is from line above, ^PS(53.1,ON,0) 67 .S X=$P(^(0),U,25) S ST=$S(X["N"!(X["P"):$P($G(^PS(53.1,+X,0)),U,7),X["V":"C",1:$P($G(^PS(55,PSGP,5,+X,0)),U,7)) 68 .I ST]"" S (PSGOST,PSGST)=ST,PSGSTN=$$ENSTN^PSGMI(ST) Q 69 I ST="" D 70 . ;PSJ*5*156 - Don't allow backdoor to override intended schedule type from CPRS unless the default 71 . ; schedule type (if any) is "Fill on Request". 72 . S PD=+$G(^PS(53.1,+ON,.2)) S X=$G(^PS(50.7,PD,0)),ST=$P(X,U,7) ;see if there is a default schedule type. 73 . I ST="R" Q ;Fill on Request default schedule type will override incoming schedule type from CPRS 74 . S ST="" ;Reset to null in case default schedule type other than Fill on Request is defined. 75 . D OTS I ST="O" Q 76 . I PSGSCH="ON CALL"!(PSGSCH="ONCALL")!(PSGSCH="ON-CALL") S ST="OC" Q 77 . I PSGSCH["PRN" S ST="P" Q 78 . S ST="C" 79 S (PSGOST,PSGST)=ST,PSGSTN=$$ENSTN^PSGMI(ST) 80 Q 81 OTS I PSGSCH]"" S X=+$O(^PS(51.1,"B",PSGSCH,0)) I $P($G(^PS(51.1,X,0)),"^",5)="O" S ST="O" Q 82 I PSGSCH="TODAY"!(PSGSCH="NOW")!(PSGSCH="STAT")!(PSGSCH="ONCE")!(PSGSCH="ONE TIME")!(PSGSCH="ONE-TIME")!(PSGSCH="ONETIME")!(PSGSCH="1TIME")!(PSGSCH="1 TIME")!(PSGSCH="1-TIME") S ST="O" 83 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGOEC.m
r613 r623 1 PSGOEC ;BIR/CML3-CANCEL ORDERS ;02 Mar 99 / 9:29 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**23,58,110,175,201,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to ^PSSLOCK is supported by DBIA 2789. 6 ; 7 ENA ; all orders 8 D ENCV^PSGSETU Q:$D(XQUIT) S CF=$P(PSJSYSP0,U,5) N ND,ND1 S ND="$D(^PS(55,PSGP,5,PSGDA,4)),$P(^(4),U,12),$P(^(4),U,13)",ND1="$D(^PS(53.1,PSGDA,4)),$P(^(4),U,12),$P(^(4),U,13)" 9 F W !!,"Do you want to ",$S(CF:"discontinue",1:"mark for discontinuation")," all of this patient's orders" S %=1 D YN^DICN Q:% D ENCAM^PSGOEM 10 S PSGCF=0 Q:%<0 S PSGCF=1,T=$E("T",'PSJSYSU) G:%=1 ENCA F T=0:0 S T=$O(^PS(55,PSGP,5,"AUS",T)) Q:'T F PSGDA=0:0 S PSGDA=$O(^PS(55,PSGP,5,"AUS",T,PSGDA)) Q:'PSGDA I @ND Q 11 E F PSGDA=0:0 S PSGDA=$O(^PS(53.1,"AC",PSGP,PSGDA)) Q:'PSGDA I @ND1 Q 12 E G DONE 13 W !!,"SOME OR ALL OF THESE ORDERS HAVE" D ENUMK^PSGOEM Q:%'=1 14 W !!,"...a few moments, please..." S PSGAL("C")=PSJSYSU*10+21400 15 F T=PSGDT:0 S T=$O(^PS(55,PSGP,5,"AUS",T)) Q:'T F PSGDA=0:0 S PSGDA=$O(^PS(55,PSGP,5,"AUS",T,PSGDA)) Q:'PSGDA I @ND W "." D RS,^PSGAL5 16 F PSGDA=0:0 S PSGDA=$O(^PS(53.1,"AC",PSGP,PSGDA)) Q:'PSGDA I @ND1 W "." D RS 17 W " . . . DONE!" G DONE 18 ENCA ; 19 D NOW^%DTC S (Q1,PSGDT)=+$E(%,1,12) F S Q1=$O(^PS(55,PSGP,5,"AUS",Q1)) Q:'Q1 F Q2=0:0 S Q2=$O(^PS(55,PSGP,5,"AUS",Q1,Q2)) Q:'Q2 I $P($G(^PS(55,PSGP,5,Q2,0)),"^",21) Q 20 E F Q2=0:0 S Q2=$O(^PS(53.1,"AC",PSGP,Q2)) Q:'Q2 I $P($G(^PS(53.1,Q2,0)),U,21) Q 21 I S PSJNOO=$$ENNOO^PSJUTL5("D") I PSJNOO<0!('$$REQPROV) D G DONE 22 .W !!,$C(7),"No changes made to this order." D PAUSE^VALM1 23 S PSGALR=$S('$D(PSGALO):20,PSGALO?4N&($E(PSGALO)=1):10,1:20) I $P(PSJSYSP0,U,5) D ENHE^PSJADT0 S PSGOP=PSGP D ASET 24 F SD=PSGDT:0 S SD=$O(^PS(55,PSGP,5,"AUS",SD)) Q:'SD F PSGORD=0:0 S PSGORD=$O(^PS(55,PSGP,5,"AUS",SD,PSGORD)) Q:'PSGORD S PSGORD=+PSGORD_"A" D AC 25 D NSET S CF=$P(PSJSYSP0,U,5) F PSGORD=0:0 S PSGORD=$O(^PS(53.1,"AC",PSGP,PSGORD)) Q:'PSGORD S PSGORD=+PSGORD_"N" D NC 26 W " . . . DONE!" K PSGORD G DONE 27 ENO(PSGP,PSGORD) ; single order 28 I PSGSTAT="D" W !,"This order has already been DISCONTINUED." D PAUSE^VALM1 Q 29 S CF=$S($P(PSJSYSP0,U,5):1,PSGORD["U":0,1:($P($G(^PS(53.1,+PSGORD,0)),U,25)=""&($P($G(^(4)),U,7)=DUZ))) 30 S PSJCOM=+$S(PSGORD["U":$P($G(^PS(55,PSGP,5,+PSGORD,.2)),"^",8),1:$P($G(^PS(53.1,+PSGORD,.2)),"^",8)) 31 I 'CF,PSJCOM W !!,"This order is part of a complex order and CANNOT be marked for discontinuation." Q 32 I $$PNDRNOK(PSGORD) N PSJDCTYP S PSJDCTYP=$$PNDRNA(PSGORD) D:(PSJDCTYP=1!(PSJDCTYP=2)) PNDRN($G(PSJDCTYP),PSGORD) G DONE 33 I PSJCOM W !!,"This order is part of a complex order. If you discontinue this order the",!,"following orders will be discontinued too (unless the stop date has already",!,"been reached)." D CMPLX^PSJCOM1(PSGP,PSJCOM,PSGORD) 34 F W !!,"Do you want to ",$S(PSJCOM:"discontinue this series of complex orders",CF:"discontinue this order",1:"mark this order for discontinuation") S %=1 D YN^DICN Q:% D ENCOM^PSGOEM 35 I %<0 S VALMBCK="" Q 36 G:%=1 SOC I $S(PSGORD["U":$D(^PS(55,PSGP,5,+PSGORD,4)),1:$D(^PS(53.1,+PSGORD,4))),$P(^(4),U,12) W !!,"THIS ORDER HAS" 37 I D ENUMK^PSGOEM I %=1 W "..." K DA S:PSGORD["A" PSGAL("C")=PSJSYSU*10+21400,DA=+PSGORD,DA(1)=PSGP D RS,^PSGAL5:PSGORD["A" W " . . . DONE!" 38 G DONE 39 SOC ; 40 I 'CF,'$P($S(PSGORD["U":$G(^PS(55,PSGP,5,+PSGORD,0)),1:$G(^PS(53.1,+PSGORD,0))),U,21) W !!,"...one moment, please..." 41 E I CF,'($G(PSJDCTYP)=2) S PSJNOO=$$ENNOO^PSJUTL5("D") I PSJNOO<0 D ABORT^PSGOEE G DONE 42 ; prompt for requesting provider 43 I '($G(PSJDCTYP)=2) I CF,'$$REQPROV D ABORT^PSGOEE G DONE 44 K DA D NOW^%DTC S PSGDT=%,T=$E("T",'PSJSYSU),PSGALR=20,DA=+PSGORD,DA(1)=PSGP 45 I 'PSJCOM D 46 .I PSGORD["U" D ASET:CF,AC 47 .I PSGORD'["U" D NSET:CF,NC 48 I PSJCOM N COMFLG S COMFLG=0 D 49 . I PSGORD["P" Q:('$$LOCK^PSJOEA(PSGP,PSJCOM)) D 50 .. N O S O="" F S O=$O(^PS(53.1,"ACX",PSJCOM,O)) Q:O="" S (PSGORD,PSJORD)=O_"P" D NSET,NC 51 .I PSGORD["U" N O,OO S O=0,OO="" F S O=$O(^PS(55,"ACX",PSJCOM,O)) Q:'O F S OO=$O(^PS(55,"ACX",PSJCOM,O,OO)) Q:OO="" Q:COMFLG D 52 .. Q:OO=PSGORD I '$$LS^PSSLOCK(DFN,OO) S COMFLG=1 Q 53 I PSJCOM Q:COMFLG N O,OO S O=0,OO="" F S O=$O(^PS(55,"ACX",PSJCOM,O)) Q:'O F S OO=$O(^PS(55,"ACX",PSJCOM,O,OO)) Q:OO="" D 54 . I OO["V" S ON55=OO D D1^PSIVOPT2 S PSIVALT=1,PSIVALCK="STOP",PSIVREA="D",ON=ON55,P(3)=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,3) D 55 .. D LOG^PSIVORAL N PSJORD S PSJORD=ON55,P(3)=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,3),P("NAT")=PSJNOO D HL^PSIVORA 56 . I OO["U" N PSGORD,PSJORD S (PSGORD,PSJORD)=OO D ASET^PSGOEC,AC^PSGOEC 57 Q 58 D1 N %,DA,DIE,DIU,STP,NSTOP 59 D NOW^%DTC S NSTOP=+$E(%,1,12),STP=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,3),NSTOP=+$S(STP>NSTOP:NSTOP,1:STP),P(17)="D" 60 S DA(1)=DFN,DA=+ON55,DIE="^PS(55,"_DFN_",""IV"",",DR="109////"_NSTOP_$S('$P($G(^PS(55,DFN,"IV",+ON55,2)),U,7):";116////"_STP,1:"")_";100///D;.03////"_NSTOP,PSIVACT=1 D ^DIE 61 I $S($G(PSIVAC)="OD":0,$G(PSIVAC)'="AD":1,$G(PSGALO)<1060:0,1:$P($G(PSJSYSW0),U,15)) S X=$S($G(PSIVAC)="AD":1,1:2) D ENLBL^PSIVOPT(X,$S(X=1:+$G(PSGUOW),1:DUZ),DFN,3,+ON55,$E("AD",1,3-X)) 62 D:'$D(PSJIVORF) ORPARM^PSIVOREN Q:'PSJIVORF ;* S ORIFN=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,21) Q:'ORIFN 63 Q 64 OUT ; 65 W $S(PSJCOM:"...ORDER ",1:"...ORDERS "),$S(CF:"DISCONTINUED!",1:"MARKED!") S PSGCANFL=1 66 DONE ; 67 K CF,DA,DIE,DP,DR,ORIFN,ORETURN,PSGAL,PSGALR,PSGDA,SD,ST,T,UCF,Y,PSJDCTYP Q 68 ASET ; 69 S DIE="^PS(55,"_PSGP_",5,",DR="28////"_$S($P($G(^PS(55,PSGP,5,+$G(PSJORD),0)),U,27)="E":"DE",$D(PSGEDIT):"DE",1:"D")_";Q;34////"_PSGDT_$S(T]"":";49////1",1:"") 70 Q 71 NSET ; 72 S DIE="^PS(53.1,",DR="28////"_$S($P($G(^PS(53.1,+$G(PSJORD),0)),U,27)="E":"DE",$D(PSGEDIT):"DE",1:"D")_$S(T]"":";42////1",1:"")_";25////"_PSGDT Q 73 AC ; 74 I 'CF K DA S $P(^PS(55,PSGP,5,+PSGORD,4),U,11,14)="^1^"_DUZ_U_PSGDT,PSGAL("C")=13040,DA=+PSGORD,DA(1)=PSGP D ^PSGAL5 75 I 'CF,$D(PSJSYSO) S PSGORD=+PSGORD_"A",PSGPOSA="C",PSGPOSD=PSGDT D ENPOS^PSGVDS 76 Q:'CF K DA,ORIFN S PSGAL("C")=PSJSYSU*10+4000,DA=+PSGORD,DA(1)=PSGP D ^PSGAL5 S $P(^(2),U,3)=$P(^PS(55,PSGP,5,+PSGORD,2),U,4) D ^DIE S ^PS(55,"AUE",PSGP,+PSGORD)="" 77 I PSJSYSL K DA S $P(^PS(55,PSGP,5,+PSGORD,7),U,1,2)=PSGDT_U_$S($D(PSGEDIT):"DE",1:"D"),PSGTOL=2,PSGUOW=DUZ,PSGTOO=1,DA=+PSGORD,DA(1)=PSGP D ENL^PSGVDS 78 S ORIFN=$P($G(^PS(55,PSGP,5,+PSGORD,0)),U,21) D:ORIFN DCOR^PSGOECS 79 Q 80 NC ; 81 I 'CF S $P(^PS(53.1,+PSGORD,4),"^",11,14)="^1^"_DUZ_U_PSGDT 82 I 'CF,$D(PSJSYSO) S PSGORD=+PSGORD_"N",PSGPOSA="C",PSGPOSD=PSGDT D ENPOS^PSGVDS 83 Q:'CF S PSGSTAT=$P($G(^PS(53.1,+PSGORD,0)),U,9),PSGORIFN=$P($G(^(0)),U,21) 84 I PSGSTAT'="U" K DA,ORIFN S DA=+PSGORD D ^DIE I PSJSYSL,PSJSYSL<3,(PSGSTAT'="P") S $P(^PS(53.1,+PSGORD,7),U,1,2)=PSGDT_U_$S($D(PSGEDIT):"DE",1:"D"),PSGTOO=2,PSGUOW=DUZ,PSGTOL=2 D ENL^PSGVDS 85 I PSGSTAT="U" K DA S DA=+PSGORD,DIK="^PS(53.1," D ^DIK 86 I PSGORIFN S ORIFN=PSGORIFN D DCOR^PSGOECS 87 Q 88 T ; 89 F W !!,"Is this due to the patient being transferred" S %=2 D YN^DICN Q:% D ENCTM^PSGOEM1 90 S T=$S(%<0:"^",1:$E("T",%=1)) Q 91 RS ; 92 ; naked ref below is from variable ND1, ^PS(53.1,PSGDA,4) 93 S $P(^(4),U,11,14)="^^^" Q 94 REQPROV() ; 95 I $G(PSJDCTYP)=2 Q 1 96 K PSJDCPRV,DIC,DUOUT,DTOUT,Y 97 N PROVIDER,PROVNAME,RESULT,RSB S RESULT=0 98 S PROVIDER=+$P($G(^PS(55,DFN,5.1)),"^",2),PROVNAME="" 99 I PROVIDER>0 D 100 .S DIC=200,DR="53.1;53.4",DIQ="RSB",DIQ(0)="I",DA=PROVIDER D EN^DIQ1 101 .K DIC,DR,DA,DIQ 102 .I $G(RSB(200,PROVIDER,53.1,"I"))="1"&(($G(RSB(200,PROVIDER,53.4,"I"))="")!($G(RSB(200,PROVIDER,53.4,"I"))>DT)) D 103 ..S DIC=200,DA=PROVIDER,DR=".01",DIQ="RSB",DIQ(0)="E" D EN^DIQ1 104 ..S PROVNAME=$G(RSB(200,PROVIDER,.01,"E")) K DA,DIQ,DR 105 K DIC S DIC=200,DIC(0)="AEMQZ" 106 S:PROVNAME]"" DIC("B")=PROVNAME 107 S DIC("A")="Requesting PROVIDER: " 108 S DIC("S")="I $D(^(""PS"")),^(""PS""),$S('$P(^(""PS""),""^"",4):1,1:$P(^(""PS""),""^"",4)>DT)" D ^DIC K DIC 109 I +Y>0,'$D(DUOUT),'$D(DTOUT) S RESULT=1,PSJDCPRV=+Y 110 Q RESULT 111 ; 112 PNDRNA(ORDER) ; Ask Discontinue Pending Renewal only, or both Pending Renew and Renewed Order 113 ; Perform this action only for pending renewals 114 I '$G(ORDER)!'($G(ORDER)["P") Q 3 115 ; Quit if original order is no longer active 116 N ORIGORD,ORIGSTOP S ORIGORD=$P($G(^PS(53.1,+ORDER,0)),"^",25) Q:'ORIGORD D I ORIGSTOP<$G(PSGDT) Q 1 117 .S ORIGSTOP=$S(ORIGORD["U":$P($G(^PS(55,PSGP,5,+ORIGORD,2)),"^",4),ORIGORD["V":$P($G(^PS(55,PSGP,"IV",+ORIGORD,0)),"^",3),1:"") 118 N NDP2 119 S NDP2=^PS(53.1,+ORDER,.2) S DRG=NDP2,DO=$P(DRG,"^",2) S DRG=$$ENPDN^PSGMI($P(DRG,"^")) 120 S ND2=^PS(53.1,+ORDER,2) S SCH=$P(ND2,"^"),START=$P(ND2,"^",2),START=$$FMTE^XLFDT(START,2) 121 W !!?5,DRG_" "_DO 122 W !?5,"This order has a pending status. If this pending order" 123 W !?5,"is discontinued, the original order may still be active." 124 S DIR("A")="Select order(s) to discontinue" 125 S DIR(0)="S^1:DC BOTH Orders;2:DC Pending Order;3:Cancel - No Action Taken" 126 S DIR("L",1)="1 - DC BOTH Orders" 127 S DIR("L",2)="2 - DC Pending Order" 128 S DIR("L",3)="3 - Cancel - No Action Taken" D ^DIR 129 ; Reverse order - Y=1 - Pending only Y=2:BOTH 130 S Y=$S(Y=1:2,Y=2:1,1:3) 131 Q Y 132 ; 133 PNDRN(PSJDCTYP,ORDER) ; Perform Discontinue action for Pending order only or both Pending and Renewed 134 ; Perform this action only for pending renewals 135 N PSGORD S PSGORD=ORDER 136 Q:'$G(PSGORD)!'($G(PSGORD)["P") 137 I PSJDCTYP=1 G SOC 138 I PSJDCTYP=2 S PSJDCTYP=1 D SOC Q:'$G(PSJDCTYP) D 139 .I ($G(PSJNOO)<0) Q 140 .N ND5310 S ND5310=$G(^PS(53.1,+PSGORD,0)) 141 .N PSGORD S PSGORD=$P(ND5310,"^",25) I PSGORD S PSJDCTYP=2 D SOC K PSJDCTYP 142 Q 143 PNDRNOK(ORDER) ; Execute DC Pending Renew if 144 ; 1) Renewal order is pending/non-verified, and 145 ; 2) Original order is not DC'd or Expired 146 Q:'$G(PSGORD)!'($G(PSGORD)["P") 0 147 N ORIGORD,ORIGSTOP S ORIGORD=$P($G(^PS(53.1,+ORDER,0)),"^",25) Q:'ORIGORD 0 D I ORIGSTOP<$G(PSGDT) Q 0 148 .S ORIGSTOP=$S(ORIGORD["U":$P($G(^PS(55,PSGP,5,+ORIGORD,2)),"^",4),ORIGORD["V":$P($G(^PS(55,PSGP,"IV",+ORIGORD,0)),"^",3),1:"") 149 Q:'($P($G(^PS(53.1,+PSGORD,0)),U,24)="R") 0 150 Q 1 1 PSGOEC ;BIR/CML3-CANCEL ORDERS ;02 Mar 99 / 9:29 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**23,58,110,175**;16 DEC 97;Build 18 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to ^PSSLOCK is supported by DBIA 2789. 6 ; 7 ENA ; all orders 8 D ENCV^PSGSETU Q:$D(XQUIT) S CF=$P(PSJSYSP0,U,5) N ND,ND1 S ND="$D(^PS(55,PSGP,5,PSGDA,4)),$P(^(4),U,12),$P(^(4),U,13)",ND1="$D(^PS(53.1,PSGDA,4)),$P(^(4),U,12),$P(^(4),U,13)" 9 F W !!,"Do you want to ",$S(CF:"discontinue",1:"mark for discontinuation")," all of this patient's orders" S %=1 D YN^DICN Q:% D ENCAM^PSGOEM 10 S PSGCF=0 Q:%<0 S PSGCF=1,T=$E("T",'PSJSYSU) G:%=1 ENCA F T=0:0 S T=$O(^PS(55,PSGP,5,"AUS",T)) Q:'T F PSGDA=0:0 S PSGDA=$O(^PS(55,PSGP,5,"AUS",T,PSGDA)) Q:'PSGDA I @ND Q 11 E F PSGDA=0:0 S PSGDA=$O(^PS(53.1,"AC",PSGP,PSGDA)) Q:'PSGDA I @ND1 Q 12 E G DONE 13 W !!,"SOME OR ALL OF THESE ORDERS HAVE" D ENUMK^PSGOEM Q:%'=1 14 W !!,"...a few moments, please..." S PSGAL("C")=PSJSYSU*10+21400 15 F T=PSGDT:0 S T=$O(^PS(55,PSGP,5,"AUS",T)) Q:'T F PSGDA=0:0 S PSGDA=$O(^PS(55,PSGP,5,"AUS",T,PSGDA)) Q:'PSGDA I @ND W "." D RS,^PSGAL5 16 F PSGDA=0:0 S PSGDA=$O(^PS(53.1,"AC",PSGP,PSGDA)) Q:'PSGDA I @ND1 W "." D RS 17 W " . . . DONE!" G DONE 18 ENCA ; 19 D NOW^%DTC S (Q1,PSGDT)=+$E(%,1,12) F S Q1=$O(^PS(55,PSGP,5,"AUS",Q1)) Q:'Q1 F Q2=0:0 S Q2=$O(^PS(55,PSGP,5,"AUS",Q1,Q2)) Q:'Q2 I $P($G(^PS(55,PSGP,5,Q2,0)),"^",21) Q 20 E F Q2=0:0 S Q2=$O(^PS(53.1,"AC",PSGP,Q2)) Q:'Q2 I $P($G(^PS(53.1,Q2,0)),U,21) Q 21 I S PSJNOO=$$ENNOO^PSJUTL5("D") I PSJNOO<0!('$$REQPROV) D G DONE 22 .W !!,$C(7),"No changes made to this order." D PAUSE^VALM1 23 S PSGALR=$S('$D(PSGALO):20,PSGALO?4N&($E(PSGALO)=1):10,1:20) I $P(PSJSYSP0,U,5) D ENHE^PSJADT0 S PSGOP=PSGP D ASET 24 F SD=PSGDT:0 S SD=$O(^PS(55,PSGP,5,"AUS",SD)) Q:'SD F PSGORD=0:0 S PSGORD=$O(^PS(55,PSGP,5,"AUS",SD,PSGORD)) Q:'PSGORD S PSGORD=+PSGORD_"A" D AC 25 D NSET S CF=$P(PSJSYSP0,U,5) F PSGORD=0:0 S PSGORD=$O(^PS(53.1,"AC",PSGP,PSGORD)) Q:'PSGORD S PSGORD=+PSGORD_"N" D NC 26 W " . . . DONE!" K PSGORD G DONE 27 ENO(PSGP,PSGORD) ; single order 28 I PSGSTAT="D" W !,"This order has already been DISCONTINUED." D PAUSE^VALM1 Q 29 S CF=$S($P(PSJSYSP0,U,5):1,PSGORD["U":0,1:($P($G(^PS(53.1,+PSGORD,0)),U,25)=""&($P($G(^(4)),U,7)=DUZ))) 30 S PSJCOM=+$S(PSGORD["U":$P($G(^PS(55,PSGP,5,+PSGORD,.2)),"^",8),1:$P($G(^PS(53.1,+PSGORD,.2)),"^",8)) 31 I 'CF,PSJCOM W !!,"This order is part of a complex order and CANNOT be marked for discontinuation." Q 32 I PSJCOM W !!,"This order is part of a complex order. If you discontinue this order the",!,"following orders will be discontinued too (unless the stop date has already",!,"been reached)." D CMPLX^PSJCOM1(PSGP,PSJCOM,PSGORD) 33 F W !!,"Do you want to ",$S(PSJCOM:"discontinue this series of complex orders",CF:"discontinue this order",1:"mark this order for discontinuation") S %=1 D YN^DICN Q:% D ENCOM^PSGOEM 34 I %<0 S VALMBCK="" Q 35 G:%=1 SOC I $S(PSGORD["U":$D(^PS(55,PSGP,5,+PSGORD,4)),1:$D(^PS(53.1,+PSGORD,4))),$P(^(4),U,12) W !!,"THIS ORDER HAS" 36 I D ENUMK^PSGOEM I %=1 W "..." K DA S:PSGORD["A" PSGAL("C")=PSJSYSU*10+21400,DA=+PSGORD,DA(1)=PSGP D RS,^PSGAL5:PSGORD["A" W " . . . DONE!" 37 G DONE 38 SOC ; 39 I 'CF,'$P($S(PSGORD["U":$G(^PS(55,PSGP,5,+PSGORD,0)),1:$G(^PS(53.1,+PSGORD,0))),U,21) W !!,"...one moment, please..." 40 E I CF S PSJNOO=$$ENNOO^PSJUTL5("D") I PSJNOO<0 D ABORT^PSGOEE G DONE 41 ; prompt for requesting provider 42 I CF,'$$REQPROV D ABORT^PSGOEE G DONE 43 K DA D NOW^%DTC S PSGDT=%,T=$E("T",'PSJSYSU),PSGALR=20,DA=+PSGORD,DA(1)=PSGP 44 I 'PSJCOM D 45 .I PSGORD["U" D ASET:CF,AC 46 .I PSGORD'["U" D NSET:CF,NC 47 I PSJCOM N COMFLG S COMFLG=0 D 48 . I PSGORD["P" Q:('$$LOCK^PSJOEA(PSGP,PSJCOM)) D 49 .. N O S O="" F S O=$O(^PS(53.1,"ACX",PSJCOM,O)) Q:O="" S (PSGORD,PSJORD)=O_"P" D NSET,NC 50 .I PSGORD["U" N O,OO S O=0,OO="" F S O=$O(^PS(55,"ACX",PSJCOM,O)) Q:'O F S OO=$O(^PS(55,"ACX",PSJCOM,O,OO)) Q:OO="" Q:COMFLG D 51 .. Q:OO=PSGORD I '$$LS^PSSLOCK(DFN,OO) S COMFLG=1 Q 52 I PSJCOM Q:COMFLG N O,OO S O=0,OO="" F S O=$O(^PS(55,"ACX",PSJCOM,O)) Q:'O F S OO=$O(^PS(55,"ACX",PSJCOM,O,OO)) Q:OO="" D 53 . I OO["V" S ON55=OO D D1^PSIVOPT2 S PSIVALT=1,PSIVALCK="STOP",PSIVREA="D",ON=ON55,P(3)=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,3) D 54 .. D LOG^PSIVORAL N PSJORD S PSJORD=ON55,P(3)=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,3),P("NAT")=PSJNOO D HL^PSIVORA 55 . I OO["U" N PSGORD,PSJORD S (PSGORD,PSJORD)=OO D ASET^PSGOEC,AC^PSGOEC 56 Q 57 D1 N %,DA,DIE,DIU,STP,NSTOP 58 D NOW^%DTC S NSTOP=+$E(%,1,12),STP=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,3),NSTOP=+$S(STP>NSTOP:NSTOP,1:STP),P(17)="D" 59 S DA(1)=DFN,DA=+ON55,DIE="^PS(55,"_DFN_",""IV"",",DR="109////"_NSTOP_$S('$P($G(^PS(55,DFN,"IV",+ON55,2)),U,7):";116////"_STP,1:"")_";100///D;.03////"_NSTOP,PSIVACT=1 D ^DIE 60 I $S($G(PSIVAC)="OD":0,$G(PSIVAC)'="AD":1,$G(PSGALO)<1060:0,1:$P($G(PSJSYSW0),U,15)) S X=$S($G(PSIVAC)="AD":1,1:2) D ENLBL^PSIVOPT(X,$S(X=1:+$G(PSGUOW),1:DUZ),DFN,3,+ON55,$E("AD",1,3-X)) 61 D:'$D(PSJIVORF) ORPARM^PSIVOREN Q:'PSJIVORF ;* S ORIFN=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,21) Q:'ORIFN 62 Q 63 OUT ; 64 W $S(PSJCOM:"...ORDER ",1:"...ORDERS "),$S(CF:"DISCONTINUED!",1:"MARKED!") S PSGCANFL=1 65 DONE ; 66 K CF,DA,DIE,DP,DR,ORIFN,ORETURN,PSGAL,PSGALR,PSGDA,SD,ST,T,UCF,Y Q 67 ASET ; 68 S DIE="^PS(55,"_PSGP_",5,",DR="28////"_$S($P($G(^PS(55,PSGP,5,+$G(PSJORD),0)),U,27)="E":"DE",$D(PSGEDIT):"DE",1:"D")_";Q;34////"_PSGDT_$S(T]"":";49////1",1:"") 69 Q 70 NSET ; 71 S DIE="^PS(53.1,",DR="28////"_$S($P($G(^PS(53.1,+$G(PSJORD),0)),U,27)="E":"DE",$D(PSGEDIT):"DE",1:"D")_$S(T]"":";42////1",1:"")_";25////"_PSGDT Q 72 AC ; 73 I 'CF K DA S $P(^PS(55,PSGP,5,+PSGORD,4),U,11,14)="^1^"_DUZ_U_PSGDT,PSGAL("C")=13040,DA=+PSGORD,DA(1)=PSGP D ^PSGAL5 74 I 'CF,$D(PSJSYSO) S PSGORD=+PSGORD_"A",PSGPOSA="C",PSGPOSD=PSGDT D ENPOS^PSGVDS 75 Q:'CF K DA,ORIFN S PSGAL("C")=PSJSYSU*10+4000,DA=+PSGORD,DA(1)=PSGP D ^PSGAL5 S $P(^(2),U,3)=$P(^PS(55,PSGP,5,+PSGORD,2),U,4) D ^DIE S ^PS(55,"AUE",PSGP,+PSGORD)="" 76 I PSJSYSL K DA S $P(^PS(55,PSGP,5,+PSGORD,7),U,1,2)=PSGDT_U_$S($D(PSGEDIT):"DE",1:"D"),PSGTOL=2,PSGUOW=DUZ,PSGTOO=1,DA=+PSGORD,DA(1)=PSGP D ENL^PSGVDS 77 S ORIFN=$P($G(^PS(55,PSGP,5,+PSGORD,0)),U,21) D:ORIFN DCOR^PSGOECS 78 Q 79 NC ; 80 I 'CF S $P(^PS(53.1,+PSGORD,4),"^",11,14)="^1^"_DUZ_U_PSGDT 81 I 'CF,$D(PSJSYSO) S PSGORD=+PSGORD_"N",PSGPOSA="C",PSGPOSD=PSGDT D ENPOS^PSGVDS 82 Q:'CF S PSGSTAT=$P($G(^PS(53.1,+PSGORD,0)),U,9),PSGORIFN=$P($G(^(0)),U,21) 83 I PSGSTAT'="U" K DA,ORIFN S DA=+PSGORD D ^DIE I PSJSYSL,PSJSYSL<3,(PSGSTAT'="P") S $P(^PS(53.1,+PSGORD,7),U,1,2)=PSGDT_U_$S($D(PSGEDIT):"DE",1:"D"),PSGTOO=2,PSGUOW=DUZ,PSGTOL=2 D ENL^PSGVDS 84 I PSGSTAT="U" K DA S DA=+PSGORD,DIK="^PS(53.1," D ^DIK 85 I PSGORIFN S ORIFN=PSGORIFN D DCOR^PSGOECS 86 Q 87 T ; 88 F W !!,"Is this due to the patient being transferred" S %=2 D YN^DICN Q:% D ENCTM^PSGOEM1 89 S T=$S(%<0:"^",1:$E("T",%=1)) Q 90 RS ; 91 ; naked ref below is from variable ND1, ^PS(53.1,PSGDA,4) 92 S $P(^(4),U,11,14)="^^^" Q 93 ; 94 REQPROV() ; 95 K PSJDCPRV,DIC,DUOUT,DTOUT,Y 96 N PROVIDER,PROVNAME,RESULT,RSB S RESULT=0 97 S PROVIDER=+$P($G(^PS(55,DFN,5.1)),"^",2),PROVNAME="" 98 I $G(PSJRQPND) S PROVIDER=0 99 I PROVIDER>0 D 100 .S DIC=200,DR="53.1;53.4",DIQ="RSB",DIQ(0)="I",DA=PROVIDER D EN^DIQ1 101 .K DIC,DR,DA,DIQ 102 .I $G(RSB(200,PROVIDER,53.1,"I"))="1"&(($G(RSB(200,PROVIDER,53.4,"I"))="")!($G(RSB(200,PROVIDER,53.4,"I"))>DT)) D 103 ..S DIC=200,DA=PROVIDER,DR=".01",DIQ="RSB",DIQ(0)="E" D EN^DIQ1 104 ..S PROVNAME=$G(RSB(200,PROVIDER,.01,"E")) K DA,DIQ,DR 105 K DIC S DIC=200,DIC(0)="AEMQZ" 106 S:PROVNAME]"" DIC("B")=PROVNAME 107 S DIC("A")="Requesting PROVIDER: " 108 S DIC("S")="I $D(^(""PS"")),^(""PS""),$S('$P(^(""PS""),""^"",4):1,1:$P(^(""PS""),""^"",4)>DT)" D ^DIC K DIC 109 I +Y>0,'$D(DUOUT),'$D(DTOUT) S RESULT=1,PSJDCPRV=+Y 110 Q RESULT -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGOECS.m
r613 r623 1 PSGOECS ;BIR/CML3-CANCEL SELECTED ORDERS ;02 Mar 99 / 9:29 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**23,29,44,58,81,110,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to FULL^VALM1 is supported by DBIA# 10116. 5 ; Reference to ^PS(55 is supported by DBIA# 2191. 6 ; Reference to ^PSSLOCK is supported by DBIA #2789. 7 ; 8 AM ; 9 W !,"...marking ",$P(X,U),"..." S $P(^PS(55,PSGP,5,DA,4),"^",11,14)="^1^"_DUZ_"^"_PSGDT,PSGAL("C")=13040 W "." D ^PSGAL5 W "." 10 I $D(PSJSYSO) S PSGORD=+PSGORD_"A",PSGPOSA="C",PSGPOSD=PSGDT D ENPOS^PSGVDS 11 Q 12 ; 13 NM ; 14 W !,"...marking ",$P(X,U),"..." S $P(^PS(53.1,DA,4),"^",11,14)="^1^"_DUZ_"^"_PSGDT W "." 15 I $D(PSJSYSO) S PSGORD=+PSGORD_"N",PSGPOSD=PSGDT,PSGPOSA="C" D ENPOS^PSGVDS 16 Q 17 ; 18 AC ; discontinue active order 19 K DA S DA(1)=PSGP,DA=+PSGORD 20 S X=$G(^PS(55,PSGP,5,DA,.2)) 21 I $P(X,U,4)="D" W !,$P($$DRUGNAME^PSJLMUTL(DFN,PSGORD),U,1),!,"NO ACTION WAS TAKEN ON DONE ORDER",!,$C(7) HANG 1 Q 22 NEW XX S XX=$P(^PS(55,PSGP,5,DA,0),U,9) 23 I $S(XX="E":1,XX="D":1,XX="DE":1,1:0) W !,$P($$DRUGNAME^PSJLMUTL(DFN,PSGORD),U,1),!,"NO ACTION WAS TAKEN ON "_$$CODES^PSIVUTL(XX,55.06,28)_" ORDER",!,$C(7) HANG 1 Q 24 S X=$$DRUGNAME^PSJLMUTL(PSGP,PSGORD) 25 I '$P(PSJSYSP0,"^",5) D AM Q 26 W !,"...discontinuing ",$P(X,U),"...",! S PSGAL("C")=PSJSYSU*10+4000 D ^PSGAL5 27 S PSGALR=20,DIE="^PS(55,"_PSGP_",5,",DR="28////D;Q;34////"_PSGDT_$S(PSJSYSU:"",1:";49////1"),DP=55.06,$P(^(2),"^",3)=$P(^PS(55,PSGP,5,DA,2),"^",4) D ^DIE S ^PS(55,"AUE",PSGP,DA)="" 28 D EN1^PSJHL2(PSGP,"OD",PSGORD) S DA(1)=PSGP,DA=+PSGORD 29 I PSJSYSL S $P(^PS(55,PSGP,5,DA,7),"^",1,2)=PSGDT_"^D",PSGTOL=2,PSGUOW=DUZ,PSGTOO=1 D ENL^PSGVDS 30 Q 31 ; 32 NC ; discontinue non-verifed order 33 I $P($G(^PS(53.1,+PSGORD,0)),U,24)="R" S PSJDCTYP=$$PNDRNA^PSGOEC(PSGORD) I $G(PSJDCTYP)'=1 D PNDRN($G(PSJDCTYP)) Q 34 NC2 ; Called from PNDRN to discontinue both pending renewal and original order 35 K DA S DA=+PSGORD,X=$G(^PS(53.1,DA,.2)),X=$$DRUGNAME^PSJLMUTL(PSGP,PSGORD) 36 I $S($P(PSJSYSP0,"^",5):0,'$D(^PS(53.1,DA,4)):1,1:$P(^(4),"^",7)'=DUZ) D NM Q 37 W !,"...discontinuing ",$P(X,U),"...",! S DIE="^PS(53.1,",DR="28////D"_$S(PSJSYSU:"",1:";42////1") D ^DIE 38 D EN1^PSJHL2(PSGP,"OC",PSGORD) 39 S DA=+PSGORD I PSJSYSL,PSJSYSL<3 S $P(^PS(53.1,DA,7),"^",1,2)=PSGDT_"^D",PSGTOO=2,PSGUOW=DUZ,PSGTOL=2 D ENL^PSGVDS 40 I $G(PSJDCTYP) D UNL^PSSLOCK(DFN,PSGORD) 41 Q 42 ; 43 EN ; enter here 44 I $G(PSJIVPRF) D ^PSIVSPDC Q ;Use for Speed DC in IV Order Profile 45 D FULL^VALM1 46 EN1 ; 47 S (PSGONC,PSGLMT)=PSJOCNT,PSGONW="C" D ENWO^PSGON I "^"[X K X G RESET 48 D NOW^%DTC S PSGDT=+$E(%,1,12) 49 W ! F PSGOECS=1:1:PSGODDD F PSGOECS1=1:1 S PSGOECS2=$P(PSGODDD(PSGOECS),",",PSGOECS1) Q:'PSGOECS2 D 50 .S PSGORD=^TMP("PSJON",$J,PSGOECS2) ; I $P($G(@($S((PSGORD["A")!(PSGORD["U"):"^PS(55,"_PSGP_",5,",(PSGORD["V"):"^PS(55,"_PSGP_",""IV"",",1:"^PS(53.1,")_(+PSGORD)_",0)")),"^",21) Q 51 S PSJNOO=$$ENNOO^PSJUTL5("D") G:PSJNOO<0 EN1 52 ;Prompt for requesting provider 53 W ! I '$$REQPROV^PSGOEC G EN1 54 W ! 55 ; 56 ;Replaced above line with block structure below. 57 N COMFLG,PSJCOM S (EXITLOOP,PSJCOM)=0 58 F PSGOECS=1:1:PSGODDD D 59 .F PSGOECS1=1:1 D Q:EXITLOOP=1 60 ..S PSGOECS2=$P(PSGODDD(PSGOECS),",",PSGOECS1) 61 ..I 'PSGOECS2 S EXITLOOP=1 Q 62 ..S (ON,PSGORD)=^TMP("PSJON",$J,PSGOECS2) 63 ..I PSGORD=+PSGORD D DCCOM Q 64 ..I '$$LS^PSSLOCK(DFN,PSGORD) D Q 65 ... W:PSGORD'["V" !,$P($$DRUGNAME^PSJLMUTL(DFN,PSGORD),"^",1),!,"NO ACTION WAS TAKEN",!,$C(7) HANG 1 Q 66 ... W ! I PSGORD["V" N PSJLINE S PSJLINE=1 D DSPLORDV^PSJLMUT1(PSGP,PSGORD) D W !,"NO ACTION WAS TAKEN",!,$C(7) HANG 1 67 ....F X=0:0 S X=$O(PSJOC(ON,X)) Q:'X D 68 .....W !,$G(PSJOC(ON,X)) 69 ..D CHKCOM I COMFLG D 70 ... I PSGORD'["V" W !,$P($$DRUGNAME^PSJLMUTL(DFN,PSGORD),"^",1),!,"NO ACTION WAS TAKEN",!,$C(7) HANG 1 Q 71 ... W ! I PSGORD["V" N PSJLINE S PSJLINE=1 D DSPLORDV^PSJLMUT1(PSGP,PSGORD) D W !,"NO ACTION WAS TAKEN",!,$C(7) HANG 1 72 ....F X=0:0 S X=$O(PSJOC(ON,X)) Q:'X D 73 .....W !,$G(PSJOC(ON,X)) 74 ..Q:PSJCOM 75 ..D:(PSGORD["U") AC 76 ..D:(PSGORD["P") NC 77 ..D:(PSGORD["V") SPDCIV^PSIVSPDC 78 ..; Call the unlock procedure 79 ..D UNL^PSSLOCK(DFN,PSGORD) 80 S X="" 81 RESET ; 82 I $G(PSGORD)["V" D INIT^PSJLMHED(3) S VALMBK="R" G DONE 83 D INIT^PSJLMHED(1) S VALMBCK="R" 84 ; 85 DONE ; 86 K DA,DIE,DP,DR,PSGAL,PSGALR,PSGLMT,PSGODDD,PSGOECS,PSGOECS1,PSGOECS2,PSGONW,PSGORD,PSGPOSA,PSGPOSD,PSGTOL,PSGTOO,PSGUOW,ORIFN,ORETURN,ORNATR 87 Q 88 ; 89 DCOR ; Create DC order/update stop date in OE/RR. 90 S PSOC=$S(PSGORD["P":"OC",PSGORD["N":"OC",1:"OD") 91 D EN1^PSJHL2(PSGP,PSOC,PSGORD) 92 Q 93 ; 94 ENOR ; 95 K DA S PSGEDIT=$S($D(PSGEDIT):PSGEDIT,1:"D"),CF=1,PSGALR=20,DA=+PSGORD,T="" I PSGORD'["U",(PSGORD'["O") D:CF NSET^PSGOEC D NC^PSGOEC D ENOR2 G DONE^PSGOEC 96 S DA(1)=PSGP D:CF ASET^PSGOEC D AC^PSGOEC 97 G DONE^PSGOEC 98 ; 99 ENOR2 ;Check to see if order being DC'd is a Pending Renewal and is being DC'd due to edit. 100 I PSGEDIT="DE",$P(^PS(53.1,+PSGORD,0),U,25),$P(^PS(53.1,+PSGORD,0),U,24)="R",PSGSD<$P($G(^PS(55,PSGP,5,+$P(^PS(53.1,+PSGORD,0),U,25),2)),U,4) D 101 .K DA,DR S DA(1)=PSGP,DA=+$P(^PS(53.1,+PSGORD,0),U,25),DIE="^PS(55,"_PSGP_",5,",DR="34////"_PSGSD_";25////"_$P($G(^PS(55,PSGP,5,+$P(^PS(53.1,+PSGORD,0),U,25),2)),U,4) 102 .D ^DIE,EN1^PSJHL2(PSGP,"XX",$P(^PS(53.1,+PSGORD,0),U,25)) 103 Q 104 ; 105 CHKCOM ;Check to see if order is part of complex order series. 106 S PSJCOM=$S(PSGORD["V":$P($G(^PS(55,PSGP,"IV",+PSGORD,.2)),U,8),PSGORD["U":$P($G(^PS(55,PSGP,5,+PSGORD,.2)),U,8),1:$P($G(^PS(53.1,+PSGORD,.2)),U,8)),COMFLG=0 107 N PSJSTAT S PSJSTAT=$S(PSGORD["V":$P($G(^PS(55,PSGP,"IV",+PSGORD,0)),"^",17),PSGORD["U":$P($G(^PS(55,PSGP,5,+PSGORD,0)),"^",9),1:$P($G(^PS(53.1,+PSGORD,0)),"^",9)) 108 Q:'PSJCOM I "DE"[PSJSTAT Q 109 W ! I PSGORD["V" N PSJLINE S PSJLINE=1 D DSPLORDV^PSJLMUT1(PSGP,PSGORD) D 110 .F X=0:0 S X=$O(PSJOC(ON,X)) Q:'X D 111 ..W !,$G(PSJOC(ON,X)) 112 I PSGORD["U" W !,$P($$DRUGNAME^PSJLMUTL(PSGP,PSGORD),"^",1) D 113 .W !!,"is part of a complex order. If you discontinue this order the following orders",!,"will be discontinued too (unless the stop date has already been reached)." D CMPLX^PSJCOM1(PSGP,PSJCOM,PSGORD) 114 F W !!,"Do you want to discontinue this series of complex orders" S %=1 D YN^DICN Q:% 115 I %'=1 S COMFLG=1 Q 116 N O,OO S O=0,OO="" F S O=$O(^PS(55,"ACX",PSJCOM,O)) Q:'O F S OO=$O(^PS(55,"ACX",PSJCOM,O,OO)) Q:OO="" D Q:COMFLG 117 .Q:OO=PSGORD I '$$LS^PSSLOCK(DFN,OO) S COMFLG=1 Q 118 Q:COMFLG 119 N O,OO S O=0,OO="" F S O=$O(^PS(55,"ACX",PSJCOM,O)) Q:'O F S OO=$O(^PS(55,"ACX",PSJCOM,O,OO)) Q:OO="" D 120 .I (OO["U") N PSGORD S PSGORD=OO D AC 121 .I (OO["V") N PSGORD S (ON,PSGORD)=OO D SPDCIV^PSIVSPDC 122 .D UNL^PSSLOCK(DFN,PSGORD) 123 Q 124 ; 125 DCCOM ;DC pending/non-verified complex order 126 I '$$LOCK^PSJOEA(DFN,PSGORD) W !,"Order # ",PSGOECS2," could not be discontinued.",!,$C(7) HANG 1 Q 127 N PSGORD1 S PSGORD1=PSGORD 128 N PSJO S PSJO=0 F S PSJO=$O(^PS(53.1,"ACX",PSGORD1,PSJO)) Q:'PSJO S PSGORD=PSJO_"P" D NC 129 Q 130 PNDRN(PSJDCTYP) ; Discontinue both pending renewal and original order 131 N TMPORD S TMPORD=$G(PSGORD) 132 I PSJDCTYP=2 S PSJDCTYP=1 D NC2 Q:'$G(PSJDCTYP) D 133 .I ($G(PSJNOO)<0) Q 134 .N ND5310 S ND5310=$G(^PS(53.1,+PSGORD,0)) 135 .N PSGORD S PSGORD=$P(ND5310,"^",25) I PSGORD S PSJDCTYP=2 D 136 ..I '$$LS^PSSLOCK(DFN,PSGORD) K PSJDCTYP Q 137 ..D @$S(PSGORD["U":"AC",PSGORD["V":"SPDCIV^PSIVSPDC",1:"") 138 S PSGORD=TMPORD 139 Q 1 PSGOECS ;BIR/CML3-CANCEL SELECTED ORDERS ;02 Mar 99 / 9:29 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**23,29,44,58,81,110**;16 DEC 97 3 ; 4 ; Reference to FULL^VALM1 is supported by DBIA# 10116. 5 ; Reference to ^PS(55 is supported by DBIA# 2191. 6 ; Reference to ^PSSLOCK is supported by DBIA #2789. 7 ; 8 AM ; 9 W !,"...marking ",$P(X,U),"..." S $P(^PS(55,PSGP,5,DA,4),"^",11,14)="^1^"_DUZ_"^"_PSGDT,PSGAL("C")=13040 W "." D ^PSGAL5 W "." 10 I $D(PSJSYSO) S PSGORD=+PSGORD_"A",PSGPOSA="C",PSGPOSD=PSGDT D ENPOS^PSGVDS 11 Q 12 ; 13 NM ; 14 W !,"...marking ",$P(X,U),"..." S $P(^PS(53.1,DA,4),"^",11,14)="^1^"_DUZ_"^"_PSGDT W "." 15 I $D(PSJSYSO) S PSGORD=+PSGORD_"N",PSGPOSD=PSGDT,PSGPOSA="C" D ENPOS^PSGVDS 16 Q 17 ; 18 AC ; discontinue active order 19 K DA S DA(1)=PSGP,DA=+PSGORD 20 S X=$G(^PS(55,PSGP,5,DA,.2)) 21 I $P(X,U,4)="D" W !,$P($$DRUGNAME^PSJLMUTL(DFN,PSGORD),U,1),!,"NO ACTION WAS TAKEN ON DONE ORDER",!,$C(7) HANG 1 Q 22 NEW XX S XX=$P(^PS(55,PSGP,5,DA,0),U,9) 23 I $S(XX="E":1,XX="D":1,XX="DE":1,1:0) W !,$P($$DRUGNAME^PSJLMUTL(DFN,PSGORD),U,1),!,"NO ACTION WAS TAKEN ON "_$$CODES^PSIVUTL(XX,55.06,28)_" ORDER",!,$C(7) HANG 1 Q 24 S X=$$DRUGNAME^PSJLMUTL(PSGP,PSGORD) 25 I '$P(PSJSYSP0,"^",5) D AM Q 26 W !,"...discontinuing ",$P(X,U),"...",! S PSGAL("C")=PSJSYSU*10+4000 D ^PSGAL5 27 S PSGALR=20,DIE="^PS(55,"_PSGP_",5,",DR="28////D;Q;34////"_PSGDT_$S(PSJSYSU:"",1:";49////1"),DP=55.06,$P(^(2),"^",3)=$P(^PS(55,PSGP,5,DA,2),"^",4) D ^DIE S ^PS(55,"AUE",PSGP,DA)="" 28 D EN1^PSJHL2(PSGP,"OD",PSGORD) S DA(1)=PSGP,DA=+PSGORD 29 I PSJSYSL S $P(^PS(55,PSGP,5,DA,7),"^",1,2)=PSGDT_"^D",PSGTOL=2,PSGUOW=DUZ,PSGTOO=1 D ENL^PSGVDS 30 Q 31 ; 32 NC ; discontinue non-verifed order 33 K DA S DA=+PSGORD,X=$G(^PS(53.1,DA,.2)),X=$$DRUGNAME^PSJLMUTL(PSGP,PSGORD) 34 I $S($P(PSJSYSP0,"^",5):0,'$D(^PS(53.1,DA,4)):1,1:$P(^(4),"^",7)'=DUZ) D NM Q 35 W !,"...discontinuing ",$P(X,U),"...",! S DIE="^PS(53.1,",DR="28////D"_$S(PSJSYSU:"",1:";42////1") D ^DIE 36 D EN1^PSJHL2(PSGP,"OC",PSGORD) 37 S DA=+PSGORD I PSJSYSL,PSJSYSL<3 S $P(^PS(53.1,DA,7),"^",1,2)=PSGDT_"^D",PSGTOO=2,PSGUOW=DUZ,PSGTOL=2 D ENL^PSGVDS 38 Q 39 ; 40 EN ; enter here 41 I $G(PSJIVPRF) D ^PSIVSPDC Q ;Use for Speed DC in IV Order Profile 42 D FULL^VALM1 43 EN1 ; 44 S (PSGONC,PSGLMT)=PSJOCNT,PSGONW="C" D ENWO^PSGON I "^"[X K X G RESET 45 D NOW^%DTC S PSGDT=+$E(%,1,12) 46 W ! F PSGOECS=1:1:PSGODDD F PSGOECS1=1:1 S PSGOECS2=$P(PSGODDD(PSGOECS),",",PSGOECS1) Q:'PSGOECS2 D 47 .S PSGORD=^TMP("PSJON",$J,PSGOECS2) ; I $P($G(@($S((PSGORD["A")!(PSGORD["U"):"^PS(55,"_PSGP_",5,",(PSGORD["V"):"^PS(55,"_PSGP_",""IV"",",1:"^PS(53.1,")_(+PSGORD)_",0)")),"^",21) Q 48 S PSJNOO=$$ENNOO^PSJUTL5("D") G:PSJNOO<0 EN1 49 ;Prompt for requesting provider 50 W ! I '$$REQPROV^PSGOEC G EN1 51 W ! 52 ; 53 ;F PSGOECS=1:1:PSGODDD F PSGOECS1=1:1 S PSGOECS2=$P(PSGODDD(PSGOECS),",",PSGOECS1) Q:'PSGOECS2 S (ON,PSGORD)=^TMP("PSJON",$J,PSGOECS2) D:(PSGORD["U") AC D:(PSGORD["P") NC D:(PSGORD["V") SPDCIV^PSIVSPDC 54 ;Replaced above line with block structure below. 55 N COMFLG,PSJCOM S (EXITLOOP,PSJCOM)=0 56 F PSGOECS=1:1:PSGODDD D 57 .F PSGOECS1=1:1 D Q:EXITLOOP=1 58 ..S PSGOECS2=$P(PSGODDD(PSGOECS),",",PSGOECS1) 59 ..I 'PSGOECS2 S EXITLOOP=1 Q 60 ..S (ON,PSGORD)=^TMP("PSJON",$J,PSGOECS2) 61 ..I PSGORD=+PSGORD D DCCOM Q 62 ..I '$$LS^PSSLOCK(DFN,PSGORD) D Q 63 ... W:PSGORD'["V" !,$P($$DRUGNAME^PSJLMUTL(DFN,PSGORD),"^",1),!,"NO ACTION WAS TAKEN",!,$C(7) HANG 1 Q 64 ... W ! I PSGORD["V" N PSJLINE S PSJLINE=1 D DSPLORDV^PSJLMUT1(PSGP,PSGORD) D W !,"NO ACTION WAS TAKEN",!,$C(7) HANG 1 65 ....F X=0:0 S X=$O(PSJOC(ON,X)) Q:'X D 66 .....W !,$G(PSJOC(ON,X)) 67 ..D CHKCOM I COMFLG D 68 ... I PSGORD'["V" W !,$P($$DRUGNAME^PSJLMUTL(DFN,PSGORD),"^",1),!,"NO ACTION WAS TAKEN",!,$C(7) HANG 1 Q 69 ... W ! I PSGORD["V" N PSJLINE S PSJLINE=1 D DSPLORDV^PSJLMUT1(PSGP,PSGORD) D W !,"NO ACTION WAS TAKEN",!,$C(7) HANG 1 70 ....F X=0:0 S X=$O(PSJOC(ON,X)) Q:'X D 71 .....W !,$G(PSJOC(ON,X)) 72 ..Q:PSJCOM 73 ..D:(PSGORD["U") AC 74 ..D:(PSGORD["P") NC 75 ..D:(PSGORD["V") SPDCIV^PSIVSPDC 76 ..; Call the unlock procedure 77 ..D UNL^PSSLOCK(DFN,PSGORD) 78 S X="" 79 RESET ; 80 I $G(PSGORD)["V" D INIT^PSJLMHED(3) S VALMBK="R" G DONE 81 D INIT^PSJLMHED(1) S VALMBCK="R" 82 ; 83 DONE ; 84 K DA,DIE,DP,DR,PSGAL,PSGALR,PSGLMT,PSGODDD,PSGOECS,PSGOECS1,PSGOECS2,PSGONW,PSGORD,PSGPOSA,PSGPOSD,PSGTOL,PSGTOO,PSGUOW,ORIFN,ORETURN,ORNATR 85 Q 86 ; 87 DCOR ; Create DC order/update stop date in OE/RR. 88 S PSOC=$S(PSGORD["P":"OC",PSGORD["N":"OC",1:"OD") 89 D EN1^PSJHL2(PSGP,PSOC,PSGORD) 90 Q 91 ; 92 ENOR ; 93 K DA S PSGEDIT=$S($D(PSGEDIT):PSGEDIT,1:"D"),CF=1,PSGALR=20,DA=+PSGORD,T="" I PSGORD'["U",(PSGORD'["O") D:CF NSET^PSGOEC D NC^PSGOEC D ENOR2 G DONE^PSGOEC 94 S DA(1)=PSGP D:CF ASET^PSGOEC D AC^PSGOEC 95 G DONE^PSGOEC 96 ; 97 ENOR2 ;Check to see if order being DC'd is a Pending Renewal and is being DC'd due to edit. 98 I PSGEDIT="DE",$P(^PS(53.1,+PSGORD,0),U,25),$P(^PS(53.1,+PSGORD,0),U,24)="R",PSGSD<$P($G(^PS(55,PSGP,5,+$P(^PS(53.1,+PSGORD,0),U,25),2)),U,4) D 99 .K DA,DR S DA(1)=PSGP,DA=+$P(^PS(53.1,+PSGORD,0),U,25),DIE="^PS(55,"_PSGP_",5,",DR="34////"_PSGSD_";25////"_$P($G(^PS(55,PSGP,5,+$P(^PS(53.1,+PSGORD,0),U,25),2)),U,4) 100 .D ^DIE,EN1^PSJHL2(PSGP,"XX",$P(^PS(53.1,+PSGORD,0),U,25)) 101 Q 102 ; 103 CHKCOM ;Check to see if order is part of complex order series. 104 S PSJCOM=$S(PSGORD["V":$P($G(^PS(55,PSGP,"IV",+PSGORD,.2)),U,8),PSGORD["U":$P($G(^PS(55,PSGP,5,+PSGORD,.2)),U,8),1:$P($G(^PS(53.1,+PSGORD,.2)),U,8)),COMFLG=0 105 N PSJSTAT S PSJSTAT=$S(PSGORD["V":$P($G(^PS(55,PSGP,"IV",+PSGORD,0)),"^",17),PSGORD["U":$P($G(^PS(55,PSGP,5,+PSGORD,0)),"^",9),1:$P($G(^PS(53.1,+PSGORD,0)),"^",9)) 106 Q:'PSJCOM I "DE"[PSJSTAT Q 107 W ! I PSGORD["V" N PSJLINE S PSJLINE=1 D DSPLORDV^PSJLMUT1(PSGP,PSGORD) D 108 .F X=0:0 S X=$O(PSJOC(ON,X)) Q:'X D 109 ..W !,$G(PSJOC(ON,X)) 110 I PSGORD["U" W !,$P($$DRUGNAME^PSJLMUTL(PSGP,PSGORD),"^",1) D 111 .W !!,"is part of a complex order. If you discontinue this order the following orders",!,"will be discontinued too (unless the stop date has already been reached)." D CMPLX^PSJCOM1(PSGP,PSJCOM,PSGORD) 112 F W !!,"Do you want to discontinue this series of complex orders" S %=1 D YN^DICN Q:% 113 I %'=1 S COMFLG=1 Q 114 N O,OO S O=0,OO="" F S O=$O(^PS(55,"ACX",PSJCOM,O)) Q:'O F S OO=$O(^PS(55,"ACX",PSJCOM,O,OO)) Q:OO="" D Q:COMFLG 115 .Q:OO=PSGORD I '$$LS^PSSLOCK(DFN,OO) S COMFLG=1 Q 116 Q:COMFLG 117 N O,OO S O=0,OO="" F S O=$O(^PS(55,"ACX",PSJCOM,O)) Q:'O F S OO=$O(^PS(55,"ACX",PSJCOM,O,OO)) Q:OO="" D 118 .I (OO["U") N PSGORD S PSGORD=OO D AC 119 .I (OO["V") N PSGORD S (ON,PSGORD)=OO D SPDCIV^PSIVSPDC 120 .D UNL^PSSLOCK(DFN,PSGORD) 121 Q 122 ; 123 DCCOM ;DC pending/non-verified complex order 124 I '$$LOCK^PSJOEA(DFN,PSGORD) W !,"Order # ",PSGOECS2," could not be discontinued.",!,$C(7) HANG 1 Q 125 N PSGORD1 S PSGORD1=PSGORD 126 N PSJO S PSJO=0 F S PSJO=$O(^PS(53.1,"ACX",PSGORD1,PSJO)) Q:'PSJO S PSGORD=PSJO_"P" D NC 127 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGOEF.m
r613 r623 1 PSGOEF ;BIR/CML3-FINISH ORDERS ENTERED THROUGH OE/RR ;14 May 98 / 2:17 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**7,30,29,35,39,47,50,56,80,116,110,111,133,153,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191 5 ; Reference to ^PSDRUG( is supported by DBIA 2192 6 ; Reference to DOSE^PSSORPH is supported by DBIA 3234. 7 ; 8 START ; 9 I '$D(^PS(53.1,+PSGORD)) W $C(7),!?3,"Cannot find this pending order (#",+PSGORD,")." Q 10 D NOW^%DTC S PSGDT=+$E(%,1,12) K PSGFDX,PSGEFN,PSGOEEF,PSGOES,PSGONF,PSGRDTX S PSGOES=1,(PSGOEF,PSGOEEF)=0,PSGOEEG=3 11 I $D(PSJTUD) S PSGDO=$P($G(^PS(53.1,+PSGORD,.3)),U),(PSGPDRG,PSGPD)=PSJCOI,(PSGPDRGN,PSGPDN)=$$OINAME^PSJLMUTL(PSGPD) 12 I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" S X=PSGSCH D EN^PSGORS0 D 13 . S:($D(X)&($P($G(^PS(53.1,+PSGORD,2)),"^",5)="")&($P($G(^PS(53.1,+PSGORD,0)),"^",24)="N")) PSGAT=PSGS0Y 14 . NEW PSJDOX,PSJDOSE,PSJPIECE,PSJUNIT,PSJX,X 15 . S X=$G(^PS(53.1,+PSGORD,1,1,0)) Q:'+X 16 . D DOSE^PSSORPH(.PSJDOX,+X,"U") 17 . I $S('$D(PSJDOX):1,1:+PSJDOX(1)=-1) Q 18 . S PSJPIECE=$S($P(PSJDOX(1),U)="":3,1:1) 19 . S X=^PS(53.1,+PSGORD,.2) 20 . S:PSJPIECE=3 PSJDOSE=$P(X,U,2) 21 . S:PSJPIECE=1 PSJDOSE=$P(X,U,5),PSJUNIT=$P(X,U,6) 22 . F X=0:0 S X=$O(PSJDOX(X)) Q:+$G(PSJX)!'X D 23 .. I PSJPIECE=3,($P(PSJDOX(X),U,3)'=PSJDOSE) Q 24 .. I PSJPIECE=1,($P(PSJDOX(X),U,1)_$P(PSJDOX(X),U,2)'=(PSJDOSE_PSJUNIT)) Q 25 .. S:+$P(PSJDOX(X),U,12) $P(^PS(53.45,PSJSYSP,2,1,0),U,2)=+$P(PSJDOX(X),U,12),PSJX=1 26 I PSGEB'=PSGOPR F X=7,11 S Y=$T(@(3_X)),@("PSGEFN("_X_")="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))="",PSGOEEF=PSGOEEF+1 27 D GTST^PSGOE6(+PSGORD) 28 I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" S PSGSD="" D:PSGS0Y]"" 29 .N PSJX S PSJX=$P($G(^PS(53.1,+PSGORD,0)),U,25) I PSJX="" Q 30 .I PSJX["U" S PSGSD=$P($G(^PS(55,DFN,5,+PSJX,2)),U,2) Q 31 .I PSJX["V" S PSGSD=$P($G(^PS(55,DFN,"IV",+PSJX,0)),U,2) Q 32 .I PSJX["P" S PSGSD=$P($G(^PS(53.1,+PSJX,2)),U,2) 33 S:PSGSD="" PSGSD=PSGLI 34 S PSGNEDFD=$$GTNEDFD^PSGOE7("U",+PSGPD) 35 S:$P($G(PSGNEDFD),U,3)="" $P(PSGNEDFD,U,3)=PSGST ; N PSGOEA S PSGOEA="R" 36 S (PSGNESD,PSGSD)=$$ENSD^PSGNE3(PSGSCH,PSGS0Y,PSGLI,PSGSD) 37 ;if this is a renewal order, ignore any 'requested start date' received. Use the system calculated start date. 38 I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" D 39 . D REQDT^PSJLIVMD(PSGORD) 40 E D 41 . S X=$$DSTART^PSJDCU(DFN,$P(^PS(53.1,+PSGORD,0),U,25)) I X]"" S (PSGNESD,PSGSD)=X K PSGRSD 42 D ; Extend the Default Stop Date if needed for the first renewed order. 43 .N PSGOEAO,PSGWALLO 44 .I $P($G(^PS(53.1,+PSGORD,0)),U,24)="R" S PSGOEAO=PSGOEA,PSGOEA="R",PSGWALLO=$P(^PS(55,DFN,5.1),U) 45 .D ENFD^PSGNE3(PSGLI) S PSGFD=$S($G(PSGRDTX(+PSGORD,"PSGFD")):PSGRDTX(+PSGORD,"PSGFD"),1:PSGNEFD) 46 .I $P($G(^PS(53.1,+PSGORD,0)),U,24)="R" S PSGOEA=PSGOEAO,$P(^PS(55,DFN,5.1),U)=PSGWALLO 47 N DUR,PSGRNSD S PSGRNSD=+$$LASTREN^PSJLMPRI(DFN,PSGORD) I PSGRNSD S DUR=$$GETDUR^PSJLIVMD(DFN,PSGORD,"P",1) I DUR]"" D 48 . N DURMIN S DURMIN=$$DURMIN^PSJLIVMD(DUR) I DURMIN S PSGFD=$$FMADD^XLFDT(PSGRNSD,,,DURMIN) 49 S PSGOFD="",PSGSDN=$$ENDD^PSGMI(PSGSD)_U_$$ENDTC^PSGMI(PSGSD),PSGFDN=$$ENDD^PSGMI(PSGFD)_U_$$ENDTC^PSGMI(PSGFD) 50 S PSGLIN=$$ENDD^PSGMI(PSGLI)_U_$$ENDTC^PSGMI(PSGLI) 51 I '$O(^PS(53.45,PSJSYSP,2,0)) N DRG,DRGCNT S DRGCNT=0 D 52 .F X=0:0 S X=$O(^PSDRUG("ASP",+PSGPD,X)) Q:'X!(DRGCNT>1) S:$P($G(^PSDRUG(+X,2)),U,3)["U" DRGCNT=DRGCNT+1,DRG=+X 53 .I DRGCNT=1 K ^PS(53.45,PSJSYSP,2) S ^PS(53.45,PSJSYSP,2,1,0)=DRG_U_1,^PS(53.45,PSJSYSP,2,0)="^53.4502^1^1",PS(53.45,PSJSYSP,2,"B",+DRG,1)="" 54 Q 55 FINISH ; 56 ; force display of second screen if CPRS order checks exist 57 N NSFF,PSGOEF39 S NSFF=1 K PSJNSS 58 I $G(PSGORD),$D(PSGRDTX(+PSGORD)) D K PSGRDTX 59 . S:$G(PSGRDTX(+PSGORD,"PSGRSD")) PSGSD=PSGRDTX(+PSGORD,"PSGRSD") 60 . S:$G(PSGRDTX(+PSGORD,"PSGRFD")) PSGFD=$S($G(PSGRDTX(+PSGORD,"PSGRFD")):PSGRDTX(+PSGORD,"PSGRFD"),1:$G(PSGNEFD)) 61 N PSJCOM S PSJCOM=+$P($G(^PS(53.1,+PSGORD,.2)),"^",8) 62 I $O(^PS(53.1,+PSGORD,12,0))!$O(^PS(53.1,+PSGORD,10,0)) D 63 .Q:$G(PSJLMX)=1 ; there's no second screen to display 64 .S VALMBG=16 D RE^VALM4,PAUSE^VALM1 65 D FULL^VALM1 66 I $G(PSJPROT)=3,'$D(PSJTUD),'$$ENIVUD^PSGOEF1(PSGORD) Q 67 I $G(PSGOSCH)]"" D S:$G(PSGS0XT)'="" $P(^PS(53.1,+PSGORD,2),"^",6)=PSGS0XT 68 .N PSGOES,PSGS0Y,PSGSCH S X=PSGOSCH K:$G(PSJTUD) NSFF D ENOS^PSGS0 69 .I '($G(PSGORD)["P"&($P($G(^PS(53.1,+PSGORD,0)),"^",24)="R")) I $G(X)]""&$G(PSGS0Y) S:$G(PSGAT)="" PSGAT=PSGS0Y 70 .I $G(PSJNSS) S PSGOSCH="" K PSJNSS 71 .I $G(PSGORD)["P",$G(PSGAT),$G(PSGS0Y),($G(PSGOSCH)]"") I PSGAT'=PSGS0Y D 72 ..S PSGNSTAT=1 W $C(7),!!,"PLEASE NOTE: This order's admin times (",PSGAT,")" 73 ..W !?13," do not match the ward times (",PSGS0Y,")" 74 ..W !?13," for this administration schedule (",PSGOSCH,")",! 75 ..S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR K DIR W ! 76 I $G(PSGS0XT)="" S $P(^PS(53.1,+PSGORD,2),"^",6)=$S($P($G(ZZND),"^",3)'="":$P(ZZND,"^",3),1:"") 77 S CHK=0 S:$P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" PSGSI=$$ENPC^PSJUTL("U",+PSJSYSP,180,PSGSI) 78 I '$G(PSJTUD),$G(PSJNSS),($G(PSGOSCH)]"") D NSSCONT^PSGS0(PSGOSCH,PSGS0XT) K PSJNSS S PSGOSCH="" 79 S PSGOEFF=PSGOSCH=""+('$O(^PS(53.45,PSJSYSP,2,0))*10) 80 I PSGOEFF S X=$S(PSGOEFF#2:" a SCHEDULE",1:"")_$S(PSGOEFF=11:" and",1:"")_$S(PSGOEFF>9:" at least one DISPENSE DRUG",1:"") 81 I 'PSGOEFF I (($G(PSGS0XT)="D")&($G(PSGAT)="")) S X=" Admin Times",PSGOEFF=1,PSGOEF39=1 82 I PSGOEFF,X]"" S X=X_" before it can be finished." 83 I PSGOEFF S CHK=1 W $C(7),!!,"PLEASE NOTE: This order must have" F Q=1:1:$L(X," ") S Y=$P(X," ",Q) W:$L(Y)+$X>78 ! W Y," " 84 I $G(PSGOEF39) S PSGOEE=0,PSGOEFF=0 D I 'PSGOEE D REFRESH^VALM G DONE 85 .S F1=53.1,MSG=0,Y=$T(39),@("PSGFN(39)="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))=1,(PSGOEEF,PSGOEE)=1 W ! D @$P($T(39),";",3) S CHK=0 86 I PSGOEFF=1 S F1=53.1,MSG=0,Y=$T(38),@("PSGFN(38)="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))=1,(PSGOEE,PSGOEEF)=1 W ! D @$P($T(38),";",3) S CHK=0 G:'PSGOEE DONE 87 I PSGOEFF=11 S F1=53.1,MSG=0,Y=$T(32),@("PSGFN(32)="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))=1,(PSGOEE,PSGOEEF)=1 W ! D @$P($T(32),";",3) D G:'PSGOEE DONE 88 .S F1=53.1,MSG=0,Y=$T(38),@("PSGFN(38)="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))=1,(PSGOEE,PSGOEEF)=1 W ! D @$P($T(38),";",3) S CHK=0 89 I PSGOEFF>9 S CHK=7 D ENDRG^PSGOEF1(+PSGPD,0) I CHK D ABORTACC Q 90 I 'PSGOEFF D OC531^PSGOESF ; check every dispense drug from CPRS 91 S VALMBG=1 92 I 'PSGOEFF&($D(PSGORQF)) D RE^VALM4 Q 93 I $G(MSG) K DIR S DIR(0)="E" W !! D ^DIR 94 I PSGOEFF D:PSGST="" GTST^PSGOE6(+PSGORD) 95 S PSJLMFIN=1 96 K PSJACEPT I $O(^PS(53.1,+PSGORD,12,0)) S PSJLMP2=1 97 S PSGOEENO=0,PSGSTAT=$S($P(PSJSYSP0,U,9):"ACTIVE",1:"NON-VERIFIED") 98 NEW PSJDOSE,PSJDOX,PSJDSFLG 99 D DOSECHK^PSJDOSE 100 S:+$G(PSJDSFLG) VALMSG="Dosage Ordered & Dispense Drug are not compatible" 101 I PSGODO=PSGDO S PSGOEEF(109)="" 102 I PSGODO'=PSGDO S PSGOEENO=1,VALMSG="This change will cause a new order to be created " 103 D EN^VALM("PSJU LM ACCEPT") 104 I $G(PSJNSS) D S PSGOEEF(26)="" K PSJACEPT,PSJNSS 105 .K DIR S DIR(0)="FOA",DIR("A")="Invalid Schedule" D ^DIR K DIR 106 I $G(PSGS0XT)="D",'$G(PSGS0Y),'$G(PSGAT),((",P,R,")'[(","_$G(PSGST)_",")) D S PSGOEEF(39)="" K PSJACEPT 107 .K DIR S DIR(0)="FOA",DIR("A")=" WARNING - Admin times are required for DAY OF WEEK schedules " D ^DIR K DIR 108 I '$G(PSJACEPT) D ABORTACC Q 109 I $G(PSJRNF),$G(^PS(53.1,+PSGORD,4)) D 110 . W $C(7),!!,"ACCEPTING THIS ORDER WILL CHANGE THE STATUS TO ACTIVE." 111 . S DIR(0)="Y",DIR("A")="Do you wish to make this order Active",DIR("?",1)="Enter ""N"" if you wish to exit without Activating this order," 112 . S DIR("?")="or ""Y"" to continue with the Activation process." D ^DIR S:'Y Y=-1 K DIR 113 I $G(PSJRNF),$G(Y)=-1 S PSJACEPT=0 D ABORTACC Q 114 I $G(PSJRNF),$G(Y)=1 S PSGOEAV=1 115 I PSGOEENO S PSJNOO=$$ENNOO^PSJUTL5("E"),PSJACEPT=$S(PSJNOO<0:0,1:1) 116 ACCEPT ; 117 S VALMBCK=$S($G(PSJACEPT):"Q",1:"R") 118 I '$G(PSJACEPT) D ABORTACC Q 119 K PSGOES,PSGRSD,PSGRSDN D:PSGOEENO NEW3^PSGOEE D:'PSGOEENO UPD^PSGOEF1 I $D(PSGOEF)!PSGOEENO S PSGCANFL=-1 120 D DONE1^PSGOEE 121 D DONE 122 Q 123 BYPASS ; 124 S PSGCANFL=1 125 ; 126 DONE ; 127 K CHK,DA,DIE,DR,DRG,MSG,Q1,Q2,PSGNSTAT ;PSGND,PSGOEE,PSGOEEF,PSGOEEND,PSGOEEG,PSGOEF,PSGOEFF,PSGOES,PSGOPD,PSGOPDN,PSGOPR,PSGOSCH,PSGPDRG,PSGDRGN,PSG0XT,PSGS0Y,OSGSD,Q1,Q2 128 Q 129 ABORTACC ; Abort Accept process. 130 D ABORT^PSGOEE K PSGOEEF D GETUD^PSJLMGUD(PSGP,PSGORD),^PSGOEF,ENSFE^PSGOEE0(PSGP,PSGORD),INIT^PSJLMUDE(PSGP,PSGORD) S VALMBCK="R",PSGSD=PSGNESD,PSGFD=PSGNEFD Q 131 ; 132 ; 133 31 ;;101^PSGOE8;PSGOPD;PSGPD;101;1 134 32 ;;109^PSGOE8;PSGODO;PSGDO;109;PSGODO]"" 135 33 ;;10^PSGOE81;PSGOSD;PSGSD;10;0 136 34 ;;3^PSGOE8;PSGOMR;PSGMR;3;1 137 35 ;;25^PSGOE81;PSGOFD;PSGFD;25;0 138 36 ;;7^PSGOE8;PSGOST;PSGST;7;0 139 37 ;;5^PSGOE82;PSGOSM;PSGSM;5;0 140 38 ;;26^PSGOE8;PSGOSCH;PSGSCH;26;1 141 39 ;;39^PSGOE81;PSGOAT;PSGAT;39;0 142 310 ;;1^PSGOE82;PSGOPR;PSGPR;1;1 143 311 ;;8^PSGOE81;PSGOSI;PSGSI;8;0 144 312 ;;2^PSGOE82;;;2;0 145 313 ;;40^PSGOE82;;;40;0 146 ; 147 AH ; 148 W !!?2,"Answer 'YES' to accept this order as a NON-VERIFIED UNIT DOSE order. Answer",!,"'NO' to edit this order now. Enter '^' to BYPASS this order, leaving it as",!,"a PENDING INPATIENT order." 149 Q 1 PSGOEF ;BIR/CML3-FINISH ORDERS ENTERED THROUGH OE/RR ;14 May 98 / 2:17 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**7,30,29,35,39,47,50,56,80,116,110,111,133,153**;16 DEC 97 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191 5 ; Reference to ^PSDRUG( is supported by DBIA 2192 6 ; Reference to DOSE^PSSORPH is supported by DBIA 3234. 7 ; 8 START ; 9 I '$D(^PS(53.1,+PSGORD)) W $C(7),!?3,"Cannot find this pending order (#",+PSGORD,")." Q 10 D NOW^%DTC S PSGDT=+$E(%,1,12) K PSGFDX,PSGEFN,PSGOEEF,PSGOES,PSGONF,PSGRDTX S PSGOES=1,(PSGOEF,PSGOEEF)=0,PSGOEEG=3 11 I $D(PSJTUD) S PSGDO=$P($G(^PS(53.1,+PSGORD,.3)),U),(PSGPDRG,PSGPD)=PSJCOI,(PSGPDRGN,PSGPDN)=$$OINAME^PSJLMUTL(PSGPD) 12 I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" S X=PSGSCH D EN^PSGORS0 S:$D(X) PSGAT=PSGS0Y D 13 . NEW PSJDOX,PSJDOSE,PSJPIECE,PSJUNIT,PSJX,X 14 . S X=$G(^PS(53.1,+PSGORD,1,1,0)) Q:'+X 15 . D DOSE^PSSORPH(.PSJDOX,+X,"U") 16 . I $S('$D(PSJDOX):1,1:+PSJDOX(1)=-1) Q 17 . S PSJPIECE=$S($P(PSJDOX(1),U)="":3,1:1) 18 . S X=^PS(53.1,+PSGORD,.2) 19 . S:PSJPIECE=3 PSJDOSE=$P(X,U,2) 20 . S:PSJPIECE=1 PSJDOSE=$P(X,U,5),PSJUNIT=$P(X,U,6) 21 . F X=0:0 S X=$O(PSJDOX(X)) Q:+$G(PSJX)!'X D 22 .. I PSJPIECE=3,($P(PSJDOX(X),U,3)'=PSJDOSE) Q 23 .. I PSJPIECE=1,($P(PSJDOX(X),U,1)_$P(PSJDOX(X),U,2)'=(PSJDOSE_PSJUNIT)) Q 24 .. S:+$P(PSJDOX(X),U,12) $P(^PS(53.45,PSJSYSP,2,1,0),U,2)=+$P(PSJDOX(X),U,12),PSJX=1 25 I PSGEB'=PSGOPR F X=7,11 S Y=$T(@(3_X)),@("PSGEFN("_X_")="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))="",PSGOEEF=PSGOEEF+1 26 D GTST^PSGOE6(+PSGORD) 27 I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" S PSGSD="" D:PSGS0Y]"" 28 .N PSJX S PSJX=$P($G(^PS(53.1,+PSGORD,0)),U,25) I PSJX="" Q 29 .I PSJX["U" S PSGSD=$P($G(^PS(55,DFN,5,+PSJX,2)),U,2) Q 30 .I PSJX["V" S PSGSD=$P($G(^PS(55,DFN,"IV",+PSJX,0)),U,2) Q 31 .I PSJX["P" S PSGSD=$P($G(^PS(53.1,+PSJX,2)),U,2) 32 S:PSGSD="" PSGSD=PSGLI 33 S PSGNEDFD=$$GTNEDFD^PSGOE7("U",+PSGPD) 34 S:$P($G(PSGNEDFD),U,3)="" $P(PSGNEDFD,U,3)=PSGST ; N PSGOEA S PSGOEA="R" 35 S (PSGNESD,PSGSD)=$$ENSD^PSGNE3(PSGSCH,PSGS0Y,PSGLI,PSGSD) 36 ;if this is a renewal order, ignore any 'requested start date' received. Use the system calculated start date. 37 I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" D 38 . D REQDT^PSJLIVMD(PSGORD) 39 E D 40 . S X=$$DSTART^PSJDCU(DFN,$P(^PS(53.1,+PSGORD,0),U,25)) I X]"" S (PSGNESD,PSGSD)=X K PSGRSD 41 D ; Extend the Default Stop Date if needed for the first renewed order. 42 .N PSGOEAO,PSGWALLO 43 .I $P($G(^PS(53.1,+PSGORD,0)),U,24)="R" S PSGOEAO=PSGOEA,PSGOEA="R",PSGWALLO=$P(^PS(55,DFN,5.1),U) 44 .D ENFD^PSGNE3(PSGLI) S PSGFD=$S($G(PSGRDTX(+PSGORD,"PSGFD")):PSGRDTX(+PSGORD,"PSGFD"),1:PSGNEFD) 45 .I $P($G(^PS(53.1,+PSGORD,0)),U,24)="R" S PSGOEA=PSGOEAO,$P(^PS(55,DFN,5.1),U)=PSGWALLO 46 N DUR,PSGRNSD S PSGRNSD=+$$LASTREN^PSJLMPRI(DFN,PSGORD) I PSGRNSD S DUR=$$GETDUR^PSJLIVMD(DFN,PSGORD,"P",1) I DUR]"" D 47 . N DURMIN S DURMIN=$$DURMIN^PSJLIVMD(DUR) I DURMIN S PSGFD=$$FMADD^XLFDT(PSGRNSD,,,DURMIN) 48 S PSGOFD="",PSGSDN=$$ENDD^PSGMI(PSGSD)_U_$$ENDTC^PSGMI(PSGSD),PSGFDN=$$ENDD^PSGMI(PSGFD)_U_$$ENDTC^PSGMI(PSGFD) 49 S PSGLIN=$$ENDD^PSGMI(PSGLI)_U_$$ENDTC^PSGMI(PSGLI) 50 I '$O(^PS(53.45,PSJSYSP,2,0)) N DRG,DRGCNT S DRGCNT=0 D 51 .F X=0:0 S X=$O(^PSDRUG("ASP",+PSGPD,X)) Q:'X!(DRGCNT>1) S:$P($G(^PSDRUG(+X,2)),U,3)["U" DRGCNT=DRGCNT+1,DRG=+X 52 .I DRGCNT=1 K ^PS(53.45,PSJSYSP,2) S ^PS(53.45,PSJSYSP,2,1,0)=DRG_U_1,^PS(53.45,PSJSYSP,2,0)="^53.4502^1^1",PS(53.45,PSJSYSP,2,"B",+DRG,1)="" 53 Q 54 FINISH ; 55 ; force display of second screen if CPRS order checks exist 56 N NSFF,PSGOEF39 S NSFF=1 K PSJNSS 57 I $G(PSGORD),$D(PSGRDTX(+PSGORD)) D K PSGRDTX 58 . S:$G(PSGRDTX(+PSGORD,"PSGRSD")) PSGSD=PSGRDTX(+PSGORD,"PSGRSD") 59 . S:$G(PSGRDTX(+PSGORD,"PSGRFD")) PSGFD=$S($G(PSGRDTX(+PSGORD,"PSGRFD")):PSGRDTX(+PSGORD,"PSGRFD"),1:$G(PSGNEFD)) 60 N PSJCOM S PSJCOM=+$P($G(^PS(53.1,+PSGORD,.2)),"^",8) 61 I $O(^PS(53.1,+PSGORD,12,0))!$O(^PS(53.1,+PSGORD,10,0)) D 62 .Q:$G(PSJLMX)=1 ; there's no second screen to display 63 .S VALMBG=16 D RE^VALM4,PAUSE^VALM1 64 D FULL^VALM1 65 I $G(PSJPROT)=3,'$D(PSJTUD),'$$ENIVUD^PSGOEF1(PSGORD) Q 66 S CHK=0 S:$P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" PSGSI=$$ENPC^PSJUTL("U",+PSJSYSP,180,PSGSI) 67 I $G(PSGOSCH)]"" D S:$G(PSGS0XT)'<0 $P(^PS(53.1,+PSGORD,2),"^",6)=PSGS0XT 68 .N PSGOES,PSGS0Y,PSGSCH S X=PSGOSCH K:$G(PSJTUD) NSFF D ENOS^PSGS0 I '($G(PSGORD)["P"&($P($G(^PS(53.1,+PSGORD,0)),"^",24)="R")) I $G(X)]""&$G(PSGS0Y) S PSGAT=PSGS0Y 69 .I $G(PSJNSS) S PSGOSCH="" K PSJNSS 70 I '$G(PSJTUD),$G(PSJNSS),($G(PSGOSCH)]"") D NSSCONT^PSGS0(PSGOSCH,PSGS0XT) K PSJNSS S PSGOSCH="" 71 S PSGOEFF=PSGOSCH=""+('$O(^PS(53.45,PSJSYSP,2,0))*10) 72 I PSGOEFF S X=$S(PSGOEFF#2:" a SCHEDULE",1:"")_$S(PSGOEFF=11:" and",1:"")_$S(PSGOEFF>9:" at least one DISPENSE DRUG",1:"") 73 I 'PSGOEFF I (($G(PSGS0XT)="D")&($G(PSGAT)="")) S X=" Admin Times",PSGOEFF=1,PSGOEF39=1 74 I PSGOEFF,X]"" S X=X_" before it can be finished." 75 I PSGOEFF S CHK=1 W $C(7),!!,"PLEASE NOTE: This order must have" F Q=1:1:$L(X," ") S Y=$P(X," ",Q) W:$L(Y)+$X>78 ! W Y," " 76 I $G(PSGOEF39) S PSGOEE=0,PSGOEFF=0 D I 'PSGOEE D REFRESH^VALM G DONE 77 .S F1=53.1,MSG=0,Y=$T(39),@("PSGFN(39)="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))=1,(PSGOEEF,PSGOEE)=1 W ! D @$P($T(39),";",3) S CHK=0 78 I PSGOEFF=1 S F1=53.1,MSG=0,Y=$T(38),@("PSGFN(38)="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))=1,(PSGOEE,PSGOEEF)=1 W ! D @$P($T(38),";",3) S CHK=0 G:'PSGOEE DONE 79 I PSGOEFF=11 S F1=53.1,MSG=0,Y=$T(32),@("PSGFN(32)="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))=1,(PSGOEE,PSGOEEF)=1 W ! D @$P($T(32),";",3) D G:'PSGOEE DONE 80 .S F1=53.1,MSG=0,Y=$T(38),@("PSGFN(38)="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))=1,(PSGOEE,PSGOEEF)=1 W ! D @$P($T(38),";",3) S CHK=0 81 I PSGOEFF>9 S CHK=7 D ENDRG^PSGOEF1(+PSGPD,0) I CHK D ABORTACC Q 82 I 'PSGOEFF D OC531^PSGOESF ; check every dispense drug from CPRS 83 S VALMBG=1 84 I 'PSGOEFF&($D(PSGORQF)) D RE^VALM4 Q 85 I $G(MSG) K DIR S DIR(0)="E" W !! D ^DIR 86 I PSGOEFF D:PSGST="" GTST^PSGOE6(+PSGORD) 87 S PSJLMFIN=1 88 K PSJACEPT I $O(^PS(53.1,+PSGORD,12,0)) S PSJLMP2=1 89 S PSGOEENO=0,PSGSTAT=$S($P(PSJSYSP0,U,9):"ACTIVE",1:"NON-VERIFIED") 90 NEW PSJDOSE,PSJDOX,PSJDSFLG 91 D DOSECHK^PSJDOSE 92 S:+$G(PSJDSFLG) VALMSG="Dosage Ordered & Dispense Drug are not compatible" 93 I PSGODO=PSGDO S PSGOEEF(109)="" 94 I PSGODO'=PSGDO S PSGOEENO=1,VALMSG="This change will cause a new order to be created " 95 D EN^VALM("PSJU LM ACCEPT") 96 I $G(PSJNSS) D S PSGOEEF(26)="" K PSJACEPT,PSJNSS 97 .K DIR S DIR(0)="FOA",DIR("A")="Invalid Schedule" D ^DIR K DIR 98 I $G(PSGS0XT)="D",'$G(PSGS0Y),'$G(PSGAT),((",P,R,")'[(","_$G(PSGST)_",")) D S PSGOEEF(39)="" K PSJACEPT 99 .K DIR S DIR(0)="FOA",DIR("A")=" WARNING - Admin times are required for DAY OF WEEK schedules " D ^DIR K DIR 100 I '$G(PSJACEPT) D ABORTACC Q 101 I $G(PSJRNF),$G(^PS(53.1,+PSGORD,4)) D 102 . W $C(7),!!,"ACCEPTING THIS ORDER WILL CHANGE THE STATUS TO ACTIVE." 103 . S DIR(0)="Y",DIR("A")="Do you wish to make this order Active",DIR("?",1)="Enter ""N"" if you wish to exit without Activating this order," 104 . S DIR("?")="or ""Y"" to continue with the Activation process." D ^DIR S:'Y Y=-1 K DIR 105 I $G(PSJRNF),$G(Y)=-1 S PSJACEPT=0 D ABORTACC Q 106 I $G(PSJRNF),$G(Y)=1 S PSGOEAV=1 107 I PSGOEENO S PSJNOO=$$ENNOO^PSJUTL5("E"),PSJACEPT=$S(PSJNOO<0:0,1:1) 108 ACCEPT ; 109 S VALMBCK=$S($G(PSJACEPT):"Q",1:"R") 110 I '$G(PSJACEPT) D ABORTACC Q 111 K PSGOES,PSGRSD,PSGRSDN D:PSGOEENO NEW3^PSGOEE D:'PSGOEENO UPD^PSGOEF1 I $D(PSGOEF)!PSGOEENO S PSGCANFL=-1 112 D DONE1^PSGOEE 113 D DONE 114 Q 115 BYPASS ; 116 S PSGCANFL=1 117 ; 118 DONE ; 119 K CHK,DA,DIE,DR,DRG,MSG,Q1,Q2 ;PSGND,PSGOEE,PSGOEEF,PSGOEEND,PSGOEEG,PSGOEF,PSGOEFF,PSGOES,PSGOPD,PSGOPDN,PSGOPR,PSGOSCH,PSGPDRG,PSGDRGN,PSG0XT,PSGS0Y,OSGSD,Q1,Q2 120 Q 121 ABORTACC ; Abort Accept process. 122 D ABORT^PSGOEE K PSGOEEF D GETUD^PSJLMGUD(PSGP,PSGORD),^PSGOEF,ENSFE^PSGOEE0(PSGP,PSGORD),INIT^PSJLMUDE(PSGP,PSGORD) S VALMBCK="R",PSGSD=PSGNESD,PSGFD=PSGNEFD Q 123 ; 124 ; 125 31 ;;101^PSGOE8;PSGOPD;PSGPD;101;1 126 32 ;;109^PSGOE8;PSGODO;PSGDO;109;PSGODO]"" 127 33 ;;10^PSGOE81;PSGOSD;PSGSD;10;0 128 34 ;;3^PSGOE8;PSGOMR;PSGMR;3;1 129 35 ;;25^PSGOE81;PSGOFD;PSGFD;25;0 130 36 ;;7^PSGOE8;PSGOST;PSGST;7;0 131 37 ;;5^PSGOE82;PSGOSM;PSGSM;5;0 132 38 ;;26^PSGOE8;PSGOSCH;PSGSCH;26;1 133 39 ;;39^PSGOE81;PSGOAT;PSGAT;39;0 134 310 ;;1^PSGOE82;PSGOPR;PSGPR;1;1 135 311 ;;8^PSGOE81;PSGOSI;PSGSI;8;0 136 312 ;;2^PSGOE82;;;2;0 137 313 ;;40^PSGOE82;;;40;0 138 ; 139 AH ; 140 W !!?2,"Answer 'YES' to accept this order as a NON-VERIFIED UNIT DOSE order. Answer",!,"'NO' to edit this order now. Enter '^' to BYPASS this order, leaving it as",!,"a PENDING INPATIENT order." 141 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGOT.m
r613 r623 1 PSGOT ;BIR/CML3-TRANSFERS DATA FROM 53.1 TO 55 ;24 SEP 97 / 7:54 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**13,68,90,110,173,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 supported by DBIA 2191. 5 ; 6 START ; get internal record number, lock record, and write 7 S ODA=+PSGORD S:$D(^PS(55,PSGP,0))[0 ^(0)=PSGP,^PS(55,"B",PSGP,PSGP)="",$P(^PS(55,0),U,3,4)=PSGP_U_($P($G(^PS(55,0)),U,4)+1) F L +^PS(55,PSGP,5,0):1 I Q 8 S ZND=$G(^PS(55,PSGP,5,0)) S:ZND="" ZND="^55.06IA" F DA=$P(ZND,"^",3)+1:1 I '$D(^PS(55,PSGP,5,DA)),'$D(^("B",DA)) L +^PS(55,PSGP,5,DA):1 I S $P(ZND,"^",3)=DA,$P(ZND,"^",4)=$P(ZND,"^",4)+1,^PS(55,PSGP,5,0)=ZND Q 9 L -^PS(55,PSGP,5,0) S ND0=^PS(53.1,ODA,0),$P(ND0,"^",23)=PSJPWD,^PS(55,PSGP,5,DA,0)=ND0 10 S (ND1,^PS(55,PSGP,5,DA,.2))=$G(^PS(53.1,ODA,.2)),^PS(55,PSGP,5,DA,.3)=$G(^PS(53.1,ODA,.3)),(ND2,^PS(55,PSGP,5,DA,2))=^PS(53.1,ODA,2),^PS(55,PSGP,5,DA,4)=$G(^PS(53.1,ODA,4)),^PS(55,"AUD",+$P(ND2,"^",4),PSGP,DA)="" 11 S X=^PS(55,PSGP,0) I $P(X,"^",7)="" S $P(X,"^",7)=$P($P(ND0,"^",16),"."),$P(X,"^",8)="A",^(0)=X 12 I $P($G(^PS(55,PSGP,5,DA,2)),"^",6)="" S $P(^PS(55,PSGP,5,DA,2),"^",6)=$S($G(PSGS0XT)'="":PSGS0XT,$P($G(ZZND),"^",3)'="":$P(ZZND,"^",3),1:""),$P(^PS(53.1,ODA,2),"^",6)=$P(^PS(55,PSGP,5,DA,2),"^",6) 13 F X=6,7,13 I $D(^PS(53.1,ODA,X)) S ^PS(55,PSGP,5,DA,X)=^(X) 14 I $D(^PS(53.1,ODA,"DSS")) S ^PS(55,PSGP,5,DA,8)=^("DSS") 15 I $O(^PS(53.1,ODA,1,0)) S (C,X)=0 F S X=$O(^PS(53.1,ODA,1,X)) Q:'X S:$D(^(X,0)) C=C+1,^PS(55,PSGP,5,DA,1,C,0)=^(0),^PS(55,PSGP,5,DA,1,"B",+$P($G(^(0)),U),C)="" 16 I $O(^PS(53.1,ODA,1,0)) S ^PS(55,PSGP,5,DA,1,0)="^55.07P^"_C_"^"_C 17 F X=3,12 D S ^PS(55,PSGP,5,DA,X,0)="^55.0"_$S(X=3:8,1:612)_U_CNT_U_CNT 18 .S CNT=0 F C=0:0 S C=$O(^PS(53.1,ODA,X,C)) Q:'C I $D(^(C,0)) S ^PS(55,PSGP,5,DA,X,C,0)=^(0),CNT=CNT+1 19 S $P(^PS(53.1,ODA,0),"^",19)=DA 20 CR ; set x-refs 21 N A 22 I $D(^PS(55,PSGP,5.1)),$P(^(5.1),"^",6) S X=$P(^(5.1),"^",6) I $P(ND2,"^",3),$P(ND2,"^",6)'>X S $P(^(5.1),"^",6)=$P(ND2,"^",3) 23 S ^PS(55,PSGP,5,"B",+ODA,DA)="",^PS(55,PSGP,5,"AU",$P(ND0,"^",7),+$P(ND2,"^",4),DA)="" 24 S ^PS(55,PSGP,5,"AUS",+$P(ND2,"^",4),DA)="" 25 S ^PS(55,PSGP,5,"C",+ND1,DA)="",^PS(55,"AUE",PSGP,DA)="" 26 S ^PS(55,"AUDS",+$P(ND2,"^",2),PSGP,DA)="" 27 I $D(^PS(55,PSGP,5,DA,8)) S A=^(8),^PS(55,"AUDC",+$P(ND2,"^",4),+A,PSGP,DA)="" 28 I $$PATCH^XPDUTL("PXRM*1.5*12") S X(1)=+$P(ND2,"^",2),X(2)=+$P(ND2,"^",4),DA(1)=PSGP D SPSPA^PSJXRFS(.X,.DA,"UD") 29 K DIK S DA(1)=PSGP S DIK="^PS(55,"_DA(1)_",5,",DIK(1)=125 D EN1^DIK K DIK 30 S PSGTOL=2,PSGTOO=1 F PSGUOW=0:0 S PSGUOW=$O(^PS(53.41,2,1,PSGUOW)) Q:'PSGUOW I $D(^(PSGUOW,1,PSGP,1,2,1,ODA)) K ^(ODA) D ENL^PSGVDS 31 DONE I $D(PSGOE2),PSGOE2]"",$D(^TMP("PSJON",$J,PSGOE2)) S ^(PSGOE2)=DA_"U" 32 S PSGODA=ODA,PSGORD=DA_"U" 33 S PSGNODE=$G(^PS(55,PSGP,5,DA,0)),PSG25=$P(PSGNODE,"^",25),PSG26=$P(PSGNODE,"^",26) 34 I PSG25 S X=$S(PSG25["V":"^PS(55,"_PSGP_",""IV"",",PSG25["U"!(PSG25["A"):"^PS(55,"_PSGP_",5,",1:"^PS(53.1,")_+PSG25_","_$E("02",PSG25["V"+1)_")" I $D(@X) S $P(@X,"^",$S(PSG25["V":6,1:26))=DA_"U" 35 I $P(PSGNODE,"^",26),$P(PSGNODE,"^",26)'["V",$D(^PS(55,PSGP,5,+$P(PSGNODE,"^",26),0)) S $P(^(0),"^",25)=DA_"U" 36 F Q=0:0 S Q=$O(^PS(53.44,Q)) Q:'Q I $D(^(Q,1,PSGP,ODA,0)) S $P(^(0),"^",2)=DA 37 L -^PS(53.1,ODA) L -^PS(55,DFN,5,+PSGORD) K CNT,ND,ODA,XX,ZND Q 1 PSGOT ;BIR/CML3-TRANSFERS DATA FROM 53.1 TO 55 ;24 SEP 97 / 7:54 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**13,68,90,110,173**;16 DEC 97;Build 4 3 ; 4 ; Reference to ^PS(55 supported by DBIA 2191. 5 ; 6 START ; get internal record number, lock record, and write 7 S ODA=+PSGORD S:$D(^PS(55,PSGP,0))[0 ^(0)=PSGP,^PS(55,"B",PSGP,PSGP)="",$P(^PS(55,0),U,3,4)=PSGP_U_($P($G(^PS(55,0)),U,4)+1) F L +^PS(55,PSGP,5,0):1 I Q 8 S ZND=$G(^PS(55,PSGP,5,0)) S:ZND="" ZND="^55.06IA" F DA=$P(ZND,"^",3)+1:1 I '$D(^PS(55,PSGP,5,DA)),'$D(^("B",DA)) L +^PS(55,PSGP,5,DA):1 I S $P(ZND,"^",3)=DA,$P(ZND,"^",4)=$P(ZND,"^",4)+1,^PS(55,PSGP,5,0)=ZND Q 9 L -^PS(55,PSGP,5,0) S ND0=^PS(53.1,ODA,0),$P(ND0,"^",23)=PSJPWD,^PS(55,PSGP,5,DA,0)=ND0 10 S (ND1,^PS(55,PSGP,5,DA,.2))=$G(^PS(53.1,ODA,.2)),^PS(55,PSGP,5,DA,.3)=$G(^PS(53.1,ODA,.3)),(ND2,^PS(55,PSGP,5,DA,2))=^PS(53.1,ODA,2),^PS(55,PSGP,5,DA,4)=$G(^PS(53.1,ODA,4)),^PS(55,"AUD",+$P(ND2,"^",4),PSGP,DA)="" 11 S X=^PS(55,PSGP,0) I $P(X,"^",7)="" S $P(X,"^",7)=$P($P(ND0,"^",16),"."),$P(X,"^",8)="A",^(0)=X 12 F X=6,7,13 I $D(^PS(53.1,ODA,X)) S ^PS(55,PSGP,5,DA,X)=^(X) 13 I $D(^PS(53.1,ODA,"DSS")) S ^PS(55,PSGP,5,DA,8)=^("DSS") 14 I $O(^PS(53.1,ODA,1,0)) S (C,X)=0 F S X=$O(^PS(53.1,ODA,1,X)) Q:'X S:$D(^(X,0)) C=C+1,^PS(55,PSGP,5,DA,1,C,0)=^(0),^PS(55,PSGP,5,DA,1,"B",+$P($G(^(0)),U),C)="" 15 ;F C=0:0 S C=$O(^PS(55,PSGP,5,DA,1,C)) Q:'C S X=+$G(^(C,0)) S:X ^PS(55,PSGP,5,DA,1,"B",X,C)="" 16 I $O(^PS(53.1,ODA,1,0)) S ^PS(55,PSGP,5,DA,1,0)="^55.07P^"_C_"^"_C 17 F X=3,12 D S ^PS(55,PSGP,5,DA,X,0)="^55.0"_$S(X=3:8,1:612)_U_CNT_U_CNT 18 .S CNT=0 F C=0:0 S C=$O(^PS(53.1,ODA,X,C)) Q:'C I $D(^(C,0)) S ^PS(55,PSGP,5,DA,X,C,0)=^(0),CNT=CNT+1 19 ;F X=3,12 I $O(^PS(53.1,ODA,X,0)) S ^PS(55,PSGP,5,DA,X,0)=^(0) F C=0:0 S C=$O(^PS(53.1,ODA,X,C)) Q:'C I $D(^(C,0)) S ^PS(55,PSGP,5,DA,X,C,0)=^(0) 20 S $P(^PS(53.1,ODA,0),"^",19)=DA 21 CR ; set x-refs 22 N A 23 I $D(^PS(55,PSGP,5.1)),$P(^(5.1),"^",6) S X=$P(^(5.1),"^",6) I $P(ND2,"^",3),$P(ND2,"^",6)'>X S $P(^(5.1),"^",6)=$P(ND2,"^",3) 24 S ^PS(55,PSGP,5,"B",+ODA,DA)="",^PS(55,PSGP,5,"AU",$P(ND0,"^",7),+$P(ND2,"^",4),DA)="" 25 S ^PS(55,PSGP,5,"AUS",+$P(ND2,"^",4),DA)="" 26 S ^PS(55,PSGP,5,"C",+ND1,DA)="",^PS(55,"AUE",PSGP,DA)="" 27 S ^PS(55,"AUDS",+$P(ND2,"^",2),PSGP,DA)="" 28 I $D(^PS(55,PSGP,5,DA,8)) S A=^(8),^PS(55,"AUDC",+$P(ND2,"^",4),+A,PSGP,DA)="" 29 I $$PATCH^XPDUTL("PXRM*1.5*12") S X(1)=+$P(ND2,"^",2),X(2)=+$P(ND2,"^",4),DA(1)=PSGP D SPSPA^PSJXRFS(.X,.DA,"UD") 30 K DIK S DA(1)=PSGP S DIK="^PS(55,"_DA(1)_",5,",DIK(1)=125 D EN1^DIK K DIK 31 S PSGTOL=2,PSGTOO=1 F PSGUOW=0:0 S PSGUOW=$O(^PS(53.41,2,1,PSGUOW)) Q:'PSGUOW I $D(^(PSGUOW,1,PSGP,1,2,1,ODA)) K ^(ODA) D ENL^PSGVDS 32 DONE I $D(PSGOE2),PSGOE2]"",$D(^TMP("PSJON",$J,PSGOE2)) S ^(PSGOE2)=DA_"U" 33 S PSGODA=ODA,PSGORD=DA_"U" 34 S PSGNODE=$G(^PS(55,PSGP,5,DA,0)),PSG25=$P(PSGNODE,"^",25),PSG26=$P(PSGNODE,"^",26) 35 I PSG25 S X=$S(PSG25["V":"^PS(55,"_PSGP_",""IV"",",PSG25["U"!(PSG25["A"):"^PS(55,"_PSGP_",5,",1:"^PS(53.1,")_+PSG25_","_$E("02",PSG25["V"+1)_")" I $D(@X) S $P(@X,"^",$S(PSG25["V":6,1:26))=DA_"U" 36 I $P(PSGNODE,"^",26),$P(PSGNODE,"^",26)'["V",$D(^PS(55,PSGP,5,+$P(PSGNODE,"^",26),0)) S $P(^(0),"^",25)=DA_"U" 37 ;I $P(PSGNODE,"^",21) S X=$O(^ORD(101,"B","PS EVSEND OR",0))_";ORD(101,",PSOC="SC",PSJORDER=$$ORDER^PSJHLU(PSGORD) D EN1^XQOR:X K X 38 F Q=0:0 S Q=$O(^PS(53.44,Q)) Q:'Q I $D(^(Q,1,PSGP,ODA,0)) S $P(^(0),"^",2)=DA 39 L -^PS(53.1,ODA) L -^PS(55,DFN,5,+PSGORD) K CNT,ND,ODA,XX,ZND Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGPLR.m
r613 r623 1 PSGPLR ;BIR/CML3-PRINTS PICK LIST REPORT ; 6/15/07 1:12pm 2 ;;5.0; INPATIENT MEDICATIONS ;**10,50,67,119,129,191**;16 DEC 97;Build 9 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to ^PS(59.7 is supported by DBIA# 2181. 6 ; Reference to ^PSDRUG is supported by DBIA# 2192. 7 ; Reference to ^%DTC is supported by DBIA# 10000. 8 ; Reference to ^VADPT is supported by DBIA# 10061. 9 ; 10 N PSGY,OLDWARD,STPDT D NOW^%DTC S PSGDT=+$E(%,1,12),PPLD=$$ENDTC^PSGMI(PSGDT),$P(OLINE,"-",75)="",PSGPLXR=$S($G(PSGPLUPF)=1:"AU",1:"AC") 11 S PGN=0,(FACL,LINE)="",$P(LINE,"-",81)="",$P(FACL,"_",31)="",TND=$G(^PS(53.5,PSGPLG,0)),PSD=$P(TND,"^",3),PFD=$P(TND,"^",4),WSF=$P(TND,"^",7),WGPN=$S('$D(^PS(57.5,PSGPLWG,0)):"N/F",$P(^(0),"^")]"":$P(^(0),"^"),1:"N/F") 12 S FFF=$S($P(PSGPLWGP,"^",4):2,$P(PSGPLWGP,"^",5):1,1:0),CML=IO'=IO(0)!($E(IOST,1,2)'="C-") 13 F X="PSD","PFD" S @X=$$ENDTC^PSGMI(@X) 14 U IO 15 I '$D(^PS(53.5,$S($D(PSGPLUPF):"AU",1:"AC"),PSGPLG)) S NPLF=0 D HEADER W !!?25,"*** No orders to fill ***" W:(IO'=IO(0)!(IOST'["C-"))&($Y) @IOF G DONE 16 ; 17 BEGIN ; 18 I '$$LOCK^PSGPLUTL(PSGPLG,"PSGPLR") H 60 G BEGIN 19 S NPLF=1,TM=0 F S TM=$O(^PS(53.5,PSGPLXR,PSGPLG,TM)) Q:TM=""!(TM["~") S (DDRG,PDRG,PN,PST,RM,WDN)="" D HEADER:'FFF,^PSGPLR0 I CML,'FFF D PAGECK W !!?25,"FILLED BY: ",FACL,!!?25,"CHECKED BY: ",FACL 20 I CML,FFF D PAGECK W !!?25,"FILLED BY: ",FACL,!!?25,"CHECKED BY: ",FACL W:$Y @IOF 21 ; 22 DONE ; 23 D UNLOCK^PSGPLUTL(PSGPLG,"PSGPLR") 24 K AT,ATC,CML,DDRG,DIS,DND,DO,DR,DRN,DRG,FACL,FD,FFF,FQC,LINE,ND,ND0,ND1,ND2,ND6,NEED,NPLF,OLINE,PSGPLDC,PSGPLXR,PSGPLXRX 25 K PSJJORD,PSJORDN,PFD,PGN,PN,POP,PPLD,PPN,PRM,PSD,PSGID,PSGOD,PSGP,PST,PW,RM,RTE,SCH,SD,SM,PSSN,TD,TM,TND,WDN,WL,WG,WSF,WGPN,X 26 Q 27 ; 28 DD ; 29 N PSJRNW,CNT 30 I $D(PSGPLREN("B",$G(PSGP),$G(PSJJORD))),$G(PSGPLUP) D 31 .N OSTOP,DRGND S (DDRG,OLDWARD)="" S DRGND=$O(PSGPLREN("B",PSGP,PSJJORD,0)) Q:'DRGND S OSTOP=PSGPLREN("B",PSGP,PSJJORD,DRGND) Q:'OSTOP 32 .N ST,TMPDRG S CNT=0,ST=$P(ND0,"^",7) S TMPDRG=0 S TMPDRG=$O(PSGPLREN("B",PSGP,PSJJORD,TMPDRG)) S TMPDRG=$P(DRG,"^")_"^"_TMPDRG 33 .F PSGPLXRX="AU","AC" Q:CNT F I=0:1 S DDRG=$O(PSGPLREN(53.5,PSGPLXRX,PSGPLG,TM,WDN,RM,PN,PST,TMPDRG,DDRG)) Q:(DDRG="")!(DDRG="NO DISPENSE DRUG") D 34 ..S X=$G(PSGPLREN(53.5,PSGPLG,1,PSGP,1,+DRGND,1,$P(DDRG,"^",2),0)) S DR=+X,DND=$P(X,U,2,4) Q:'X 35 ..S DRN=$G(^PS(55,PSGP,5,PSJJORD,1,DR,0)),DR=$$ENDDN^PSGMI($P(DRN,"^")) I DND?7N1"DI" S DND=$E($$ENDTC^PSGMI(+DND),1,8) 36 ..S DIS=$P(DND,"^",2),NEED=$S($P(DND,"^")]"":$P(DND,"^"),1:0) 37 ..;GMZ;PSJ*5*191;Allow for Multiple Dispensed Drug units needed 38 ..S PSJRNW(I)=1_"^"_+NEED 39 ..Q 40 .K PSGPLREN("B",PSGP,PSJJORD),PSGPLREN(53.5,PSGPLG,1,PSGP,1,+DRGND) W !! 41 ; 42 S CNT=0 43 S (DDRG,OLDWARD)="" N ST S ST=$P(ND0,"^",7) F S DDRG=$O(^PS(53.5,PSGPLXR,PSGPLG,TM,WDN,RM,PN,PST,DRG,DDRG)) Q:(DDRG="")!(DDRG="NO DISPENSE DRUG") S X=$G(^PS(53.5,PSGPLG,1,+$P(PN,U,2),1,+$P(DRG,U,2),1,+$P(DDRG,U,2),0)),DR=+X,DND=$P(X,U,2,4) D 44 .S DRN=$G(^PS(55,PSGP,5,PSJJORD,1,DR,0)),DR=$$ENDDN^PSGMI($P(DRN,"^")) I DND?7N1"DI" S DND=$E($$ENDTC^PSGMI(+DND),1,8) W !?6,DR,?48,ST,?51,"(DI "_DND_")",?66,"Returns: ____" Q 45 .S UD=$P(DRN,"^",2),ATC=$P($G(^PSDRUG(+DRN,8.5)),"^",2)]"" S:ATC ATC=$D(^(212,"AC",PSGPLWG)) 46 .S DIS=$P(DND,"^",2),NEED=$S($P(DND,"^")]"":$P(DND,"^"),1:0) I ATC S ATCFF=+$P($G(^PS(59.7,1,26)),"^",7),ATC=$S(ATCFF:NEED,UD#1:0,DIS]"":+DIS,1:NEED) I ATC,$S(ATC<1:1,ATC'?1.3N:1,1:ATC#1) S ATC=0 47 .I ATC S X=0,X=$O(^PS(59.7,X)) I $P($G(^(X,26)),U,2)=1,PST="OC" S ATC=0 48 .S UD=$S('UD:1,UD=.5:"1/2",UD=.25:"1/4",UD<1:"0"_UD,1:UD) 49 .I $D(PSJRNW) D 50 ..I 'CNT W !?35,"**** RENEWAL ****" 51 ..S NEED=NEED-$P(PSJRNW(CNT),"^",2) S:NEED<0 NEED=0 S CNT=CNT+1 52 .W !?6,DR,?48,ST W:(ATC)&(NEED>0) ?57,"ATC" W ?61,$J(UD,4),?68,$J(NEED,4),?75,$S(DIS]"":$J(DIS,4),1:"____") 53 .S:ST="DISCONTINUED" OLDWARD=1 S ST="" 54 I DDRG="NO DISPENSE DRUG" W !?6,PDRG,?48,ST,?57,"OI" S:ST="DISCONTINUED" OLDWARD=1 S ST="" 55 N GIVSTR S GIVSTR=$S(DO]"":DO_" ",1:"")_RTE_" "_SCH D 56 .N MARX,I,Y,X D TXT^PSGMUTL(GIVSTR,60) 57 .F I=1:1:MARX W:I=1 !?10,"Give: ",MARX(1) W:I>1 !?16,MARX(I) 58 D:OLDWARD WARDCHK W:AT]"" !,?65-$L(AT),AT W !?7,"Start: ",SD,?37,"Stop: ",FD 59 I Y]"" W !?10 F Q=1:1:$L(Y," ") S X=$P(Y," ",Q) W:$X+$L(X)>65 !?10 W X_" " 60 K ST 61 Q 62 ; 63 EXDD ; 64 W ! S (DDRG,OLDWARD)="" F S DDRG=$O(^PS(53.5,PSGPLXR,PSGPLG,TM,WDN,RM,PN,PST,DRG,DDRG)) Q:(DDRG="")!(DDRG="NO DISPENSE DRUG") S DND=^(DDRG) D 65 .S DR=$P(DDRG,"^",2),DRN=$G(^PS(55,PSGP,5,PSJJORD,1,DR,0)),ID=$P(DRN,"^",3),DR=$$ENDDN^PSGMI($P(DRN,"^")) W !?6,DR,?48,DIS,?66,"Returns: ____" S:DIS="DISCONTINUED" OLDWARD=1 S DIS="" 66 I DDRG="NO DISPENSE DRUG" S ND1=$G(^PS(55,PSGP,5,PSJJORD,.2)),PDRG=$$ENPDN^PSGMI($P(ND1,"^")) W !?6,PDRG,?48,DIS,?66,"Returns: ____" S:DIS="DISCONTINUED" OLDWARD=1 S DIS="" 67 W !?10,"Give: ",$S(DO]"":DO_" ",1:""),RTE," ",SCH D:OLDWARD WARDCHK W !?7,"Start: ",SD,?37,"Stop: ",FD 68 Q 69 ; 70 FCL ; 71 I PGN,CML,$P(PSGPLWGP,"^",6) W !!?25,"FILLED BY: ",FACL,!!?25,"CHECKED BY: "_FACL 72 ; 73 HEADER ; 74 S PGN=PGN+1 W:$Y @IOF 75 W ?1,"(",PSGPLG,")",?$S($D(PSGPLUPF):27,1:32),"PICK LIST REPORT" W:$D(PSGPLUPF) " (UPDATE)" W ?64,PPLD,!,"Ward group: ",WGPN,?73-$L(PGN),"Page: ",PGN,!?18,"For ",PSD," through ",PFD W:NPLF !,"Team: ",$S(TM'["zz":TM,1:"** N/F **") 76 W !!,$S($P(TND,"^",6)&'$P(TND,"^",8):"Bed-Room",1:"Room-Bed"),?15,"Patient",?67,"Units",?74,"Units",!?9,"Medication",?48,"ST",?62,"U/D",?66,"Needed",?74,"Disp'd",!,LINE Q 77 ; 78 PAGECK ; 79 S PSGPY=$Y,PSGPY=$Y+4 I PSGPY+4>IOSL W @IOF 80 Q 81 ; 82 WARDCHK ; if patient has discontinued orders from a different ward, print the ward and room/bed that the orders were discontinued from. 83 Q:'$G(STPDT) 84 S VAINDT=$$MINUTES(STPDT,5) 85 S DFN=PSGP D INP^VADPT I PW'=$P(VAIN(4),"^",2) W ?48,$E("(from "_$P(VAIN(4),"^",2)_" "_VAIN(5)_")",1,31) 86 S OLDWARD="" Q 87 ; 88 MINUTES(STPDT,LESS) ; pass in a FM date/time and the number of minutes (9 or less) to subtract from it 89 S VAINDT=$S($E(STPDT,9,12)<LESS:($E(STPDT,1,7)-1)_"."_(($E(STPDT,9,12)+2360)-LESS),$E(STPDT,11,12)<5:$E(STPDT,1,8)_$S($E(STPDT,9,10)="10":"09",$E(STPDT,9,10)="20":"19",1:$E(STPDT,9)_($E(STPDT,10)-1))_(60+$E(STPDT,12)-LESS),1:STPDT-(LESS*.0001)) 90 Q VAINDT 1 PSGPLR ;BIR/CML3-PRINTS PICK LIST REPORT ;04 May 98 / 11:23 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**10,50,67,119,129**;16 DEC 97 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to ^PS(59.7 is supported by DBIA# 2181. 6 ; Reference to ^PSDRUG is supported by DBIA# 2192. 7 ; Reference to ^%DTC is supported by DBIA# 10000. 8 ; Reference to ^VADPT is supported by DBIA# 10061. 9 ; 10 N PSGY,OLDWARD,STPDT D NOW^%DTC S PSGDT=+$E(%,1,12),PPLD=$$ENDTC^PSGMI(PSGDT),$P(OLINE,"-",75)="",PSGPLXR=$S($G(PSGPLUPF)=1:"AU",1:"AC") 11 S PGN=0,(FACL,LINE)="",$P(LINE,"-",81)="",$P(FACL,"_",31)="",TND=$G(^PS(53.5,PSGPLG,0)),PSD=$P(TND,"^",3),PFD=$P(TND,"^",4),WSF=$P(TND,"^",7),WGPN=$S('$D(^PS(57.5,PSGPLWG,0)):"N/F",$P(^(0),"^")]"":$P(^(0),"^"),1:"N/F") 12 S FFF=$S($P(PSGPLWGP,"^",4):2,$P(PSGPLWGP,"^",5):1,1:0),CML=IO'=IO(0)!($E(IOST,1,2)'="C-") 13 F X="PSD","PFD" S @X=$$ENDTC^PSGMI(@X) 14 U IO 15 I '$D(^PS(53.5,$S($D(PSGPLUPF):"AU",1:"AC"),PSGPLG)) S NPLF=0 D HEADER W !!?25,"*** No orders to fill ***" W:(IO'=IO(0)!(IOST'["C-"))&($Y) @IOF G DONE 16 ; 17 BEGIN ; 18 I '$$LOCK^PSGPLUTL(PSGPLG,"PSGPLR") H 60 G BEGIN 19 S NPLF=1,TM=0 F S TM=$O(^PS(53.5,PSGPLXR,PSGPLG,TM)) Q:TM=""!(TM["~") S (DDRG,PDRG,PN,PST,RM,WDN)="" D HEADER:'FFF,^PSGPLR0 I CML,'FFF D PAGECK W !!?25,"FILLED BY: ",FACL,!!?25,"CHECKED BY: ",FACL 20 I CML,FFF D PAGECK W !!?25,"FILLED BY: ",FACL,!!?25,"CHECKED BY: ",FACL W:$Y @IOF 21 ; 22 DONE ; 23 D UNLOCK^PSGPLUTL(PSGPLG,"PSGPLR") 24 K AT,ATC,CML,DDRG,DIS,DND,DO,DR,DRN,DRG,FACL,FD,FFF,FQC,LINE,ND,ND0,ND1,ND2,ND6,NEED,NPLF,OLINE,PSGPLDC,PSGPLXR,PSGPLXRX 25 K PSJJORD,PSJORDN,PFD,PGN,PN,POP,PPLD,PPN,PRM,PSD,PSGID,PSGOD,PSGP,PST,PW,RM,RTE,SCH,SD,SM,PSSN,TD,TM,TND,WDN,WL,WG,WSF,WGPN,X 26 Q 27 ; 28 DD ; 29 N PSJRNW,CNT 30 I $D(PSGPLREN("B",$G(PSGP),$G(PSJJORD))),$G(PSGPLUP) D 31 .N OSTOP,DRGND S (DDRG,OLDWARD)="" S DRGND=$O(PSGPLREN("B",PSGP,PSJJORD,0)) Q:'DRGND S OSTOP=PSGPLREN("B",PSGP,PSJJORD,DRGND) Q:'OSTOP 32 .N ST,TMPDRG S CNT=0,ST=$P(ND0,"^",7) S TMPDRG=0 S TMPDRG=$O(PSGPLREN("B",PSGP,PSJJORD,TMPDRG)) S TMPDRG=$P(DRG,"^")_"^"_TMPDRG 33 .F PSGPLXRX="AU","AC" Q:CNT F S DDRG=$O(PSGPLREN(53.5,PSGPLXRX,PSGPLG,TM,WDN,RM,PN,PST,TMPDRG,DDRG)) Q:(DDRG="")!(DDRG="NO DISPENSE DRUG") D 34 ..S X=$G(PSGPLREN(53.5,PSGPLG,1,PSGP,1,+DRGND,1,$P(DDRG,"^",2),0)) S DR=+X,DND=$P(X,U,2,4) Q:'X 35 ..S DRN=$G(^PS(55,PSGP,5,PSJJORD,1,DR,0)),DR=$$ENDDN^PSGMI($P(DRN,"^")) I DND?7N1"DI" S DND=$E($$ENDTC^PSGMI(+DND),1,8) 36 ..S DIS=$P(DND,"^",2),NEED=$S($P(DND,"^")]"":$P(DND,"^"),1:0) 37 ..S PSJRNW=1_"^"_+NEED 38 ..Q 39 .K PSGPLREN("B",PSGP,PSJJORD),PSGPLREN(53.5,PSGPLG,1,PSGP,1,+DRGND) W !! 40 ; 41 S CNT=0 42 S (DDRG,OLDWARD)="" N ST S ST=$P(ND0,"^",7) F S DDRG=$O(^PS(53.5,PSGPLXR,PSGPLG,TM,WDN,RM,PN,PST,DRG,DDRG)) Q:(DDRG="")!(DDRG="NO DISPENSE DRUG") S X=$G(^PS(53.5,PSGPLG,1,+$P(PN,U,2),1,+$P(DRG,U,2),1,+$P(DDRG,U,2),0)),DR=+X,DND=$P(X,U,2,4) D 43 .S DRN=$G(^PS(55,PSGP,5,PSJJORD,1,DR,0)),DR=$$ENDDN^PSGMI($P(DRN,"^")) I DND?7N1"DI" S DND=$E($$ENDTC^PSGMI(+DND),1,8) W !?6,DR,?48,ST,?51,"(DI "_DND_")",?66,"Returns: ____" Q 44 .S UD=$P(DRN,"^",2),ATC=$P($G(^PSDRUG(+DRN,8.5)),"^",2)]"" S:ATC ATC=$D(^(212,"AC",PSGPLWG)) 45 .S DIS=$P(DND,"^",2),NEED=$S($P(DND,"^")]"":$P(DND,"^"),1:0) I ATC S ATCFF=+$P($G(^PS(59.7,1,26)),"^",7),ATC=$S(ATCFF:NEED,UD#1:0,DIS]"":+DIS,1:NEED) I ATC,$S(ATC<1:1,ATC'?1.3N:1,1:ATC#1) S ATC=0 46 .I ATC S X=0,X=$O(^PS(59.7,X)) I $P($G(^(X,26)),U,2)=1,PST="OC" S ATC=0 47 .S UD=$S('UD:1,UD=.5:"1/2",UD=.25:"1/4",UD<1:"0"_UD,1:UD) 48 .I $G(PSJRNW),'CNT W !?35,"**** RENEWAL ****" S CNT=CNT+1,NEED=NEED-$P(PSJRNW,"^",2) S:NEED<0 NEED=0 49 .W !?6,DR,?48,ST W:(ATC)&(NEED>0) ?57,"ATC" W ?61,$J(UD,4),?68,$J(NEED,4),?75,$S(DIS]"":$J(DIS,4),1:"____") 50 .S:ST="DISCONTINUED" OLDWARD=1 S ST="" 51 I DDRG="NO DISPENSE DRUG" W !?6,PDRG,?48,ST,?57,"OI" S:ST="DISCONTINUED" OLDWARD=1 S ST="" 52 N GIVSTR S GIVSTR=$S(DO]"":DO_" ",1:"")_RTE_" "_SCH D 53 .N MARX,I,Y,X D TXT^PSGMUTL(GIVSTR,60) 54 .F I=1:1:MARX W:I=1 !?10,"Give: ",MARX(1) W:I>1 !?16,MARX(I) 55 D:OLDWARD WARDCHK W:AT]"" !,?65-$L(AT),AT W !?7,"Start: ",SD,?37,"Stop: ",FD 56 I Y]"" W !?10 F Q=1:1:$L(Y," ") S X=$P(Y," ",Q) W:$X+$L(X)>65 !?10 W X_" " 57 K ST 58 Q 59 ; 60 EXDD ; 61 W ! S (DDRG,OLDWARD)="" F S DDRG=$O(^PS(53.5,PSGPLXR,PSGPLG,TM,WDN,RM,PN,PST,DRG,DDRG)) Q:(DDRG="")!(DDRG="NO DISPENSE DRUG") S DND=^(DDRG) D 62 .S DR=$P(DDRG,"^",2),DRN=$G(^PS(55,PSGP,5,PSJJORD,1,DR,0)),ID=$P(DRN,"^",3),DR=$$ENDDN^PSGMI($P(DRN,"^")) W !?6,DR,?48,DIS,?66,"Returns: ____" S:DIS="DISCONTINUED" OLDWARD=1 S DIS="" 63 I DDRG="NO DISPENSE DRUG" S ND1=$G(^PS(55,PSGP,5,PSJJORD,.2)),PDRG=$$ENPDN^PSGMI($P(ND1,"^")) W !?6,PDRG,?48,DIS,?66,"Returns: ____" S:DIS="DISCONTINUED" OLDWARD=1 S DIS="" 64 W !?10,"Give: ",$S(DO]"":DO_" ",1:""),RTE," ",SCH D:OLDWARD WARDCHK W !?7,"Start: ",SD,?37,"Stop: ",FD 65 Q 66 ; 67 FCL ; 68 I PGN,CML,$P(PSGPLWGP,"^",6) W !!?25,"FILLED BY: ",FACL,!!?25,"CHECKED BY: "_FACL 69 ; 70 HEADER ; 71 S PGN=PGN+1 W:$Y @IOF 72 W ?1,"(",PSGPLG,")",?$S($D(PSGPLUPF):27,1:32),"PICK LIST REPORT" W:$D(PSGPLUPF) " (UPDATE)" W ?64,PPLD,!,"Ward group: ",WGPN,?73-$L(PGN),"Page: ",PGN,!?18,"For ",PSD," through ",PFD W:NPLF !,"Team: ",$S(TM'["zz":TM,1:"** N/F **") 73 W !!,$S($P(TND,"^",6)&'$P(TND,"^",8):"Bed-Room",1:"Room-Bed"),?15,"Patient",?67,"Units",?74,"Units",!?9,"Medication",?48,"ST",?62,"U/D",?66,"Needed",?74,"Disp'd",!,LINE Q 74 ; 75 PAGECK ; 76 S PSGPY=$Y,PSGPY=$Y+4 I PSGPY+4>IOSL W @IOF 77 Q 78 ; 79 WARDCHK ; if patient has discontinued orders from a different ward, print the ward and room/bed that the orders were discontinued from. 80 Q:'$G(STPDT) 81 S VAINDT=$$MINUTES(STPDT,5) 82 S DFN=PSGP D INP^VADPT I PW'=$P(VAIN(4),"^",2) W ?48,$E("(from "_$P(VAIN(4),"^",2)_" "_VAIN(5)_")",1,31) 83 S OLDWARD="" Q 84 ; 85 MINUTES(STPDT,LESS) ; pass in a FM date/time and the number of minutes (9 or less) to subtract from it 86 S VAINDT=$S($E(STPDT,9,12)<LESS:($E(STPDT,1,7)-1)_"."_(($E(STPDT,9,12)+2360)-LESS),$E(STPDT,11,12)<5:$E(STPDT,1,8)_$S($E(STPDT,9,10)="10":"09",$E(STPDT,9,10)="20":"19",1:$E(STPDT,9)_($E(STPDT,10)-1))_(60+$E(STPDT,12)-LESS),1:STPDT-(LESS*.0001)) 87 Q VAINDT -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGS0.m
r613 r623 1 PSGS0 ;BIR/CML3-SCHEDULE PROCESSOR ;29 Jan 99 / 8:04 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**12,25,26,50,63,74,83,116,110,111,133,138,174,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(51.1 is supported by DBIA 2177 5 ; Reference to ^PS(55 is supported by DBIA 2191 6 ; 7 ENA ; entry point for train option 8 D ENCV^PSGSETU Q:$D(XQUIT) 9 F S (PSGS0Y,PSGS0XT)="" R !!,"Select STANDARD SCHEDULE: ",X:DTIME W:'$T $C(7) S:'$T X="^" Q:"^"[X D:X?1."?" ENQ^PSGSH I X'?1."?" D EN W:$D(X)[0 $C(7)," ??" I $D(X)#2,'PSGS0Y,PSGS0XT W " Every ",PSGS0XT," minutes" 10 K DIC,DIE,PSGS0XT,PSGS0Y,Q,X,Y,PSGDT Q 11 ; 12 EN3 ; 13 S PSGST=$P($G(^PS(53.1,DA,0)),"^",7) G EN 14 ; 15 EN5 ; 16 S PSGST=$P($G(^PS(55,DA(1),5,DA,0)),"^",7) 17 ; 18 EN ; validate 19 K PSGS0Y 20 I X[""""!($A(X)=45)!(X?.E1C.E)!($L(X)>70)!($L(X)<1) K X Q 21 S X=$$TRIM^XLFSTR(X,"R"," ") 22 I X?.E1L.E S X=$$ENLU^PSGMI(X) I '$D(PSGOES) D EN^DDIOL(" ("_X_")") 23 ; 24 ENOS ; order set entry 25 N X0,Y0,PSJXI,PSJDIC2,TMPAT 26 I $G(X)="",$G(P(2)),$G(P(3)) S X=$G(P(9)) 27 I $G(X)="" Q 28 S PSGXT=$G(PSGS0XT),(PSGS0XT,PSGS0Y,XT,Y,PSJNSS)="" 29 S X0=X I X?2.4N1"-".E!(X?2.4N) D ENCHK S:$D(X) Y=X G Q 30 ; * GUI 27 CHANGES * Check for admin times to be derived from 'base' schedule 31 I X["@" S TMPAT=$P(X,"@",2) I TMPAT]"" D 32 .I '$D(^PS(51.1,"AC","PSJ",TMPAT)) K TMPAT Q 33 .I '$$DOW^PSIVUTL($P(X,"@")) K TMPAT Q 34 .N LYN,ZZND,PSGS0XT,PSGS0Y,X S (PSGS0Y,PSGS0XT,X)="" 35 .S X=TMPAT D DIC I $G(Y0)>0 S TMPAT=Y0 36 I $G(TMPAT) S (PSGS0Y,$P(X,"@",2))=TMPAT,PSGS0XT="D" 37 ; * GUI 27 CHANGES * 38 I X["PRN",$$PRNOK(X),'$D(^PS(51.1,"AC","PSJ",X)) D G Q 39 .I X["@"!$$DOW^PSIVUTL($P(X," PRN")) N DOW D I $G(DOW) S (Y0,Y,PSGS0Y)=$P($P(X,"@",2)," ") 40 ..N TMP S TMP=X N X S X=$P(TMP," PRN") D DW I $G(X)]"" S DOW=1 41 ..I $G(DOW),$G(PSGST)]"" I ",P,R,"'[(","_PSGST_",") S (XT,PSGS0XT)="D" 42 D DIC I $G(XT)]""!$G(Y0)!($G(X)]""&$G(PSJXI)) D I $G(X)]"" G:$D(^PS(51.1,"AC","PSJ",X)) Q3 I $P(X,"@")]"" G:$D(^PS(51.1,"AC","PSJ",$P(X,"@"))) Q3 43 .S PSGS0XT=XT S:$G(Y0) (Y,PSGS0Y)=Y0 S:'PSGS0Y&((PSGS0XT)="D")&(X["@") PSGS0Y=$P(X,"@",2) 44 .S PSGS0Y=$P(PSGS0Y," ") 45 N TMPSCHX S TMPSCHX=X I $L(X,"@")<3 S TMPX=X D DW I $G(X)]"" K PSJNSS S (PSGS0XT,XT)="D" D G Q 46 .S Y=$S(($G(TMPSCHX)["@"):$P(TMPSCHX,"@",2),1:"") 47 .I Y,(X'["@"),(TMPSCHX["@") S X=TMPSCHX 48 S X=TMPSCHX 49 I X'="" I $D(^PS(51.1,"AC","PSJ",X)) K PSJNSS G Q 50 ; 51 NS I ($G(X)="^")!($G(X)="") K X S Y="" Q 52 N NS S NS=0,PSJNSS=0 53 I $G(Y)'>0 S X=X0,Y="",NS=1,PSJNSS=1 54 Q ; 55 S PSGS0XT=$S(XT]"":XT,1:$G(PSGS0XT)),PSGS0Y=$S($G(Y):Y,$G(PSGS0Y):PSGS0Y,1:"") S:PSGS0XT<0 PSGS0XT="" 56 I ('$G(PSGS0Y)&'$G(PSJDIC2)&$G(PSGAT))&'$G(PSJNEWOE)&$G(PSGS0XT) I PSGS0XT<1441 I ($L($G(PSGAT),"-")=PSGS0XT/1440)!($G(X)]""&($G(PSGSCH)=$G(X))) S PSGS0Y=$G(PSGAT) 57 Q2 K YY 58 I '$G(PSJNSS),'$G(PSGS0Y),$G(YY) S PSGS0Y=YY 59 I $G(X)]"",$$SCHREQ^PSJLIVFD(.P) D 60 .I $$DOW^PSIVUTL(X)!$$PRNOK(X)!$D(^PS(51.1,"AC","PSJ",X)) S PSJNSS=0 Q 61 .I $G(P(2))&$G(P(3)) D NSSCONT(X,PSGS0XT) S TMPX="" K X 62 I ($G(PSJNSS)&($G(VALMBCK)'="Q"))!($G(PSJNSS)&$G(PSJLIFNI))!($G(PSJNSS)&$G(PSJTUD)) D 63 .I $G(P(2))&$G(P(3)) Q 64 .I ($G(X)]"") I ($G(PSGS0XT)'="D") D NSSCONT(X,PSGS0XT) S TMPX="" K X 65 Q3 I $G(X)]"" I $D(^PS(51.1,"AC","PSJ",X)) K PSJNSS 66 K QX,SDW,SWD,X0,XT,Z Q 67 ; 68 NSSCONT(SCH,FREQ) ; 69 Q:SCH=""!($G(VALMBCK)]"")!$G(PSGMARSD)!$G(PSIVFN1) 70 I $G(PSGOES),'$G(NSFF) Q 71 N PSGS0XT,PSGSCH,DIR,X,Y S PSGSCH=SCH,PSGS0XT=FREQ,PSJNSS=1 72 D NSSMSG I ($L(PSJNSS)>2),'$G(PSJXI) W !!,PSJNSS,! S PSJNSS=1 73 S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR 74 K NSFF Q 75 ; 76 NSSMSG ; 77 Q:$G(PSJXI) 78 I '(",O,"[(","_$G(PSGST)_",")),$G(PSJNSS),$G(PSGSCH)]"" D 79 .S PSJNSS=" WARNING - "_PSGSCH_" is an invalid schedule." 80 S PSGSCH="",PSGS0XT="" 81 Q 82 ; 83 NSO(FQ) ; 84 Q:'FQ!(FQ<0)!(",D,O,"[(","_$G(PSGST)_",")) "" 85 K FRQOUT S FRQOUT=$S(FQ<60:(FQ_"minute"),(FQ<1440)&(FQ#60):(FQ_" minute"),(FQ<1440)!(FQ#1440):(FQ/60_" hour"),1:(FQ/1440_" day")) D 86 . S:(+FRQOUT'=1) FRQOUT=FRQOUT_"s" 87 Q FRQOUT 88 ; 89 ENCHK ; 90 I $S($L($P(X,"-"))>4:1,$L(X)>119:1,$L(X)<2:1,X'>0:1,1:X'?.ANP) K X Q 91 S X(1)=$P(X,"-") I X(1)'?2N,X(1)'?4N K X Q 92 S X(1)=$L(X(1)) I X'["-"&((X>$E(2400,1,X(1))!($E(X,3,4)>59))) K X Q 93 F X(2)=2:1:$L(X,"-") S X(3)=$P(X,"-",X(2)) I $S($L(X(3))'=X(1):1,X(3)>$E(2400,1,X(1)):1,$E(X(3),3,4)>59:1,1:X(3)'>$P(X,"-",X(2)-1)) K X Q 94 K:$D(X) X(1),X(2),X(3) Q 95 ; 96 DIC ; Check for schedule's existence in ADMINISTRATION SCHEDULE file (#51.1) 97 ; Input: 98 ; X = Schedule Name 99 ; PSJSLUP = If $G(PSJSLUP), perform interactive fileman lookup (optional). 100 ; PSGSFLG = If $G(PSGSFLG), return schedule IEN in PSGSCIEN variable (optional) 101 ; PSJLIFNI = Flag indicating a U/D order is being finished as an IV (optional). 102 ; PSGOES = If PSGOES=1, IX^DIC is called silently. If PSGOES=2, IX^DIC is not called (optional). 103 ; PSJPWD = IEN of Inpatient Ward associated with the patient/order/schedule combination (optional). 104 ; Output: 105 ; X = Schedule Name if valid Input Schedule X, undefined if invalid Input Schedule X. 106 ; PSGS0XT = Frequency of validated schedule. 107 ; PSGS0Y = Default Admin Times of validated schedule. 108 ; PSGSCIEN = IEN of validated schedule, if PSGSLFG is passed in and is evaluated to TRUE. 109 ; 110 ; 111 K Y0,PSJXI N Y 112 S Z=0 F PSJXI=0:1 S Z=$O(^PS(51.1,"AC","PSJ",X,Z)) Q:'Z 113 I $G(X)]"",'$G(PSJSLUP) D 114 .I $D(^PS(51.1,"AC","PSJ",X)) D Q:$G(PSGS0Y)&($G(PSGS0XT)]"") 115 ..I $$DOW^PSIVUTL(X) S PSGS0XT="D",PSJNSS=0 S:X["@" (Y0,PSGS0Y)=$P(X,"@",2) Q 116 ..I $G(NSFF) S Y0=$S($G(PSGS0Y):PSGS0Y,$G(PSGAT)&'$G(PSJNEWOE):PSGAT,1:"") S:Y0 PSGS0Y=Y0 117 .; Check for duplicate schedules - force selection 118 .Q:PSJXI>1&('$G(PSGOES))&($G(PSGS0XT)]"") 119 .I $D(^PS(51.1,"AC","PSJ",X)) N FREQ,ADMATCH S FREQ=$G(PSGS0XT) D 120 ..N PSGS0XT,PSGS0Y,PSGST D ADMIN^PSJORPOE S:$G(PSGS0XT) XT=PSGS0XT S:$G(PSGS0Y) (Y0,Y)=PSGS0Y 121 ..;Check flag PSGSFLG to determine whether to return the schedule IEN in PSGSCIEN. 122 .S:$G(XT)]"" PSGS0XT=XT S:$G(Y) PSGS0Y=Y 123 .I $$DOW^PSIVUTL(X) S:PSGS0XT="" (XT,PSGS0XT)="D" S:PSGS0Y="" (Y0,PSGS0Y)=$S($P(X,"@",2):$P(X,"@",2),1:"") 124 I $G(PSJLIFNI)!($G(P(4))]""&($G(P(2))]"")) I '$D(^PS(51.1,"AC","PSJ",X))!($G(PSJXI)>1) S PSJSLUP=1 125 I $G(NSFF),$G(PSJXI)>1 D 126 .I $G(PSGS0XT)="",$G(NSFF),$G(PSGXT)]"" S PSGS0XT=PSGXT Q 127 .I $G(PSGS0XT)=""!($G(PSGS0Y)="") S PSJSLUP=1 128 I '$G(PSJSLUP) Q:$G(PSGS0XT)]""&($G(PSGS0Y)]"") Q:($G(PSGS0XT)="D"&('$D(^PS(51.1,"AC","PSJ",X)))) 129 Q:$G(PSGOES)=2 130 Q:$G(PSGS0XT)]""&(PSJXI=1) 131 K PSJSLUP 132 ; 133 K DIC S DIC="^PS(51.1,",DIC(0)=$E("E",'$D(PSGOES))_"ISZ",DIC("W")="W "" "","_$S('$D(PSJPWD):"$P(^(0),""^"",2)",'PSJPWD:"$P(^(0),""^"",2)",1:"$S($D(^PS(51.1,+Y,1,+PSJPWD,0)):$P(^(0),""^"",2),1:$P(^PS(51.1,+Y,0),""^"",2))"),D="APPSJ" 134 I $D(PSGST) ;S DIC("S")="I $P(^(0),""^"",5)"_$E("'",PSGST'="O")_"=""O""" 135 S PSJDIC2=1 136 D IX^DIC K DIC S:$D(DIE)#2 DIC=DIE I Y'>0 D Q 137 .I '$$DOW^PSIVUTL(X),'$$PRNOK(X) S X="",PSJNSS=1,XT="",PSJXI="" 138 S XT=$S("C"[$P(Y(0),"^",5):$P(Y(0),"^",3),1:$P(Y(0),"^",5)) 139 S X=+Y,Y="" I $D(PSJPWD),$D(^PS(51.1,+X,1,+PSJPWD,0)) S Y=$P(^(0),"^",2) 140 ;Check flag PSGSFLG to determine whether to return the schedule IEN in PSGSCIEN. 141 I $G(PSGSFLG) S PSGSCIEN=X 142 S (X,X0)=Y(0,0) S:$G(Y)="" Y=$P(Y(0),"^",2) 143 S (PSGS0Y,Y0)=$G(Y),Y0(0)=Y(0) I $P(Y(0),"^",3) S XT=$P(Y(0),"^",3) 144 I $G(PSGS0XT)="",$$DOW^PSIVUTL(X) S (XT,PSGS0XT)="D" 145 Q 146 ; 147 DW ; 148 N Y 149 Q:($L(X,"@")>2) 150 N AT I X["@" S AT=$P(X,"@",2) 151 S SWD="SUNDAYS^MONDAYS^TUESDAYS^WEDNESDAYS^THURSDAYS^FRIDAYS^SATURDAYS",SDW=X,X=$P(X,"@",2) N XABB S XABB="" 152 I X]"" D ENCHK Q:'$D(X) 153 S X=$P(SDW,"@"),X(1)="-" I X?.E1P.E,X'["-" ;F QX=1:1:$L(X) I $E(X,QX)?1P S X(1)=$E(X,QX) Q 154 F Q=1:1:$L(X,X(1)) K:SWD="" X Q:SWD="" S Z=$P(X,X(1),Q) D DWC Q:'$D(X) 155 I $D(X) F II=1:1:$L(X,X(1)) S XABB=$G(XABB)_$E($P(X,X(1),II),1,2)_"-" 156 K X(1) S:$D(X) X=SDW I $G(X)]"" I $TR(XABB,"-")]"" S X=$E($G(XABB),1,$L(XABB)-1) 157 I $G(AT) S PSGS0Y=AT 158 Q 159 DWC I $L(Z)<2 K X Q 160 F QX=1:1:$L(SWD,"^") S Y=$P(SWD,"^",QX) I $P(Y,Z)="" S SWD=$P(SWD,Y,2) S:$L(SWD) SWD=$E(SWD,2,50) Q 161 E K X 162 Q 163 ; 164 PRNOK(PSCH) ; 165 Q:PSCH'["PRN" 0 166 I $TR(PSCH," ")="PRN" Q 1 167 N BASE,I,OK S OK=0 S I=$P(PSCH," PRN") I I]"",$D(^PS(51.1,"AC","PSJ",I)) S OK=1 168 I 'OK D 169 .I PSCH["@" I $D(^PS(51.1,"AC","PSJ",$P(PSCH,"@")))!$$DOW^PSIVUTL($P(PSCH,"@")) S OK=1 Q 170 .I $$DOW^PSIVUTL($P(PSCH," PRN")) S OK=1 171 Q OK 172 ODD(PSF) ;determine if this is an odd schedule 173 I PSF>1439,PSF#1440 Q 1 174 I PSF,PSF<1440,1440#PSF Q 1 175 Q 0 1 PSGS0 ;BIR/CML3-SCHEDULE PROCESSOR ;29 Jan 99 / 8:04 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**12,25,26,50,63,74,83,116,110,111,133,138,174**;16 DEC 97 3 ; 4 ; Reference to ^PS(51.1 is supported by DBIA 2177 5 ; Reference to ^PS(55 is supported by DBIA 2191 6 ; 7 ENA ; entry point for train option 8 D ENCV^PSGSETU Q:$D(XQUIT) 9 F S (PSGS0Y,PSGS0XT)="" R !!,"Select STANDARD SCHEDULE: ",X:DTIME W:'$T $C(7) S:'$T X="^" Q:"^"[X D:X?1."?" ENQ^PSGSH I X'?1."?" D EN W:$D(X)[0 $C(7)," ??" I $D(X)#2,'PSGS0Y,PSGS0XT W " Every ",PSGS0XT," minutes" 10 K DIC,DIE,PSGS0XT,PSGS0Y,Q,X,Y,PSGDT Q 11 ; 12 EN3 ; 13 S PSGST=$P($G(^PS(53.1,DA,0)),"^",7) G EN 14 ; 15 EN5 ; 16 S PSGST=$P($G(^PS(55,DA(1),5,DA,0)),"^",7) 17 ; 18 EN ; validate 19 K PSGS0Y 20 I X[""""!($A(X)=45)!(X?.E1C.E)!($L(X)>70)!($L(X)<1) K X Q 21 S X=$$TRIM^XLFSTR(X,"R"," ") 22 I X?.E1L.E S X=$$ENLU^PSGMI(X) I '$D(PSGOES) D EN^DDIOL(" ("_X_")") 23 ; 24 ENOS ; order set entry 25 N X0,Y0,PSJXI,PSJDIC2 26 I $G(X)="",$G(P(2)),$G(P(3)) S X=$G(P(9)) 27 I $G(X)="" Q 28 S PSGXT=$G(PSGS0XT),(PSGS0XT,PSGS0Y,XT,Y,PSJNSS)="" 29 S X0=X I X?2.4N1"-".E!(X?2.4N) D ENCHK S:$D(X) Y=X G Q 30 I X["PRN",$$PRNOK(X),'$D(^PS(51.1,"AC","PSJ",X)) D G Q 31 .I X["@"!$$DOW^PSIVUTL($P(X," PRN")) N DOW D I $G(DOW) S (Y0,Y,PSGS0Y)=$P($P(X,"@",2)," ") 32 ..N TMP S TMP=X N X S X=$P(TMP," PRN") D DW I $G(X)]"" S DOW=1 33 ..I $G(DOW),$G(PSGST)]"" I ",P,R,"'[(","_PSGST_",") S (XT,PSGS0XT)="D" 34 D DIC I $G(XT)]""!$G(Y0)!($G(X)]""&$G(PSJXI)) D I $G(X)]"" G:$D(^PS(51.1,"AC","PSJ",X)) Q3 I $P(X,"@")]"" G:$D(^PS(51.1,"AC","PSJ",$P(X,"@"))) Q3 35 .S PSGS0XT=XT S:$G(Y0) (Y,PSGS0Y)=Y0 S:'PSGS0Y&((PSGS0XT)="D")&(X["@") PSGS0Y=$P(X,"@",2) 36 .S PSGS0Y=$P(PSGS0Y," ") 37 N TMPSCHX S TMPSCHX=X I $L(X,"@")<3 S TMPX=X D DW I $G(X)]"" K PSJNSS S (PSGS0XT,XT)="D" D G Q 38 .S Y=$S(($G(TMPSCHX)["@"):$P(TMPSCHX,"@",2),1:"") 39 .I Y,(X'["@"),(TMPSCHX["@") S X=TMPSCHX 40 S X=TMPSCHX 41 I X'="" I $D(^PS(51.1,"AC","PSJ",X)) K PSJNSS G Q 42 ; 43 NS I ($G(X)="^")!($G(X)="") K X S Y="" Q 44 N NS S NS=0,PSJNSS=0 45 I $G(Y)'>0 S X=X0,Y="",NS=1,PSJNSS=1 46 Q ; 47 S PSGS0XT=$S(XT]"":XT,1:$G(PSGS0XT)),PSGS0Y=$S($G(Y):Y,$G(PSGS0Y):PSGS0Y,1:"") S:PSGS0XT<0 PSGS0XT="" 48 I ('$G(PSGS0Y)&'$G(PSJDIC2)&$G(PSGAT))&'$G(PSJNEWOE)&$G(PSGS0XT) I PSGS0XT<1441 I ($L($G(PSGAT),"-")=PSGS0XT/1440)!($G(X)]""&($G(PSGSCH)=$G(X))) S PSGS0Y=$G(PSGAT) 49 Q2 K YY 50 I '$G(PSJNSS),'$G(PSGS0Y),$G(YY) S PSGS0Y=YY 51 I $G(X)]"",$$SCHREQ^PSJLIVFD(.P) D 52 .I $$DOW^PSIVUTL(X)!$$PRNOK(X)!$D(^PS(51.1,"AC","PSJ",X)) S PSJNSS=0 Q 53 .I $G(P(2))&$G(P(3)) D NSSCONT(X,PSGS0XT) S TMPX="" K X 54 I ($G(PSJNSS)&($G(VALMBCK)'="Q"))!($G(PSJNSS)&$G(PSJLIFNI))!($G(PSJNSS)&$G(PSJTUD)) D 55 .I $G(P(2))&$G(P(3)) Q 56 .I ($G(X)]"") I ($G(PSGS0XT)'="D") D NSSCONT(X,PSGS0XT) S TMPX="" K X 57 Q3 I $G(X)]"" I $D(^PS(51.1,"AC","PSJ",X)) K PSJNSS 58 K QX,SDW,SWD,X0,XT,Z Q 59 ; 60 NSSCONT(SCH,FREQ) ; 61 Q:SCH=""!($G(VALMBCK)]"")!$G(PSGMARSD)!$G(PSIVFN1) 62 I $G(PSGOES),'$G(NSFF) Q 63 N PSGS0XT,PSGSCH,DIR,X,Y S PSGSCH=SCH,PSGS0XT=FREQ,PSJNSS=1 64 D NSSMSG I ($L(PSJNSS)>2),'$G(PSJXI) W !!,PSJNSS,! S PSJNSS=1 65 S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR 66 K NSFF Q 67 ; 68 NSSMSG ; 69 Q:$G(PSJXI) 70 I '(",O,"[(","_$G(PSGST)_",")),$G(PSJNSS),$G(PSGSCH)]"" D 71 .S PSJNSS=" WARNING - "_PSGSCH_" is an invalid schedule." 72 S PSGSCH="",PSGS0XT="" 73 Q 74 ; 75 NSO(FQ) ; 76 Q:'FQ!(FQ<0)!(",D,O,"[(","_$G(PSGST)_",")) "" 77 K FRQOUT S FRQOUT=$S(FQ<60:(FQ_"minute"),(FQ<1440)&(FQ#60):(FQ_" minute"),(FQ<1440)!(FQ#1440):(FQ/60_" hour"),1:(FQ/1440_" day")) D 78 . S:(+FRQOUT'=1) FRQOUT=FRQOUT_"s" 79 Q FRQOUT 80 ; 81 ENCHK ; 82 I $S($L($P(X,"-"))>4:1,$L(X)>119:1,$L(X)<2:1,X'>0:1,1:X'?.ANP) K X Q 83 S X(1)=$P(X,"-") I X(1)'?2N,X(1)'?4N K X Q 84 S X(1)=$L(X(1)) I X'["-"&((X>$E(2400,1,X(1))!($E(X,3,4)>59))) K X Q 85 F X(2)=2:1:$L(X,"-") S X(3)=$P(X,"-",X(2)) I $S($L(X(3))'=X(1):1,X(3)>$E(2400,1,X(1)):1,$E(X(3),3,4)>59:1,1:X(3)'>$P(X,"-",X(2)-1)) K X Q 86 K:$D(X) X(1),X(2),X(3) Q 87 ; 88 DIC ; 89 K Y0,PSJXI N Y 90 S Z=0 F PSJXI=0:1 S Z=$O(^PS(51.1,"AC","PSJ",X,Z)) Q:'Z 91 I $G(X)]"",'$G(PSJSLUP) D 92 .I $D(^PS(51.1,"AC","PSJ",X)) D Q:$G(PSGS0Y)&($G(PSGS0XT)]"") 93 ..I $$DOW^PSIVUTL(X) S PSGS0XT="D",PSJNSS=0 S:X["@" (Y0,PSGS0Y)=$P(X,"@",2) Q 94 ..I $G(NSFF) S Y0=$S($G(PSGS0Y):PSGS0Y,$G(PSGAT)&'$G(PSJNEWOE):PSGAT,1:"") S:Y0 PSGS0Y=Y0 95 .; Check for duplicate schedules - force selection 96 .Q:PSJXI>1&('$G(PSGOES))&($G(PSGS0XT)]"") 97 .I $D(^PS(51.1,"AC","PSJ",X)) N FREQ,ADMATCH S FREQ=PSGS0XT D 98 ..N PSGS0XT,PSGS0Y,PSGST D ADMIN^PSJORPOE S:$G(PSGS0XT) XT=PSGS0XT S:$G(PSGS0Y) (Y0,Y)=PSGS0Y 99 .S:$G(XT)]"" PSGS0XT=XT S:$G(Y) PSGS0Y=Y 100 .I $$DOW^PSIVUTL(X) S:PSGS0XT="" (XT,PSGS0XT)="D" S:PSGS0Y="" (Y0,PSGS0Y)=$S($P(X,"@",2):$P(X,"@",2),1:"") 101 I $G(PSJLIFNI)!($G(P(4))]""&($G(P(2))]"")) I '$D(^PS(51.1,"AC","PSJ",X))!($G(PSJXI)>1) S PSJSLUP=1 102 I $G(NSFF),$G(PSJXI)>1 D 103 .I $G(PSGS0XT)="",$G(NSFF),$G(PSGXT)]"" S PSGS0XT=PSGXT Q 104 .I $G(PSGS0XT)=""!($G(PSGS0Y)="") S PSJSLUP=1 105 I '$G(PSJSLUP) Q:$G(PSGS0XT)]""&($G(PSGS0Y)]"") Q:($G(PSGS0XT)="D"&('$D(^PS(51.1,"AC","PSJ",X)))) 106 Q:$G(PSGOES)=2 107 Q:$G(PSGS0XT)]""&(PSJXI=1) 108 K PSJSLUP 109 ; 110 K DIC S DIC="^PS(51.1,",DIC(0)=$E("E",'$D(PSGOES))_"ISZ",DIC("W")="W "" "","_$S('$D(PSJPWD):"$P(^(0),""^"",2)",'PSJPWD:"$P(^(0),""^"",2)",1:"$S($D(^PS(51.1,+Y,1,+PSJPWD,0)):$P(^(0),""^"",2),1:$P(^PS(51.1,+Y,0),""^"",2))"),D="APPSJ" 111 I $D(PSGST) ;S DIC("S")="I $P(^(0),""^"",5)"_$E("'",PSGST'="O")_"=""O""" 112 S PSJDIC2=1 113 D IX^DIC K DIC S:$D(DIE)#2 DIC=DIE I Y'>0 D Q 114 .I '$$DOW^PSIVUTL(X),'$$PRNOK(X) S X="",PSJNSS=1,XT="",PSJXI="" 115 S XT=$S("C"[$P(Y(0),"^",5):$P(Y(0),"^",3),1:$P(Y(0),"^",5)) 116 S X=+Y,Y="" I $D(PSJPWD),$D(^PS(51.1,+X,1,+PSJPWD,0)) S Y=$P(^(0),"^",2) 117 S (X,X0)=Y(0,0) S:$G(Y)="" Y=$P(Y(0),"^",2) 118 S (PSGS0Y,Y0)=$G(Y),Y0(0)=Y(0) I $P(Y(0),"^",3) S XT=$P(Y(0),"^",3) 119 I $G(PSGS0XT)="",$$DOW^PSIVUTL(X) S (XT,PSGS0XT)="D" 120 Q 121 ; 122 DW ; 123 N Y 124 Q:($L(X,"@")>2) 125 N AT I X["@" S AT=$P(X,"@",2) 126 S SWD="SUNDAYS^MONDAYS^TUESDAYS^WEDNESDAYS^THURSDAYS^FRIDAYS^SATURDAYS",SDW=X,X=$P(X,"@",2) N XABB S XABB="" 127 I X]"" D ENCHK Q:'$D(X) 128 S X=$P(SDW,"@"),X(1)="-" I X?.E1P.E,X'["-" ;F QX=1:1:$L(X) I $E(X,QX)?1P S X(1)=$E(X,QX) Q 129 F Q=1:1:$L(X,X(1)) K:SWD="" X Q:SWD="" S Z=$P(X,X(1),Q) D DWC Q:'$D(X) 130 I $D(X) F II=1:1:$L(X,X(1)) S XABB=$G(XABB)_$E($P(X,X(1),II),1,2)_"-" 131 K X(1) S:$D(X) X=SDW I $G(X)]"" I $TR(XABB,"-")]"" S X=$E($G(XABB),1,$L(XABB)-1) 132 I $G(AT) S PSGS0Y=AT 133 Q 134 DWC I $L(Z)<2 K X Q 135 F QX=1:1:$L(SWD,"^") S Y=$P(SWD,"^",QX) I $P(Y,Z)="" S SWD=$P(SWD,Y,2) S:$L(SWD) SWD=$E(SWD,2,50) Q 136 E K X 137 Q 138 ; 139 PRNOK(PSCH) ; 140 Q:PSCH'["PRN" 0 141 I $TR(PSCH," ")="PRN" Q 1 142 N BASE,I,OK S OK=0 S I=$P(PSCH," PRN") I I]"",$D(^PS(51.1,"AC","PSJ",I)) S OK=1 143 I 'OK D 144 .I PSCH["@" I $D(^PS(51.1,"AC","PSJ",$P(PSCH,"@")))!$$DOW^PSIVUTL($P(PSCH,"@")) S OK=1 Q 145 .I $$DOW^PSIVUTL($P(PSCH," PRN")) S OK=1 146 Q OK 147 ODD(PSF) ;determine if this is an odd schedule 148 I PSF>1439,PSF#1440 Q 1 149 I PSF,PSF<1440,1440#PSF Q 1 150 Q 0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGSICHK.m
r613 r623 1 PSGSICHK ;BIR/CML3-CHECKS SPECIAL INSTRUCTIONS ;17 Aug 98 / 8:33 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**3,9,26,29,44,49,59,110,139,146,160,175,201,185**;16 DEC 97;Build 6 3 ; 4 ; Reference to ^PS(50.605 is supported by DBIA 696. 5 ; Reference to EN^PSOORDRG is supported by DBIA 2190. 6 ; Reference to ^PSI(58.1 is supported by DBIA 2284. 7 ; Reference to ^PSDRUG( is supported by DBIA 2192. 8 ; Reference to ^PSD(58.8 is supported by DBIA 2283. 9 ; Reference to ^PS(55 is supported by DBIA 2191. 10 ; Reference to ^PS(51.2 is supported by DBIA 2178. 11 ; Reference to ^PS(51 is supported by DBIA 2176. 12 ; Reference to ^ORRDI1 is supported by DBIA 4659. 13 ; Reference to ^XTMP("ORRDI" is supported by DBIA 4660. 14 ; Reference to GETDATA^GMRAOR supported by DBIA 4847. 15 ; Reference to ^TMP("GMRAOC" supported by DBIA 4848. 16 ; 17 START ; 18 I $S(X'?.ANP:1,X["^":1,1:$L(X)>180) K X Q 19 S Y="" F Y(1)=1:1:$L(X," ") S Y(2)=$P(X," ",Y(1)) I Y(2)]"" D CHK Q:'$D(X) 20 I $D(X),Y]"",X'=$E(Y,1,$L(Y)-1) D EN^DDIOL("EXPANDS TO: ") W Y F Y(1)=1:1 S Y(2)=$P(Y," ",Y(1)) Q:Y(2)="" D:$L(Y(2))+$X>78 EN^DDIOL(Y(2)_" ") 21 Q 22 ; 23 CHK ; 24 I $L(Y(2))<31,$D(^PS(51,+$O(^PS(51,"B",Y(2),0)),0)),$P(^(0),"^",2)]"",$P(^(0),"^",4) S Y(2)=$P(^(0),"^",2) 25 I $L(Y)+$L(Y(2))>180 K X Q 26 S Y=Y_Y(2)_" " Q 27 ; 28 ENSET(X) ; expands the SPECIAL INSTRUCTIONS field contained in X into Y 29 N X1,X2,Y S Y="" 30 ;BHW;PSJ*5*185;Modified Logic below to NOT strip spaces and allow existing logic to flow. 31 ; ;Removed code I X2]"" Before Set of Y and created argumentless DO structure. 32 F X1=1:1:$L(X," ") S X2=$P(X," ",X1) D 33 . I X2']"" S Y=Y_" " Q ;if multiple spaces in text and were $P'ing through text, X2 will="" so just add space and continue 34 . S Y=Y_$S($L(X2)>30:X2,'$D(^PS(51,+$O(^PS(51,"B",X2,0)),0)):X2,$P(^(0),"^",2)]""&$P(^(0),"^",4):$P(^(0),"^",2),1:X2)_" " 35 . Q 36 ;BHW;Modified stripping of spaces at end of string 37 F X1=$L(Y):-1:0 Q:$E(Y,X1,X1)'=" " S Y=$E(Y,1,X1-1) 38 Q Y 39 ; 40 END ; used by DRUG (55.06,101 & 53.1,101) x-refs to warn user if patient is receiving or about to receive the drug just ordered 41 Q:$D(PSJHLSKP) 42 N Z,ZZ,STATUSNP I $G(PSJPWD)&($P($G(PSJSYSU),";")=3)&($G(PSGDRG)) I ($D(^PSI(58.1,"D",PSGDRG,PSJPWD)))!($D(^PSD(58.8,"D",PSGDRG,PSJPWD))) D EN^DDIOL(" *** A WARD STOCK ITEM ***") 43 D NOW^%DTC 44 N PSJDCHK F Z=%:0 S Z=$O(^PS(55,+PSGP,5,"AUS",Z)) Q:'Z!$D(DUOUT) F ZZ=0:0 S ZZ=$O(^PS(55,+PSGP,5,"AUS",Z,ZZ)) Q:'ZZ!$D(DUOUT) I +$G(^PS(55,+PSGP,5,ZZ,.2))=PSGX D PDWCHK(+PSGP,ZZ_"U") S PSJDCHK=1 45 F STATUSNP="N","P" F Z=0:0 S Z=$O(^PS(53.1,"AS",STATUSNP,+PSGP,Z)) Q:'Z!$D(DUOUT) I +$G(^PS(53.1,+Z,.2))=PSGX D PDWCHK(+PSGP,Z_"P") S PSJDCHK=1 46 I $D(PSJDCHK) N DIR D 47 .S DIR(0)="Y",DIR("A")="Do you wish to continue entering this order",DIR("?",1)="Enter ""N"" if you wish to exit without creating a new order," 48 .S DIR("?")="or ""Y"" to continue with the order entry process." D ^DIR S:'Y Y=-1,X="^" 49 K Z,ZZ 50 Q 51 ; 52 ENDDC(PSGP,PSJDD) ; Perform Duplicate Drug, Duplicate Class, 53 ; Drug-Drug interaction check, Drug-Allergy interaction check. 54 N PSJLINE,Z,ZZ,PSJFST 55 S (PSJLINE,PSJFST)=0 56 I $G(PSJPWD)&($P($G(PSJSYSU),";")=3)&($G(PSJDD)) I ($D(^PSI(58.1,"D",PSJDD,PSJPWD)))!($D(^PSD(58.8,"D",PSJDD,PSJPWD))) W !?25,"*** A WARD STOCK ITEM ***" 57 D EN^PSOORDRG(PSGP,PSJDD) K PSJPDRG N INTERVEN,PSJIREQ,PSJRXREQ S Y=1,(PSJIREQ,PSJRXREQ,INTERVEN,X)="" S DFN=PSGP 58 I $T(HAVEHDR^ORRDI1)]"",$$HAVEHDR^ORRDI1,'$D(^XTMP("ORRDI","OUTAGE INFO","DOWN")) D 59 . I $P($G(^XTMP("ORRDI","PSOO",PSGP,0)),"^",3)<0 W !,"Remote data not available - Only local order checks processed." D PAUSE^PSJLMUT1 60 I $D(^TMP($J,"DD")) D ORDCHK^PSJLMUT1(PSGP,"DD",4) 61 I $D(^TMP($J,"DC")) D ORDCHK^PSJLMUT1(PSGP,"DC",6) 62 IVSOL ;*** Start order check for IV solution at this point. 63 I '$D(PSJFST) N PSJFST S PSJFST=0 64 I $D(^TMP($J,"DI")) S INTERVEN=1 D ORDCHK^PSJLMUT1(PSGP,"DI",8) 65 ;*** Allergy/adverse reaction check. 66 N PTR,X 67 S PTR=$P($G(^PSDRUG(PSJDD,"ND")),U)_"."_$P($G(^PSDRUG(PSJDD,"ND")),U,3) 68 K ^TMP("PSJDAI",$J) S PSJACK=$$ORCHK^GMRAOR(DFN,"DR",PTR) D:$G(PSJACK)=1 69 .S ^TMP("PSJDAI",$J,0)=1 70 .S I=0 F S I=$O(GMRAING(I)) Q:'I S ^TMP("PSJDAI",$J,I,0)=GMRAING(I) 71 I $D(^TMP("PSJDAI",$J)) S PSJPDRG=1 D 72 .W $C(7),!!,"A Drug-Allergy Reaction exists for this medication!",!! 73 .W !?7,"Drug: "_$P($G(^PSDRUG(PSJDD,0)),"^") I $O(^TMP("PSJDAI",$J)) W !,"Ingredients: " D 74 ..S I=0 F S I=$O(^TMP("PSJDAI",$J,I)) Q:'I W:$X+$L($G(^(I,0)))+2>IOM !?19 W:I=1 $G(^TMP("PSJDAI",$J,I,0)) W:I>1 ", ",$G(^TMP("PSJDAI",$J,I,0)) 75 .W !! 76 K PSJACK,GMRAING,I,^TMP($J) 77 D ALGCLASS 78 CONT ; Ask user if they wish to continue in spite of an order check. 79 Q:'$D(PSJPDRG) N DIR S DIR(0)="Y",DIR("A")="Do you wish to continue entering this order",DIR("?",1)="Enter ""N"" if you wish to exit without creating a new order," 80 S DIR("?")="or ""Y"" to continue with the order entry process.",DIR("B")="NO" D ^DIR I 'Y S PSGORQF=1,X="^",COMQUIT=1 Q 81 I 'INTERVEN!($P(PSJSYSU,";")'=3) Q 82 NEW PSJY 83 W:PSJIREQ !!,"This is a CRITICAL interaction, you must enter an intervention log to continue" 84 S DIR(0)="Y",DIR("A")="Do you wish to log an intervention",DIR("?",1)="Enter ""N"" if you do not wish to log an intervention,",DIR("?")="or ""Y"" to log an intervention." D ^DIR S PSJY=Y D:Y ^PSJRXI 85 I 'PSJY,PSJIREQ S PSGORQF=1,COMQUIT=1 86 Q 87 ; 88 ENDL ; used by PSGTRAIN DRUG LOOK-UP option 89 D ENCV^PSGSETU Q:$D(XQUIT) 90 F S DIC="^PSDRUG(",DIC(0)="AEIMOQZ",DIC("A")="Select DRUG: " W ! D ^DIC K DIC Q:+Y'>0 D SF 91 D ENKV^PSGSETU K N5,ND,Q,Y Q 92 ; 93 SF ; 94 S Y=+Y,ND=$G(^PSDRUG(Y,0)),PSGID=+$G(^("I")) I PSGID W !!,"THIS DRUG IS INACTIVE AS OF ",$E($$ENDTC^PSGMI(PSGID),1,8) 95 W !!,$S($P(ND,"^",9):"NON-",1:""),"FORMULARY ITEM" W:$P(ND,"^",10)]"" !,$P(ND,"^",10) 96 S ND=$P($G(^PSDRUG(Y,2)),"^",3)["U" W !,$P("NOT^","^",ND+1)," A UNIT DOSE DRUG" W ! S ND=$G(^(8)),N5=$G(^(8.5)) W !?2,"DAY (nD) or DOSE (nL) LIMIT: " I ND W $P(ND,"^") 97 W !?10,"UNIT DOSE MED ROUTE: " I $P(ND,"^",2) W $S($D(^PS(51.2,$P(ND,"^",2),0)):$P(^(0),"^"),1:$P(ND,"^",2)) 98 ; NAKED REF below refers to ^PS(51.2, on line above. 99 W !?6,"UNIT DOSE SCHEDULE TYPE: " I $P(ND,"^",3)]"" W $P($P(";"_$P(^(0),"^",3),";"_$P(ND,"^",3)_":",2),";") 100 W !?11,"UNIT DOSE SCHEDULE: " I $P(ND,"^",4)]"" W $P(ND,"^",4) 101 W !,"CORRESPONDING OUTPATIENT DRUG: " I $P(ND,"^",5) W $S('$D(^PSDRUG(+$P(ND,"^",5),0)):$P(ND,"^",5),$P(^(0),"^")]"":$P(^(0),"^"),1:$P(ND,"^",5)) 102 W !?17,"ATC MNEMONIC: " I $P(N5,"^",2)]"" W $P(N5,"^",2) 103 W !?17,"ATC CANISTER: " F Q=0:0 S Q=$O(^PSDRUG(Y,212,Q)) Q:'Q S ND=$G(^(Q,0)) I ND,$P(ND,"^",2) W ?31,$S('$D(^PS(57.5,+ND,0)):+ND_";PS(57.5,",$P(^(0),"^")]"":$P(^(0),"^"),1:+ND_";PS(57.5,"),?56,$P(ND,"^",2),! 104 Q 105 ; 106 OCHK ; Add drugs in current order to ^TMP("ORDERS" and call order checker. 107 ; Set PSJOCHK=1 so OP order check doesn't Kill array. 108 ; 109 K ^TMP($J,"ORDERS") 110 N PSJOCHK S PSJOCHK=1 111 PDWCHK(DFN,ON) ; Print Dup Drug order. 112 N ND,ND0,ND2,X 113 W:'$D(PSJDCHK) $C(7),$C(7),!!,"WARNING! THIS PATIENT HAS THE FOLLOWING ORDER(S) FOR THIS MEDICATION:",!! 114 S ND=$$DRUGNAME^PSJLMUTL(DFN,ON) 115 S F=$S(ON["P":"^PS(53.1,",1:"^PS(55,"_DFN_",5,"),ND0=$G(@(F_+ON_",0)")),ND2=$G(^(2)),X=$P(ND,U,2),X=$S(X=.2:$P($G(^(.2)),U,2),1:$G(^(.3))) 116 W ?10,$P(ND,U),!,?13,"Give: ",X," ",$$ENMRN^PSGMI(+$P(ND0,U,3))," ",$P(ND2,U),!! 117 Q 118 ALGCLASS ; checks any Drug allergies or reactions to see if 119 ; the new drug is the same class 120 ; this call can be removed by commenting out the call on IVSOL+16 121 N PSJLIST,CT,CLS,CLCHK,CNT,PSJL,LIST,DCCNT,PSCLASS,LEN 122 S PSCLASS=$P($G(^PSDRUG(PSJDD,0)),"^",2),LEN=4 I $E(PSCLASS,1,4)="CN10" S LEN=5 ;look at 5 chars if ANALGESICS 123 I $T(GETDATA^GMRAOR)]"" G ALGC2 124 S GMRA="0^0^111" D EN1^GMRADPT 125 F PSJLIST=0:0 S PSJLIST=$O(GMRAL(PSJLIST)) Q:'PSJLIST D 126 .K PSJAGL D EN1^GMRAOR2(PSJLIST,"PSJAGL") 127 .; is the allergy/reaction drug class first four digits the same as the 128 .; the class for the drug being entered? 129 .S (CT,CLS)="",DCCNT=0 130 .I $D(PSJAGL("V")) D 131 ..F S DCCNT=$O(PSJAGL("V",DCCNT)) Q:'DCCNT S:$E($P($G(PSJAGL("V",DCCNT)),"^"),1,LEN)=$E(PSCLASS,1,LEN) (PSJPDRG,CLCHK)=1,CNT=$S('$D(CNT):1,1:CNT+1),LIST(CNT)=$P($G(PSJAGL),"^")_"^"_$P($G(PSJAGL("V",DCCNT)),"^",2) 132 D:$G(CLCHK) 133 .W !!,$C(7),"A Drug-Allergy Reaction exists for this medication and/or class!" 134 .F PSJL=0:0 S PSJL=$O(LIST(PSJL)) Q:'PSJL D 135 ..W !?6,"Drug: "_$P(LIST(PSJL),"^"),!,"Drug Class: "_$P(LIST(PSJL),"^",2),! 136 Q 137 ALGC2 ; 138 K GMRADRCL 139 D GETDATA^GMRAOR(DFN) Q:'$D(^TMP("GMRAOC",$J,"APC")) 140 N GMRACL,RET 141 S RET=0,GMRACL="" F S GMRACL=$O(^TMP("GMRAOC",$J,"APC",GMRACL)) Q:'$L(GMRACL) D 142 .N GMRANM,GMRALOC 143 .S GMRALOC=^TMP("GMRAOC",$J,"APC",GMRACL) 144 .S GMRANM=$P(^PS(50.605,+$O(^PS(50.605,"B",GMRACL,0)),0),U,2) 145 .S GMRADRCL(GMRACL)=GMRACL_U_GMRANM_" ("_GMRALOC_")" 146 .S RET=RET+1 147 Q:'RET K ^TMP("GMRAOC",$J) 148 S CLCHK="",CT="" F S CT=$O(GMRADRCL(CT)) Q:CT="" D 149 .I $E(PSCLASS,1,LEN)=$E(CT,1,LEN) S CLCHK=$G(CLCHK)+1,^TMP($J,"PSJDRCLS",CLCHK)=CT_" "_$P(GMRADRCL(CT),"^",2) 150 CLASSDSP ; 151 I '$D(^TMP($J,"PSJDRCLS")) Q 152 W $C(7),!,"A Drug-Allergy Reaction exists for this medication and/or class!",! 153 W !,"Drug: "_$P($G(^PSDRUG(PSJDD,0)),"^") 154 S CT="" F S CT=$O(^TMP($J,"PSJDRCLS",CT)) Q:CT="" W !,"Drug Class: "_^TMP($J,"PSJDRCLS",CT) 155 K ^TMP($J,"PSJDRCLS") 156 S DIR("?",1)="Answer 'YES' if you DO want to enter a reaction for this medication," 157 S DIR("?")=" 'NO' if you DON'T want to enter a reaction for this medication," 158 S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Intervene? ",DIR("B")="Y" W ! D ^DIR 159 I Y D ^PSJRXI 160 I '$G(Y) K DIR,DTOUT,DIRUT,DIROUT,DUOUT,Y Q 161 Q 1 PSGSICHK ;BIR/CML3-CHECKS SPECIAL INSTRUCTIONS ;17 Aug 98 / 8:33 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**3,9,26,29,44,49,59,110,139,146,160,175**;16 DEC 97;Build 18 3 ; 4 ; Reference to EN^PSOORDRG is supported by DBIA 2190. 5 ; Reference to ^PSI(58.1 is supported by DBIA 2284. 6 ; Reference to ^PSDRUG( is supported by DBIA 2192. 7 ; Reference to ^PSD(58.8 is supported by DBIA 2283. 8 ; Reference to ^PS(55 is supported by DBIA 2191. 9 ; Reference to ^PS(51.2 is supported by DBIA 2178. 10 ; Reference to ^PS(51 is supported by DBIA 2176. 11 ; Reference to ^ORRDI1 is supported by DBIA 4659. 12 ; Reference to ^XTMP("ORRDI" is supported by DBIA 4660. 13 ; 14 START ; 15 I $S(X'?.ANP:1,X["^":1,1:$L(X)>180) K X Q 16 S Y="" F Y(1)=1:1:$L(X," ") S Y(2)=$P(X," ",Y(1)) I Y(2)]"" D CHK Q:'$D(X) 17 I $D(X),Y]"",X'=$E(Y,1,$L(Y)-1) D EN^DDIOL("EXPANDS TO: ") W Y F Y(1)=1:1 S Y(2)=$P(Y," ",Y(1)) Q:Y(2)="" D:$L(Y(2))+$X>78 EN^DDIOL(Y(2)_" ") 18 Q 19 ; 20 CHK ; 21 I $L(Y(2))<31,$D(^PS(51,+$O(^PS(51,"B",Y(2),0)),0)),$P(^(0),"^",2)]"",$P(^(0),"^",4) S Y(2)=$P(^(0),"^",2) 22 I $L(Y)+$L(Y(2))>180 K X Q 23 S Y=Y_Y(2)_" " Q 24 ; 25 ENSET(X) ; expands the SPECIAL INSTRUCTIONS field contained in X into Y 26 N X1,X2,Y S Y="" 27 F X1=1:1:$L(X," ") S X2=$P(X," ",X1) I X2]"" S Y=Y_$S($L(X2)>30:X2,'$D(^PS(51,+$O(^PS(51,"B",X2,0)),0)):X2,$P(^(0),"^",2)]""&$P(^(0),"^",4):$P(^(0),"^",2),1:X2)_" " 28 S Y=$E(Y,1,$L(Y)-1) Q Y 29 ; 30 END ; used by DRUG (55.06,101 & 53.1,101) x-refs to warn user if patient is receiving or about to receive the drug just ordered 31 Q:$D(PSJHLSKP) 32 N Z,ZZ,STATUSNP I $G(PSJPWD)&($P($G(PSJSYSU),";")=3)&($G(PSGDRG)) I ($D(^PSI(58.1,"D",PSGDRG,PSJPWD)))!($D(^PSD(58.8,"D",PSGDRG,PSJPWD))) D EN^DDIOL(" *** A WARD STOCK ITEM ***") 33 D NOW^%DTC 34 N PSJDCHK F Z=%:0 S Z=$O(^PS(55,+PSGP,5,"AUS",Z)) Q:'Z!$D(DUOUT) F ZZ=0:0 S ZZ=$O(^PS(55,+PSGP,5,"AUS",Z,ZZ)) Q:'ZZ!$D(DUOUT) I +$G(^PS(55,+PSGP,5,ZZ,.2))=PSGX D PDWCHK(+PSGP,ZZ_"U") S PSJDCHK=1 35 F STATUSNP="N","P" F Z=0:0 S Z=$O(^PS(53.1,"AS",STATUSNP,+PSGP,Z)) Q:'Z!$D(DUOUT) I +$G(^PS(53.1,+Z,.2))=PSGX D PDWCHK(+PSGP,Z_"P") S PSJDCHK=1 36 I $D(PSJDCHK) N DIR D 37 .S DIR(0)="Y",DIR("A")="Do you wish to continue entering this order",DIR("?",1)="Enter ""N"" if you wish to exit without creating a new order," 38 .S DIR("?")="or ""Y"" to continue with the order entry process." D ^DIR S:'Y Y=-1,X="^" 39 K Z,ZZ 40 Q 41 ; 42 ENDDC(PSGP,PSJDD) ; Perform Duplicate Drug, Duplicate Class, 43 ; Drug-Drug interaction check, Drug-Allergy interaction check. 44 N PSJLINE,Z,ZZ,PSJFST 45 S (PSJLINE,PSJFST)=0 46 I $G(PSJPWD)&($P($G(PSJSYSU),";")=3)&($G(PSJDD)) I ($D(^PSI(58.1,"D",PSJDD,PSJPWD)))!($D(^PSD(58.8,"D",PSJDD,PSJPWD))) W !?25,"*** A WARD STOCK ITEM ***" 47 D EN^PSOORDRG(PSGP,PSJDD) K PSJPDRG N INTERVEN,PSJIREQ,PSJRXREQ S Y=1,(PSJIREQ,PSJRXREQ,INTERVEN,X)="" S DFN=PSGP 48 I $T(HAVEHDR^ORRDI1)]"",$$HAVEHDR^ORRDI1,'$D(^XTMP("ORRDI","OUTAGE INFO","DOWN")) D 49 . I $P($G(^XTMP("ORRDI","PSOO",PSGP,0)),"^",3)<0 W !,"Remote data not available - Only local order checks processed." D PAUSE^PSJLMUT1 50 K ^TMP($J,"DUPDRG") ;DEM - Duplicate Drug Check Ehancement. 51 I $D(^TMP($J,"DD")) D ORDCHK^PSJLMUT1(PSGP,"DD",4) 52 I $D(^TMP($J,"DC")) D ORDCHK^PSJLMUT1(PSGP,"DC",6) 53 IVSOL ;*** Start order check for IV solution at this point. 54 I '$D(PSJFST) N PSJFST S PSJFST=0 55 I $D(^TMP($J,"DI")) S INTERVEN=1 D ORDCHK^PSJLMUT1(PSGP,"DI",8) 56 D DUPDRG^PSJLMUT2(PSGP) K ^TMP($J,"DUPDRG") ;DEM - Duplicate Drug Check Ehancement. 57 ;*** Allergy/adverse reaction check. 58 N PTR,X 59 S PTR=$P($G(^PSDRUG(PSJDD,"ND")),U)_"."_$P($G(^PSDRUG(PSJDD,"ND")),U,3) 60 K ^TMP("PSJDAI",$J) S PSJACK=$$ORCHK^GMRAOR(DFN,"DR",PTR) D:$G(PSJACK)=1 61 .S ^TMP("PSJDAI",$J,0)=1 62 .S I=0 F S I=$O(GMRAING(I)) Q:'I S ^TMP("PSJDAI",$J,I,0)=GMRAING(I) 63 I $D(^TMP("PSJDAI",$J)) S PSJPDRG=1 D 64 .W $C(7),!!,"A Drug-Allergy Reaction exists for this medication!",!! 65 .W !?7,"Drug: "_$P($G(^PSDRUG(PSJDD,0)),"^") I $O(^TMP("PSJDAI",$J)) W !,"Ingredients: " D 66 ..S I=0 F S I=$O(^TMP("PSJDAI",$J,I)) Q:'I W:$X+$L($G(^(I,0)))+2>IOM !?19 W:I=1 $G(^TMP("PSJDAI",$J,I,0)) W:I>1 ", ",$G(^TMP("PSJDAI",$J,I,0)) 67 .W !! 68 K PSJACK,GMRAING,I,^TMP($J) 69 D ALGCLASS^PSGSICH1 70 CONT ; Ask user if they wish to continue in spite of an order check. 71 ;Variable PSJDDCON is the order continuation flag for Duplicate Drug Check Enhancement. 72 I $D(PSJDDCON("DD")),'PSJDDCON("DD") Q 73 I '$D(PSJDDCON("DD")) Q:'$D(PSJPDRG) N DIR D I 'Y S PSGORQF=1,X="^",COMQUIT=1 K PSJDDCON Q 74 . S DIR(0)="Y",DIR("A")=$S($G(PSJDDCON("DI")):"Do you wish to continue with the current order",1:"Do you wish to continue entering this order") 75 . S DIR("?",1)="Enter ""N"" if you wish to exit without creating a new order,",DIR("?")="or ""Y"" to continue with the order entry process.",DIR("B")=$S($G(PSJDDCON("DI")):"YES",1:"NO") 76 . D ^DIR 77 . Q 78 ; 79 K PSJDDCON ;Order continuation flag for Duplicate Drug Check Enhancement. 80 I 'INTERVEN!($P(PSJSYSU,";")'=3) Q 81 N PSJY 82 W:PSJIREQ !!,"This is a CRITICAL interaction, you must enter an intervention log to continue" 83 S DIR(0)="Y",DIR("A")="Do you wish to log an intervention",DIR("?",1)="Enter ""N"" if you do not wish to log an intervention,",DIR("?")="or ""Y"" to log an intervention." D ^DIR S PSJY=Y D:Y ^PSJRXI 84 I 'PSJY,PSJIREQ S PSGORQF=1,COMQUIT=1 85 Q 86 ; 87 ENDL ; used by PSGTRAIN DRUG LOOK-UP option 88 D ENCV^PSGSETU Q:$D(XQUIT) 89 F S DIC="^PSDRUG(",DIC(0)="AEIMOQZ",DIC("A")="Select DRUG: " W ! D ^DIC K DIC Q:+Y'>0 D SF 90 D ENKV^PSGSETU K N5,ND,Q,Y 91 Q 92 ; 93 SF ; 94 N PSGID 95 S Y=+Y,ND=$G(^PSDRUG(Y,0)),PSGID=+$G(^("I")) I PSGID W !!,"THIS DRUG IS INACTIVE AS OF ",$E($$ENDTC^PSGMI(PSGID),1,8) 96 W !!,$S($P(ND,"^",9):"NON-",1:""),"FORMULARY ITEM" W:$P(ND,"^",10)]"" !,$P(ND,"^",10) 97 S ND=$P($G(^PSDRUG(Y,2)),"^",3)["U" W !,$P("NOT^","^",ND+1)," A UNIT DOSE DRUG" W ! S ND=$G(^(8)),N5=$G(^(8.5)) W !?2,"DAY (nD) or DOSE (nL) LIMIT: " I ND W $P(ND,"^") 98 W !?10,"UNIT DOSE MED ROUTE: " I $P(ND,"^",2) W $S($D(^PS(51.2,$P(ND,"^",2),0)):$P(^(0),"^"),1:$P(ND,"^",2)) 99 ; NAKED REF below refers to ^PS(51.2, on line above. 100 W !?6,"UNIT DOSE SCHEDULE TYPE: " I $P(ND,"^",3)]"" W $P($P(";"_$P(^(0),"^",3),";"_$P(ND,"^",3)_":",2),";") 101 W !?11,"UNIT DOSE SCHEDULE: " I $P(ND,"^",4)]"" W $P(ND,"^",4) 102 W !,"CORRESPONDING OUTPATIENT DRUG: " I $P(ND,"^",5) W $S('$D(^PSDRUG(+$P(ND,"^",5),0)):$P(ND,"^",5),$P(^(0),"^")]"":$P(^(0),"^"),1:$P(ND,"^",5)) 103 W !?17,"ATC MNEMONIC: " I $P(N5,"^",2)]"" W $P(N5,"^",2) 104 W !?17,"ATC CANISTER: " F Q=0:0 S Q=$O(^PSDRUG(Y,212,Q)) Q:'Q S ND=$G(^(Q,0)) I ND,$P(ND,"^",2) W ?31,$S('$D(^PS(57.5,+ND,0)):+ND_";PS(57.5,",$P(^(0),"^")]"":$P(^(0),"^"),1:+ND_";PS(57.5,"),?56,$P(ND,"^",2),! 105 Q 106 ; 107 OCHK ; Add drugs in current order to ^TMP("ORDERS" and call order checker. 108 ; Set PSJOCHK=1 so OP order check doesn't Kill array. 109 ; 110 K ^TMP($J,"ORDERS") 111 N PSJOCHK S PSJOCHK=1 112 PDWCHK(DFN,ON) ; Print Dup Drug order. 113 N ND,ND0,ND2,X 114 W:'$D(PSJDCHK) $C(7),$C(7),!!,"WARNING! THIS PATIENT HAS THE FOLLOWING ORDER(S) FOR THIS MEDICATION:",!! 115 S ND=$$DRUGNAME^PSJLMUTL(DFN,ON) 116 S F=$S(ON["P":"^PS(53.1,",1:"^PS(55,"_DFN_",5,"),ND0=$G(@(F_+ON_",0)")),ND2=$G(^(2)),X=$P(ND,U,2),X=$S(X=.2:$P($G(^(.2)),U,2),1:$G(^(.3))) 117 W ?10,$P(ND,U),!,?13,"Give: ",X," ",$$ENMRN^PSGMI(+$P(ND0,U,3))," ",$P(ND2,U),!! 118 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR3.m
r613 r623 1 PSGXR3 ; DRIVER FOR COMPILED XREFS FOR FILE #53.1 ; 11/08/091 PSGXR3 ; DRIVER FOR COMPILED XREFS FOR FILE #53.1 ; 01/17/08 2 2 ; 3 3 N DH,DU,DIKILL,DISET,DIKJ,DIKZ,DIKYR,DIKZA,DIK0Z,DIKZK,DIKDP,DIKM1,DIKUP,DIKUM,DV,DIIX,DIKF,DIAU,DIKNM,DIKDA,DIKLK,DIKLM,DIKY,DIXR,DIKCOND,DIKSVDA,DIKPUSH,X1,X2 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR31.m
r613 r623 1 PSGXR31 ; COMPILED XREF FOR FILE #53.1 ; 11/08/091 PSGXR31 ; COMPILED XREF FOR FILE #53.1 ; 01/17/08 2 2 ; 3 3 S DIKZK=2 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR310.m
r613 r623 1 PSGXR310 ; COMPILED XREF FOR FILE #53.1114 ; 11/08/091 PSGXR310 ; COMPILED XREF FOR FILE #53.1114 ; 01/17/08 2 2 ; 3 3 S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR311.m
r613 r623 1 PSGXR311 ; COMPILED XREF FOR FILE #53.157 ; 11/08/091 PSGXR311 ; COMPILED XREF FOR FILE #53.157 ; 01/17/08 2 2 ; 3 3 S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR312.m
r613 r623 1 PSGXR312 ; COMPILED XREF FOR FILE #53.158 ; 11/08/091 PSGXR312 ; COMPILED XREF FOR FILE #53.158 ; 01/17/08 2 2 ; 3 3 S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR32.m
r613 r623 1 PSGXR32 ; COMPILED XREF FOR FILE #53.11 ; 11/08/091 PSGXR32 ; COMPILED XREF FOR FILE #53.11 ; 01/17/08 2 2 ; 3 3 S DA(1)=DA S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR33.m
r613 r623 1 PSGXR33 ; COMPILED XREF FOR FILE #53.1112 ; 11/08/091 PSGXR33 ; COMPILED XREF FOR FILE #53.1112 ; 01/17/08 2 2 ; 3 3 S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR34.m
r613 r623 1 PSGXR34 ; COMPILED XREF FOR FILE #53.1114 ; 11/08/091 PSGXR34 ; COMPILED XREF FOR FILE #53.1114 ; 01/17/08 2 2 ; 3 3 S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR35.m
r613 r623 1 PSGXR35 ; COMPILED XREF FOR FILE #53.157 ; 11/08/091 PSGXR35 ; COMPILED XREF FOR FILE #53.157 ; 01/17/08 2 2 ; 3 3 S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR36.m
r613 r623 1 PSGXR36 ; COMPILED XREF FOR FILE #53.158 ; 11/08/091 PSGXR36 ; COMPILED XREF FOR FILE #53.158 ; 01/17/08 2 2 ; 3 3 S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR37.m
r613 r623 1 PSGXR37 ; COMPILED XREF FOR FILE #53.1 ; 11/08/091 PSGXR37 ; COMPILED XREF FOR FILE #53.1 ; 01/17/08 2 2 ; 3 3 S DIKZK=1 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR38.m
r613 r623 1 PSGXR38 ; COMPILED XREF FOR FILE #53.11 ; 11/08/091 PSGXR38 ; COMPILED XREF FOR FILE #53.11 ; 01/17/08 2 2 ; 3 3 S DA(1)=DA S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGXR39.m
r613 r623 1 PSGXR39 ; COMPILED XREF FOR FILE #53.1112 ; 11/08/091 PSGXR39 ; COMPILED XREF FOR FILE #53.1112 ; 01/17/08 2 2 ; 3 3 S DA=0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVCAL.m
r613 r623 1 PSIVCAL ;BIR/RGY,PR-CALCULATES START AND STOP DATES ;12 Mar 99 / 12:42 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**4,26,41,47,63,67,69,58,94,80,110,111,177,120,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(50.7 is supported by DBIA #2180. 5 ; Reference to ^PS(52.6 is supported by DBIA #1231. 6 ; Reference to ^PS(55 is supported by DBIA #2191. 7 ; 8 ENT ;NEEDS PSIVTYPE (P(4)) 9 I $G(PSJREN) D Q:P(2) 10 . I $G(P("OLDON")) N P2 S P2=$G(@("^PS(55,"_DFN_",""IV"","_+P("OLDON")_",0)")),P2=$P(P2,"^",2) I P2 S P(2)=P2 11 I $G(PSJORD)["P",$G(P("APPT"))?7N1"."1.N S START=$$DATE2^PSJUTL2(P("APPT")) G Q 12 I $G(PSJSYSW0)=""!($P(PSJSYSW0,U,5)=2) S START=+$E(P("LOG"),1,12) G Q 13 S PSIVSN=+P("IVRM"),START="",PSIVTYPE=$G(P(4)) Q:PSIVTYPE="" 14 N PSIV X $S($E(PSIVAC)="C":"S X=+$E(P(""LOG""),1,12) D H^%DTC S PSIV=%T",1:"S PSIV=$P($H,"","",2)") G T2:PSIVTYPE'["P"&('P(5)) 15 I P(11)']"" X $S($E(PSIVAC)="C":"S Y=+$E(P(""LOG""),1,12)",1:"D NOW^%DTC S Y=%") S Y=Y+.007\.01/100 S:'$P(Y,".",2) Y=$$MDNGHT(Y) X ^DD("DD") S START=Y G Q 16 S X=P(11) D CHK S PX=Y,X1=PSIV\3600,X2=PSIV#3600\60,X=$E(".0",1,$L(X1)#2+1)_X1_$E("0",X2<10)_X2,START=$S($E(PSIVAC)="C":$P(P("LOG"),"."),1:"T") 17 S X1=$P(PX,"-"),X1=$E(".0",1,$L(X1)#2+1)_X1,X2=$P(PX,"-",PSGCNT),X2=$E(".0",1,$L(X2)#2+1)_X2 18 S NAT=+$P($G(^PS(59.6,+$O(^PS(59.6,"B",+VAIN(4),0)),0)),U,5) 19 I '$D(PSGDT) S PSGDT=$$DATE^PSJUTL2() 20 I X<X1,'NAT S START=$$ENSD^PSGNE3(P(9),P(11),+$E(P("LOG"),1,12),PSGDT) G Q 21 I X>X2 S START=$$ENSD^PSGNE3(P(9),P(11),+$E(P("LOG"),1,12),PSGDT) G Q 22 T6 F I=2:1:PSGCNT S X1="."_$P(PX,"-",I-1),X2="."_$P(PX,"-",I) Q:+X1<X&(+X2>X) 23 S X1=X-X1,X2=$S(NAT:0,1:X2-X),START=$S(X1<X2:$P(PX,"-",I-1),1:$P(PX,"-",I)) S:START="" START=$P(PX,"-") X $S($E(PSIVAC)="C":"S Y=$P(P(""LOG""),""."") X ^DD(""DD"") S PSIV=Y",1:"S PSIV=""TODAY""") S START=PSIV_"@"_$E("0",$L(START)=3)_START G Q 24 T2 S X=+("."_$E(10000+(PSIV\3600*100)+(PSIV#3600\60),2,5)),START=$O(^PS(59.5,PSIVSN,3,"AT",X)) S:'START START=$O(^(0)),PSIVTOM=1 I 'START S START=X K PSIVTOM 25 S START=$S($E(PSIVAC)="C":$P(P("LOG"),"."),1:DT)_START I $D(PSIVTOM) S X1=$S($E(PSIVAC)="C":$P(P("LOG"),"."),1:DT),X2=1 D C^%DTC S Y=$P(X,".")_START K PSIVTOM 26 S X=START,%DT="XRTX" D ^%DT 27 Q ; 28 I START["@" S X=START,%DT="RTX" D ^%DT S START=+Y 29 S P(2)=START 30 I $G(PSJORD)["P" D:'$G(PSGRDTX(+PSJORD,"PSGSD")) REQDT^PSJLIVMD(PSJORD) S START=$G(PSGRDTX(+PSJORD,"PSGSD")) S P(2)=$S(START:START,1:P(2)) 31 K NAT,START,PSIVTYPE,PSIVSTRT,PSGCNT,X1,X2,PX 32 Q 33 CHK F Y=1:1 Q:$L(X)>240!($P(X,"-",Y)="") S $P(X,"-",Y)=$P(X,"-",Y)_$E("0000",1,4-$L($P(X,"-",Y))) 34 S Y=X,PSGCNT=$L(X,"-") S:X]""&(PSGCNT<1) PSGCNT=1 Q 35 ; 36 ENSTOP ; WILL CALCULATE STOP DATE FOR ORDER 37 ;NEEDS (DFN) & ON 38 N WALL,P3,ADX,DDLX,OIX,DRGT,PSIDAY,PSIMIN,LIMDAY S (WALL,P3,PSIDAY,PSIMIN)=0 39 D:'$G(PSIVSITE) ^PSIVSET Q:'P(2) 40 I P(23)'="" S PSIVTYPE="C" 41 S STOP="",X="",PSIVSTRT=P(2),PSIVTYPE=$G(P(4)) I $G(PSJREN) D 42 . N RDT I $G(ON)["P" S RDT=+$$LASTREN^PSJLMPRI(DFN,ON) 43 . S PSIVSTRT=$$DATE2^PSJUTL2($S($G(RDT):RDT,1:$G(PSGDT))) 44 ;BHW - PSJ*5*177 - Begin Modifications - Reset Start date to Last Renewed date for active orders that have been renewed 45 I ('$G(PSJREN))&($G(P(4))="A")&($G(ON)["V") D 46 . N RDT S RDT=+$$LASTREN^PSJLMPRI(DFN,ON) 47 . I +RDT S PSIVSTRT=RDT 48 . Q 49 ;BHW - PSJ*5*177 - End Modifications - Resetting PSIVSTRT will recalculate the stop date based on the Last renewed date. 50 ; 51 I $S("^NOW^STAT^ONCE^ONE-TIME^ONE TIME^ONETIME^1TIME^1-TIME^1 TIME^"[(U_P(9)_U):1,1:0),PSIVTYPE="P"!P(5)!(P(23)="P") S X=$$ENOSD^PSJDCU(PSJSYSW0,PSIVSTRT,DFN) I X]"" S:P(11)=""&($G(ON)["P") PSIVCAL=1 G END 52 I '$G(P("OVRIDE")),$G(ON) N DUR,DURMIN,PSJPROV,PSJDNM,A,PSJDAY I $G(ON)["V"!(($G(ON)["P")&($P($G(^PS(53.1,+ON,0)),"^",4)="F")) D 53 . S DUR=$$GETDUR^PSJLIVMD(DFN,+ON,"IV",1) I DUR]"" S DURMIN=$$DURMIN^PSJLIVMD(DUR) I DURMIN S PSIMIN=DURMIN 54 I $P(PSIVSITE,"^",5) D 55 . N Z S Y=0 56 . F S Y=$O(^PS(55,DFN,"IV",Y)) Q:'Y S Z=^(Y,0) D Q:X]"" 57 .. I $P(Z,"^",17)="A",$$ONE^PSJBCMA(DFN,Y_"V",$P(Z,"^",9))'="O" S X=$P(Z,"^",3) Q 58 S:$G(X) WALL=X 59 S PSIDAY=$S(PSIVTYPE="A":$P(PSIVSITE,"^",4),PSIVTYPE="H":$P(PSIVSITE,"^",17),PSIVTYPE="P":$P(PSIVSITE,"^",18),PSIVTYPE="S":$P(PSIVSITE,"^",20),1:$P(PSIVSITE,"^",21)) 60 I $G(ON)["P"!($G(ON)["V") I '$G(P("OVRIDE")) N MINS,LIM S PSIVLIM=$$GETLIM(DFN,ON) I $G(PSIVLIM)]"" S MINS=$$GETMIN(PSIVLIM,DFN,ON,.LIMDAY) D 61 .I (MINS&(MINS<PSIMIN))!'PSIMIN S PSIMIN=MINS 62 S PSJDAY="" D I PSJDAY]"",PSJDAY<PSIDAY S PSIDAY=PSJDAY 63 . N A,B,PSJCLIN 64 . Q:'$D(PSJORD) S A="" 65 . I PSJORD["P" S A=$G(^PS(53.1,+PSJORD,"DSS")) 66 . I PSJORD["U" S A=$G(^PS(55,PSGP,5,+PSJORD,8)) 67 . I PSJORD["V" S A=$G(^PS(55,PSGP,"IV",+PSJORD,"DSS")) 68 . S (PSJCLIN,A)=$P(A,"^") Q:A="" S PSJCLIN=$P(^SC(PSJCLIN,0),"^") I $D(^PS(53.46,"B",A)) S B=$O(^PS(53.46,"B",A,"")),PSJDAY=$P(^PS(53.46,B,0),"^",2) 69 F X=0:0 S X=$O(DRG("AD",X)) Q:'X I $P(^PS(52.6,+$P(DRG("AD",+X),U),0),"^",4),($P(^(0),"^",4))<+PSIDAY S PSIDAY=$P(^(0),"^",4) 70 I WALL,($$FMADD^XLFDT(PSIVSTRT,PSIDAY,"D"))>WALL S PSIDAY=$$FMDIFF^XLFDT(WALL,PSIVSTRT,1) S:PSIDAY<1 PSIDAY="" 71 S DRGT=$S($D(DRG("AD")):"AD",1:"SOL") F ADX=0:0 S ADX=$O(DRG(DRGT,ADX)) Q:'ADX!($G(DRGTMP)&($G(DRGTN)["AD")&(DRGT="SOL")) D 72 . S OIX=+$P(DRG(DRGT,ADX),"^",6),DDLX=$P(^PS(50.7,OIX,0),"^",5) Q:'DDLX D DDLIM(.PSIDAY,.P3) 73 I '$G(DRG("AD",0)),$G(DRGTMP),($G(DRGTN)["SOL") S OIX=$P($G(DRGTMP),"^",6) I OIX S DDLX=$P(^PS(50.7,OIX,0),"^",5) I DDLX D DDLIM(.PSIDAY,.P3) 74 I $G(PSIVLIM)["a",'$G(P("OVRIDE")) S DDLX=$P(PSIVLIM,"a",2)_"L" I $G(DDLX) D DDLIM(.PSIDAY,.P3) 75 I $G(P(2)) I P3>P(2) S X=P3 76 S:('PSIDAY&'PSIMIN) PSIDAY=1 77 TIME S X2=PSIDAY,X1=PSIVSTRT D C^%DTC S X=$P(X,"."),X=X_$S($P(PSIVSITE,"^",14)="":.2359,1:"."_$P(PSIVSITE,"^",14)) 78 I PSIMIN D 79 . I $G(PSIDAY),((PSIDAY*1440)<PSIMIN) K PSIVLIM,P("LIMIT") S P("OVRIDE")=1 Q 80 . I (PSIMIN<(PSIDAY*1440)!'$G(PSIDAY)) S X=$$FMADD^XLFDT(PSIVSTRT,,,PSIMIN) D 81 .. I '(PSIMIN#1440) S X=$P(X,"."),X=X_$S($P(PSIVSITE,"^",14)="":.2359,1:"."_$P(PSIVSITE,"^",14)) 82 END ; 83 S P(3)=+X 84 I $G(PSJORD)["P" D:'$G(PSGRDTX(+PSJORD,"PSGFD")) REQDT^PSJLIVMD(PSJORD) S P(3)=$S($G(PSGRDTX(+PSJORD,"PSGFD")):PSGRDTX(+PSJORD,"PSGFD"),1:P(3)) 85 S P(3)=$$DATE2^PSJUTL2(P(3)),P(2)=$$DATE2^PSJUTL2(P(2)) 86 Q 87 ; 88 ENAD ;Will get last admin. time for order (needs dfn and on) 89 N P4,PSIVX,PSIVY 90 I $P(PSJSYSW0,U,5)=2 S PSIVADM=$$DATE^PSJUTL2() Q 91 I $S($G(PSIVAC)["R":1,P(9)="QOD":1,1:P(9)?1"Q".N1"D") S PSIVADM=$$ENSD^PSGNE3(P(9),P(11),+$E(P("LOG"),1,12),+$P($G(^PS(55,DFN,"IV",+P("OLDON"),0)),U,2)) Q:PSIVADM 92 S PSIVX=X,PSIVY=Y,P4=P(4) S:P(4)="C" P4=P(23) S:P4="S" P4=$S(P(5):"P",1:"A") D NOW^%DTC S Y=%,PSIVNOW=Y I (P4="P"&(P(11)="")&'P(15))!("HA"[P4&'P(15)) S Y=Y+.007\.01/100 G QAD 93 D P:P4="P"&('P(15)),AH:P(15) 94 QAD ; 95 S:'$D(PSGSA) PSGSA="" 96 S PSIVSD=Y I Y S OD=$L(PSGSA," ") I OD>2 S X=+PSGSA\1 F OD1=2:1:OD-1 I $P(PSGSA," ",OD1)'>$S(OD1>2:$P(PSGSA," ",OD1-1),1:PSGSA#1) S X1=X,X2=1 D C^%DTC 97 I PSIVSD,OD>2 S Y=X_PSIVSD 98 S PSIVADM=+Y,X=PSIVX,Y=PSIVY K PSGSA,PSIVSD,OD,OD1,PSIVMI,PSIVNOW S:PSIVADM<P(2) PSIVADM=P(2) Q 99 ; 100 P S CD=PSIVNOW,PSGSA="",(PSIVSD,OD)=DT_.0001,X=P(11) D CHK S P(11)=X D ENP4^PSIVWL 101 I PSGSA="" S PSIVSD=DT_.0001,PSIVMIN=-1440 D ENT^PSIVWL S $P(Y,".",2)=$P(P(11),"-",$L(P(11),"-")) Q 102 S Y=$P(PSGSA," ",$L(PSGSA," ")-1) Q 103 AH F PSIVADM=0:-1 S CD=PSIVNOW,(X,X1)=DT,X2=PSIVADM D:X2 C^%DTC S X=$P(X,".") S (OD1,PSIVSD,OD)=X_.0001,PSIVMIN=P(15) D ENP3^PSIVWL Q:PSIVADM<-4!(PSGSA]"") 104 S Y=$P(PSGSA," ",$L(PSGSA," ")-1) Q 105 MDNGHT(Y) ;Sets Start Date/Time on orders placed between midnight and 12:30 106 S Y=$$FMADD^XLFDT(Y,-1,0,0,0),Y=$P(Y,".")_".24" Q Y 107 ; 108 DDLIM(PSIVDUR,STPDT) ; Day Dose Limit 109 N P3,NEWDAYS,NEWDUR 110 I DDLX["D" D Q:(STPDT=0) 111 .I +DDLX'<+PSIVDUR S STPDT=0 Q 112 .S PSIVDUR=+DDLX,X2=PSIVDUR,X1=PSIVSTRT D C^%DTC S X=$P(X,"."),X=X_$S($P(PSIVSITE,"^",14)="":.2359,1:"."_$P(PSIVSITE,"^",14)) I X>P(2) S P(3)=X 113 I DDLX["L",($G(P(9))]""),("AH"'[$G(PSIVTYPE)) S LASTD=$$DOSES(DDLX,.P) I LASTD D 114 .S NEWDUR=$$FMDIFF^XLFDT(LASTD,P(2),2) I NEWDUR>0 S NEWDAYS=(NEWDUR/86400) 115 .I $G(NEWDAYS) I NEWDAYS<PSIVDUR S PSIVDUR=NEWDAYS S P(3)=$$DATE2^PSJUTL2(LASTD) 116 S P(3)=$$DATE2^PSJUTL2(P(3)),P(2)=$$DATE2^PSJUTL2(P(2)) S STPDT=P(3) 117 Q 118 ; 119 GETLIM(DFN,PSJORD) ; Convert IV Limits to minutes (only if in 'time' form). 120 N ND2P5,F 121 S F=$S(PSJORD["P":"^PS(53.1,+PSJORD,",PSJORD["V":"^PS(55,DFN,""IV"",+PSJORD,",1:"") 122 S ND2P5=$G(@(F_"2.5)")) S LIM=$P(ND2P5,"^",4) Q:LIM="" 0 123 S ND0=$G(@(F_"0)")) I PSJORD["P",$P(ND0,"^",4)="U" Q 0 124 N MULT S MULT=$S($E(LIM)="h":60,$E(LIM)="d":1440,$E(LIM)="m":LIM,$E(LIM)="l":LIM,$E(LIM)="a":LIM,1:0) I MULT S LIM=MULT*$E(LIM,2,99) 125 Q LIM 126 ; 127 GETMIN(LIM,DFN,PSJORD,DAYS) ; Return the duration of the IV Limit in minutes (includes IV Limits in volume and doses format) 128 S LIM=$$GETMIN^PSIVUTL1(LIM,DFN,PSJORD,.DAYS) 129 Q LIM 130 DOSES(DDLX,PRAY) ; Find stop date when 'doses' are sent as an IV Limit 131 Q:$G(DDLX)'["L" "" 132 I $P(DDLX,"L")["." S DDLX=($P(DDLX,".")+1)_"L" 133 I '$G(PRAY(15)),$G(PRAY(11)) S PRAY(15)=1440/$L(PRAY(11),"-") 134 Q:'$G(PRAY(2))!'$G(OIX) "" 135 N FIRST,DOSAR,LAST,TMP9 S LAST="",TMP9=PRAY(9) 136 S STRING=PRAY(2)_"^"_$S($G(STPDT):STPDT,1:$$FMADD^XLFDT(PSGDT,30))_"^"_PRAY(9)_"^C^"_OIX S FIRST=$$ENQ^PSJORP2(DFN,STRING) 137 S P(9)=TMP9 138 S FIRST=$S($G(FIRST):FIRST,1:PRAY(2)) Q:'FIRST S DSTMP=FIRST,DOSAR(1)=DSTMP D 139 .I '$G(PRAY(11)) F I=2:1:DDLX+1 S DOSAR(I)=$$FMADD^XLFDT(DSTMP,,,PRAY(15)),DSTMP=DOSAR(I) Q 140 .I $G(PRAY(11)) N ADMS,NXT,LAST,DAY S LAST=$P(DSTMP,".",2),DAY=$P(DSTMP,".") D 141 ..F II=1:1:$L(PRAY(11),"-") S ADMS(+$P(PRAY(11),"-",II))=$P(PRAY(11),"-",II) 142 ..F IJ=2:1:DDLX+1 S NXT=$O(ADMS(+LAST)),LAST=NXT D 143 ...I NXT="" S NXT=$O(ADMS(NXT)),LAST=NXT,DAY=$$FMADD^XLFDT(DAY,1) 144 ...S DOSAR(IJ)=DAY_"."_ADMS(NXT),DSTMP=DOSAR(IJ) 145 ..I +DDLX=1 S NXT=$O(ADMS(LAST)),LAST=NXT D 146 ...I NXT="" S NXT=$O(ADMS(NXT)),LAST=NXT 147 I $D(DOSAR) S LAST=$O(DOSAR(""),-1) I LAST S LAST=DOSAR(LAST) 148 Q LAST 1 PSIVCAL ;BIR/RGY,PR-CALCULATES START AND STOP DATES ;12 Mar 99 / 12:42 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**4,26,41,47,63,67,69,58,94,80,110,111,177,120**;16 DEC 97;Build 10 3 ; 4 ; Reference to ^PS(50.7 is supported by DBIA #2180. 5 ; Reference to ^PS(52.6 is supported by DBIA #1231. 6 ; Reference to ^PS(55 is supported by DBIA #2191. 7 ; 8 ENT ;NEEDS PSIVTYPE (P(4)) 9 I $G(PSJREN) D Q:P(2) 10 . I $G(P("OLDON")) N P2 S P2=$G(@("^PS(55,"_DFN_",""IV"","_+P("OLDON")_",0)")),P2=$P(P2,"^",2) I P2 S P(2)=P2 11 I $G(PSJORD)["P",$G(P("APPT"))?7N1"."1.N S START=$$DATE2^PSJUTL2(P("APPT")) G Q 12 I $G(PSJSYSW0)=""!($P(PSJSYSW0,U,5)=2) S START=+$E(P("LOG"),1,12) G Q 13 ;I $G(P("RES"))="R" N PSIVAC S PSIVAC="PR" D ENAD I PSIVADM S P(2)=PSIVADM Q 14 S PSIVSN=+P("IVRM"),START="",PSIVTYPE=$G(P(4)) Q:PSIVTYPE="" 15 N PSIV X $S($E(PSIVAC)="C":"S X=+$E(P(""LOG""),1,12) D H^%DTC S PSIV=%T",1:"S PSIV=$P($H,"","",2)") G T2:PSIVTYPE'["P"&('P(5)) 16 I P(11)']"" X $S($E(PSIVAC)="C":"S Y=+$E(P(""LOG""),1,12)",1:"D NOW^%DTC S Y=%") S Y=Y+.007\.01/100 S:'$P(Y,".",2) Y=$$MDNGHT(Y) X ^DD("DD") S START=Y G Q 17 S X=P(11) D CHK S PX=Y,X1=PSIV\3600,X2=PSIV#3600\60,X=$E(".0",1,$L(X1)#2+1)_X1_$E("0",X2<10)_X2,START=$S($E(PSIVAC)="C":$P(P("LOG"),"."),1:"T") 18 S X1=$P(PX,"-"),X1=$E(".0",1,$L(X1)#2+1)_X1,X2=$P(PX,"-",PSGCNT),X2=$E(".0",1,$L(X2)#2+1)_X2 19 S NAT=+$P($G(^PS(59.6,+$O(^PS(59.6,"B",+VAIN(4),0)),0)),U,5) 20 I '$D(PSGDT) S PSGDT=$$DATE^PSJUTL2() 21 I X<X1,'NAT S START=$$ENSD^PSGNE3(P(9),P(11),+$E(P("LOG"),1,12),PSGDT) G Q 22 I X>X2 S START=$$ENSD^PSGNE3(P(9),P(11),+$E(P("LOG"),1,12),PSGDT) G Q 23 T6 F I=2:1:PSGCNT S X1="."_$P(PX,"-",I-1),X2="."_$P(PX,"-",I) Q:+X1<X&(+X2>X) 24 S X1=X-X1,X2=$S(NAT:0,1:X2-X),START=$S(X1<X2:$P(PX,"-",I-1),1:$P(PX,"-",I)) S:START="" START=$P(PX,"-") X $S($E(PSIVAC)="C":"S Y=$P(P(""LOG""),""."") X ^DD(""DD"") S PSIV=Y",1:"S PSIV=""TODAY""") S START=PSIV_"@"_$E("0",$L(START)=3)_START G Q 25 T2 S X=+("."_$E(10000+(PSIV\3600*100)+(PSIV#3600\60),2,5)),START=$O(^PS(59.5,PSIVSN,3,"AT",X)) S:'START START=$O(^(0)),PSIVTOM=1 I 'START S START=X K PSIVTOM 26 S START=$S($E(PSIVAC)="C":$P(P("LOG"),"."),1:DT)_START I $D(PSIVTOM) S X1=$S($E(PSIVAC)="C":$P(P("LOG"),"."),1:DT),X2=1 D C^%DTC S Y=$P(X,".")_START K PSIVTOM 27 S X=START,%DT="XRTX" D ^%DT 28 Q ; 29 I START["@" S X=START,%DT="RTX" D ^%DT S START=+Y 30 S P(2)=START 31 I $G(PSJORD)["P" D:'$G(PSGRDTX(+PSJORD,"PSGSD")) REQDT^PSJLIVMD(PSJORD) S START=$G(PSGRDTX(+PSJORD,"PSGSD")) S P(2)=$S(START:START,1:P(2)) 32 K NAT,START,PSIVTYPE,PSIVSTRT,PSGCNT,X1,X2,PX 33 Q 34 CHK F Y=1:1 Q:$L(X)>240!($P(X,"-",Y)="") S $P(X,"-",Y)=$P(X,"-",Y)_$E("0000",1,4-$L($P(X,"-",Y))) 35 S Y=X,PSGCNT=$L(X,"-") S:X]""&(PSGCNT<1) PSGCNT=1 Q 36 ; 37 ENSTOP ; WILL CALCULATE STOP DATE FOR ORDER 38 ;NEEDS (DFN) & ON 39 N WALL,P3,ADX,DDLX,OIX,DRGT,PSIDAY,PSIMIN S (WALL,P3,PSIDAY,PSIMIN)=0 40 D:'$G(PSIVSITE) ^PSIVSET Q:'P(2) 41 I P(23)'="" S PSIVTYPE="C" 42 S STOP="",X="",PSIVSTRT=P(2),PSIVTYPE=$G(P(4)) I $G(PSJREN) D 43 . N RDT I $G(ON)["P" S RDT=+$$LASTREN^PSJLMPRI(DFN,ON) 44 . S PSIVSTRT=$$DATE2^PSJUTL2($S($G(RDT):RDT,1:$G(PSGDT))) 45 ;BHW - PSJ*5*177 - Begin Modifications - Reset Start date to Last Renewed date for active orders that have been renewed 46 I ('$G(PSJREN))&($G(P(4))="A")&($G(ON)["V") D 47 . N RDT S RDT=+$$LASTREN^PSJLMPRI(DFN,ON) 48 . I +RDT S PSIVSTRT=RDT 49 . Q 50 ;BHW - PSJ*5*177 - End Modifications - Resetting PSIVSTRT will recalculate the stop date based on the Last renewed date. 51 ; 52 I $S("^NOW^STAT^ONCE^ONE-TIME^ONE TIME^ONETIME^1TIME^1-TIME^1 TIME^"[(U_P(9)_U):1,1:0),PSIVTYPE="P"!P(5)!(P(23)="P") S X=$$ENOSD^PSJDCU(PSJSYSW0,PSIVSTRT,DFN) I X]"" S:P(11)=""&($G(ON)["P") PSIVCAL=1 G END 53 N DUR,DURMIN,PSJPROV,PSJDNM,A,PSJDAY I $G(PSJORD)["V" S DUR=$$GETDUR^PSJLIVMD(DFN,+PSJORD,"IV",1) I DUR]"" S DURMIN=$$DURMIN^PSJLIVMD(DUR) I DURMIN S PSIMIN=DURMIN 54 I $G(PSJORD)["P"!($G(PSJORD)["V") N MINS,LIM S PSIVLIM=$$GETLIM(DFN,PSJORD) I PSIVLIM]"" S MINS=$$GETMIN(PSIVLIM,DFN,PSJORD) I MINS,MINS<PSIMIN!'PSIMIN S PSIMIN=MINS 55 I $P(PSIVSITE,"^",5) D 56 . N Z S Y=0 57 . F S Y=$O(^PS(55,DFN,"IV",Y)) Q:'Y S Z=^(Y,0) D Q:X]"" 58 .. I $P(Z,"^",17)="A",$$ONE^PSJBCMA(DFN,Y_"V",$P(Z,"^",9))'="O" S X=$P(Z,"^",3) Q 59 S:X WALL=X 60 S PSIDAY=$S(PSIVTYPE="A":$P(PSIVSITE,"^",4),PSIVTYPE="H":$P(PSIVSITE,"^",17),PSIVTYPE="P":$P(PSIVSITE,"^",18),PSIVTYPE="S":$P(PSIVSITE,"^",20),1:$P(PSIVSITE,"^",21)) 61 S PSJDAY="" D I PSJDAY]"",PSJDAY<PSIDAY S PSIDAY=PSJDAY 62 . N A,B,PSJCLIN 63 . Q:'$D(PSJORD) S A="" 64 . I PSJORD["P" S A=$G(^PS(53.1,+PSJORD,"DSS")) 65 . I PSJORD["U" S A=$G(^PS(55,PSGP,5,+PSJORD,8)) 66 . I PSJORD["V" S A=$G(^PS(55,PSGP,"IV",+PSJORD,"DSS")) 67 . S (PSJCLIN,A)=$P(A,"^") Q:A="" S PSJCLIN=$P(^SC(PSJCLIN,0),"^") I $D(^PS(53.46,"B",A)) S B=$O(^PS(53.46,"B",A,"")),PSJDAY=$P(^PS(53.46,B,0),"^",2) 68 F X=0:0 S X=$O(DRG("AD",X)) Q:'X I $P(^PS(52.6,+$P(DRG("AD",+X),U),0),"^",4),($P(^(0),"^",4))<+PSIDAY S PSIDAY=$P(^(0),"^",4) 69 I WALL,($$FMADD^XLFDT(PSIVSTRT,PSIDAY,"D"))>WALL S PSIDAY=$$FMDIFF^XLFDT(WALL,PSIVSTRT,1) S:PSIDAY<1 PSIDAY="" 70 S DRGT=$S($D(DRG("AD")):"AD",1:"SOL") F ADX=0:0 S ADX=$O(DRG(DRGT,ADX)) Q:'ADX!($G(DRGTMP)&($G(DRGTN)["AD")&(DRGT="SOL")) D 71 . S OIX=+$P(DRG(DRGT,ADX),"^",6),DDLX=$P(^PS(50.7,OIX,0),"^",5) Q:'DDLX D DDLIM(.PSIDAY,.P3) 72 I '$G(DRG("AD",0)),$G(DRGTMP),($G(DRGTN)["SOL") S OIX=$P($G(DRGTMP),"^",6) I OIX S DDLX=$P(^PS(50.7,OIX,0),"^",5) I DDLX D DDLIM(.PSIDAY,.P3) 73 I $G(P3),$G(P(2)) I P3>P(2) S X=P3 G END 74 S:('PSIDAY&'PSIMIN) PSIDAY=1 75 TIME S X2=PSIDAY,X1=PSIVSTRT D C^%DTC S X=$P(X,"."),X=X_$S($P(PSIVSITE,"^",14)="":.2359,1:"."_$P(PSIVSITE,"^",14)) 76 I PSIMIN,PSIMIN<(PSIDAY*1440) S X=$$FMADD^XLFDT(PSIVSTRT,,,PSIMIN) D 77 . I '(PSIMIN#1440) S X=$P(X,"."),X=X_$S($P(PSIVSITE,"^",14)="":.2359,1:"."_$P(PSIVSITE,"^",14)) 78 END ; 79 S P(3)=+X 80 I $G(PSJORD)["P" D:'$G(PSGRDTX(+PSJORD,"PSGFD")) REQDT^PSJLIVMD(PSJORD) S P(3)=$S($G(PSGRDTX(+PSJORD,"PSGFD")):PSGRDTX(+PSJORD,"PSGFD"),1:P(3)) 81 S P(3)=$$DATE2^PSJUTL2(P(3)),P(2)=$$DATE2^PSJUTL2(P(2)) 82 Q 83 ; 84 ENAD ;Will get last admin. time for order (needs dfn and on) 85 N P4,PSIVX,PSIVY 86 I $P(PSJSYSW0,U,5)=2 S PSIVADM=$$DATE^PSJUTL2() Q 87 I $S($G(PSIVAC)["R":1,P(9)="QOD":1,1:P(9)?1"Q".N1"D") S PSIVADM=$$ENSD^PSGNE3(P(9),P(11),+$E(P("LOG"),1,12),+$P($G(^PS(55,DFN,"IV",+P("OLDON"),0)),U,2)) Q:PSIVADM 88 S PSIVX=X,PSIVY=Y,P4=P(4) S:P(4)="C" P4=P(23) S:P4="S" P4=$S(P(5):"P",1:"A") D NOW^%DTC S Y=%,PSIVNOW=Y I (P4="P"&(P(11)="")&'P(15))!("HA"[P4&'P(15)) S Y=Y+.007\.01/100 G QAD 89 D P:P4="P"&('P(15)),AH:P(15) 90 QAD ; 91 S:'$D(PSGSA) PSGSA="" 92 S PSIVSD=Y I Y S OD=$L(PSGSA," ") I OD>2 S X=+PSGSA\1 F OD1=2:1:OD-1 I $P(PSGSA," ",OD1)'>$S(OD1>2:$P(PSGSA," ",OD1-1),1:PSGSA#1) S X1=X,X2=1 D C^%DTC 93 I PSIVSD,OD>2 S Y=X_PSIVSD 94 S PSIVADM=+Y,X=PSIVX,Y=PSIVY K PSGSA,PSIVSD,OD,OD1,PSIVMI,PSIVNOW S:PSIVADM<P(2) PSIVADM=P(2) Q 95 ; 96 P S CD=PSIVNOW,PSGSA="",(PSIVSD,OD)=DT_.0001,X=P(11) D CHK S P(11)=X D ENP4^PSIVWL 97 I PSGSA="" S PSIVSD=DT_.0001,PSIVMIN=-1440 D ENT^PSIVWL S $P(Y,".",2)=$P(P(11),"-",$L(P(11),"-")) Q 98 S Y=$P(PSGSA," ",$L(PSGSA," ")-1) Q 99 AH F PSIVADM=0:-1 S CD=PSIVNOW,(X,X1)=DT,X2=PSIVADM D:X2 C^%DTC S X=$P(X,".") S (OD1,PSIVSD,OD)=X_.0001,PSIVMIN=P(15) D ENP3^PSIVWL Q:PSIVADM<-4!(PSGSA]"") 100 S Y=$P(PSGSA," ",$L(PSGSA," ")-1) Q 101 MDNGHT(Y) ;Sets Start Date/Time on orders placed between midnight and 12:30 102 S Y=$$FMADD^XLFDT(Y,-1,0,0,0),Y=$P(Y,".")_".24" Q Y 103 ; 104 DDLIM(PSIVDUR,STPDT) ; 105 N P3 106 I DDLX["D" D Q:(STPDT=0) 107 . I +DDLX'<+PSIVDUR S STPDT=0 Q 108 . S PSIVDUR=+DDLX,X2=PSIVDUR,X1=PSIVSTRT D C^%DTC S X=$P(X,"."),X=X_$S($P(PSIVSITE,"^",14)="":.2359,1:"."_$P(PSIVSITE,"^",14)) I X>P(2) S P(3)=X 109 I DDLX["L",($G(P(9))]""),$G(P(15)),("AH"'[PSIVTYPE) D 110 . Q:'$G(P(2))!'$G(OIX) N FIRST,DOSAR,LAST,NEWDUR 111 . S STRING=P(2)_"^"_$S($G(STPDT):STPDT,1:$$FMADD^XLFDT(PSGDT,30))_"^"_P(9)_"^C^"_OIX S FIRST=$$ENQ^PSJORP2(DFN,STRING) 112 . S FIRST=$S($G(FIRST):FIRST,1:P(2)) Q:'FIRST S DSTMP=FIRST,DOSAR(1)=DSTMP F I=2:1:DDLX+1 S DOSAR(I)=$$FMADD^XLFDT(DSTMP,,,P(15)),DSTMP=DOSAR(I) 113 . I $D(DOSAR) S LAST=$O(DOSAR(""),-1) I LAST S LAST=DOSAR(LAST) I LAST>P(2) S NEWDUR=$$FMDIFF^XLFDT(LAST,P(2)) I NEWDUR<PSIVDUR S P(3)=LAST 114 S P(3)=$$DATE2^PSJUTL2(P(3)),P(2)=$$DATE2^PSJUTL2(P(2)) S STPDT=P(3) 115 Q 116 ; 117 GETLIM(DFN,PSJORD) ; 118 N ND2P5,F 119 S F=$S(PSJORD["P":"^PS(53.1,+PSJORD,",PSJORD["V":"^PS(55,DFN,""IV"",+PSJORD,",1:"") 120 S ND2P5=$G(@(F_"2.5)")) S LIM=$P(ND2P5,"^",4) Q:LIM="" 0 121 S ND0=$G(@(F_"0)")) I PSJORD["P",$P(ND0,"^",4)="U" Q 0 122 N MULT S MULT=$S($E(LIM)="h":60,$E(LIM)="d":1440,$E(LIM)="m":LIM,$E(LIM)="l":LIM,1:0) I MULT S LIM=MULT*$E(LIM,2,99) 123 Q LIM 124 ; 125 GETMIN(LIM,DFN,PSJORD) ; 126 N F 127 I LIM!(LIM=0) Q LIM 128 S F=$S(PSJORD["P":"^PS(53.1,+PSJORD,",PSJORD["V":"^PS(55,DFN,""IV"",+PSJORD,",1:"") 129 N RATE S RATE=$S(PSJORD["P":+$P($G(@(F_"8)")),"^",5),PSJORD["V":+$P($G(@(F_"0)")),"^",8),1:0) I RATE D 130 . S LIM=$S($E(LIM)="m":$E(LIM,2,99),$E(LIM)="l":($E(LIM,2,99)*1000),1:0)/RATE S LIM=LIM*60 131 Q LIM -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVEDT.m
r613 r623 1 PSIVEDT ;BIR/MLM-EDIT IV ORDER ;10 Feb 98 / 3:23 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**4,110,127,133,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^DD(53.1 is supported by DBIA 2256. 5 ; Reference to ^PS(52.7 is supported by DBIA 2173. 6 ; Reference to ^PS(52.6 is supported by DBIA 1231. 7 ; Reference to ^PS(51.2 is supported by DBIA 2178. 8 ; Reference to ^PS(50.7 is supported by DBIA 2180. 9 ; Reference to ^PS(55 is supported by DBIA 2191. 10 ; 11 EDIT ; 12 I $G(DFN)&($G(PSJORD)["V") I $$COMPLEX^PSJOE(DFN,PSJORD) D 13 . N X,Y,PARENT,P2ND S P2ND=$S($G(^PS(55,PSGP,"IV",+PSJORD,.2)):$G(^PS(55,PSGP,"IV",+PSJORD,.2)),1:$G(^PS(55,PSGP,5,+PSJORD,.2))) 14 . S PARENT=$P(P2ND,"^",8) 15 . I PARENT D FULL^VALM1 W !!?5,"This order is part of a complex order. Please review the following ",!?5,"associated orders before changing this order." D CMPLX^PSJCOM1(PSGP,PARENT,PSJORD) 16 S DONE=0 17 F PSIVE=1:1 S:DONE&$E(PSIVAC)="C" OREND=1 Q:PSIVE>$L(EDIT,U)!(DONE) Q:'$L($P(EDIT,U,PSIVE)) D @($P(EDIT,U,PSIVE)) S:$E(PSIVAC,2)="N" PSIVOK=PSIVOK_U_$P(EDIT,U,PSIVE) I $E(X)=U,$L(X)>1 S:PSIVE>1 PSIVE=PSIVE-1 F D FF Q:Y<0 D @Y Q:$E(X)'=U 18 K EDIT,PSIVOK,PSGDI 19 Q 20 ; 21 1 ; Provider. 22 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+$G(ON),0)),"^",24)="R" D Q 23 . W !!?5,"This is Renewal order. Provider may not be edited at this point." D PAUSE^VALM1 24 I $G(DFN)&($G(ON)["V") I $$COMPLEX^PSJOE(DFN,ON) D Q 25 .Q:$G(PSJBKDR) W !!?5,"This is a Complex Order. Provider may not be edited at this point." D PAUSE^VALM1 26 S P(6)=$S('$G(^VA(200,+P(6),"PS")):"",'$P(^("PS"),U,4):P(6),$P(^("PS"),U,4)<DT:"",1:P(6)) 27 W !,"PROVIDER: "_$S($P(P(6),U,2)]"":$P(P(6),U,2)_"//",1:"") R X:DTIME S:'$T X=U S:X=U DONE=1 I $E(X)=U!(X=""&P(6)) Q 28 I X["???",($E(P("OT"))="I"),(PSIVAC["C") D ORFLDS^PSIVEDT1 G 1 29 I X]"" K DIC S DIC=200,DIC(0)="EQMZ",DIC("S")="I $D(^(""PS"")),^(""PS""),$S('$P(^(""PS""),U,4):1,$P(^(""PS""),U,4)>DT:1,1:0)" D ^DIC K DIC I Y>0 S P(6)=+Y_U_Y(0,0) Q 30 S F1=53.1,F2=1 D ENHLP^PSIVORC1 W $C(7),!!,"A Provider must be entered.",!! G 1 31 Q 32 ; 33 3 ; Med Route. 34 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+ON,0)),"^",24)="R" D Q 35 . W !!?5,"Med Route may not be edited at this point." D PAUSE^VALM1 36 I $G(DFN)&($G(ON)["V") I $$COMPLEX^PSJOE(DFN,ON) D Q 37 .Q:$G(PSJBKDR) W !!?5,"This is a Complex Order. Med Route may not be edited at this point." D PAUSE^VALM1 38 S P(6)=$S('$G(^VA(200,+P(6),"PS")):"",'$P(^("PS"),U,4):P(6),$P(^("PS"),U,4)<DT:"",1:P(6)) 39 I P("MR")="" D 40 .N AD,SOL,OI,RT,RTCNT 41 .S AD=0 F S AD=$O(DRG("AD",AD)) Q:'AD S OI=$P(DRG("AD",AD),"^",6) I OI S OI(OI)="" 42 .S SOL=0 F S SOL=$O(DRG("SOL",SOL)) Q:'SOL S OI=$P(DRG("SOL",SOL),"^",6) I OI S OI(OI)="" 43 .S OI="" F S OI=$O(OI(OI)) Q:'OI S RT=$P(^PS(50.7,OI,0),"^",6) S:RT="" RT="NONE" S RT(RT)=$P($G(^PS(51.2,+RT,0)),"^",3) 44 .S RT="" F RTCNT=0:1 S RT=$O(RT(RT)) Q:RT="" 45 .Q:RTCNT>1 46 .S RT=$O(RT("")) I RT]"" S P("MR")=RT_"^"_$G(RT(RT)) 47 W !,"MED ROUTE: "_$S($P(P("MR"),U,2)]"":$P(P("MR"),U,2)_"//",1:"") R X:DTIME S:'$T X=U S:X=U DONE=1 I X=U!(X=""&P("MR"))!($E(X)=U) Q 48 I X["???",($E(P("OT"))="I"),(PSIVAC["C") D ORFLDS^PSIVEDT1 G 3 49 I X]"" K DIC S DIC=51.2,DIC(0)="EQMZ",DIC("S")="I $P(^(0),U,4)" D ^DIC K DIC I Y>0 S P("MR")=+Y_U_$P(Y(0),U,3) Q 50 S F1=53.1,F2=3 D ENHLP^PSIVORC1 W $C(7),!!,"A Med Route must be entered." G 3 51 Q 52 ; 53 10 ; Start Date. 54 D 10^PSIVEDT1 55 Q 56 ; 57 25 ; Stop Date. 58 D 25^PSIVEDT1 59 Q 60 26 ; Schedule 61 D 26^PSIVEDT1 62 Q 63 ; 64 39 ; Admin Times. 65 D 39^PSIVEDT1 66 Q 67 ; 68 57 ; Additive. 69 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+ON,0)),"^",24)="R" D Q 70 . W !!?5,"Additive may not be edited at this point." D PAUSE^VALM1 71 I $G(DFN)&($G(ON)["V") I $$COMPLEX^PSJOE(DFN,ON) D Q 72 .Q:$G(PSJBKDR) W !!?5,"This is a Complex Order. Provider may not be edited at this point." D PAUSE^VALM1 73 I $E(PSIVAC)="O" W !!,"Only additives marked for use in IV Fluid Order Entry may be selected." 74 S FIL=52.6,DRGT="AD",DRGTN="ADDITIVE" D DRG^PSIVEDRG,DKILL 75 Q 76 ; 77 58 ; Solution. 78 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+ON,0)),"^",24)="R" D Q 79 . W !!?5,"Solution may not be edited at this point." D PAUSE^VALM1 80 S FIL=52.7,DRGT="SOL",DRGTN="SOLUTION" D DRG^PSIVEDRG 81 ; 82 DKILL ; Kill for drug edit. 83 K DRGI,DRGN,DRGT,DRGTN,FIL,PSIVSTR 84 Q 85 ; 86 59 ; Infusion Rate. 87 D 59^PSIVEDT1 88 Q 89 ; 90 62 ; IV Room. 91 N DIR S DIR(0)="PA^59.5",DIR("A")="IV Room: ",DIR("??")="^S F1=59.5,F2=.01 D ENHLP^PSIVORC1" S:P("IVRM") DIR("B")=$P(P("IVRM"),U,2) 92 D ^DIR Q:$D(DIRUT) I Y>0 S P("IVRM")=Y W $P($P(Y,U,2),X,2) 93 Q 94 ; 95 63 ; Remarks. 96 D 63^PSIVEDT1 97 Q 98 ; 99 64 ; Other Print Info. 100 D 64^PSIVEDT1 101 Q 102 ; 103 66 ; Provider's comments. 104 N DA,DIE,DIR S DA=PSIVUP,DIE="^PS(53.45,",DR=4 D ^DIE S PSGSI=X,Y=1 105 Q 106 ; 107 101 ; Orderable Item. 108 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+ON,0)),"^",24)="R" D Q 109 . W !!?5,"This is Renewal order. Orderable Item may not be edited at this point." D PAUSE^VALM1 110 I $G(DFN)&($G(ON)["V") I $$COMPLEX^PSJOE(DFN,ON) D Q 111 .Q:$G(PSJBKDR) W !!?5,"This is a Complex Order. Orderable Item may not be edited at this point." D PAUSE^VALM1 112 W !,"Orderable Item: "_$S(P("PD"):$P(P("PD"),U,2)_"//",1:"") R X:DTIME S:'$T X=U S:X=U DONE=1 I $E(X)=U!(X=""&P("PD")) Q 113 I X]"" N DIC S DIC="^PS(50.7,",DIC(0)="EMQZ",DIC("B")=$S(P("PD")]"":+$P(("PD"),U),1:""),DIC("S")="S PSJSCT=1 I $$DRGSC^PSIVUTL(Y,PSJSCT) K PSJSCT" D ^DIC K DIC I Y>0 S P("PD")=Y Q 114 W $C(7),!!,"Orderable Item is required!",!! G 101 115 Q 116 109 ; Dosage Ordered. 117 W !,"DOSAGE ORDERED: "_$S(P("DO")]"":P("DO")_"//",1:"") R X:DTIME S:'$T X=U S:X=U DONE=1 I $E(X)=U!(P("DO")]""&(X="")) Q 118 I X="???" D ORFLDS^PSIVEDT1 G 109 119 D:X]"" CHK^DIE(53.1,109,"",X,.X) I $G(X)="^" W $C(7),!!,"Enter the dosage in which the Orderable Item entered should be dispensed.",! W "Answer must be 1-20 characters in length." G 109 120 S P("DO")=X 121 Q 122 ; 123 FF ; up-arrow to another field. 124 N DIC S X=$P(X,U,2),DIC="^DD(53.1,",DIC(0)="QEM",DIC("S")="I U_PSIVOK_U[(U_+Y_U)" D ^DIC K DIC S Y=+Y 125 Q 126 ; 127 NEWDRG ; Ask if adding a new drug. 128 K DIR S DIR(0)="Y",DIR("A")="Are you adding "_$P(TDRG,U,2)_" as a new "_$S(DRGT="AD":"additive",1:"solution")_" for this order",DIR("B")="NO" D ^DIR I $D(DTOUT)!$D(DUOUT) Q 129 I Y S (DRGI,DRG(DRGT,0))=DRG(DRGT,0)+1,DRG=TDRG,DRG(DRGT,+DRGI)=+DRG_U_$P(DRG,U,2) I DRGT="SOL" S X=$G(^PS(52.7,+DRG,0)),$P(DRG(DRGT,DRG),U,3)=$P(X,U,3) 130 Q 1 PSIVEDT ;BIR/MLM-EDIT IV ORDER ;10 Feb 98 / 3:23 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**4,110,127,133**;16 DEC 97 3 ; 4 ; Reference to ^DD(53.1 is supported by DBIA 2256. 5 ; Reference to ^PS(52.7 is supported by DBIA 2173. 6 ; Reference to ^PS(52.6 is supported by DBIA 1231. 7 ; Reference to ^PS(51.2 is supported by DBIA 2178. 8 ; Reference to ^PS(50.7 is supported by DBIA 2180. 9 ; Reference to ^PS(55 is supported by DBIA 2191. 10 ; 11 EDIT ; 12 I $G(DFN)&($G(PSJORD)["V") I $$COMPLEX^PSJOE(DFN,PSJORD) D 13 . N X,Y,PARENT,P2ND S P2ND=$S($G(^PS(55,PSGP,"IV",+PSJORD,.2)):$G(^PS(55,PSGP,"IV",+PSJORD,.2)),1:$G(^PS(55,PSGP,5,+PSJORD,.2))) 14 . S PARENT=$P(P2ND,"^",8) 15 . I PARENT D FULL^VALM1 W !!?5,"This order is part of a complex order. Please review the following ",!?5,"associated orders before changing this order." D CMPLX^PSJCOM1(PSGP,PARENT,PSJORD) 16 S DONE=0 17 F PSIVE=1:1 S:DONE&$E(PSIVAC)="C" OREND=1 Q:PSIVE>$L(EDIT,U)!(DONE) Q:'$L($P(EDIT,U,PSIVE)) D @($P(EDIT,U,PSIVE)) S:$E(PSIVAC,2)="N" PSIVOK=PSIVOK_U_$P(EDIT,U,PSIVE) I $E(X)=U,$L(X)>1 S:PSIVE>1 PSIVE=PSIVE-1 F D FF Q:Y<0 D @Y Q:$E(X)'=U 18 K EDIT,PSIVOK,PSGDI 19 Q 20 ; 21 1 ; Provider. 22 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+$G(ON),0)),"^",24)="R" D Q 23 . W !!?5,"This is Renewal order. Provider may not be edited at this point." D PAUSE^VALM1 24 I $G(DFN)&($G(ON)["V") I $$COMPLEX^PSJOE(DFN,ON) D Q 25 .Q:$G(PSJBKDR) W !!?5,"This is a Complex Order. Provider may not be edited at this point." D PAUSE^VALM1 26 S P(6)=$S('$G(^VA(200,+P(6),"PS")):"",'$P(^("PS"),U,4):P(6),$P(^("PS"),U,4)<DT:"",1:P(6)) 27 W !,"PROVIDER: "_$S($P(P(6),U,2)]"":$P(P(6),U,2)_"//",1:"") R X:DTIME S:'$T X=U S:X=U DONE=1 I $E(X)=U!(X=""&P(6)) Q 28 I X["???",($E(P("OT"))="I"),(PSIVAC["C") D ORFLDS^PSIVEDT1 G 1 29 I X]"" K DIC S DIC=200,DIC(0)="EQMZ",DIC("S")="I $D(^(""PS"")),^(""PS""),$S('$P(^(""PS""),U,4):1,$P(^(""PS""),U,4)>DT:1,1:0)" D ^DIC K DIC I Y>0 S P(6)=+Y_U_Y(0,0) Q 30 S F1=53.1,F2=1 D ENHLP^PSIVORC1 W $C(7),!!,"A Provider must be entered.",!! G 1 31 Q 32 ; 33 3 ; Med Route. 34 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+ON,0)),"^",24)="R" D Q 35 . W !!?5,"Med Route may not be edited at this point." D PAUSE^VALM1 36 I $G(DFN)&($G(ON)["V") I $$COMPLEX^PSJOE(DFN,ON) D Q 37 .Q:$G(PSJBKDR) W !!?5,"This is a Complex Order. Med Route may not be edited at this point." D PAUSE^VALM1 38 S P(6)=$S('$G(^VA(200,+P(6),"PS")):"",'$P(^("PS"),U,4):P(6),$P(^("PS"),U,4)<DT:"",1:P(6)) 39 I P("MR")="" S X=$O(^PS(51.2,"B","INTRAVENOUS",0)) I $P($G(^PS(51.2,+X,0)),U,4) S P("MR")=+X_U_$P(^(0),U,3) 40 W !,"MED ROUTE: "_$S($P(P("MR"),U,2)]"":$P(P("MR"),U,2)_"//",1:"") R X:DTIME S:'$T X=U S:X=U DONE=1 I X=U!(X=""&P("MR"))!($E(X)=U) Q 41 I X["???",($E(P("OT"))="I"),(PSIVAC["C") D ORFLDS^PSIVEDT1 G 3 42 I X]"" K DIC S DIC=51.2,DIC(0)="EQMZ",DIC("S")="I $P(^(0),U,4)" D ^DIC K DIC I Y>0 S P("MR")=+Y_U_$P(Y(0),U,3) Q 43 S F1=53.1,F2=3 D ENHLP^PSIVORC1 W $C(7),!!,"A Med Route must be entered." G 3 44 Q 45 ; 46 10 ; Start Date. 47 D 10^PSIVEDT1 48 Q 49 ; 50 25 ; Stop Date. 51 D 25^PSIVEDT1 52 Q 53 26 ; Schedule 54 D 26^PSIVEDT1 55 Q 56 ; 57 39 ; Admin Times. 58 D 39^PSIVEDT1 59 Q 60 ; 61 57 ; Additive. 62 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+ON,0)),"^",24)="R" D Q 63 . W !!?5,"Additive may not be edited at this point." D PAUSE^VALM1 64 I $G(DFN)&($G(ON)["V") I $$COMPLEX^PSJOE(DFN,ON) D Q 65 .Q:$G(PSJBKDR) W !!?5,"This is a Complex Order. Provider may not be edited at this point." D PAUSE^VALM1 66 I $E(PSIVAC)="O" W !!,"Only additives marked for use in IV Fluid Order Entry may be selected." 67 S FIL=52.6,DRGT="AD",DRGTN="ADDITIVE" D DRG^PSIVEDRG,DKILL 68 Q 69 ; 70 58 ; Solution. 71 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+ON,0)),"^",24)="R" D Q 72 . W !!?5,"Solution may not be edited at this point." D PAUSE^VALM1 73 S FIL=52.7,DRGT="SOL",DRGTN="SOLUTION" D DRG^PSIVEDRG 74 ; 75 DKILL ; Kill for drug edit. 76 K DRGI,DRGN,DRGT,DRGTN,FIL,PSIVSTR 77 Q 78 ; 79 59 ; Infusion Rate. 80 D 59^PSIVEDT1 81 Q 82 ; 83 62 ; IV Room. 84 N DIR S DIR(0)="PA^59.5",DIR("A")="IV Room: ",DIR("??")="^S F1=59.5,F2=.01 D ENHLP^PSIVORC1" S:P("IVRM") DIR("B")=$P(P("IVRM"),U,2) 85 D ^DIR Q:$D(DIRUT) I Y>0 S P("IVRM")=Y W $P($P(Y,U,2),X,2) 86 Q 87 ; 88 63 ; Remarks. 89 D 63^PSIVEDT1 90 Q 91 ; 92 64 ; Other Print Info. 93 D 64^PSIVEDT1 94 Q 95 ; 96 66 ; Provider's comments. 97 N DA,DIE,DIR S DA=PSIVUP,DIE="^PS(53.45,",DR=4 D ^DIE S PSGSI=X,Y=1 98 Q 99 ; 100 101 ; Orderable Item. 101 I $G(P("RES"))="R" I $G(PSJORD)["P",$P($G(^PS(53.1,+ON,0)),"^",24)="R" D Q 102 . W !!?5,"This is Renewal order. Orderable Item may not be edited at this point." D PAUSE^VALM1 103 I $G(DFN)&($G(ON)["V") I $$COMPLEX^PSJOE(DFN,ON) D Q 104 .Q:$G(PSJBKDR) W !!?5,"This is a Complex Order. Orderable Item may not be edited at this point." D PAUSE^VALM1 105 W !,"Orderable Item: "_$S(P("PD"):$P(P("PD"),U,2)_"//",1:"") R X:DTIME S:'$T X=U S:X=U DONE=1 I $E(X)=U!(X=""&P("PD")) Q 106 I X]"" N DIC S DIC="^PS(50.7,",DIC(0)="EMQZ",DIC("B")=$S(P("PD")]"":+$P(("PD"),U),1:""),DIC("S")="S PSJSCT=1 I $$DRGSC^PSIVUTL(Y,PSJSCT) K PSJSCT" D ^DIC K DIC I Y>0 S P("PD")=Y Q 107 W $C(7),!!,"Orderable Item is required!",!! G 101 108 Q 109 109 ; Dosage Ordered. 110 W !,"DOSAGE ORDERED: "_$S(P("DO")]"":P("DO")_"//",1:"") R X:DTIME S:'$T X=U S:X=U DONE=1 I $E(X)=U!(P("DO")]""&(X="")) Q 111 I X="???" D ORFLDS^PSIVEDT1 G 109 112 D:X]"" CHK^DIE(53.1,109,"",X,.X) I $G(X)="^" W $C(7),!!,"Enter the dosage in which the Orderable Item entered should be dispensed.",! W "Answer must be 1-20 characters in length." G 109 113 S P("DO")=X 114 Q 115 ; 116 FF ; up-arrow to another field. 117 N DIC S X=$P(X,U,2),DIC="^DD(53.1,",DIC(0)="QEM",DIC("S")="I U_PSIVOK_U[(U_+Y_U)" D ^DIC K DIC S Y=+Y 118 Q 119 ; 120 NEWDRG ; Ask if adding a new drug. 121 K DIR S DIR(0)="Y",DIR("A")="Are you adding "_$P(TDRG,U,2)_" as a new "_$S(DRGT="AD":"additive",1:"solution")_" for this order",DIR("B")="NO" D ^DIR I $D(DTOUT)!$D(DUOUT) Q 122 I Y S (DRGI,DRG(DRGT,0))=DRG(DRGT,0)+1,DRG=TDRG,DRG(DRGT,+DRGI)=+DRG_U_$P(DRG,U,2) I DRGT="SOL" S X=$G(^PS(52.7,+DRG,0)),$P(DRG(DRGT,DRG),U,3)=$P(X,U,3) 123 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVORA.m
r613 r623 1 PSIVORA ;BIR/MLM-MAIN DRIVER FOR IV FLUIDS - OE/RR INTERFACE ;08 JAN 97 / 2:47 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**29,41,110,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191 5 ; 6 EN ; Entry point called by IV Fluid protocol. 7 S X=ORACTION,PSIVAC="O"_$S(X=0:"N",X=1:"E",X=2:"R",X=4:"H",X=6:"D",X="8":"S",1:"") S:X'=5&(X'=7) PSIVUP=+$$GTPCI^PSIVUTL 8 S (PSGP,DFN)=+ORVP,PSJACNWP=1 D ^PSJAC I "578"[ORACTION D @ORACTION,DONE^PSIVORA1 Q 9 D ENCPP^PSIVOREN Q:'PSJIVORF!('PSJORF) D EN1,DONE^PSIVORA1 10 Q 11 ; 12 EN1 ; Take action on existing order. 13 S PSJORD=$G(ORPK) I ORGY>8 D @ORGY Q 14 I 'ORACTION D ^PSIVORFE Q 15 I '$G(ORPK) W !,"INSUFFICIENT INFORMATION, CANNOT CONTINUE." S OREND=1 Q 16 I ORPK["V",($P($G(^PS(55,DFN,"IV",+ORPK,0)),U,17)="O") D ONCALL^PSIVORV1 Q 17 I ORACTION<3 S P("FRES")=$S(ORPK["V":$P($G(^PS(55,DFN,"IV",+ORPK,2)),U,9),1:$P($G(^PS(53.1,+ORPK,0)),U,27)) I P("FRES")]"" D @$S(P("FRES")="R":"ALLREN^PSIVORV1",1:"ALLED^PSIVORV1") Q 18 S PSJORSTS=ORSTS,PSJORIFN=ORIFN L +@$S(PSJORD["V":"^PS(55,DFN,""IV"",+PSJORD)",1:"^PS(53.1,+PSJORD)"):1 E D LOCKERR^PSIVORA1 Q 19 D @ORACTION L -@$S(PSJORD["V":"^PS(55,DFN,""IV"",+PSJORD)",1:"^PS(53.1,+PSJORD)") 20 Q 21 ; 22 1 ; Edit an existing order. 23 D EDIT^PSIVORA1 24 Q 25 ; 26 2 ; Renew 27 D RENEW^PSIVORA1 28 Q 29 ; 30 3 ; Flag 31 Q 32 ; 33 4 ; Hold 34 I ORSTS'=3,ORSTS'=6 W !,$C(7),"Only ACTIVE orders may be placed on HOLD." S OREND=1 Q 35 S PSIVREA=$S(ORSTS=6:"H",1:"U"),ON55=PSJORD,$P(^PS(55,DFN,"IV",+ON55,0),U,10)=$S(PSIVREA="H":1,1:""),Y=$G(^PS(55,DFN,"IV",+ON55,0)),P(3)=$P(Y,U,3),P(17)=$P(Y,U,17) 36 D NOW^%DTC I ORSTS=3,P(3)<% S P(17)="E" D UPSTAT^PSIVOPT S ORSTS=7 W $C(7)," This order has expired." Q 37 S XED=0,PSIVALT=2,P(17)=$S(PSIVREA="H":"H",1:"A") D UPSTAT^PSIVOPT,LOG^PSIVORAL S ORSTS=$S(PSIVREA="H":3,1:6) 38 Q 39 ; 40 5 ; Event 41 N DA,DIE,DR,ON,P,PSIVACT,X 42 S ON=ORPK I ON["V" S X=$G(^PS(55,+ORVP,"IV",+ON,0)),P(3)=$P(X,U,3),P(17)=$P(X,U,17) 43 I ON'["V" S P(3)=$P($G(^PS(53.1,+ON,2)),U,4),P(17)=$P($G(^PS(53.1,+ON,0)),U,9) 44 Q:"AR"'[P(17) D NOW^%DTC Q:P(3)>% 45 I ON["V" S DR="100///E",DIE="^PS(55,"_+ORVP_",""IV"",",DA(1)=+ORVP 46 I ON'["V" S DR="28///E",DIE="^PS(53.1," 47 S PSIVACT=1,DA=+ON D ^DIE S ORSTS=7 48 Q 49 ; 50 6 ; Cancel - Delete pending or unreleased orders from Nonverified orders 51 ; (53.1) and Orders (100) files. 52 I ORSTS=1 W $C(7),!,"This order has already been DISCONTINUED." Q 53 I ORSTS=7 W $C(7),!,"Expired orders cannot be DISCONTINUED." Q 54 I PSJORD'["V",ORSTS=11 D Q 55 .S P("OLDON")=$P($G(^PS(53.1,+PSJORD,0)),U,25) I P("OLDON") D 56 ..I P("OLDON")["V",$D(^PS(55,DFN,"IV",+P("OLDON"),2)) S PSJRES=$P(^(2),U,9) S:PSJRES'="R" $P(^(2),U,6)="",$P(^(2),U,9)="" ;; D:PSJRES="R" ENBKOUT^PSJOREN(DFN,PSJORD) 57 ..I P("OLDON")'["V",$D(^PS(53.1,+P("OLDON"),0)) S PSJRES=$P(^(0),U,27) S:PSJRES'="R" $P(^(0),U,26,27)="^" I PSJRES="R" ;; D ENBKOUT^PSJOREN(DFN,PSJORD) 58 .K DA,DIK S DIK="^PS(53.1,",DA=+PSJORD D ^DIK S PSGP=DFN,X="P" D ENSK^PSGAXR K DA,DIK S ORIFN=PSJORIFN,ORSTS="K" Q 59 ; 60 DC ; DC order from Pharmacy complete function. 61 I PSJORD["V",'PSJCOM N PSIVREA S ON55=PSJORD,X=$G(^PS(55,DFN,"IV",+ON55,0)),P(3)=$P(X,U,3),P(17)=$P(X,U,17),PSIVREA="D",PSIVALT=2,PSIVALCK="STOP" D D^PSIVOPT2 D HL Q 62 I PSJORD["V",PSJCOM N PSIVREA S ON55=PSJORD,X=$G(^PS(55,DFN,"IV",+ON55,0)),P(3)=$P(X,U,3),P(17)=$P(X,U,17),PSIVREA="D",PSIVALT=2,PSIVALCK="STOP" D D^PSIVOPT2 Q 63 N DA,DR,DIE,PSJND S DA=+PSJORD,PSJND=$G(^PS(53.1,DA,0)),P("OLDON")=$P(PSJND,U,25),DIE="^PS(53.1,",DR="28///"_$S($P(PSJND,U,27)="E":"DE",1:"D") D ^DIE 64 D HL 65 Q 66 HL ; 67 Q:'$D(P("NAT")) 68 NEW PSJCD,PSJTX,PSJOTMP 69 I PSJORD["P" N PSJNOO S PSJCD="OC",PSJTX="ORDER CANCELED",PSJNOO=$G(P("NAT")) 70 E S PSJCD="OD",PSJTX="ORDER DISCONTINUED" 71 S PSJOTMP=$G(P("OT")) S P("OT")="F" D EN1^PSJHL2(DFN,PSJCD,PSJORD,PSJTX) 72 Q 73 ; 74 7 ; Purge 75 N ND S ND=$S(ORPK["V":$P($G(^PS(55,+ORVP,"IV",+ORPK,0)),U,17)_U_$P($G(^(0)),U,3),1:$P($G(^PS(53.1,+ORPK,0)),U,9)_U_$P($G(^(2)),U,4)) 76 Q:"DE"'[$P(ND,U) S X1=+$P(ND,U,2),X2=30 D C^%DTC S ND=X D NOW^%DTC Q:ND>% 77 I ORPK["V",$D(^PS(55,+ORVP,"IV",+ORPK,0)) S $P(^(0),U,21)="" 78 I ORPK'["V",$D(^PS(53.1,+ORPK,0)) S $P(^(0),U,21)="" 79 S ORSTS="K" 80 Q 81 ; 82 8 ; Print 83 K DIR S DIR(0)="E" D ^DIR K DIR I $D(DUOUT)!'($D(ORPK)) S OREND=1 Q 84 S:'$G(PSIVUP) PSIVUP=+$$GTPCI^PSIVUTL S:'$D(PSIVAC) PSIVAC="OS" S (ON,ON55)=ORPK,DFN=+ORVP D @$S(ON["V":"GT55^PSIVORFB",1:"GT531^PSIVORFA("_DFN_","""_ON_""")"),ENDT^PSIVORV1 85 Q 86 ; 87 9 ; Release order (status=incomplete in 53.1, pending in 100) 88 S X=ORACTION I X=4!(X=6) D @ORACTION Q 89 Q:"36"[ORSTS N ON,PSJORIFN S PSJORIFN=ORIFN,ON=ORPK L +^PS(53.1,+ON):1 E D LOCKERR^PSIVORA1 Q 90 S Y=$G(^PS(53.1,+ON,0)),P("RES")=$P(Y,U,24),P("OLDON")=$P(Y,U,25) 91 N DA,DIE,DR,OREND S DR="28////P",DIE="^PS(53.1,",DA=+ON D ^DIE 92 I P("OLDON")]"" K DA,DIE,DR S DA=P("OLDON") D 93 .I DA["V" S DA(1)=+ORPV,DIE="^PS(55,"_DA(1)_",""IV"",",DR="114////"_+ON_"P"_";123////"_P("RES") 94 .E S DIE="^PS(53.1,",DR="105////"_ON_"P"_";107////"_P("RES") I P("RES")="E",$P($G(^PS(53.1,+P("OLDON"),0)),U,9)="D" S DR=DR_";28////DE" 95 .S DA=+DA L +@(DIE_DA_")"):1 E D LOCKERR^PSIVORA1 Q 96 .D ^DIE L -@(DIE_DA_")") 97 L -^PS(53.1,+ON) D DONE^PSIVORA1 98 Q 99 ; 100 10 ; Verify 101 Q 1 PSIVORA ;BIR/MLM-MAIN DRIVER FOR IV FLUIDS - OE/RR INTERFACE ;08 JAN 97 / 2:47 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**29,41,110**;16 DEC 97 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191 5 ; 6 EN ; Entry point called by IV Fluid protocol. 7 S X=ORACTION,PSIVAC="O"_$S(X=0:"N",X=1:"E",X=2:"R",X=4:"H",X=6:"D",X="8":"S",1:"") S:X'=5&(X'=7) PSIVUP=+$$GTPCI^PSIVUTL 8 S (PSGP,DFN)=+ORVP,PSJACNWP=1 D ^PSJAC I "578"[ORACTION D @ORACTION,DONE^PSIVORA1 Q 9 D ENCPP^PSIVOREN Q:'PSJIVORF!('PSJORF) D EN1,DONE^PSIVORA1 10 Q 11 ; 12 EN1 ; Take action on existing order. 13 S PSJORD=$G(ORPK) I ORGY>8 D @ORGY Q 14 I 'ORACTION D ^PSIVORFE Q 15 I '$G(ORPK) W !,"INSUFFICIENT INFORMATION, CANNOT CONTINUE." S OREND=1 Q 16 I ORPK["V",($P($G(^PS(55,DFN,"IV",+ORPK,0)),U,17)="O") D ONCALL^PSIVORV1 Q 17 I ORACTION<3 S P("FRES")=$S(ORPK["V":$P($G(^PS(55,DFN,"IV",+ORPK,2)),U,9),1:$P($G(^PS(53.1,+ORPK,0)),U,27)) I P("FRES")]"" D @$S(P("FRES")="R":"ALLREN^PSIVORV1",1:"ALLED^PSIVORV1") Q 18 S PSJORSTS=ORSTS,PSJORIFN=ORIFN L +@$S(PSJORD["V":"^PS(55,DFN,""IV"",+PSJORD)",1:"^PS(53.1,+PSJORD)"):1 E D LOCKERR^PSIVORA1 Q 19 D @ORACTION L -@$S(PSJORD["V":"^PS(55,DFN,""IV"",+PSJORD)",1:"^PS(53.1,+PSJORD)") 20 Q 21 ; 22 1 ; Edit an existing order. 23 D EDIT^PSIVORA1 24 Q 25 ; 26 2 ; Renew 27 D RENEW^PSIVORA1 28 Q 29 ; 30 3 ; Flag 31 Q 32 ; 33 4 ; Hold 34 I ORSTS'=3,ORSTS'=6 W !,$C(7),"Only ACTIVE orders may be placed on HOLD." S OREND=1 Q 35 S PSIVREA=$S(ORSTS=6:"H",1:"U"),ON55=PSJORD,$P(^PS(55,DFN,"IV",+ON55,0),U,10)=$S(PSIVREA="H":1,1:""),Y=$G(^PS(55,DFN,"IV",+ON55,0)),P(3)=$P(Y,U,3),P(17)=$P(Y,U,17) 36 D NOW^%DTC I ORSTS=3,P(3)<% S P(17)="E" D UPSTAT^PSIVOPT S ORSTS=7 W $C(7)," This order has expired." Q 37 S XED=0,PSIVALT=2,P(17)=$S(PSIVREA="H":"H",1:"A") D UPSTAT^PSIVOPT,LOG^PSIVORAL S ORSTS=$S(PSIVREA="H":3,1:6) 38 Q 39 ; 40 5 ; Event 41 N DA,DIE,DR,ON,P,PSIVACT,X 42 S ON=ORPK I ON["V" S X=$G(^PS(55,+ORVP,"IV",+ON,0)),P(3)=$P(X,U,3),P(17)=$P(X,U,17) 43 I ON'["V" S P(3)=$P($G(^PS(53.1,+ON,2)),U,4),P(17)=$P($G(^PS(53.1,+ON,0)),U,9) 44 Q:"AR"'[P(17) D NOW^%DTC Q:P(3)>% 45 I ON["V" S DR="100///E",DIE="^PS(55,"_+ORVP_",""IV"",",DA(1)=+ORVP 46 I ON'["V" S DR="28///E",DIE="^PS(53.1," 47 S PSIVACT=1,DA=+ON D ^DIE S ORSTS=7 48 Q 49 ; 50 6 ; Cancel - Delete pending or unreleased orders from Nonverified orders 51 ; (53.1) and Orders (100) files. 52 I ORSTS=1 W $C(7),!,"This order has already been DISCONTINUED." Q 53 I ORSTS=7 W $C(7),!,"Expired orders cannot be DISCONTINUED." Q 54 I PSJORD'["V",ORSTS=11 D Q 55 .S P("OLDON")=$P($G(^PS(53.1,+PSJORD,0)),U,25) I P("OLDON") D 56 ..I P("OLDON")["V",$D(^PS(55,DFN,"IV",+P("OLDON"),2)) S PSJRES=$P(^(2),U,9) S:PSJRES'="R" $P(^(2),U,6)="",$P(^(2),U,9)="" ;; D:PSJRES="R" ENBKOUT^PSJOREN(DFN,PSJORD) 57 ..I P("OLDON")'["V",$D(^PS(53.1,+P("OLDON"),0)) S PSJRES=$P(^(0),U,27) S:PSJRES'="R" $P(^(0),U,26,27)="^" I PSJRES="R" ;; D ENBKOUT^PSJOREN(DFN,PSJORD) 58 .K DA,DIK S DIK="^PS(53.1,",DA=+PSJORD D ^DIK S PSGP=DFN,X="P" D ENSK^PSGAXR K DA,DIK S ORIFN=PSJORIFN,ORSTS="K" Q 59 ; 60 DC ; DC order from Pharmacy complete function. 61 I PSJORD["V",'PSJCOM N PSIVREA S ON55=PSJORD,X=$G(^PS(55,DFN,"IV",+ON55,0)),P(3)=$P(X,U,3),P(17)=$P(X,U,17),PSIVREA="D",PSIVALT=2,PSIVALCK="STOP" D D^PSIVOPT2 D HL Q 62 I PSJORD["V",PSJCOM N PSIVREA S ON55=PSJORD,X=$G(^PS(55,DFN,"IV",+ON55,0)),P(3)=$P(X,U,3),P(17)=$P(X,U,17),PSIVREA="D",PSIVALT=2,PSIVALCK="STOP" D D^PSIVOPT2 Q 63 N DA,DR,DIE,PSJND S DA=+PSJORD,PSJND=$G(^PS(53.1,DA,0)),P("OLDON")=$P(PSJND,U,25),DIE="^PS(53.1,",DR="28///"_$S($P(PSJND,U,27)="E":"DE",1:"D") D ^DIE 64 D HL 65 Q 66 HL ; 67 Q:'$D(P("NAT")) 68 ;D EN1^PSJHL2(DFN,"OC",PSJORD,"ORDER CANCELED") 69 NEW PSJCD,PSJTX 70 I PSJORD["P" N PSJNOO S PSJCD="OC",PSJTX="ORDER CANCELED",PSJNOO=$G(P("NAT")) 71 E S PSJCD="OD",PSJTX="ORDER DISCONTINUED" 72 D EN1^PSJHL2(DFN,PSJCD,PSJORD,PSJTX) 73 ;D UNL^PSSLOCK(DFN,PSJORD) 74 Q 75 ; 76 7 ; Purge 77 N ND S ND=$S(ORPK["V":$P($G(^PS(55,+ORVP,"IV",+ORPK,0)),U,17)_U_$P($G(^(0)),U,3),1:$P($G(^PS(53.1,+ORPK,0)),U,9)_U_$P($G(^(2)),U,4)) 78 Q:"DE"'[$P(ND,U) S X1=+$P(ND,U,2),X2=30 D C^%DTC S ND=X D NOW^%DTC Q:ND>% 79 I ORPK["V",$D(^PS(55,+ORVP,"IV",+ORPK,0)) S $P(^(0),U,21)="" 80 I ORPK'["V",$D(^PS(53.1,+ORPK,0)) S $P(^(0),U,21)="" 81 S ORSTS="K" 82 Q 83 ; 84 8 ; Print 85 K DIR S DIR(0)="E" D ^DIR K DIR I $D(DUOUT)!'($D(ORPK)) S OREND=1 Q 86 S:'$G(PSIVUP) PSIVUP=+$$GTPCI^PSIVUTL S:'$D(PSIVAC) PSIVAC="OS" S (ON,ON55)=ORPK,DFN=+ORVP D @$S(ON["V":"GT55^PSIVORFB",1:"GT531^PSIVORFA("_DFN_","""_ON_""")"),ENDT^PSIVORV1 87 Q 88 ; 89 9 ; Release order (status=incomplete in 53.1, pending in 100) 90 S X=ORACTION I X=4!(X=6) D @ORACTION Q 91 Q:"36"[ORSTS N ON,PSJORIFN S PSJORIFN=ORIFN,ON=ORPK L +^PS(53.1,+ON):1 E D LOCKERR^PSIVORA1 Q 92 S Y=$G(^PS(53.1,+ON,0)),P("RES")=$P(Y,U,24),P("OLDON")=$P(Y,U,25) 93 N DA,DIE,DR,OREND S DR="28////P",DIE="^PS(53.1,",DA=+ON D ^DIE 94 I P("OLDON")]"" K DA,DIE,DR S DA=P("OLDON") D 95 .I DA["V" S DA(1)=+ORPV,DIE="^PS(55,"_DA(1)_",""IV"",",DR="114////"_+ON_"P"_";123////"_P("RES") 96 .E S DIE="^PS(53.1,",DR="105////"_ON_"P"_";107////"_P("RES") I P("RES")="E",$P($G(^PS(53.1,+P("OLDON"),0)),U,9)="D" S DR=DR_";28////DE" 97 .S DA=+DA L +@(DIE_DA_")"):1 E D LOCKERR^PSIVORA1 Q 98 .D ^DIE L -@(DIE_DA_")") 99 L -^PS(53.1,+ON) D DONE^PSIVORA1 100 Q 101 ; 102 10 ; Verify 103 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVORC.m
r613 r623 1 PSIVORC ;BIR/MLM-COMPLETE IV ORDERS ENTERED THROUGH OE/RR ;02 Mar 99 / 10:16 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**23,53,80,110,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^DIC(42 is supported by DBIA 10039 5 ; Reference to ^DPT is supported by DBIA 10035 6 ; Reference to ^%DTC is supported by DBIA 10000 7 ; Reference to ^DID is supported by DBIA 2052 8 ; 9 EN ; Set IV parameters. 10 D SITE^PSIVORE Q:'$G(PSIVQ) K PSIVQ 11 ; 12 SELECT ; 13 F S PSGSSH="ORVC" D ^PSGSEL Q:U[PSGSS D GTORDRS 14 D DONE^PSIVORC1 15 Q 16 GTORDRS ; 17 K ^TMP("PSIV",$J) N DIC,Y D @PSGSS Q:+$G(Y)'>0 W:PSGSS'="P" !,"...a few moments, please..." D @("G"_PSGSS) 18 I $G(Y),'$D(^TMP("PSIV",$J)) W !,$C(7),"NO PENDING ORDERS FOR ",$S(PSGSS="P":"PATIENT",1:"WARD"),$S(PSGSS="G":" GROUP",1:"")," SELECTED." Q 19 D NOW^%DTC S HDT=$$ENDTC^PSGMI(%),PSIVAC="C",DONE=0,WDN="" 20 F S WDN=$O(^TMP("PSIV",$J,WDN)) Q:WDN=""!DONE S PNME="" F S PNME=$O(^TMP("PSIV",$J,WDN,PNME)) Q:PNME=""!DONE D 21 . I PSGSS'="P" S PSGDFN=$P(PNME,";",2)_"^"_$P(PNME,";") D CHK^PSJDPT(.PSGDFN,1,1) I PSGDFN=-1 Q 22 . D PROFILE D:PSIVHD ASK 23 D:$G(PSIVHD) ASK 24 Q 25 ; 26 PROFILE ; Display profile of all incomplete orders. 27 ; 28 K PSGODDD S (DFN,PSGP)=$P(PNME,";",2) D ENBOTH^PSJAC 29 S RB=PSJPRB,PG=1,PSJORL=$$ENORL^PSJUTL($G(VAIN(4))),PSJIVOF=PSJORL,PSGLMT=0,LN2="" D ENHEAD^PSJO3 30 S (DONE1,TYP)="" F S TYP=$O(^TMP("PSIV",$J,WDN,PNME,TYP)) Q:TYP=""!(DONE1) D:$Y+5'>IOSL GTYP F ON1=0:0 S ON1=$O(^TMP("PSIV",$J,WDN,PNME,TYP,ON1)) Q:'ON1!(DONE1) D DISPLAY 31 Q 32 ; 33 DISPLAY ; Display order on profile. 34 I $Y+5>IOSL D ASK Q:DONE1 D ENHEAD^PSJO3,GTYP 35 S PSIVHD=1,PSGLMT=PSGLMT+1,PSIVCV(PSGLMT)=ON1,PSJC="" W !?3,PSGLMT D PIV^PSIVUTL(+ON1_"P") 36 Q 37 ; 38 GTYP ; Get formatted heading for type 39 N PSJD5314 D FIELD^DID(53.1,4,"","POINTER","PSJD5314") 40 ; removed ^DD ref 3-2-99, pass ^^_set of codes value 41 ; because codes^psivutl uses the 3rd piece 42 S X=$$CODES^PSIVUTL(TYP,"^^"_PSJD5314("POINTER"),"") 43 S PSIV=$S(X]"":X,1:"UNKNOWN"),X="",$P(X,"-",40-($L(PSIV)/2))="" W !,X_PSIV_X 44 Q 45 ; 46 ASK ; Ask which orders to view. 47 S PSIVHD=0,ACTION="ORDER" D RD1^PSGON I X="^" S (DONE,DONE1)=1 Q 48 Q:'$D(PSGODDD) S DONE1=0 F PN=1:1:$L(PSGODDD(1),",")-1 S ON=+$P(PSGODDD(1),",",PN) Q:ON=""!DONE1 S ON=+$P(PSGODDD(1),",",PN) D SHOW 49 S DONE1=1,PSGOP=DFN D:$P(PSJSYSL,U,2)]"" ENQL^PSGLW 50 Q 51 ; 52 SHOW ; Display selected order and prompt for action 53 S (P("PON"),ON)=PSIVCV(ON) 54 ; 55 SHOW1 ; Entry point from backdoor. 56 S PSIVUP=+$$GTPCI^PSIVUTL D GT531^PSIVORFA(DFN,ON) I $G(PSIVAC)="PRO" D ENNONUM^PSIVORV2(DFN,ON) Q 57 I $G(PSJORD)["P" D REQDT^PSJLIVMD(PSJORD) 58 S PSJORD=+ON D ^PSJLIFN 59 Q 60 ; 61 ; look-ups on ward group, ward, or patient; depending on value of SS 62 G S DIC="^PS(57.5,",DIC(0)="QEAMI",DIC("A")="Select WARD GROUP: " W ! D ^DIC S:+Y>0 WG=+Y Q 63 W S DIC="^DIC(42,",DIC(0)="QEAMI",DIC("A")="Select WARD: " W ! D ^DIC S:+Y>0 WD=+Y Q 64 P D ENGETP^PSIV Q:DFN<0 S Y=1 I $D(^PS(53.1,"AS","P",+DFN)) S PNME=$G(^DPT(+DFN,0)),PNME=$P(PNME,U)_";"_DFN,WDN=$S(VAIN(4)]"":$P(VAIN(4),U,2),1:"OUTPATIENT") D GP 65 Q 66 ; 67 GG ; put patient(s) with incomplete orders into array 68 F WD=0:0 S WD=$O(^PS(57.5,"AC",WG,WD)) Q:'WD D GW 69 Q 70 GW S WDN=$G(^DIC(42,WD,0)),WDN=$P(WDN,U) I WDN]"" F DFN=0:0 S DFN=$O(^DPT("CN",WDN,DFN)) Q:'DFN I $D(^PS(53.1,"AS","P",DFN)) S Y=$G(^DPT(+DFN,0)),PNME=$P(Y,U)_";"_DFN D:PNME]"" GP 71 Q 72 GP ; 73 F ON=0:0 S ON=$O(^PS(53.1,"AS","P",DFN,ON)) Q:'ON S Y=$G(^PS(53.1,ON,0)),TYP=$S($P(Y,U,4)]"":$P(Y,U,4),1:"Z"),^TMP("PSIV",$J,WDN,PNME,TYP,ON)="" 74 Q 75 DISCONT ; Cancel incomplete order 76 N PSJDCTYP I $G(ON)["P",$P($G(^PS(53.1,+$G(ON),0)),"^",24)="R" S PSJDCTYP=$$PNDRNA^PSGOEC(ON) I $G(PSJDCTYP)'=1 D PNDRN(PSJDCTYP) Q 77 D2 ; Called from PNDRN for pending order 78 D:'$D(PSJIVORF) ORPARM^PSIVOREN I PSJIVORF D NATURE^PSIVOREN I '$D(P("NAT")) W !,$C(7),"Order Unchanged." Q 79 ;Prompt for requesting provider 80 W ! I '$$REQPROV^PSGOEC W !,$C(7),"Order Unchanged." K PSJDCTYP Q 81 W ! 82 ; 83 D3 ; called from PNDRN for original order 84 I 'PSJCOM N PSJORNAT S PSJORIFN=$P($G(^PS(53.1,+ON,0)),U,21),PSJORD=ON,PSJORNAT=P("NAT") D DC^PSIVORA ;* I PSJIVORF,PSJORIFN,(ON["V") D EN1^PSJHL2(PSGP,"OD",+ON_"V","ORDER DISCONTINUED") 85 I PSJCOM,PSJORD["P" N O S O="" F S O=$O(^PS(53.1,"ACX",PSJCOM,O)) Q:O="" D 86 .S ON=O_"P",PSJORIFN=$P($G(^PS(53.1,+ON,0)),U,21),PSJORD=ON,PSJORNAT=P("NAT") D DC^PSIVORA 87 W !,"Order discontinued.",! 88 Q 89 ; 90 EDIT ; Edit incomplete order 91 S PSIVAC="CE" L +^PS(53.1,+ON):1 E W !,$C(7),"This order LOCKED by another user." Q 92 D EDIT^PSIVORC2 L -^PS(53.1,+ON) 93 Q 94 ; 95 FINISH ; Finish incomplete order 96 S PSIVAC="CF" L +^PS(53.1,+ON):1 E W !,$C(7),"This order LOCKED by another user." Q 97 D FINISH^PSIVORC2 L -^PS(53.1,+ON) 98 Q 99 ; 100 PNDRN(PSJDCTYP) ; Discontinue pending renewal only or both pending and original orders 101 I PSJDCTYP=2 S PSJDCTYP=1 D D2 Q:'$G(PSJDCTYP) D 102 .N ND5310 S ND5310=$G(^PS(53.1,+ON,0)) 103 .N ON S ON=$P(ND5310,"^",25) I ON S PSJDCTYP=2 D D3 104 Q 1 PSIVORC ;BIR/MLM-COMPLETE IV ORDERS ENTERED THROUGH OE/RR ;02 Mar 99 / 10:16 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**23,53,80,110**;16 DEC 97 3 ; 4 ; Reference to ^DIC(42 is supported by DBIA 10039 5 ; Reference to ^DPT is supported by DBIA 10035 6 ; Reference to ^%DTC is supported by DBIA 10000 7 ; Reference to ^DID is supported by DBIA 2052 8 ; 9 EN ; Set IV parameters. 10 D SITE^PSIVORE Q:'$G(PSIVQ) K PSIVQ 11 ; 12 SELECT ; 13 F S PSGSSH="ORVC" D ^PSGSEL Q:U[PSGSS D GTORDRS 14 D DONE^PSIVORC1 15 Q 16 GTORDRS ; 17 K ^TMP("PSIV",$J) N DIC,Y D @PSGSS Q:+$G(Y)'>0 W:PSGSS'="P" !,"...a few moments, please..." D @("G"_PSGSS) 18 I $G(Y),'$D(^TMP("PSIV",$J)) W !,$C(7),"NO PENDING ORDERS FOR ",$S(PSGSS="P":"PATIENT",1:"WARD"),$S(PSGSS="G":" GROUP",1:"")," SELECTED." Q 19 D NOW^%DTC S HDT=$$ENDTC^PSGMI(%),PSIVAC="C",DONE=0,WDN="" 20 F S WDN=$O(^TMP("PSIV",$J,WDN)) Q:WDN=""!DONE S PNME="" F S PNME=$O(^TMP("PSIV",$J,WDN,PNME)) Q:PNME=""!DONE D 21 . I PSGSS'="P" S PSGDFN=$P(PNME,";",2)_"^"_$P(PNME,";") D CHK^PSJDPT(.PSGDFN,1,1) I PSGDFN=-1 Q 22 . D PROFILE D:PSIVHD ASK 23 D:$G(PSIVHD) ASK 24 Q 25 ; 26 PROFILE ; Display profile of all incomplete orders. 27 ; 28 K PSGODDD S (DFN,PSGP)=$P(PNME,";",2) D ENBOTH^PSJAC 29 S RB=PSJPRB,PG=1,PSJORL=$$ENORL^PSJUTL($G(VAIN(4))),PSJIVOF=PSJORL,PSGLMT=0,LN2="" D ENHEAD^PSJO3 30 S (DONE1,TYP)="" F S TYP=$O(^TMP("PSIV",$J,WDN,PNME,TYP)) Q:TYP=""!(DONE1) D:$Y+5'>IOSL GTYP F ON1=0:0 S ON1=$O(^TMP("PSIV",$J,WDN,PNME,TYP,ON1)) Q:'ON1!(DONE1) D DISPLAY 31 Q 32 ; 33 DISPLAY ; Display order on profile. 34 I $Y+5>IOSL D ASK Q:DONE1 D ENHEAD^PSJO3,GTYP 35 S PSIVHD=1,PSGLMT=PSGLMT+1,PSIVCV(PSGLMT)=ON1,PSJC="" W !?3,PSGLMT D PIV^PSIVUTL(+ON1_"P") 36 Q 37 ; 38 GTYP ; Get formatted heading for type 39 N PSJD5314 D FIELD^DID(53.1,4,"","POINTER","PSJD5314") 40 ; removed ^DD ref 3-2-99, pass ^^_set of codes value 41 ; because codes^psivutl uses the 3rd piece 42 ;S X=$$CODES^PSIVUTL(TYP,"^^"_PSJD5314("POINTER")),PSIV=$S(X]"":X,1:"UNKNOWN"),X="",$P(X,"-",40-($L(PSIV)/2))="" W !,X_PSIV_X 43 S X=$$CODES^PSIVUTL(TYP,"^^"_PSJD5314("POINTER"),"") 44 S PSIV=$S(X]"":X,1:"UNKNOWN"),X="",$P(X,"-",40-($L(PSIV)/2))="" W !,X_PSIV_X 45 Q 46 ; 47 ASK ; Ask which orders to view. 48 S PSIVHD=0,ACTION="ORDER" D RD1^PSGON I X="^" S (DONE,DONE1)=1 Q 49 Q:'$D(PSGODDD) S DONE1=0 F PN=1:1:$L(PSGODDD(1),",")-1 S ON=+$P(PSGODDD(1),",",PN) Q:ON=""!DONE1 S ON=+$P(PSGODDD(1),",",PN) D SHOW 50 S DONE1=1,PSGOP=DFN D:$P(PSJSYSL,U,2)]"" ENQL^PSGLW 51 Q 52 ; 53 SHOW ; Display selected order and prompt for action 54 S (P("PON"),ON)=PSIVCV(ON) 55 ; 56 SHOW1 ; Entry point from backdoor. 57 S PSIVUP=+$$GTPCI^PSIVUTL D GT531^PSIVORFA(DFN,ON) I $G(PSIVAC)="PRO" D ENNONUM^PSIVORV2(DFN,ON) Q 58 I $G(PSJORD)["P" D REQDT^PSJLIVMD(PSJORD) 59 S PSJORD=+ON D ^PSJLIFN 60 Q 61 ; 62 ; look-ups on ward group, ward, or patient; depending on value of SS 63 G S DIC="^PS(57.5,",DIC(0)="QEAMI",DIC("A")="Select WARD GROUP: " W ! D ^DIC S:+Y>0 WG=+Y Q 64 W S DIC="^DIC(42,",DIC(0)="QEAMI",DIC("A")="Select WARD: " W ! D ^DIC S:+Y>0 WD=+Y Q 65 P D ENGETP^PSIV Q:DFN<0 S Y=1 I $D(^PS(53.1,"AS","P",+DFN)) S PNME=$G(^DPT(+DFN,0)),PNME=$P(PNME,U)_";"_DFN,WDN=$S(VAIN(4)]"":$P(VAIN(4),U,2),1:"OUTPATIENT") D GP 66 Q 67 ; 68 GG ; put patient(s) with incomplete orders into array 69 F WD=0:0 S WD=$O(^PS(57.5,"AC",WG,WD)) Q:'WD D GW 70 Q 71 GW S WDN=$G(^DIC(42,WD,0)),WDN=$P(WDN,U) I WDN]"" F DFN=0:0 S DFN=$O(^DPT("CN",WDN,DFN)) Q:'DFN I $D(^PS(53.1,"AS","P",DFN)) S Y=$G(^DPT(+DFN,0)),PNME=$P(Y,U)_";"_DFN D:PNME]"" GP 72 Q 73 GP ; 74 F ON=0:0 S ON=$O(^PS(53.1,"AS","P",DFN,ON)) Q:'ON S Y=$G(^PS(53.1,ON,0)),TYP=$S($P(Y,U,4)]"":$P(Y,U,4),1:"Z"),^TMP("PSIV",$J,WDN,PNME,TYP,ON)="" 75 Q 76 DISCONT ; Cancel incomplete order 77 D:'$D(PSJIVORF) ORPARM^PSIVOREN I PSJIVORF D NATURE^PSIVOREN I '$D(P("NAT")) W !,$C(7),"Order Unchanged." Q 78 ;Prompt for requesting provider 79 W ! I '$$REQPROV^PSGOEC W !,$C(7),"Order Unchanged." Q 80 W ! 81 ; 82 ;* N PSJORNAT S (PSJORIFN,ORIFN)=$P($G(^PS(53.1,+ON,0)),U,21),PSJORD=ON,PSJORNAT=P("NAT") D DC^PSIVORA ;* I PSJIVORF,PSJORIFN,(ON["V") D EN1^PSJHL2(PSGP,"OD",+ON_"V","ORDER DISCONTINUED") 83 I 'PSJCOM N PSJORNAT S PSJORIFN=$P($G(^PS(53.1,+ON,0)),U,21),PSJORD=ON,PSJORNAT=P("NAT") D DC^PSIVORA ;* I PSJIVORF,PSJORIFN,(ON["V") D EN1^PSJHL2(PSGP,"OD",+ON_"V","ORDER DISCONTINUED") 84 I PSJCOM,PSJORD["P" N O S O="" F S O=$O(^PS(53.1,"ACX",PSJCOM,O)) Q:O="" D 85 .S ON=O_"P",PSJORIFN=$P($G(^PS(53.1,+ON,0)),U,21),PSJORD=ON,PSJORNAT=P("NAT") D DC^PSIVORA 86 W !,"Order discontinued.",! 87 Q 88 ; 89 EDIT ; Edit incomplete order 90 S PSIVAC="CE" L +^PS(53.1,+ON):1 E W !,$C(7),"This order LOCKED by another user." Q 91 D EDIT^PSIVORC2 L -^PS(53.1,+ON) 92 Q 93 ; 94 FINISH ; Finish incomplete order 95 S PSIVAC="CF" L +^PS(53.1,+ON):1 E W !,$C(7),"This order LOCKED by another user." Q 96 D FINISH^PSIVORC2 L -^PS(53.1,+ON) 97 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVORC1.m
r613 r623 1 PSIVORC1 ;BIR/MLM-PROCESS INCOMPLETE IV ORDER - CONT ;13 Jan 98 / 11:36 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,37,69,110,157,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^DD("DD" is supported by DBIA 10017. 5 ; Reference to ^DD( is supported by DBIA 2255. 6 ; Reference to ^VA(200 is supported by DBIA 10060. 7 ; Reference to ^%DT is supported by DBIA 10003. 8 ; Reference to ^%DTC is supported by DBIA 10000. 9 ; Reference to ^DID is supported by DBIA 2052. 10 ; Reference to ^VALM is supported by DBIA 10118. 11 ; Reference to ^PS(55 is supported by DBIA# 2191. 12 ; 13 53 ; IV Type 14 I $G(PSGORD)["P",$G(PSGAT),($G(P(9))]"") D 15 .N X,PSGS0Y,ZZ,LYN,ZZND,ZZNDW S X=P(9) S PSGS0Y="",ZZ=0 D FIND^DIC(51.1,,,,X,,"APPSJ",,,"LYN") 16 .S ZZ=$O(LYN("DILIST",2,ZZ)) I ZZ S ZZ=+LYN("DILIST",2,ZZ) I ZZ S ZZND=$G(^PS(51.1,ZZ,0)) S PSGST=$P(ZZND,U,5),PSGS0XT=$P(ZZND,U,3) I $G(PSJPWD) D 17 ..N ZZNDW S ZZNDW=$G(^PS(51.1,ZZ,1,PSJPWD,0)) I $P(ZZNDW,"^",2)]"" S PSGS0Y=$P(ZZNDW,"^",2),$P(ZZND,"^",2)=PSGS0Y 18 .S ZZ=0 F S ZZ=$O(LYN("DILIST",1,ZZ)) Q:'ZZ I $G(LYN("DILIST",1,ZZ))'=X K LYN("DILIST",1,ZZ),LYN("DILIST",2,ZZ),LYN("DILIST","ID",ZZ,1) 19 .I $D(PSJPWD) S ZZ=0 F S ZZ=$O(LYN("DILIST",2,ZZ)) Q:'ZZ I $P($G(^PS(51.1,+LYN("DILIST",2,ZZ),1,+PSJPWD,0)),U,2)]"" S PSGS0Y=$P($G(^(0)),U,2) 20 .I '$G(PSGS0Y) S ZZ=0 F S ZZ=$O(LYN("DILIST",2,ZZ)) Q:'ZZ Q:PSGS0Y]"" I $G(LYN("DILIST","ID",ZZ,1))]"" S PSGS0Y=$G(LYN("DILIST","ID",ZZ,1)) 21 .Q:(PSGS0Y=PSGAT)!'$G(PSGS0Y)!($G(IVCAT)="C") 22 .S PSGNSTAT=1 W $C(7),!!,"PLEASE NOTE: This order's admin times (",PSGAT,")" 23 .W !?13," do not match the ward times (",PSGS0Y,")" 24 .W !?13," for this administration schedule (",P(9),")",! 25 .S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR K DIR W ! 26 S DONE=0 N DIR S DIR(0)="SNA^A:ADMIXTURE;C:CHEMOTHERAPY;H:HYPERAL;P:PIGGYBACK;S:SYRINGE",DIR("A")="IV TYPE: " 27 I $G(P("RES"))'="R",$G(PSGORD)["P" N IVCAT,IVTYPTMP S IVCAT=$P($G(^PS(53.1,+PSGORD,2.5)),"^",5) S IVTYPTMP=$S((P(9)]""):"P",$G(P(5)):"P",$G(P(23))="P":"P",1:"") 28 S DIR("B")=$S($G(IVCAT)="C"!($G(IVTYPTMP)="A"):"ADMIXTURE",$G(IVCAT)="I"!($G(IVTYPTMP)="P"):"PIGGYBACK",1:"ADMIXTURE") 29 D DIRQ,^DIR S:$D(DTOUT)!(X="^") DONE=1 Q:DONE G:$E(X)="^" 53 S P(4)=Y D:"CS"[P(4) @P(4) 30 I PSIVAC'="PN" D ENT^PSIVCAL K %DT S X=P(2),%DT="RTX" D ^%DT S P(2)=+Y D ENSTOP^PSIVCAL K %DT S X=P(3),%DT="RTX" D ^%DT S P(3)=+Y 31 OTYP ; Get order type, display type. 32 S P("DTYP")=$S(P(4)="":0,P(4)="P"!(P(23)="P")!(P(5)):1,P(4)="H":2,1:3) S:PSIVAC'="CF" P("OT")=$S(P(4)="A":"F",P(4)="H":"H",1:"I") 33 Q 34 ; 35 C ; Edit Chemo order 36 N DIR S DIR(0)="SA^A:ADMIXTURE;P:PIGGYBACK;S:SYRINGE",DIR("A")="CHEMOTHERAPY TYPE: " D DIRQ,^DIR S:$D(DTOUT)!(X=U) DONE=1 Q:$E(X)="^"!(DONE) S P(23)=Y D:P(23)["S" S 37 Q 38 ; 39 S ; Edit Syringe order 40 56 ; Intermittent Syringe 41 N DIR S DIR(0)="Y",DIR("??")="^S F1=53.1,F2=56 D ENHLP^PSIVORC1",DIR("A")="INTERMITTENT SYRINGE" D ^DIR Q:$D(DIRUT) S P(5)=Y 42 ; 43 55 ; Syringe Size 44 N DA,DIR S DIR(0)="53.1,55" D ^DIR I $D(DTOUT)!$D(DUOUT) S DONE=1 Q 45 S P("SYRS")=Y 46 Q 47 ; 48 DIRQ ; Set DIR("?") for IV Type prompt. 49 S DIR("?")="Enter a code from the list above.",DIR("??")="^S F1=55.01,F2="_$S(DIR("A")["CHEMO":106,1:.04)_" D ENHLP^PSIVORC1" 50 S DIR("?",1)="CHOOSE FROM:",Y=$P(DIR(0),U,2) F X=1:1:5 S DIR("?",X+1)=" "_$P($P(Y,";",X),":")_" "_$P($P(Y,";",X),":",2) 51 Q 52 ; 53 CKFLDS ; Find required fields missing data. 54 NEW PSIVASX,PSIVASY,FIL,DRGTMP 55 S EDIT="" F PSIVASX="AD","SOL" D 56 .I '$D(DRG(PSIVASX)) S EDIT=EDIT_U_$S(PSIVASX="AD":57,1:58) Q 57 .S DNE=0 F PSIVASY=0:0 S PSIVASY=$O(DRG(PSIVASX,PSIVASY)) Q:'PSIVASY!DNE D 58 .. I $P(DRG(PSIVASX,PSIVASY),U,3)="" S EDIT=EDIT_U_$S(PSIVASX="AD":57,1:58),DNE=1 59 S:'P("MR") EDIT=EDIT_U_3 F X=8,6,2,3 I P(X)="" S EDIT=EDIT_U_$S(X=8:59,X=6:1,X=2:10,X=3:25,1:"") 60 I P("DTYP")=1 S:P(9)="" EDIT=EDIT_U_26 S:P(11)="" EDIT=EDIT_U_39 61 S:$E(EDIT,1)=U EDIT=$E(EDIT,2,999) 62 Q 63 ; 64 DONE ; Kill variables and exit 65 K ACTION,AD,DFN,DNE,DONE,DONE1,DRG,DRGI,DRGN,DRGT,DRGTN,EDIT,ERR,F1,F2,FIL,HDT,J,LN,LN2,ND,ON,ON1,ON55,ORIFN,P,P16,PC,PDM,PG,PN,PNME,PNOW,PSGLMT,PSGODDD 66 K PSGSS,PSGSSH,PSIV,PSIVAC,PSIVAT,PSIVCV,PSIVE,PSIVHD,PSIVLN,PSIVOK,PSIVOLD,PSIVORUT,PSIVREA,PSIVSC1,PSIVSTR,PSIVSTRT,PSIVTYPE,PSIVUP,PSIVX,PSIVX1 67 K PSJIVORF,PSJORF,PSJORIFN,PSJORL,PSJORNP,PSJORPF,PSJORSTS,PSJIVOF,PSJNKF,PSJORD,RB,RF,SOL,STOP,TYP,UL80,WD,WDN,WG,^TMP("PSIV",$J) D ENIVKV^PSGSETU 68 Q 69 ENHLP ; order entry fields' help 70 N PSJHP,PSJX,PSJD 71 ; From within this routine, F1 and F2 will refer to file 53.1,field 56, file 55.01,field 106, or file 55.01,field .04 72 D FIELD^DID(F1,F2,"","HELP-PROMPT","PSJHP") 73 I X="?",$D(PSJHP("HELP-PROMPT")) S F=$G(PSJHP("HELP-PROMPT")) W !?5 F F0=1:1:$L(F," ") S F3=$P(F," ",F0) W:$L(F3)+$X>78 !?5 W F3_" " 74 ; 75 W:$D(^DD(F1,F2,12)) !,"("_^(12)_")" D FIELD^DID(F1,F2,"","XECUTABLE HELP","PSJX") I $D(PSJX("XECUTABLE HELP")) X PSJX("XECUTABLE HELP") 76 ; 77 ; new code 78 D FIELD^DID(F1,F2,"","DESCRIPTION","PSJD") 79 G:$S($G(X)="?":1,1:'$O(PSJD("DESCRIPTION",0))) SC F F=0:0 S F=$O(PSJD("DESCRIPTION",F)) Q:'F I $D(PSJD("DESCRIPTION",F)) W !?2,PSJD("DESCRIPTION",F) 80 SC ; 81 I F2=5!(F2=6) W !,"CHOOSE FROM:",!?8,0,?16,"NO",!?8,1,?16,"YES" Q 82 Q 83 COMPLTE ; 84 S P16=0,PSIVEXAM=1,(PSIVNOL,PSIVCT)=1 D GTOT^PSIVUTL(P(4)) D ^PSIVCHK I $D(DUOUT) W $C(7),!,"Order Unchanged.",! Q 85 G:'$D(PSIVFN1) EDIT1 86 I ERR=1 S Y=0 G EDIT1 87 D CKORD^PSIVORC2 I PSIVCHG D NOW^%DTC S P("LOG")=$E(%,1,12),P("CLRK")=DUZ_U_$P($G(^VA(200,DUZ,0)),U),P("INS")="" 88 W ! D ^PSIVORLB K PSIVEXAM S Y=P(2) 89 W !,"Start date: " X ^DD("DD") W $P(Y,"@")," ",$P(Y,"@",2),?30," Stop date: " S Y=P(3) X ^DD("DD") W $P(Y,"@")," ",$P(Y,"@",2),! 90 EDIT ; 91 I ERR=1 W !,"Please re-edit this order" K DIR S DIR(0)="E" D ^DIR K DIR W:'Y $C(7),"order unchanged." Q:'Y S Y=0 G EDIT1 92 ;PSJ*5*157 EFD FOR IV 93 D EFDIV^PSJUTL($G(ZZND)) 94 W:$G(PSIVCHG) !,"*** This change will cause a new order to be created. ***" 95 K DIR S DIR(0)="Y",DIR("A")="Is this O.K.",DIR("B")=$S(ERR:"NO",1:"YES"),DIR("?",1)="Enter ""Y"" to make this an active order (only allowed if no errors were" 96 S DIR("?")="found in order), ""N"" to edit the order, or ""^"" to leave order unchanged.",DIR("??")="^S HELP=""EDIT"" D ^PSIVHLP" 97 D ^DIR K DIR I $D(DIRUT) K DIRUT W $C(7),"Order unchanged." Q 98 ;* Kill Unit dose variables when calling from ^PSJLIFNI. 99 I +Y,$G(PSJLIFNI) D 100 . K ND,ND4,ND6,NDP2 101 . K PSGAT,PSGCANFL,PSGDI,PSGDO,PSGDT,PSGEB,PSGEBN,PSGEFN,PSGFD,PSGFDN 102 . K PSGHSM,PSGLI,PSGLIN,PSGLMT,PSGMR,PSGMRN,PSGNEDFD,PSGNEF,PSGNEFD 103 . K PSGNESD,PSGOAT,PSGODO,PSGODT,PSGEA,PSGOEAV,PSGOEEF 104 . K PSGOEEWF,PSGOEEG,PSGOEF,PSGOENG,PSGOES,PSGOFD,PSGOFDN,PSGOHSM 105 . K PSGOINST,PSGOMR,PSGOMRN,PSGONC 106 . K PSGOPD,PSOPDN,PSGOPR,PSGOPRN,PSGOSD,PSGOSDN,PSGOSI,PSGOSM 107 . K PSGOST,PSGOSTN 108 . K PSGPD,PSGPDN,PSGPDRG,PSGDRGN,PSGPFLG,PSGPI,PSGPR,PSGPRIO,PSGPRN 109 . K PSGPTMP,PSGRRF,PSG0XT,PSGS0Y,PSGSCH,PSGSD,PSGSDN,PSGSI,PSGSM 110 . K PSGST,PSGSTAT,PSGSTN,PSJACNWP,PSJACOK,PSJCOI 111 EDIT1 ; 112 NEW XFLG,PSIVY S PSIVY=Y 113 NEW X S X=^TMP("PSJI",$J,0),VALMBG=$S((X<17):1,1:(X-(X#16))) 114 I PSIVY=0!'$G(PSIVFN1) S PSIVFN1=1 D EN^VALM("PSJ LM IV AC/EDIT") Q 115 S PSIVCHG=0 D EDCHK^PSIVORC2 K PSIVCHG 116 S VALMBCK="Q",PSIVACEP=1 117 Q 1 PSIVORC1 ;BIR/MLM-PROCESS INCOMPLETE IV ORDER - CONT ;13 Jan 98 / 11:36 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,37,69,110,157**;16 DEC 97 3 ; 4 ; Reference to ^DD("DD" is supported by DBIA 10017. 5 ; Reference to ^DD( is supported by DBIA 2255. 6 ; Reference to ^VA(200 is supported by DBIA 10060. 7 ; Reference to ^%DT is supported by DBIA 10003. 8 ; Reference to ^%DTC is supported by DBIA 10000. 9 ; Reference to ^DID is supported by DBIA 2052. 10 ; Reference to ^VALM is supported by DBIA 10118. 11 ; 12 53 ; IV Type 13 ;*S DONE=0 N DIR S DIR(0)="SNA^A:ADMIXTURE;C:CHEMOTHERAPY;"_$S($E(PSIVAC)'["C":"H:HYPERAL;",1:"")_"P:PIGGYBACK;S:SYRINGE",DIR("A")="IV TYPE: " 14 S DONE=0 N DIR S DIR(0)="SNA^A:ADMIXTURE;C:CHEMOTHERAPY;H:HYPERAL;P:PIGGYBACK;S:SYRINGE",DIR("A")="IV TYPE: " 15 I $G(P("RES"))'="R" S:P(4)]"" DIR("B")="ADMIXTURE",P(4)="" 16 D DIRQ,^DIR S:$D(DTOUT)!(X="^") DONE=1 Q:DONE G:$E(X)="^" 53 S P(4)=Y D:"CS"[P(4) @P(4) 17 I PSIVAC'="PN" D ENT^PSIVCAL K %DT S X=P(2),%DT="RTX" D ^%DT S P(2)=+Y D ENSTOP^PSIVCAL K %DT S X=P(3),%DT="RTX" D ^%DT S P(3)=+Y 18 OTYP ; Get order type, display type. 19 S P("DTYP")=$S(P(4)="":0,P(4)="P"!(P(23)="P")!(P(5)):1,P(4)="H":2,1:3) S:PSIVAC'="CF" P("OT")=$S(P(4)="A":"F",P(4)="H":"H",1:"I") 20 Q 21 ; 22 C ; Edit Chemo order 23 N DIR S DIR(0)="SA^A:ADMIXTURE;P:PIGGYBACK;S:SYRINGE",DIR("A")="CHEMOTHERAPY TYPE: " D DIRQ,^DIR S:$D(DTOUT)!(X=U) DONE=1 Q:$E(X)="^"!(DONE) S P(23)=Y D:P(23)["S" S 24 Q 25 ; 26 S ; Edit Syringe order 27 56 ; Intermittent Syringe 28 N DIR S DIR(0)="Y",DIR("??")="^S F1=53.1,F2=56 D ENHLP^PSIVORC1",DIR("A")="INTERMITTENT SYRINGE" D ^DIR Q:$D(DIRUT) S P(5)=Y 29 ; 30 55 ; Syringe Size 31 N DA,DIR S DIR(0)="53.1,55" D ^DIR I $D(DTOUT)!$D(DUOUT) S DONE=1 Q 32 S P("SYRS")=Y 33 Q 34 ; 35 DIRQ ; Set DIR("?") for IV Type prompt. 36 S DIR("?")="Enter a code from the list above.",DIR("??")="^S F1=55.01,F2="_$S(DIR("A")["CHEMO":106,1:.04)_" D ENHLP^PSIVORC1" 37 S DIR("?",1)="CHOOSE FROM:",Y=$P(DIR(0),U,2) F X=1:1:5 S DIR("?",X+1)=" "_$P($P(Y,";",X),":")_" "_$P($P(Y,";",X),":",2) 38 Q 39 ; 40 CKFLDS ; Find required fields missing data. 41 NEW PSIVASX,PSIVASY,FIL,DRGTMP 42 S EDIT="" F PSIVASX="AD","SOL" D 43 .I '$D(DRG(PSIVASX)) S EDIT=EDIT_U_$S(PSIVASX="AD":57,1:58) Q 44 .S DNE=0 F PSIVASY=0:0 S PSIVASY=$O(DRG(PSIVASX,PSIVASY)) Q:'PSIVASY!DNE D 45 .. I $P(DRG(PSIVASX,PSIVASY),U,3)="" S EDIT=EDIT_U_$S(PSIVASX="AD":57,1:58),DNE=1 46 .. ;S FIL=$S(PSIVASX="AD":"52.6",1:"52.7") 47 .. ;S DRGTMP=DRG(PSIVASX,PSIVASY) D ORDERCHK^PSIVEDRG(DFN) 48 S:'P("MR") EDIT=EDIT_U_3 F X=8,6,2,3 I P(X)="" S EDIT=EDIT_U_$S(X=8:59,X=6:1,X=2:10,X=3:25,1:"") 49 I P("DTYP")=1 S:P(9)="" EDIT=EDIT_U_26 S:P(11)="" EDIT=EDIT_U_39 50 S:$E(EDIT,1)=U EDIT=$E(EDIT,2,999) 51 Q 52 ; 53 DONE ; Kill variables and exit 54 K ACTION,AD,DFN,DNE,DONE,DONE1,DRG,DRGI,DRGN,DRGT,DRGTN,EDIT,ERR,F1,F2,FIL,HDT,J,LN,LN2,ND,ON,ON1,ON55,ORIFN,P,P16,PC,PDM,PG,PN,PNME,PNOW,PSGLMT,PSGODDD 55 K PSGSS,PSGSSH,PSIV,PSIVAC,PSIVAT,PSIVCV,PSIVE,PSIVHD,PSIVLN,PSIVOK,PSIVOLD,PSIVORUT,PSIVREA,PSIVSC1,PSIVSTR,PSIVSTRT,PSIVTYPE,PSIVUP,PSIVX,PSIVX1 56 K PSJIVORF,PSJORF,PSJORIFN,PSJORL,PSJORNP,PSJORPF,PSJORSTS,PSJIVOF,PSJNKF,PSJORD,RB,RF,SOL,STOP,TYP,UL80,WD,WDN,WG,^TMP("PSIV",$J) D ENIVKV^PSGSETU 57 Q 58 ENHLP ; order entry fields' help 59 N PSJHP,PSJX,PSJD 60 ; 61 D FIELD^DID(F1,F2,"","HELP-PROMPT","PSJHP") 62 I X="?",$D(PSJHP("HELP-PROMPT")) S F=$G(PSJHP("HELP-PROMPT")) W !?5 F F0=1:1:$L(F," ") S F3=$P(F," ",F0) W:$L(F3)+$X>78 !?5 W F3_" " 63 ;I X="?",$D(^DD(F1,F2,3)) S F=^(3) W !?5 F F0=1:1:$L(F," ") S F3=$P(F," ",F0) W:$L(F3)+$X>78 !?5 W F3_" " 64 ; 65 W:$D(^DD(F1,F2,12)) !,"("_^(12)_")" D FIELD^DID(F1,F2,"","XECUTABLE HELP","PSJX") I $D(PSJX("XECUTABLE HELP")) X PSJX("XECUTABLE HELP") 66 ; 67 ; new code 68 D FIELD^DID(F1,F2,"","DESCRIPTION","PSJD") 69 G:$S($G(X)="?":1,1:'$O(PSJD("DESCRIPTION",0))) SC F F=0:0 S F=$O(PSJD("DESCRIPTION",F)) Q:'F I $D(PSJD("DESCRIPTION",F)) W !?2,PSJD("DESCRIPTION",F) 70 SC ; 71 I F2=5!(F2=6) W !,"CHOOSE FROM:",!?8,0,?16,"NO",!?8,1,?16,"YES" Q 72 Q 73 COMPLTE ; 74 S P16=0,PSIVEXAM=1,(PSIVNOL,PSIVCT)=1 D GTOT^PSIVUTL(P(4)) D ^PSIVCHK I $D(DUOUT) W $C(7),!,"Order Unchanged.",! Q 75 G:'$D(PSIVFN1) EDIT1 76 I ERR=1 S Y=0 G EDIT1 77 D CKORD^PSIVORC2 I PSIVCHG D NOW^%DTC S P("LOG")=$E(%,1,12),P("CLRK")=DUZ_U_$P($G(^VA(200,DUZ,0)),U),P("INS")="" 78 W ! D ^PSIVORLB K PSIVEXAM S Y=P(2) 79 W !,"Start date: " X ^DD("DD") W $P(Y,"@")," ",$P(Y,"@",2),?30," Stop date: " S Y=P(3) X ^DD("DD") W $P(Y,"@")," ",$P(Y,"@",2),! 80 EDIT ; 81 I ERR=1 W !,"Please re-edit this order" K DIR S DIR(0)="E" D ^DIR K DIR W:'Y $C(7),"order unchanged." Q:'Y S Y=0 G EDIT1 82 ;PSJ*5*157 EFD FOR IV 83 D EFDIV^PSJUTL($G(ZZND)) 84 W:$G(PSIVCHG) !,"*** This change will cause a new order to be created. ***" 85 K DIR S DIR(0)="Y",DIR("A")="Is this O.K.",DIR("B")=$S(ERR:"NO",1:"YES"),DIR("?",1)="Enter ""Y"" to make this an active order (only allowed if no errors were" 86 S DIR("?")="found in order), ""N"" to edit the order, or ""^"" to leave order unchanged.",DIR("??")="^S HELP=""EDIT"" D ^PSIVHLP" 87 D ^DIR K DIR I $D(DIRUT) K DIRUT W $C(7),"Order unchanged." Q 88 ;* Kill Unit dose variables when calling from ^PSJLIFNI. 89 I +Y,$G(PSJLIFNI) D 90 . K ND,ND4,ND6,NDP2 91 . K PSGAT,PSGCANFL,PSGDI,PSGDO,PSGDT,PSGEB,PSGEBN,PSGEFN,PSGFD,PSGFDN 92 . K PSGHSM,PSGLI,PSGLIN,PSGLMT,PSGMR,PSGMRN,PSGNEDFD,PSGNEF,PSGNEFD 93 . K PSGNESD,PSGOAT,PSGODO,PSGODT,PSGEA,PSGOEAV,PSGOEEF 94 . K PSGOEEWF,PSGOEEG,PSGOEF,PSGOENG,PSGOES,PSGOFD,PSGOFDN,PSGOHSM 95 . K PSGOINST,PSGOMR,PSGOMRN,PSGONC 96 . K PSGOPD,PSOPDN,PSGOPR,PSGOPRN,PSGOSD,PSGOSDN,PSGOSI,PSGOSM 97 . K PSGOST,PSGOSTN 98 . K PSGPD,PSGPDN,PSGPDRG,PSGDRGN,PSGPFLG,PSGPI,PSGPR,PSGPRIO,PSGPRN 99 . K PSGPTMP,PSGRRF,PSG0XT,PSGS0Y,PSGSCH,PSGSD,PSGSDN,PSGSI,PSGSM 100 . K PSGST,PSGSTAT,PSGSTN,PSJACNWP,PSJACOK,PSJCOI 101 EDIT1 ; 102 NEW XFLG,PSIVY S PSIVY=Y 103 NEW X S X=^TMP("PSJI",$J,0),VALMBG=$S((X<17):1,1:(X-(X#16))) 104 I PSIVY=0!'$G(PSIVFN1) S PSIVFN1=1 D EN^VALM("PSJ LM IV AC/EDIT") Q 105 S PSIVCHG=0 D EDCHK^PSIVORC2 K PSIVCHG 106 S VALMBCK="Q",PSIVACEP=1 107 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVOREN.m
r613 r623 1 PSIVOREN ;BIR/MLM-UTILITIES FOR IV FLUIDS - OE/RR INTERFACE ; 25 Sep 98 / 2:00 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**3,18,69,110,127,133,140,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191. 5 ; Reference to ^VA(200 is supported by DBIA 10060. 6 ; Reference to ^DIE is supported by DBIA 10018. 7 ; 8 ENCPP ; Check Package Parameter 9 D ORPARM I 'PSJORF W !!,"Inpatient Medications is not turned on for OE/RR.",!,"You will not be able to enter or edit IV or Unit Dose orders." 10 I 'PSJIVORF W !!,"IV Medications is not turned on for OE/RR.",!,"You will not be able to enter or edit IV orders." 11 I 'PSJORF!'PSJIVORF S PSJIVORF="" D DONE^PSIVORA1 Q 12 S PSJORL=$G(VAIN(4)) I 'PSJORL,$G(DFN) D INP^VADPT S PSJORL=$G(VAIN(4)) 13 S PSJORPF=0,P("OT")="F^",PSJORNP=$S($G(PSJORNP):PSJORNP,1:+$G(DUZ)) 14 Q 15 ; 16 PS ; Check if MD is authorized to write med. orders. 17 S PSJORPF=0 S:PSJORNP X=$G(^VA(200,+PSJORNP,"PS")) Q:$S('PSJORNP:0,'X:0,'$P(X,U,4):1,$P(X,U,4)>DT:1,1:0) D 18 .W !?2,"(The selected PROVIDER is NOT qualified to write MEDICATION orders. You must",!,"select a valid provider to be able to continue with Inpatient Medications.)" 19 .K DIC S DIC="^VA(200,",DIC(0)="AEMQZ",DIC("A")="Select PHARMACY PROVIDER: ",DIC("S")="S PSIV=$G(^(""PS"")) I PSIV,$S($P(PSIV,""^"",4)="""":1,DT<$P(PSIV,""^"",4):1,1:0)" F W ! D ^DIC Q:$D(DUOUT)!$D(DTOUT)!(Y>0) W $C(7)," (Required.)" 20 .K DIC S:Y'>0 PSJORPF=11 S:Y>0 PSJORNP=+Y Q 21 K DTOUT 22 Q 23 ; 24 RUPDATE(DFN,ON,NSTRT) ; 25 ; Update renewal orders (called from Pharmacy options). 26 N DA,DIE,DR,ND,NSTOP,OSTOP,NOO,ORETURN,PSIVACT,PSIVAL,PSIVALCK,PSJOSTRT,PSGOLDOE S DIE="^PS(55,"_DFN_"," 27 I ON["P" S OLDON=$P($G(^PS(53.1,+ON,0)),"^",25),NOO=$P($G(^PS(53.1,+ON,.2)),"^",3) 28 I ON["V" S OLDON=ON,NOO=$P($G(^PS(55,DFN,"IV",+ON,.2)),"^",5) 29 I ON["U" S OLDON=$P($G(^PS(55,DFN,5,+ON,0)),U,25) 30 I OLDON["P" S OLDON=$P($G(^PS(53.1,+OLDON,0)),U,25) 31 I OLDON["V" S ON55=OLDON,X=$G(^PS(55,DFN,"IV",+OLDON,2)),PSJOSTRT=$P(X,U,7),OSTOP=$S(($G(PSJOSTOP)>PSJOSTRT):PSJOSTOP,1:$P($G(^(0)),U,3)),DIE=DIE_"""IV"",",DR="100////A",PSIVACT=1 32 I OLDON["U" S X=$G(^PS(55,DFN,5,+OLDON,2)),PSJOSTRT=$P(X,U,7),OSTOP=$P(X,U,4),DIE=DIE_"5," 33 S NSTOP=+$S($G(P(3)):P(3),1:0),DA=+OLDON,DA(1)=DFN I 'NSTOP W !,"CAN'T RENEW THIS ORDER!" D PAUSE^VALM1 Q 34 ; 35 I ON["V"!(ON["P") D EXPOE^PSGOER(DFN,ON) 36 ; 37 S DR=DR_";"_$S(OLDON["V":.03,OLDON["U":34,1:25)_"////"_NSTOP_";"_$S(OLDON["V":"114////@;123////@",1:"105////@;107////@") S:+$G(P(6))?1.30N DR=DR_";.06////"_+P(6) D ^DIE 38 I ON["P" S DIE="^PS(53.1,",DR="28////A;105////@;",DA=+ON D ^DIE D 39 .I $G(OLDON)["V" S PSGOLDOE=$P($G(^PS(55,DFN,"IV",+OLDON,0)),"^",21) 40 .N NOEORD,VN,VNDT S NOEORD=$P(^PS(53.1,+ON,0),U,21) S VN=$P($G(^PS(53.1,+ON,4)),"^") I VN S VNDT=$P($G(^PS(53.1,+ON,4)),"^",2) 41 .I NOEORD K DA,DR,DIE S DIE="^PS(55,"_DFN_",""IV"",",DA(1)=DFN,DA=+ON55,DR="110////"_+NOEORD D 42 ..S DR=DR_";16////"_$S($G(VN):VN,1:"@")_";17////"_$S($G(VNDT):VNDT,1:"@")_";" D ^DIE I NOEORD[";" S $P(^PS(53.1,+ON,0),U,21)=NOEORD 43 ..I $G(VN) D EN1^PSJHL2(DFN,"ZV",ON55) 44 I ON["V" S DIE="^PS(55,DFN,""IV"",",DR="100////A;114////@;16////@;17////@" S DA=+ON55 D ^DIE 45 N RDT S RDT=$P($G(@("^PS(53.1,"_+ON_",14,0)")),U,3) S:RDT RDT=+(^(RDT,0)) S RDT=$S(RDT:RDT,1:$$DATE^PSJUTL2) I RDT D UPDREN^PSIVOPT2(DFN,OLDON,RDT,+P(6),+$G(OSTOP),$G(NOO)) 46 ; 47 I ON["V" D EN1^PSJHL2(DFN,"SN",ON,"NEW ORDER CREATED") 48 I OLDON["V" S (ON,ON55)=OLDON,PSIVAL="",PSIVALCK="STOP",(P("FRES"),PSIVREA)="R" D LOG^PSIVORAL D 49 .I $G(ON55),$G(OSTOP),$G(DFN) D STIX(OSTOP,OLDON,DFN) 50 .;Add check to If statement below. If New Stop date ='s the old Stop Don't delete AIV x-ref (NSTOP'=PSJOSTOP) 51 .I $G(PSJOSTOP),$G(NSTOP) I NSTOP=$P($G(^PS(55,DFN,"IV",+ON55,0)),"^",3),$D(^PS(55,"AIV",NSTOP,DFN,+ON55)),NSTOP'=PSJOSTOP K ^PS(55,"AIV",PSJOSTOP,DFN,+ON55) 52 D:'$D(PSJIVORF) ORPARM Q:'PSJIVORF 53 Q 54 ; 55 RUPTXT(DFN,OLDON) ; 56 ;Update ORTX( in OE/RR 57 I OLDON'["V" ;; D ENUDTX^PSJOREN(DFN,OLDON,"OR") S ORIFN=$P($G(^PS(55,DFN,"IV",+OLDON,0)),U,21) 58 I OLDON["V" S P("FRES")="R" D GTPC^PSIVORFB(OLDON),SORTX^PSIVORFE S ORIFN=$P($G(^PS(55,DFN,"IV",+OLDON,0)),U,21) 59 Q 60 ; 61 ORPARM ;Check if inpatient pkges are on. 62 S (PSJORF,PSJIVORF)=1 63 Q 64 ; 65 NATURE ; Ask nature of order. 66 Q:$G(PSJDCTYP)=2 67 I '+$G(PSJSYSU) S P("NAT")="W" Q 68 K P("NAT") NEW X 69 I $D(XQORNOD(0)) S X=$E($P(XQORNOD(0),U,3),1,1) S:X="" X="E" 70 S:'$D(X) X="N" S:"AF"[X X="E" 71 I $G(PSIVCOPY) S X="N" 72 S P("NAT")=$$ENNOO^PSJUTL5(X) 73 K:P("NAT")=-1 P("NAT") 74 Q 75 CLINIC ;Ask clinic where outpt is being seen for DSS 76 K P("CLIN") NEW X1,X2,X,PSJDT,DIC,Y 77 S X1=DT,X2=-7 D C^%DTC S PSJDT=X 78 S DIC("S")="I $P($G(^SC(Y,0)),U,3)=""C"",$S('$P($G(^(""I"")),U):1,($P($G(^(""I"")),U)>PSJDT):1,(($P($G(^(""I"")),U)<PSJDT)&($P($G(^(""I"")),U,2)]"""")&(DT>$P($G(^(""I"")),U,2))):1,1:0)" 79 S DIC=44,DIC(0)="QEAZ",DIC("A")="Select CLINIC LOCATION: " D ^DIC 80 I $S($D(DTOUT):1,$D(DUOUT):1,1:0) Q 81 S:+Y>0 P("CLIN")=+Y,$P(^PS(55,DFN,"IV",+ON55,"DSS"),"^")=+Y 82 Q 83 ; 84 STIX(OST,OON,DFN) ; Check start index, cleanup old start 85 I $G(OST),$G(OON) S OS="" F S OS=$O(^PS(55,DFN,"IV","AIS",OS)) Q:'OS D 86 . Q:'$D(^PS(55,DFN,"IV","AIS",OS,+OON)) 87 . I $P($G(^PS(55,DFN,"IV",+OON,0)),"^",3)'=OS K ^PS(55,DFN,"IV","AIS",OS,+OON) 88 Q 1 PSIVOREN ;BIR/MLM-UTILITIES FOR IV FLUIDS - OE/RR INTERFACE ; 25 Sep 98 / 2:00 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**3,18,69,110,127,133,140**;16 DEC 97 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191. 5 ; Reference to ^VA(200 is supported by DBIA 10060. 6 ; Reference to ^DIE is supported by DBIA 10018. 7 ; 8 ENCPP ; Check Package Parameter 9 D ORPARM I 'PSJORF W !!,"Inpatient Medications is not turned on for OE/RR.",!,"You will not be able to enter or edit IV or Unit Dose orders." 10 I 'PSJIVORF W !!,"IV Medications is not turned on for OE/RR.",!,"You will not be able to enter or edit IV orders." 11 I 'PSJORF!'PSJIVORF S PSJIVORF="" D DONE^PSIVORA1 Q 12 S PSJORL=$G(VAIN(4)) I 'PSJORL,$G(DFN) D INP^VADPT S PSJORL=$G(VAIN(4)) 13 S PSJORPF=0,P("OT")="F^",PSJORNP=$S($G(PSJORNP):PSJORNP,1:+$G(DUZ)) 14 ;; S PSJORL=ORL,PSJORPF=0,P("OT")="F^"_$O(^ORD(101,"B","PSJI OR PAT FLUID OE",0))_";ORD(101,",PSJORNP=ORNP 15 Q 16 ; 17 PS ; Check if MD is authorized to write med. orders. 18 S PSJORPF=0 S:PSJORNP X=$G(^VA(200,+PSJORNP,"PS")) Q:$S('PSJORNP:0,'X:0,'$P(X,U,4):1,$P(X,U,4)>DT:1,1:0) D 19 .W !?2,"(The selected PROVIDER is NOT qualified to write MEDICATION orders. You must",!,"select a valid provider to be able to continue with Inpatient Medications.)" 20 .K DIC S DIC="^VA(200,",DIC(0)="AEMQZ",DIC("A")="Select PHARMACY PROVIDER: ",DIC("S")="S PSIV=$G(^(""PS"")) I PSIV,$S($P(PSIV,""^"",4)="""":1,DT<$P(PSIV,""^"",4):1,1:0)" F W ! D ^DIC Q:$D(DUOUT)!$D(DTOUT)!(Y>0) W $C(7)," (Required.)" 21 .K DIC S:Y'>0 PSJORPF=11 S:Y>0 PSJORNP=+Y Q 22 K DTOUT 23 Q 24 ; 25 RUPDATE(DFN,ON,NSTRT) ; 26 ; Update renewal orders (called from Pharmacy options). 27 N DA,DIE,DR,ND,NSTOP,OSTOP,NOO,ORETURN,PSIVACT,PSIVAL,PSIVALCK,PSJOSTRT,PSGOLDOE S DIE="^PS(55,"_DFN_"," 28 I ON["P" S OLDON=$P($G(^PS(53.1,+ON,0)),"^",25),NOO=$P($G(^PS(53.1,+ON,.2)),"^",3) 29 I ON["V" S OLDON=ON,NOO=$P($G(^PS(55,DFN,"IV",+ON,.2)),"^",5) 30 I ON["U" S OLDON=$P($G(^PS(55,DFN,5,+ON,0)),U,25) 31 I OLDON["P" S OLDON=$P($G(^PS(53.1,+OLDON,0)),U,25) 32 I OLDON["V" S ON55=OLDON,X=$G(^PS(55,DFN,"IV",+OLDON,2)),PSJOSTRT=$P(X,U,7),OSTOP=$S(($G(PSJOSTOP)>PSJOSTRT):PSJOSTOP,1:$P($G(^(0)),U,3)),DIE=DIE_"""IV"",",DR="100////A",PSIVACT=1 33 I OLDON["U" S X=$G(^PS(55,DFN,5,+OLDON,2)),PSJOSTRT=$P(X,U,7),OSTOP=$P(X,U,4),DIE=DIE_"5," 34 S NSTOP=+$S($G(P(3)):P(3),1:0),DA=+OLDON,DA(1)=DFN I 'NSTOP W !,"CAN'T RENEW THIS ORDER!" D PAUSE^VALM1 Q 35 ;I OSTOP>NSTOP W !,"NEW STOP DATE IS LESS THAN PREVIOUS STOP DATE" D PAUSE^VALM1 36 ; 37 I ON["V"!(ON["P") D EXPOE^PSGOER(DFN,ON) 38 ; 39 S DR=DR_";"_$S(OLDON["V":.03,OLDON["U":34,1:25)_"////"_NSTOP_";"_$S(OLDON["V":"114////@;123////@",1:"105////@;107////@") S:+$G(P(6))?1.30N DR=DR_";.06////"_+P(6) D ^DIE 40 I ON["P" S DIE="^PS(53.1,",DR="28////A;105////@;",DA=+ON D ^DIE D 41 .I $G(OLDON)["V" S PSGOLDOE=$P($G(^PS(55,DFN,"IV",+OLDON,0)),"^",21) 42 .N NOEORD,VN,VNDT S NOEORD=$P(^PS(53.1,+ON,0),U,21) S VN=$P($G(^PS(53.1,+ON,4)),"^") I VN S VNDT=$P($G(^PS(53.1,+ON,4)),"^",2) 43 .I NOEORD K DA,DR,DIE S DIE="^PS(55,"_DFN_",""IV"",",DA(1)=DFN,DA=+ON55,DR="110////"_+NOEORD D 44 ..S DR=DR_";16////"_$S($G(VN):VN,1:"@")_";17////"_$S($G(VNDT):VNDT,1:"@")_";" D ^DIE I NOEORD[";" S $P(^PS(53.1,+ON,0),U,21)=NOEORD 45 ..I $G(VN) D EN1^PSJHL2(DFN,"ZV",ON55) 46 I ON["V" S DIE="^PS(55,DFN,""IV"",",DR="100////A;114////@;16////@;17////@" S DA=+ON55 D ^DIE 47 N RDT S RDT=$P($G(@("^PS(53.1,"_+ON_",14,0)")),U,3) S:RDT RDT=+(^(RDT,0)) S RDT=$S(RDT:RDT,1:$$DATE^PSJUTL2) I RDT D UPDREN^PSIVOPT2(DFN,OLDON,RDT,+P(6),+$G(OSTOP),$G(NOO)) 48 ; 49 I ON["V" D EN1^PSJHL2(DFN,"SN",ON,"NEW ORDER CREATED") 50 I OLDON["V" S (ON,ON55)=OLDON,PSIVAL="",PSIVALCK="STOP",(P("FRES"),PSIVREA)="R" D LOG^PSIVORAL D 51 .I $G(ON55),$G(OSTOP),$G(DFN) D STIX(OSTOP,OLDON,DFN) 52 .;Add check to If statement below. If New Stop date ='s the old Stop Don't delete AIV x-ref (NSTOP'=PSJOSTOP) 53 .I $G(PSJOSTOP),$G(NSTOP) I NSTOP=$P($G(^PS(55,DFN,"IV",+ON55,0)),"^",3),$D(^PS(55,"AIV",NSTOP,DFN,+ON55)),NSTOP'=PSJOSTOP K ^PS(55,"AIV",PSJOSTOP,DFN,+ON55) 54 D:'$D(PSJIVORF) ORPARM Q:'PSJIVORF 55 Q 56 ; 57 RUPTXT(DFN,OLDON) ; 58 ;Update ORTX( in OE/RR 59 I OLDON'["V" ;; D ENUDTX^PSJOREN(DFN,OLDON,"OR") S ORIFN=$P($G(^PS(55,DFN,"IV",+OLDON,0)),U,21) 60 I OLDON["V" S P("FRES")="R" D GTPC^PSIVORFB(OLDON),SORTX^PSIVORFE S ORIFN=$P($G(^PS(55,DFN,"IV",+OLDON,0)),U,21) 61 ;; F X=0:0 S X=$O(ORTX(X)) Q:'X S ORETURN("ORTX",X)=ORTX(X) 62 Q 63 ; 64 ORPARM ;Check if inpatient pkges are on. 65 S (PSJORF,PSJIVORF)=1 66 Q 67 ; 68 NATURE ; Ask nature of order. 69 I '+$G(PSJSYSU) S P("NAT")="W" Q 70 K P("NAT") NEW X 71 I $D(XQORNOD(0)) S X=$E($P(XQORNOD(0),U,3),1,1) S:X="" X="E" 72 ;* S:'$D(X) X="N" S:X="A" X="E" 73 S:'$D(X) X="N" S:"AF"[X X="E" 74 I $G(PSIVCOPY) S X="N" 75 S P("NAT")=$$ENNOO^PSJUTL5(X) 76 K:P("NAT")=-1 P("NAT") 77 Q 78 CLINIC ;Ask clinic where outpt is being seen for DSS 79 K P("CLIN") NEW X1,X2,X,PSJDT,DIC,Y 80 S X1=DT,X2=-7 D C^%DTC S PSJDT=X 81 S DIC("S")="I $P($G(^SC(Y,0)),U,3)=""C"",$S('$P($G(^(""I"")),U):1,($P($G(^(""I"")),U)>PSJDT):1,(($P($G(^(""I"")),U)<PSJDT)&($P($G(^(""I"")),U,2)]"""")&(DT>$P($G(^(""I"")),U,2))):1,1:0)" 82 S DIC=44,DIC(0)="QEAZ",DIC("A")="Select CLINIC LOCATION: " D ^DIC 83 I $S($D(DTOUT):1,$D(DUOUT):1,1:0) Q 84 S:+Y>0 P("CLIN")=+Y,$P(^PS(55,DFN,"IV",+ON55,"DSS"),"^")=+Y 85 Q 86 ; 87 STIX(OST,OON,DFN) ; Check start index, cleanup old start 88 I $G(OST),$G(OON) S OS="" F S OS=$O(^PS(55,DFN,"IV","AIS",OS)) Q:'OS D 89 . Q:'$D(^PS(55,DFN,"IV","AIS",OS,+OON)) 90 . I $P($G(^PS(55,DFN,"IV",+OON,0)),"^",3)'=OS K ^PS(55,DFN,"IV","AIS",OS,+OON) 91 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVORFA.m
r613 r623 1 PSIVORFA 2 ;;5.0; INPATIENT MEDICATIONS ;**4,7,18,28,50,71,58,91,80,110,111,134**;16 DEC 97;Build 124 3 4 5 6 7 8 9 GT531(DFN,ON) 10 11 12 13 14 15 16 17 18 19 20 21 22 23 S Y=$G(^PS(53.1,+ON,2)),P(9)=$P(Y,U),P(11)=$P(Y,U,5),P(15)=$S($P(Y,U,6)'="":$P(Y,U,6),$G(PSGS0XT)'="":PSGS0XT,$P($G(ZZND),"^",3)'="":$P(ZZND,"^",3),1:""),P(2)=$P(Y,U,2),P(3)=$P(Y,U,4)24 S Y=$G(^PS(53.1,+ON,4)),P("CLRK")=$P(Y,U,7)_U_$P($G(^VA(200,+$P(Y,U,7),0)),U),P("REN")=$P(Y,U,9),X=P(9)25 I $P($G(^PS(53.1,+ON,0)),U,7)="P",(P(9)'["PRN") S P(9)=P(9)_" PRN" 26 K PSGST,XT 27 I P(9)]"",(P(11)="") D S P(15)=$S($G(XT)]""&'+$G(XT):XT,+$G(XT)>0:XT,$G(PSGS0XT):PSGS0XT,1:1440),P(11)=Y 28 . I $O(^PS(51.1,"APPSJ",P(9),0)) D DIC^PSGORS0 Q 29 . I '$O(^PS(51.1,"APPSJ",P(9),0)) N NOECH,PSGSCH S NOECH=1 D EN^PSIVSP 30 S Y=$G(^PS(53.1,+ON,8)),P(4)=$P(Y,U),P(23)=$P(Y,U,2),P("SYRS")=$P(Y,U,3),P(5)=$P(Y,U,4),P(8)=$P(Y,U,5),P(7)=$P(Y,U,7),P("IVRM")=$P(Y,U,8) 31 S P(4)=$S(P(4)'="":P(4),$G(PSIVTYPE):PSIVTYPE,1:"")32 33 34 35 D GTDRG,GTOT^PSIVUTL(P(4)) D:'$D(PSJLABEL) GTPC(ON)36 N ND2P5 S ND2P5=$G(^PS(53.1,+ON,2.5)) D 37 .S P("DUR")=$P(ND2P5,"^",2) 38 .S P("LIMIT")=$P(ND2P5,"^",4) 39 .S P("IVCAT")=$P(ND2P5,"^",5) 40 Q 41 GTDRG ; 42 K DRG F X="AD","SOL" S FIL=$S(X="AD":52.6,1:52.7) F Y=0:0 S Y=$O(^PS(53.1,+ON,X,Y)) Q:'Y D 43 .S (DRGI,DRG(X,0))=$G(DRG(X,0))+1,DRG=$G(^PS(53.1,+ON,X,Y,0)),ND=$G(^PS(FIL,+DRG,0)),DRGN=$P(ND,U),DRG(X,+DRGI)=+DRG_U_$P(ND,U)_U_$P(DRG,U,2)_U_$P(DRG,U,3)_U_$P(ND,U,13)_U_$P(ND,U,11) 44 Q 45 ; 46 GTPC(ON) ; Retrieve Provider Comments and create "scratch" fields to edit 47 Q 48 ; 49 PUT531 ; Move data in local variables to 53.1 50 S:'$D(P(9)) P(9)=$G(PSGSCH)51 S ND(0)=+ON_U_+P(6)_U_$S(+P("MR"):+P("MR"),1:"")_U_$P(P("OT"),U)_U_U_U_"C",$P(ND(0),U,9)=P(17),$P(ND(0),U,21)=$G(P(21))52 S $P(ND(0),U,14,16)=P("LOG")_U_DFN_U_P("LOG"),$P(ND(0),U,24,26)=$G(P("RES"))_U_$G(P("OLDON"))_U_$G(P("NEWON"))53 S ND(2)=P(9)_U_P(2)_U_U_P(3)_U_P(11)_U_$S($G(P(15))'="":P(15),$G(PSGS0XT)'="":PSGS0XT,$P($G(ZZND),"^",3)'="":$P(ZZND,"^",3),1:""),$P(ND(4),U,7,9)=+P("CLRK")_U_U_P("REN")54 S ND(8)=P(4)_U_P(23)_U_P("SYRS")_U_P(5)_U_P(8)_"^^"_P(7)_"^"_+P("IVRM"),ND(9)=$S($L(P("REM")_P("OPI")):P("REM")_U_P("OPI"),1:"") S $P(ND(4),U,1,2)=$G(P("NINIT"))_U_$G(P("NINITDT"))55 S:+$G(P("CLIN")) $P(^PS(53.1,+ON,"DSS"),"^")=P("CLIN") 56 S:+$G(P("APPT")) $P(^PS(53.1,+ON,"DSS"),"^",2)=P("APPT") 57 S:$G(P("LIMIT"))]"" $P(^PS(53.1,+ON,2.5),"^",4)=P("LIMIT") 58 I $G(PSJORD)["V"!($G(PSJORD)["P") I $G(^PS(53.1,+ON,2.5))="" N DUR S DUR=$$GETDUR^PSJLIVMD(DFN,+PSJORD,$S((PSJORD["P"):"P",1:"IV"),1) I DUR]"" D 59 .I $G(IVLIMIT) S $P(^PS(53.1,+ON,2.5),"^",4)=DUR K IVLIMIT Q 60 .S $P(^PS(53.1,+ON,2.5),"^",2)=DUR 61 F X=0,2,4,8,9 S ^PS(53.1,+ON,X)=ND(X) 62 S PSIVCAT=$$IVCAT^PSJHLU(DFN,ON,.P) S:PSIVCAT]"" $P(^PS(53.1,+ON,2.5),"^",5)=PSIVCAT K PSIVCAT 63 S:'+$G(^PS(53.1,+ON,.2)) $P(^(.2),U,1,3)=+P("PD")_U_P("DO")_U_$G(P("NAT")) 64 F DRGT="AD","SOL" D:$D(DRG(DRGT)) PTD531 65 K DA,DIK S PSGS0Y=P(11),PSGS0XT=P(15),DA=+ON,DIK="^PS(53.1," D IX^DIK K DA,DIK,PSGS0Y,PSGS0XT,ND,^PS(53.1,"AS","P",DFN,+ON)66 K:P(17)="A" ^PS(53.1,"AS","N",DFN,+ON) 67 S:P(15)="D" $P(^PS(53.1,+ON,2),U,6)="D" 68 Q 69 ; 70 UPD100 ; Update order data in file 100 71 D:'$D(PSJIVORF) ORPARM^PSIVOREN Q:'PSJIVORF 72 73 74 75 PTD531 76 77 78 79 80 1 PSIVORFA ;BIR/MLM-FILE/RETRIEVE ORDERS IN 53.1 ;26 Jun 98 / 9:16 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**4,7,18,28,50,71,58,91,80,110,111**;16 DEC 97 3 ; 4 ; Reference to ^PS(51.1 supported by DBIA 2177. 5 ; Reference to ^PS(51.2 supported by DBIA 2178. 6 ; Reference to ^PS(52.7 supported by DBIA 2173. 7 ; Reference to ^PS(52.6 supported by DBIA 1231. 8 ; 9 GT531(DFN,ON) ; Retrieve order data from 53.1 and place into local array 10 ; 11 NEW PSGOES S PSGOES=1 12 F X="CUM","LF","LFA","LF","PRNTON" S P(X)="" 13 S Y=$G(^PS(53.1,+ON,0)),P(17)=$P(Y,U,9),P("LOG")=$P(Y,U,16),(P(21),P("21FLG"),PSJORIFN)=$P(Y,U,21) 14 S P("RES")=$P(Y,U,24),P("OLDON")=$P(Y,U,25),P("NEWON")=$P(Y,U,26),P("FRES")=$P(Y,U,27) 15 S P("MR")=$P(Y,U,3),P(6)=+$P(Y,U,2),Y=$G(^VA(200,+P(6),0)),$P(P(6),U,2)=$P(Y,U),Y=$G(^PS(51.2,+P("MR"),0)),$P(P("MR"),U,2)=$S($P(Y,U,3)]"":$P(Y,U,3),1:$P(Y,U)) 16 S Y=$G(^PS(53.1,+ON,.2)),P("PD")=$S(+Y:$P(Y,U)_U_$$OIDF^PSJLMUT1(+Y),1:""),P("DO")=$P(Y,U,2),P("NAT")=$P(Y,U,3),P("PRY")=$P(Y,U,4),(PSJCOM,P("PRNTON"))=$P(Y,U,8) 17 S P("INS")=$G(^PS(53.1,+ON,.3)) 18 I $G(^PS(53.1,+ON,4))]"" S P("NINIT")=$P(^(4),U),P("NINITDT")=$P(^(4),U,2) 19 NEW NAME S NAME="" 20 I $D(^PS(53.1,+ON,1,1)) D DD^PSJLMUT1("^PS(53.1,+ON,",.NAME) 21 S P("INS")=P("INS")_$S(P("INS")]"":" of ",1:"")_NAME 22 S P("APPT")=$G(^PS(53.1,+ON,"DSS")),P("CLIN")=$P(P("APPT"),"^"),P("APPT")=$P(P("APPT"),"^",2) 23 ;;S Y=$G(^PS(53.1,+ON,2)),P(9)=$P(Y,U),P(11)=$P(Y,U,5),P(15)=$P(Y,U,6),Y=$G(^PS(53.1,+ON,4)),P("CLRK")=$P(Y,U,7)_U_$P($G(^VA(200,+$P(Y,U,7),0)),U),P("REN")=$P(Y,U,9),X=P(9) 24 S Y=$G(^PS(53.1,+ON,2)),P(9)=$P(Y,U),P(11)=$P(Y,U,5),P(15)=$P(Y,U,6),P(2)=$P(Y,U,2),P(3)=$P(Y,U,4) 25 S Y=$G(^PS(53.1,+ON,4)),P("CLRK")=$P(Y,U,7)_U_$P($G(^VA(200,+$P(Y,U,7),0)),U),P("REN")=$P(Y,U,9),X=P(9) 26 I $P($G(^PS(53.1,+ON,0)),U,7)="P",(P(9)'["PRN") S P(9)=P(9)_" PRN" 27 K PSGST,XT 28 I P(9)]"",(P(11)="") D S P(15)=$S($G(XT)]""&'+$G(XT):XT,+$G(XT)>0:XT,1:1440),P(11)=Y 29 . I $O(^PS(51.1,"APPSJ",P(9),0)) D DIC^PSGORS0 Q 30 . I '$O(^PS(51.1,"APPSJ",P(9),0)) N NOECH,PSGSCH S NOECH=1 D EN^PSIVSP 31 S Y=$G(^PS(53.1,+ON,8)),P(4)=$P(Y,U),P(23)=$P(Y,U,2),P("SYRS")=$P(Y,U,3),P(5)=$P(Y,U,4),P(8)=$P(Y,U,5),P(7)=$P(Y,U,7),P("IVRM")=$P(Y,U,8) 32 S:'P("IVRM")&($D(PSIVSN)) P("IVRM")=+PSIVSN S Y=$G(^PS(59.5,+P("IVRM"),0)),$P(P("IVRM"),U,2)=$P(Y,U),Y=$G(^PS(53.1,+ON,9)),P("REM")=$P(Y,U),P("OPI")=$P(Y,U,2,3) 33 S P("DTYP")=$S(P(4)="":0,P(4)="P"!(P(23)="P")!(P(5)):1,P(4)="H":2,1:3) 34 S P("PACT")=$G(^PS(53.1,+ON,"A",1,0)) 35 ;;D GTDRG,GTOT^PSIVUTL(P(4)) D:'$D(PSJLABEL) GTPC(ON) S (P(2),P(3))="" ;L -^PS(53.1,+ON) 36 D GTDRG,GTOT^PSIVUTL(P(4)) D:'$D(PSJLABEL) GTPC(ON) 37 Q 38 GTDRG ; 39 K DRG F X="AD","SOL" S FIL=$S(X="AD":52.6,1:52.7) F Y=0:0 S Y=$O(^PS(53.1,+ON,X,Y)) Q:'Y D 40 .S (DRGI,DRG(X,0))=$G(DRG(X,0))+1,DRG=$G(^PS(53.1,+ON,X,Y,0)),ND=$G(^PS(FIL,+DRG,0)),DRGN=$P(ND,U),DRG(X,+DRGI)=+DRG_U_$P(ND,U)_U_$P(DRG,U,2)_U_$P(DRG,U,3)_U_$P(ND,U,13)_U_$P(ND,U,11) 41 Q 42 ; 43 GTPC(ON) ; Retrieve Provider Comments and create "scratch" fields to edit 44 ;S:'$D(PSIVUP) PSIVUP=+$$GTPCI^PSIVUTL K ^PS(53.45,PSIVUP,4) I $O(^PS(53.1,+ON,12,0)) S %X="^PS(53.1,"_+ON_",12,",%Y="^PS(53.45,"_PSIVUP_",4," D %XY^%RCR 45 Q 46 ; 47 PUT531 ; Move data in local variables to 53.1 48 S ND(0)=+ON_U_+P(6)_U_$S(+P("MR"):+P("MR"),1:"")_U_$P(P("OT"),U)_U_U_U_"C",$P(ND(0),U,9)=P(17),$P(ND(0),U,21)=$G(P(21)) 49 ;;S $P(ND(0),U,14,16)=P("LOG")_U_DFN_U_P("LOG"),$P(ND(0),U,21)=$S("AD"'[P(17):PSJORIFN,1:""),$P(ND(0),U,24,26)=$G(P("RES"))_U_$G(P("OLDON"))_U_$G(P("NEWON")) S ND(2)=P(9)_U_P(2)_U_U_P(3)_U_P(11)_U_P(15),$P(ND(4),U,7,9)=+P("CLRK")_U_U_P("REN") 50 S $P(ND(0),U,14,16)=P("LOG")_U_DFN_U_P("LOG"),$P(ND(0),U,24,26)=$G(P("RES"))_U_$G(P("OLDON"))_U_$G(P("NEWON")) S ND(2)=P(9)_U_P(2)_U_U_P(3)_U_P(11)_U_P(15),$P(ND(4),U,7,9)=+P("CLRK")_U_U_P("REN") 51 S ND(8)=P(4)_U_P(23)_U_P("SYRS")_U_P(5)_U_P(8)_"^^"_P(7)_"^"_+P("IVRM"),ND(9)=$S($L(P("REM")_P("OPI")):P("REM")_U_P("OPI"),1:"") 52 S $P(ND(4),U,1,2)=$G(P("NINIT"))_U_$G(P("NINITDT")) 53 S:+$G(P("CLIN")) $P(^PS(53.1,+ON,"DSS"),"^")=P("CLIN") 54 S:+$G(P("APPT")) $P(^PS(53.1,+ON,"DSS"),"^",2)=P("APPT") 55 I $G(PSJORD)["V"!($G(PSJORD)["P") I $G(^PS(53.1,+ON,2.5))="" N DUR S DUR=$$GETDUR^PSJLIVMD(DFN,+PSJORD,$S((PSJORD["P"):"P",1:"IV"),1) I DUR]"" D 56 .I $G(IVLIMIT) S $P(^PS(53.1,+ON,2.5),"^",4)=DUR K IVLIMIT Q 57 .S $P(^PS(53.1,+ON,2.5),"^",2)=DUR 58 F X=0,2,4,8,9 S ^PS(53.1,+ON,X)=ND(X) 59 ;;S:+P("PD") ^PS(53.1,+ON,.2)=+P("PD")_U_P("DO") 60 S:'+$G(^PS(53.1,+ON,.2)) $P(^(.2),U,1,3)=+P("PD")_U_P("DO")_U_$G(P("NAT")) 61 ;;K ^PS(53.1,+ON,12) I $O(^PS(53.45,PSIVUP,4,0)) S %X="^PS(53.45,"_PSIVUP_",4,",%Y="^PS(53.1,"_+ON_",12," D %XY^%RCR 62 ;;K ^PS(53.45,+PSIVUP,4) 63 F DRGT="AD","SOL" D:$D(DRG(DRGT)) PTD531 64 K DA,DIK S PSGS0Y=P(11),PSGS0XT=P(15),DA=+ON,DIK="^PS(53.1," D IX^DIK K DA,DIK,PSGS0Y,PSGS0XT,ND,^PS(53.1,"AS","P",DFN,+ON) 65 K:P(17)="A" ^PS(53.1,"AS","N",DFN,+ON) 66 S:P(15)="D" $P(^PS(53.1,+ON,2),U,6)="D" 67 Q 68 ; 69 UPD100 ; Update order data in file 100 70 D:'$D(PSJIVORF) ORPARM^PSIVOREN Q:'PSJIVORF 71 ;* S ORIFN=PSJORIFN,PSJORL=$$ENORL^PSJUTL($G(VAIN(4))) D SET^PSIVORFE K ORETURN ;; F X="OREVENT","ORSTS","ORSTRT","ORSTOP","ORPK","ORPCL","ORNP","ORPK" S ORETURN(X)=@X 72 S PSJORL=$$ENORL^PSJUTL($G(VAIN(4))) D SET^PSIVORFE 73 Q 74 ; 75 PTD531 ; Move drug data from local array into 53.1 76 K ^PS(53.1,+ON,DRGT) S ^PS(53.1,+ON,DRGT,0)=$S(DRGT="AD":"^53.157^0^0",1:"^53.158^0^0") 77 F X=0:0 S X=$O(DRG(DRGT,X)) Q:'X D 78 .S X1=$P(DRG(DRGT,X),U),Y=^PS(53.1,+ON,DRGT,0),$P(Y,U,3)=$P(Y,U,3)+1,DRG=$P(Y,U,3),$P(Y,U,4)=$P(Y,U,4)+1 79 .S ^PS(53.1,+ON,DRGT,0)=Y,Y=+X1_U_$P(DRG(DRGT,X),U,3) S:DRGT="AD" $P(Y,U,3)=$P(DRG(DRGT,X),U,4) S ^PS(53.1,+ON,DRGT,+DRG,0)=Y 80 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVORFB.m
r613 r623 1 PSIVORFB ;BIR/MLM-FILE/RETRIEVE ORDERS IN ^PS(55 ;25 Sep 98 / 2:24 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**3,18,28,68,58,85,110,111,120,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(50.7 is supported by DBIA #2180. 5 ; Reference to ^PS(51.2 is supported by DBIA #2178. 6 ; Reference to ^PS(52.6 is supported by DBIA #1231. 7 ; Reference to ^PS(52.7 is supported by DBIA #2173. 8 ; Reference to ^PS(55 is supported by DBIA #2191. 9 ; 10 NEW55 ; Get new order number in 55. 11 N DA,DD,DO,DIC,DLAYGO,X,Y,PSIVLIM,MINS,PSJDSTP1,PSJDSTP2,A,PSJCLIN,PSJDNM,PSJPROV,PSJWARD,PSJPAO,PSJALRT 12 I $D(^PS(55,+DFN)),'$D(^PS(55,+DFN,0)) D ENSET0^PSGNE3(+DFN) 13 I $G(PSJORD)["V"!($G(PSJORD)["P"),$G(P(2))]"" D LIMSTOP(.PSJDSTP1,.PSJDSTP2) 14 I ($G(PSJORD)["P"!($G(PSJORD)["V"))&$G(PSIVLIM) I $$CMPLIM(PSJORD,PSJDSTP1,PSJDSTP2) D 15 . D 16 .. S PSJPROV=DUZ I PSJORD["P" S PSJPROV=$P($G(^PS(53.1,+PSJORD,0)),"^",2) 17 .. I PSJORD["V" S PSJPROV=$P($G(^PS(55,DFN,"IV",+PSJORD,0)),"^",6) 18 .. D NOW^%DTC S XQA(PSJPROV)="",XQAID="PSJ,"_DFN_";"_PSJPROV_";"_%,XQADATA="" 19 .. D 20 ... I PSJORD["P" S A=$G(^PS(53.1,+PSJORD,"DSS")) 21 ... I PSJORD["V" S A=$G(^PS(55,PSGP,"IV",+PSJORD,"DSS")) 22 ... S PSJCLIN=$P(A,"^") I PSJCLIN]"" S PSJCLIN=$P(^SC(PSJCLIN,0),"^") 23 .. S A=$G(^DPT(DFN,0)),PSJWARD=$G(^(.1)) 24 .. S XQAMSG=$P(A,"^")_" ("_$E($P(A,"^"))_$E($P(A,"^",9),6,9)_"): ["_$S(PSJWARD]"":$E(PSJWARD,1,10),$G(PSJCLIN)]"":$E(PSJCLIN,1,10),1:"UNKNOWN")_"] " 25 .. S A=$O(DRG("AD",0)) I A]"" S A=DRG("AD",A) 26 .. I A="" S A=$O(DRG("SOL",0)) I A]"" S A=DRG("SOL",A) 27 .. S PSJDNM=$P(^PS(50.7,+$P(A,"^",6),0),"^") 28 .. S XQAMSG=XQAMSG_PSJDNM_" your DURATION not used for stop date/time" 29 .. D SETUP^XQALERT 30 .. S PSJALRT=$$FMTDUR^PSJLIVMD($S(PSJORD["P":$P($G(^PS(53.1,+PSJORD,2.5)),"^",4),PSJORD["IV":$P($G(^PS(55,DFN,"IV",+PSJORD,2.5)),"^",4),1:"UNK")) 31 S DIC="^PS(55,",DIC(0)="LN",DLAYGO=55,(DINUM,X)=+DFN D ^DIC Q:Y<0 32 LOCK0 F L +^PS(55,DFN,"IV",0):0 I Q 33 S ND=$S($D(^PS(55,DFN,"IV",0)):^(0),1:"^55.01") F DA=$P(ND,"^",3)+1:1 W "." I '$D(^PS(55,DFN,"IV",DA)) S $P(ND,"^",3)=DA,$P(ND,"^",4)=$P(ND,"^",4)+1,^PS(55,DFN,"IV",0)=ND Q 34 L +^PS(55,DFN,"IV",+DA):0 E G LOCK0 35 S ^PS(55,DFN,"IV",+DA,0)=+DA,^PS(55,DFN,"IV","B",+DA,+DA)="" 36 L -^PS(55,DFN,"IV",0) S ON55=+DA_"V" 37 I $G(PSJALRT)]"" S PSIVAL="IV LIMIT OVERRIDDEN ("_$G(PSJALRT)_"): ALERT SENT",PSIVALT="",PSIVREA="E" D 38 .D LOG^PSIVORAL S P("LIMIT")="",P("OVRIDE")=1 K IVLIM,IVLIMIT 39 .S $P(^PS(55,DFN,"IV",+ON55,2.5),"^",4)="" S:$G(PSJORD)["P" $P(^PS(53.1,+PSJORD,2.5),"^",4)="" 40 .K PSIVAL,PSIVREA,PSIVALT 41 Q 42 SET55 ; Move data from local variables to 55. 43 I '$D(ON55) W !,"*** Can't create this order at this time ***" Q 44 N DA,DIK,ND,PSIVACT,PSIVDUR 45 S:'$D(P(21)) (P(21),P("21FLG"))="" S ND(0)=+ON55,P(22)=$S(VAIN(4):+VAIN(4),1:.5) F X=2:1:23 I $D(P(X)) S $P(ND(0),U,X)=P(X) 46 S ND(.3)=$G(P("INS")),ND(2.5)="" N X S X=$S($G(PSGORD):PSGORD,1:$G(ON)) I X D 47 .N PKG S PKG=$E(X,$L(X)) S PKG=$S(PKG="V":"""IV""",PKG="U":5,PKG="P":"P",1:"") Q:PKG="" 48 .S PSIVDUR=$$GETDUR^PSJLIVMD(DFN,+X,$E(X,$L(X)),1) Q:PSIVDUR="" 49 .I $G(IVLIMIT) S ND(2.5)="^^^"_PSIVDUR K IVLIMIT Q 50 S $P(ND(0),U,17)="A",ND(1)=P("REM"),ND(3)=P("OPI"),ND(.2)=$P($G(P("PD")),U)_U_$G(P("DO"))_U_+P("MR")_U_$G(P("PRY"))_U_$G(P("NAT"))_U_U_U_$G(P("PRNTON")) 51 F X=0,1,2.5,3,.2,.3 S ^PS(55,DFN,"IV",+ON55,X)=ND(X) 52 S $P(^PS(55,DFN,"IV",+ON55,2),U,1,4)=P("LOG")_U_+P("IVRM")_U_U_P("SYRS"),$P(^(2),U,8,10)=P("RES")_U_$G(P("FRES"))_U_$S($G(VAIN(4)):+VAIN(4),1:"") 53 S X=^PS(55,DFN,0) I $P(X,"^",7)="" S $P(X,"^",7)=$P($P(P("LOG"),"^"),"."),$P(X,"^",8)="A",^(0)=X 54 S $P(^PS(55,DFN,"IV",+ON55,2),U,11)=+P("CLRK") 55 S:+$G(P("CLIN")) $P(^PS(55,DFN,"IV",+ON55,"DSS"),"^")=P("CLIN") 56 S:+$G(P("APPT")) $P(^PS(55,DFN,"IV",+ON55,"DSS"),"^",2)=P("APPT") 57 S:+$G(P("NINIT")) ^PS(55,DFN,"IV",+ON55,4)=P("NINIT")_U_P("NINITDT") 58 I '$G(PSIVCHG)!($G(PSJREN)&($G(PSIVCHG)=2)) I $G(P("PON")),P("PON")'=ON55 D 59 . N X S X=$S(P("PON")["P":"^PS(53.1,+P(""PON""),12,0)",P("PON")["V"&$G(PSJREN):"^PS(55,DFN,""IV"",+P(""PON""),5,0)",1:"") Q:X="" 60 . I $O(@X) S %X=X,%Y="^PS(55,"_DFN_",""IV"","_+ON55_",5," D %XY^%RCR 61 F DRGT="AD","SOL" D PUTD55 62 K DA,DIK S DA(1)=DFN,DA=+ON55,DIK="^PS(55,"_DA(1)_",""IV"",",PSIVACT=1 D IX^DIK 63 I $G(PSJCOM),$G(PSJCOMSI),$G(PSJORD)["V" K PSJCOMSI N PSJCHILD,PSJOEORD S PSJOEORD=0 F S PSJOEORD=$O(^PS(55,"ACX",PSJCOM,PSJOEORD)) Q:'PSJOEORD D 64 . N PSJCHILD S PSJCHILD=0 F S PSJCHILD=$O(^PS(55,"ACX",PSJCOM,PSJOEORD,PSJCHILD)) Q:'PSJCHILD S PSJCHILD(+PSJCHILD)=PSJCOM 65 . S PSJCHILD=0 F S PSJCHILD=$O(PSJCHILD(PSJCHILD)) Q:'PSJCHILD D 66 .. Q:PSJCHILD=PSJORD K DR,DA,DIE,ORD S DR="31////"_$P($G(P("OPI")),"^",1,2),DA(1)=DFN 67 .. N ON,ON55 S (ON,ON55)=+PSJCHILD_"V" S:+$G(PSJPINIT)'>0 PSJPINIT=DUZ S PSIVALT=1,PSIVAL="COMPLEX ORDER" D ENTACT^PSIVAL D 68 ... I $P($G(^PS(55,DFN,"IV",+ON55,3)),"^")'=$P(P("OPI"),"^") S P("FC")="OTHER PRINT INFO^"_$P($G(^(3)),"^")_U_$P(P("OPI"),"^") D GTFC^PSIVORAL 69 ... I $D(^PS(55,DFN,"IV",+ON55,0)) S ^PS(55,DFN,"IV",+ON55,3)=P("OPI") D EN1^PSJHL2(DFN,"XX",ON55) 70 Q 71 ; 72 PUTD55 ; Move drug data from local array into 55 73 K ^PS(55,DFN,"IV",+ON55,DRGT) S ^PS(55,DFN,"IV",+ON55,DRGT,0)=$S(DRGT="AD":"^55.02PA",1:"^55.11IPA") 74 F X=0:0 S X=$O(DRG(DRGT,X)) Q:'X D 75 .S Y=^PS(55,DFN,"IV",+ON55,DRGT,0),$P(Y,U,3)=$P(Y,U,3)+1,DRG=$P(Y,U,3),$P(Y,U,4)=$P(Y,U,4)+1 76 .S ^PS(55,DFN,"IV",+ON55,DRGT,0)=Y,Y=$P(DRG(DRGT,X),U)_U_$P(DRG(DRGT,X),U,3) S:DRGT="AD" $P(Y,U,3)=$P(DRG(DRGT,X),U,4) S ^PS(55,DFN,"IV",+ON55,DRGT,+DRG,0)=Y 77 Q 78 GT55 ; Retrieve data from 55 into local array 79 K DRG,DRGN,P S:'$D(ON55) ON55=ON S P("REN")="",Y=$G(^PS(55,DFN,"IV",+ON55,0)) F X=1:1:23 S P(X)=$P(Y,U,X) 80 S P("21FLG")=P(21) 81 S P("PON")=ON55,PSJORIFN=P(21),P(6)=P(6)_U_$P($G(^VA(200,+P(6),0)),U),(DRG,DRGN)="",P("REM")=$G(^PS(55,DFN,"IV",+ON55,1)) 82 S Y=$G(^PS(55,DFN,"IV",+ON55,2)),P("LOG")=$P(Y,U),P("IVRM")=$P(Y,U,2)_U_$P($G(^PS(59.5,+$P(Y,U,2),0)),U) 83 S P("CLRK")=$P(Y,U,11)_U_$P($G(^VA(200,+$P(Y,U,11),0)),U),P("RES")=$P(Y,U,8),P("FRES")=$P(Y,U,9),P("SYRS")=$P(Y,U,4),P("OPI")=$G(^PS(55,DFN,"IV",+ON55,3)) 84 S P("INS")=$G(^PS(55,DFN,"IV",+ON55,.3)) 85 S P("CLIN")=$P($G(^PS(55,DFN,"IV",+ON55,"DSS")),"^"),P("APPT")=$P($G(^PS(55,DFN,"IV",+ON55,"DSS")),"^",2) 86 S P("DTYP")=$S(P(4)="":0,P(4)="P"!(P(23)="P")!(P(5)):1,P(4)="H":2,1:3) 87 D:'$D(PSJLABEL) GTPC(ON55) S ND=$G(^PS(55,DFN,"IV",+ON55,.2)),P("PD")=$S($P(ND,U):$P(ND,U)_U_$$OIDF^PSJLMUT1(+ND)_U_$P($G(^PS(50.7,+ND,0)),U),1:""),P("DO")=$P(ND,U,2),P("PRY")=$P(ND,U,4),P("NAT")=$P(ND,U,5),(PSJCOM,P("PRNTON"))=$P(ND,U,8) 88 I P("PRY")="D",'+P("IVRM") S P("IVRM")=+$G(PSIVSN)_U_$P($G(^PS(59.5,+$G(PSIVSN),0)),U) 89 S P("MR")=$P(ND,U,3),ND=$G(^PS(51.2,+P("MR"),0)),P("MR")=P("MR")_U_$S($P(ND,U,3)]"":$P(ND,U,3),1:$P(ND,U)) D GTCUM 90 D GTDRG,GTOT^PSIVUTL(P(4)) 91 N ND2P5 S ND2P5=$G(^PS(55,DFN,"IV",+ON55,2.5)) D 92 .S P("DUR")=$P(ND2P5,"^",2) 93 .S P("LIMIT")=$P(ND2P5,"^",4) 94 .S P("IVCAT")=$P(ND2P5,"^",5) 95 K ; Kill and exit. 96 K FIL,ND 97 Q 98 GTDRG ; Get drug info and place in DRG(. 99 F DRGT="AD","SOL" S FIL=$S(DRGT="AD":52.6,1:52.7) F Y=0:0 S Y=$O(^PS(55,DFN,"IV",+ON55,DRGT,Y)) Q:'Y D 100 .; naked ref below refers to line above 101 .S DRG=$G(^(Y,0)),ND=$G(^PS(FIL,+DRG,0)),(DRGI,DRG(DRGT,0))=$G(DRG(DRGT,0))+1 102 .S DRG(DRGT,+DRGI)=+DRG_U_$P(ND,U)_U_$P(DRG,U,2)_U_$P(DRG,U,3)_U_$P(ND,U,13)_U_$P(ND,U,11) 103 Q 104 ; 105 GTCUM ; Retrieve dispensing info. 106 S ND=$G(^PS(55,DFN,"IV",+ON55,9)),P("LF")=$P(ND,U),P("LFA")=$P(ND,U,2),P("CUM")=$P(ND,U,3) 107 Q 108 ; 109 GTPC(ON) ; Retrieve Provider Comments and create "scratch" fields to edit 110 Q 111 ; 112 SETNEW ; Create new order and set 113 D NEW55,SET55 114 Q 115 ; 116 CMPLIM(PSJORD,PSJDSTP1,PSJDSTP2) ; Compare stop date of order against IV Limit 117 I $P($G(^PS(53.1,+PSJORD,0)),"^",25)]"" D CHKD Q:PSJPAO 0 118 I $G(PSJDSTP1),$E(+PSJDSTP1,1,11)'=$E(+P(3),1,11),+PSJDSTP2'=+P(3) Q 1 119 Q 0 120 ; 121 LIMSTOP(PSJDSTP1,PSJDSTP2) ; Calculate default stop date using IV Limit 122 ; Output: PSJDSTP1 - Default stop using duration only 123 ; PSJDSTP2 - Default stop using duration and IV parameters for time 124 S PSIVLIM=$$GETLIM^PSIVCAL(DFN,PSJORD) 125 I 'PSIVLIM,PSIVLIM]"" S PSIVLIM=$$GETMIN^PSIVCAL(PSIVLIM,DFN,PSJORD) 126 I PSIVLIM]"" D 127 . S MINS=$$GETMIN^PSIVCAL(PSIVLIM,DFN,PSJORD),PSJDSTP1=$$FMADD^XLFDT(P(2),,,MINS) 128 . S X=$P(PSJDSTP1,"."),PSJDSTP2=X_$S($P(PSIVSITE,"^",14)="":.2359,1:"."_$P(PSIVSITE,"^",14)) 129 Q 130 ; 131 CHKD ;Check for a previous active order and compare the duration 132 N PSJPO,A,PSJDUR 133 S PSJDUR=$$GETLIM^PSIVCAL(DFN,PSJORD) 134 S PSJPAO=0,PSJPO=PSJORD 135 CHKDR S PSJPO=$P($G(^PS(53.1,+PSJPO,0)),"^",25) Q:PSJPO="" 136 I PSJPO["P" G CHKDR 137 I PSJPO["V" S PSIVLIM=$$GETLIM^PSIVCAL(DFN,PSJPO) I PSJDUR'=PSIVLIM S PSJPAO=1 Q 138 G CHKDR 1 PSIVORFB ;BIR/MLM-FILE/RETRIEVE ORDERS IN ^PS(55 ;25 Sep 98 / 2:24 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**3,18,28,68,58,85,110,111,120**;16 DEC 97;Build 10 3 ; 4 ; Reference to ^PS(50.7 is supported by DBIA #2180. 5 ; Reference to ^PS(51.2 is supported by DBIA #2178. 6 ; Reference to ^PS(52.6 is supported by DBIA #1231. 7 ; Reference to ^PS(52.7 is supported by DBIA #2173. 8 ; Reference to ^PS(55 is supported by DBIA #2191. 9 ; 10 NEW55 ; Get new order number in 55. 11 N DA,DD,DO,DIC,DLAYGO,X,Y,PSIVLIM,MINS,PSJDSTP1,PSJDSTP2,A,PSJCLIN,PSJDNM,PSJPROV,PSJWARD,PSJPAO 12 I $D(^PS(55,+DFN)),'$D(^PS(55,+DFN,0)) D ENSET0^PSGNE3(+DFN) 13 I $G(PSJORD)["V"!($G(PSJORD)["P"),$G(P(2))]"" S PSIVLIM=$$GETLIM^PSIVCAL(DFN,PSJORD) I PSIVLIM D 14 . S MINS=$$GETMIN^PSIVCAL(PSIVLIM,DFN,PSJORD),PSJDSTP1=$$FMADD^XLFDT(P(2),,,MINS) 15 . S X=$P(PSJDSTP1,"."),PSJDSTP2=X_$S($P(PSIVSITE,"^",14)="":.2359,1:"."_$P(PSIVSITE,"^",14)) 16 I $G(PSJORD)["P",$G(PSIVLIM) D 17 . I $P($G(^PS(53.1,+PSJORD,0)),"^",25)]"" D CHKD Q:PSJPAO 18 . I $G(PSJDSTP1),+PSJDSTP1'=+P(3),+PSJDSTP2'=+P(3) D 19 .. S PSJPROV=DUZ I PSJORD["P" S PSJPROV=$P($G(^PS(53.1,+PSJORD,0)),"^",2) 20 .. I PSJORD["V" S PSJPROV=$P($G(^PS(55,DFN,"IV",+PSJORD,0)),"^",6) 21 .. D NOW^%DTC S XQA(PSJPROV)="",XQAID="PSJ,"_DFN_";"_PSJPROV_";"_%,XQADATA="" 22 .. D 23 ... I PSJORD["P" S A=$G(^PS(53.1,+PSJORD,"DSS")) 24 ... I PSJORD["V" S A=$G(^PS(55,PSGP,"IV",+PSJORD,"DSS")) 25 ... S PSJCLIN=$P(A,"^") I PSJCLIN]"" S PSJCLIN=$P(^SC(PSJCLIN,0),"^") 26 .. S A=$G(^DPT(DFN,0)),PSJWARD=$G(^(.1)) 27 .. S XQAMSG=$P(A,"^")_" ("_$E($P(A,"^"))_$E($P(A,"^",9),6,9)_"): ["_$S(PSJWARD]"":$E(PSJWARD,1,10),$G(PSJCLIN)]"":$E(PSJCLIN,1,10),1:"UNKNOWN")_"] " 28 .. S A=$O(DRG("AD",0)) I A]"" S A=DRG("AD",A) 29 .. I A="" S A=$O(DRG("SOL",0)) I A]"" S A=DRG("SOL",A) 30 .. S PSJDNM=$P(^PS(50.7,+$P(A,"^",6),0),"^") 31 .. S XQAMSG=XQAMSG_PSJDNM_" your DURATION not used for stop date/time" 32 .. D SETUP^XQALERT 33 S DIC="^PS(55,",DIC(0)="LN",DLAYGO=55,(DINUM,X)=+DFN D ^DIC Q:Y<0 34 LOCK0 F L +^PS(55,DFN,"IV",0):0 I Q 35 S ND=$S($D(^PS(55,DFN,"IV",0)):^(0),1:"^55.01") F DA=$P(ND,"^",3)+1:1 W "." I '$D(^PS(55,DFN,"IV",DA)) S $P(ND,"^",3)=DA,$P(ND,"^",4)=$P(ND,"^",4)+1,^PS(55,DFN,"IV",0)=ND Q 36 L +^PS(55,DFN,"IV",+DA):0 E G LOCK0 37 S ^PS(55,DFN,"IV",+DA,0)=+DA,^PS(55,DFN,"IV","B",+DA,+DA)="" 38 L -^PS(55,DFN,"IV",0) S ON55=+DA_"V" 39 Q 40 ; 41 SET55 ; Move data from local variables to 55. 42 I '$D(ON55) W !,"*** Can't create this order at this time ***" Q 43 N DA,DIK,ND,PSIVACT,PSIVDUR 44 S:'$D(P(21)) (P(21),P("21FLG"))="" S ND(0)=+ON55,P(22)=$S(VAIN(4):+VAIN(4),1:.5) F X=2:1:23 I $D(P(X)) S $P(ND(0),U,X)=P(X) 45 S ND(.3)=$G(P("INS")),ND(2.5)="" N X S X=$S($G(PSGORD):PSGORD,1:$G(ON)) I X D 46 .N PKG S PKG=$E(X,$L(X)) S PKG=$S(PKG="V":"""IV""",PKG="U":5,PKG="P":"P",1:"") Q:PKG="" 47 .S PSIVDUR=$$GETDUR^PSJLIVMD(DFN,+X,$E(X,$L(X)),1) Q:PSIVDUR="" 48 .I $G(IVLIMIT) S ND(2.5)="^^^"_PSIVDUR K IVLIMIT Q 49 .S ND(2.5)="^"_PSIVDUR 50 S $P(ND(0),U,17)="A",ND(1)=P("REM"),ND(3)=P("OPI"),ND(.2)=$P($G(P("PD")),U)_U_$G(P("DO"))_U_+P("MR")_U_$G(P("PRY"))_U_$G(P("NAT"))_U_U_U_$G(P("PRNTON")) 51 F X=0,1,2.5,3,.2,.3 S ^PS(55,DFN,"IV",+ON55,X)=ND(X) 52 S $P(^PS(55,DFN,"IV",+ON55,2),U,1,4)=P("LOG")_U_+P("IVRM")_U_U_P("SYRS"),$P(^(2),U,8,10)=P("RES")_U_$G(P("FRES"))_U_$S($G(VAIN(4)):+VAIN(4),1:"") 53 S X=^PS(55,DFN,0) I $P(X,"^",7)="" S $P(X,"^",7)=$P($P(P("LOG"),"^"),"."),$P(X,"^",8)="A",^(0)=X 54 S $P(^PS(55,DFN,"IV",+ON55,2),U,11)=+P("CLRK") 55 S:+$G(P("CLIN")) $P(^PS(55,DFN,"IV",+ON55,"DSS"),"^")=P("CLIN") 56 S:+$G(P("APPT")) $P(^PS(55,DFN,"IV",+ON55,"DSS"),"^",2)=P("APPT") 57 S:+$G(P("NINIT")) ^PS(55,DFN,"IV",+ON55,4)=P("NINIT")_U_P("NINITDT") 58 ;S:'$D(PSIVUP) PSIVUP=+$$GTPCI^PSIVUTL K ^PS(55,DFN,"IV",+ON55,5) I $O(^PS(53.45,PSIVUP,4,0)) S %X="^PS(53.45,"_PSIVUP_",4,",%Y="^PS(55,"_DFN_",""IV"","_+ON55_",5," D %XY^%RCR 59 I '$G(PSIVCHG)!($G(PSJREN)&($G(PSIVCHG)=2)) I $G(P("PON")),P("PON")'=ON55 D 60 . N X S X=$S(P("PON")["P":"^PS(53.1,+P(""PON""),12,0)",P("PON")["V"&$G(PSJREN):"^PS(55,DFN,""IV"",+P(""PON""),5,0)",1:"") Q:X="" 61 . I $O(@X) S %X=X,%Y="^PS(55,"_DFN_",""IV"","_+ON55_",5," D %XY^%RCR 62 F DRGT="AD","SOL" D PUTD55 63 K DA,DIK S DA(1)=DFN,DA=+ON55,DIK="^PS(55,"_DA(1)_",""IV"",",PSIVACT=1 D IX^DIK 64 I $G(PSJCOM),$G(PSJCOMSI),$G(PSJORD)["V" K PSJCOMSI N PSJCHILD,PSJOEORD S PSJOEORD=0 F S PSJOEORD=$O(^PS(55,"ACX",PSJCOM,PSJOEORD)) Q:'PSJOEORD D 65 . N PSJCHILD S PSJCHILD=0 F S PSJCHILD=$O(^PS(55,"ACX",PSJCOM,PSJOEORD,PSJCHILD)) Q:'PSJCHILD S PSJCHILD(+PSJCHILD)=PSJCOM 66 . S PSJCHILD=0 F S PSJCHILD=$O(PSJCHILD(PSJCHILD)) Q:'PSJCHILD D 67 .. Q:PSJCHILD=PSJORD K DR,DA,DIE,ORD S DR="31////"_$P($G(P("OPI")),"^",1,2),DA(1)=DFN 68 .. N ON,ON55 S (ON,ON55)=+PSJCHILD_"V" S:+$G(PSJPINIT)'>0 PSJPINIT=DUZ S PSIVALT=1,PSIVAL="COMPLEX ORDER" D ENTACT^PSIVAL D 69 ... I $P($G(^PS(55,DFN,"IV",+ON55,3)),"^")'=$P(P("OPI"),"^") S P("FC")="OTHER PRINT INFO^"_$P($G(^(3)),"^")_U_$P(P("OPI"),"^") D GTFC^PSIVORAL 70 ... I $D(^PS(55,DFN,"IV",+ON55,0)) S ^PS(55,DFN,"IV",+ON55,3)=P("OPI") D EN1^PSJHL2(DFN,"XX",ON55) 71 Q 72 ; 73 PUTD55 ; Move drug data from local array into 55 74 K ^PS(55,DFN,"IV",+ON55,DRGT) S ^PS(55,DFN,"IV",+ON55,DRGT,0)=$S(DRGT="AD":"^55.02PA",1:"^55.11IPA") 75 F X=0:0 S X=$O(DRG(DRGT,X)) Q:'X D 76 .S Y=^PS(55,DFN,"IV",+ON55,DRGT,0),$P(Y,U,3)=$P(Y,U,3)+1,DRG=$P(Y,U,3),$P(Y,U,4)=$P(Y,U,4)+1 77 .S ^PS(55,DFN,"IV",+ON55,DRGT,0)=Y,Y=$P(DRG(DRGT,X),U)_U_$P(DRG(DRGT,X),U,3) S:DRGT="AD" $P(Y,U,3)=$P(DRG(DRGT,X),U,4) S ^PS(55,DFN,"IV",+ON55,DRGT,+DRG,0)=Y 78 Q 79 GT55 ; Retrieve data from 55 into local array 80 K DRG,DRGN,P S:'$D(ON55) ON55=ON S P("REN")="",Y=$G(^PS(55,DFN,"IV",+ON55,0)) F X=1:1:23 S P(X)=$P(Y,U,X) 81 S P("21FLG")=P(21) 82 S P("PON")=ON55,PSJORIFN=P(21),P(6)=P(6)_U_$P($G(^VA(200,+P(6),0)),U),(DRG,DRGN)="",P("REM")=$G(^PS(55,DFN,"IV",+ON55,1)) 83 S Y=$G(^PS(55,DFN,"IV",+ON55,2)),P("LOG")=$P(Y,U),P("IVRM")=$P(Y,U,2)_U_$P($G(^PS(59.5,+$P(Y,U,2),0)),U) 84 S P("CLRK")=$P(Y,U,11)_U_$P($G(^VA(200,+$P(Y,U,11),0)),U),P("RES")=$P(Y,U,8),P("FRES")=$P(Y,U,9),P("SYRS")=$P(Y,U,4),P("OPI")=$G(^PS(55,DFN,"IV",+ON55,3)) 85 S P("INS")=$G(^PS(55,DFN,"IV",+ON55,.3)) 86 S P("CLIN")=$P($G(^PS(55,DFN,"IV",+ON55,"DSS")),"^"),P("APPT")=$P($G(^PS(55,DFN,"IV",+ON55,"DSS")),"^",2) 87 S P("DTYP")=$S(P(4)="":0,P(4)="P"!(P(23)="P")!(P(5)):1,P(4)="H":2,1:3) 88 D:'$D(PSJLABEL) GTPC(ON55) S ND=$G(^PS(55,DFN,"IV",+ON55,.2)),P("PD")=$S($P(ND,U):$P(ND,U)_U_$$OIDF^PSJLMUT1(+ND)_U_$P($G(^PS(50.7,+ND,0)),U),1:""),P("DO")=$P(ND,U,2),P("PRY")=$P(ND,U,4),P("NAT")=$P(ND,U,5),(PSJCOM,P("PRNTON"))=$P(ND,U,8) 89 I P("PRY")="D",'+P("IVRM") S P("IVRM")=+$G(PSIVSN)_U_$P($G(^PS(59.5,+$G(PSIVSN),0)),U) 90 S P("MR")=$P(ND,U,3),ND=$G(^PS(51.2,+P("MR"),0)),P("MR")=P("MR")_U_$S($P(ND,U,3)]"":$P(ND,U,3),1:$P(ND,U)) D GTCUM 91 D GTDRG,GTOT^PSIVUTL(P(4)) 92 K ; Kill and exit. 93 K FIL,ND 94 Q 95 GTDRG ; Get drug info and place in DRG(. 96 F DRGT="AD","SOL" S FIL=$S(DRGT="AD":52.6,1:52.7) F Y=0:0 S Y=$O(^PS(55,DFN,"IV",+ON55,DRGT,Y)) Q:'Y D 97 .; naked ref below refers to line above 98 .S DRG=$G(^(Y,0)),ND=$G(^PS(FIL,+DRG,0)),(DRGI,DRG(DRGT,0))=$G(DRG(DRGT,0))+1 99 .S DRG(DRGT,+DRGI)=+DRG_U_$P(ND,U)_U_$P(DRG,U,2)_U_$P(DRG,U,3)_U_$P(ND,U,13)_U_$P(ND,U,11) 100 Q 101 ; 102 GTCUM ; Retrieve dispensing info. 103 S ND=$G(^PS(55,DFN,"IV",+ON55,9)),P("LF")=$P(ND,U),P("LFA")=$P(ND,U,2),P("CUM")=$P(ND,U,3) 104 Q 105 ; 106 GTPC(ON) ; Retrieve Provider Comments and create "scratch" fields to edit 107 ;S:'$D(PSIVUP) PSIVUP=+$$GTPCI^PSIVUTL K ^PS(53.45,PSIVUP,4) 108 ;K ^PS(53.45,PSIVUP,4) I $O(^PS(55,DFN,"IV",+ON,5,0)) S %X="^PS(55,"_DFN_",""IV"","_+ON_",5,",%Y="^PS(53.45,"_PSIVUP_",4," D %XY^%RCR 109 Q 110 ; 111 SETNEW ; Create new order and set 112 D NEW55,SET55 113 Q 114 CHKD ;Check for a previous active order and compare the duration 115 N PSJPO,A,PSJDUR 116 S PSJDUR=$$GETLIM^PSIVCAL(DFN,PSJORD) 117 S PSJPAO=0,PSJPO=PSJORD 118 CHKDR S PSJPO=$P($G(^PS(53.1,+PSJPO,0)),"^",25) Q:PSJPO="" 119 I PSJPO["P" G CHKDR 120 I PSJPO["V" S PSIVLIM=$$GETLIM^PSIVCAL(DFN,PSJPO) I PSJDUR'=PSIVLIM S PSJPAO=1 Q 121 G CHKDR -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVSP.m
r613 r623 1 PSIVSP ;BIR/RGY,PR,CML3-DOSE PROCESSOR ;09 Feb 99 / 12:30 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**30,37,41,50,56,74,83,111,133,138,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(51.1 is supported by DBIA #2177 5 ; 6 EN ; 7 Q:'$D(X) 8 S ATZERO=0 I X["@",$P(X,"@",2)=0 S ATZERO=1,X=$P(X,"@") 9 D EN^PSGS0 S (P(9),PSIVSC1)=$S($G(X)]"":X,1:$G(P(9))),P(11)=$S($G(PSGS0Y):PSGS0Y,1:$G(P(11))),(XT,P(15))=$S(($G(PSGS0XT)!($G(PSGS0XT)="O")!($G(PSGS0XT)="D")):$G(PSGS0XT),1:$G(P(15))) 10 I $G(ATZERO) S P(7)=1 11 K ATZERO Q 12 EN1 ; 13 S (PSIVAT,PSIVWAT,Y)="",XT=-1,X0=X,X=$S(X="ON CALL":X,X="ONCALL":X,X="ON-CALL":X,X="ONETIME":X,X="ONE-TIME":X,X="ONE TIME":X,X="1TIME":X,X="1 TIME":X,X="1-TIME":X,$L(X," ")<3:$P(X," "),1:$P(X," ",1,2)) 14 S:$E(X)="^" X=$E(X,2,999) G:X="" Q S:X["@0" ATZERO=1 S X=$S(X["@0":$P(X,"@"),1:X),P(7)=$S($D(ATZERO):1,1:"") K ATZERO 15 I $S($D(^PS(51.1,"AC","PSJ",X)):1,1:$E($O(^(X)),1,$L(X))=X) D DIC I Y'<0 G SH 16 NS0 S Y="" 17 I $E(X,1,2)="AD" S XT=-1 Q 18 I $E(X,1,3)="BID"!($E(X,1,3)="TID")!($E(X,1,3)="QID") S XT=1440\$F("BTQ",$E(X)) 19 E S:$E(X)="Q" X=$E(X,2,99) S:'X X=$E(X)["O"+1_X S I=+X,X=$P(X,I,2),XT=I*$S(X["'":1,(X["D"&(X'["AD"))!(X["AM")!(X["PM")!(X["HS"&(X'["THS")):1440,X["H"&(X'["TH"):60,X["AC"!(X["PC"):480,X["W":10080,X["M":40320,1:0),X=X0 D 20 . I 'XT,X'="NOW",X'="STAT",X'="ONCE",X'="ONE-TIME",X'="ONE TIME",X'="ONETIME",X'="1-TIME",X'="1 TIME",X'="1TIME",Y="" S XT=-1 21 SH ; 22 I +Y<1,$E(X0)'="^" W:$G(ON)'["P" " ",$S(XT=0&($S("^NOW^STAT^ONCE^ONE-TIME^ONETIME^1TIME^1-TIME^"[(U_$P(X," ")_U):1,X["1 TIME":1,1:X["ONE TIME")):"(ONCE ONLY)",XT>0:"Nonstandard schedule",XT<0:"",1:"(??)") W:XT>0 " (",XT," MINUTES)" 23 Q Q:X="ONE TIME" 24 N I S X0=$P(X," ")_$S($L(X0," ")-1:" ",1:"")_$P(X0," ",2,99) K:XT<0!($L(X0)>22) X S:$D(X) X=X0 K X0 S:$G(P(7)) XT="" Q 25 NEWQ ;N I S X0=$P(X," ")_$S($L(X0," ")-1:" ",1:"")_$P(X0," ",2,99) K:XT<0!($L(X0)>22) X S:$D(X) X=X0 S:P(7) X=X0 K X0 K:XT>0&('P(7)) X Q 26 Q 27 ; 28 ENDL W " Dose limit .... " S PSIVMIN=P(15)*X,PSIVSD=+P(2) 29 I PSIVMIN<0 W !!," --- There is something wrong with this order !!",!," Call inpatient supervisor ....." S Y=-1 K PSIVMIN Q 30 I P(4)="P"!(P(5))!(P(23)="P"),PSIVMIN=0,"^NOW^STAT^ONCE^ONE-TIME^ONE TIME^ON CALL^ONETIME^1TIME^1 TIME^1-TIME^"'[(U_P(9)_U) D DLP G QDL 31 D ENT^PSIVWL 32 QDL I $D(X) S X=Y X ^DD("DD") W $P(Y,"@")," ",$P(Y,"@",2) S Y=X 33 Q 34 DLP ; 35 S X=X+1,$P(PSIVSD,".",2)=$P(PSIVSD,".",2)_$E("0000",1,4-$L($P(PSIVSD,".",2))) D CHK S X2=0,Y=1 I X<2 S Y=+PSIVSD G QDLP 36 I $P(PSIVSD,".",2)>$P(P(11),"-",$L(P(11),"-")) S X2=1 G OV 37 G:$P(P(11),"-")>$P(PSIVSD,".",2) OV 38 F Y=1:1 S X1=$P(P(11),"-",Y) I X1=$P(PSIVSD,".",2)!($P(PSIVSD,".",2)<X1) Q 39 OV I P(11)="" W $C(7)," ???",!?15,"*** You have not defined any administration times !!" K X Q 40 F Y=Y:1 S:$P(P(11),"-",Y)="" X2=X2+1,Y=0,X=X+1 S X=X-1 Q:X<1 41 S X=PSIVSD\1 I X2>0 S X1=PSIVSD D C^%DTC S X=$P(X,".") ; install with version 17.3 of fileman 42 S Y=+(X_"."_$P(P(11),"-",Y)) 43 QDLP K X1,X2 Q 44 ; 45 ENI ; 46 K:$L(X)<1!($L(X)>30)!(X["""")!($A(X)=45) X I '$D(X)!'$D(P(4)) Q 47 I P(4)="P"!(P(5))!(P(23)="P") Q:'X S X="INFUSE OVER "_X_" MINUTE"_$S(X>1:"S",1:"") W " ",X Q 48 I X'=+X,($P(X,"@",2,999)'=+$P(X,"@",2,999)!(+$P(X,"@",2,999)<0)) K X Q 49 S SPSOL=$O(DRG("SOL",0)) I 'SPSOL K SPSOL,X W " You must define at least one solution !!" Q 50 I X=+X S X=X_" ml/hr" W " ml/hr" D SPSOL S P(15)=$S('X:0,1:SPSOL\X*60+(SPSOL#X/X*60+.5)\1) K SPSOL Q 51 S SPSOL=$P(X,"@",2) S:$P(X,"@")=+X $P(X,"@")=$P(X,"@")_" ml/hr" W " ",+SPSOL," Label",$S(SPSOL'=1:"s",1:"")," per day",!?15,"at an infusion rate of: ",$P(X,"@") S P(15)=$S('SPSOL:0,1:1440/SPSOL\1) K SPSOL 52 Q 53 SPSOL S SPSOL=0 F XXX=0:0 S XXX=$O(DRG("SOL",XXX)) Q:'XXX S SPSOL=SPSOL+$P(DRG("SOL",XXX),U,3) 54 K XXX Q 55 CHK F Y=1:1 Q:$L(P(11))>240!($P(P(11),"-",Y)="") S $P(P(11),"-",Y)=$P(P(11),"-",Y)_$E("0000",1,4-$L($P(P(11),"-",Y))) 56 Q 57 ; 58 DIC ; 51.1 look-up 59 N PSJSCH S PSJSCH=X I '$D(WSCHADM) N VAIP D IN5^VADPT S WSCHADM=VAIP(5),X=PSJSCH 60 K DIC S DIC="^PS(51.1,",DIC(0)=$E("E",'$D(NOECH))_"ISZ" 61 S DIC("W")="W "" "","_$S('$D(WSCHADM):"$P(^(0),""^"",2)",'+WSCHADM:"$P(^(0),""^"",2)",1:"$S($D(^PS(51.1,+Y,1,+WSCHADM,0)):$P(^(0),""^"",2),1:$P(^PS(51.1,+Y,0),""^"",2))"),D="APPSJ" S:$D(PSIVSPQF) DIC(0)=DIC(0)_"O" 62 D IX^DIC K DIC 63 S:$D(DIE)#2 DIC=DIE Q:Y<0 64 S X=Y(0,0),ZZY=Y,(XT,Y)="" I $D(WSCHADM),$D(^PS(51.1,+ZZY,1,+WSCHADM,0)),$P(^(0),"^",2)]"" S (PSIVWAT,Y)=$P(^(0),"^",2) 65 K ZZY,WSCHADM S:Y="" (X,PSIVSC1)=$P(Y(0),U),(PSIVAT,Y)=$P(Y(0),"^",2) S XT=$P(Y(0),"^",3) Q 66 ; 67 ORINF ; OERR input transform for Infusion Rate 68 ; X=data 69 N INFUSE 70 K:$L(X)<1!($L(X)>30)!(X["""")!($A(X)=45) X I '$D(X) Q 71 I X?.E1L.E S INFUSE=$$ENLU^PSGMI(X) Q:(INFUSE="TITRATE")!(INFUSE="BOLUS")!($P(INFUSE," ")="INFUSE")!($P(INFUSE," ")="Infuse") 72 Q:(X="TITRATE")!(X="BOLUS")!($P(X," ")="INFUSE")!($P(X," ")="Infuse") 73 I X["=" D Q ; NOIS LOU-0501-42191 74 .N X2,X1 S X1=$P(X,"="),X2=$P(X,"=",2) 75 .I X1["ML/HR",(+X1=$P(X1,"ML/HR"))!(+X1=$P(X1," ML/HR")) D 76 ..S X1=$TR(X1,"ML/HR","ml/hr") 77 .I X2["ML/HR",(+X2=$P(X2,"ML/HR"))!(+X2=$P(X2," ML/HR")) D 78 ..S X2=$TR(X2,"ML/HR","ml/hr") 79 .I X1[" ml/hr",(+X1=$P(X1," ml/hr")) D 80 ..S X1=$P(X1," ml/hr")_$P(X1," ml/hr",2,9999) 81 .I X2[" ml/hr",(+X2=$P(X2," ml/hr")) D 82 ..S X2=$P(X2," ml/hr")_$P(X2," ml/hr",2,9999) 83 .I X1["ml/hr",(+X1=$P(X1,"ml/hr")) D 84 ..S X1=$P(X1,"ml/hr")_$P(X1,"ml/hr",2,9999) 85 .I X2["ml/hr",(+X2=$P(X2,"ml/hr")) D 86 ..S X2=$P(X2,"ml/hr")_$P(X2,"ml/hr",2,9999) 87 .I X2'=+X2 D 88 ..I X2>0&(X2<1) Q 89 ..I ($P(X2,"@",2,999)'=+$P(X2,"@",2,999)!(+$P(X2,"@",2,999)<0)) K X Q 90 .I X1>0&(X1<1) I +X1="."_$P(X1,".",2) S X1=X1_" ml/hr" 91 .I X2>0&(X2<1) I +X2="."_$P(X2,".",2) S X2=X2_" ml/hr" 92 .I X1=+X1 S X1=X1_" ml/hr" 93 .I X2=+X2 S X2=X2_" ml/hr" 94 .S:$P(X2,"@")=+X2 $P(X2,"@")=$P(X2,"@")_" ml/hr" 95 .S X=X1_"="_X2 96 I X["ML/HR",(+X=$P(X,"ML/HR"))!(+X=$P(X," ML/HR")) S X=$TR(X,"ML/HR","ml/hr") 97 I X[" ml/hr",+X=$P(X," ml/hr") S X=$P(X," ml/hr")_$P(X," ml/hr",2,9999) 98 I X["ml/hr",+X=$P(X,"ml/hr") S X=$P(X,"ml/hr")_$P(X,"ml/hr",2,9999) 99 I X>0,X<1 D Q 100 .I X["ML/HR",(+X=$P($P(X,"ML/HR"),".",2))!(+X=$P($P(X," ML/HR"),".",2)) S X=$TR(X,"ML/HR","ml/hr") 101 .I X[" ml/hr",(+X=$P($P(X," ml/hr"),".",2)) S X=$P(X," ml/hr")_$P(X," ml/hr",2,9999) 102 .I X["ml/hr",+X=$P(X,"ml/hr") S X=$P(X,"ml/hr")_$P(X,"ml/hr",2,9999) 103 .I +X=X S X=X_" ml/hr" 104 .I $P(X,0,2)=+X S X=X_" ml/hr" 105 .S X=0_+X_$P(X,+X,2) 106 I '(X>0&X<1) I X'=+X,($P(X,"@",2,999)'=+$P(X,"@",2,999)!(+$P(X,"@",2,999)<0)) K X Q 107 I X=+X S X=X_" ml/hr" Q 108 S:$P(X,"@")=+X $P(X,"@")=$P(X,"@")_" ml/hr" 109 Q 1 PSIVSP ;BIR/RGY,PR,CML3-DOSE PROCESSOR ;09 Feb 99 / 12:30 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**30,37,41,50,56,74,83,111,133,138**;16 DEC 97 3 ; 4 ; Reference to ^PS(51.1 is supported by DBIA #2177 5 ; 6 EN ; 7 Q:'$D(X) 8 ;/S (PSIVAT,PSIVWAT,Y)="",XT=-1,X0=X,X=$S(X="ON CALL":X,X["ONE ":X,1:$P(X," ")) 9 S ATZERO=0 I X["@",$P(X,"@",2)=0 S ATZERO=1,X=$P(X,"@") 10 D EN^PSGS0 S (P(9),PSIVSC1)=$S($G(X)]"":X,1:$G(P(9))),P(11)=$S($G(PSGS0Y):PSGS0Y,1:$G(P(11))),(XT,P(15))=$S(($G(PSGS0XT)!($G(PSGS0XT)="O")!($G(PSGS0XT)="D")):$G(PSGS0XT),1:$G(P(15))) 11 I $G(ATZERO) S P(7)=1 12 K ATZERO Q 13 EN1 ; 14 S (PSIVAT,PSIVWAT,Y)="",XT=-1,X0=X,X=$S(X="ON CALL":X,X="ONCALL":X,X="ON-CALL":X,X="ONETIME":X,X="ONE-TIME":X,X="ONE TIME":X,X="1TIME":X,X="1 TIME":X,X="1-TIME":X,$L(X," ")<3:$P(X," "),1:$P(X," ",1,2)) 15 S:$E(X)="^" X=$E(X,2,999) G:X="" Q S:X["@0" ATZERO=1 S X=$S(X["@0":$P(X,"@"),1:X),P(7)=$S($D(ATZERO):1,1:"") K ATZERO 16 ;;I X0["@",$P(X0,"@",2)'=0 K X Q 17 I $S($D(^PS(51.1,"AC","PSJ",X)):1,1:$E($O(^(X)),1,$L(X))=X) D DIC I Y'<0 G SH 18 ;;I $S(X="NOW":1,X="ONCE":1,X="STAT":1,X="ONE-TIME":1,X="ONE TIME":1,1:0) S XT=0,Y(0)=X G SH 19 NS0 S Y="" 20 I $E(X,1,2)="AD" S XT=-1 Q 21 I $E(X,1,3)="BID"!($E(X,1,3)="TID")!($E(X,1,3)="QID") S XT=1440\$F("BTQ",$E(X)) 22 E S:$E(X)="Q" X=$E(X,2,99) S:'X X=$E(X)["O"+1_X S I=+X,X=$P(X,I,2),XT=I*$S(X["'":1,(X["D"&(X'["AD"))!(X["AM")!(X["PM")!(X["HS"&(X'["THS")):1440,X["H"&(X'["TH"):60,X["AC"!(X["PC"):480,X["W":10080,X["M":40320,1:0),X=X0 D 23 . I 'XT,X'="NOW",X'="STAT",X'="ONCE",X'="ONE-TIME",X'="ONE TIME",X'="ONETIME",X'="1-TIME",X'="1 TIME",X'="1TIME",Y="" S XT=-1 24 SH ; 25 I +Y<1,$E(X0)'="^" W:$G(ON)'["P" " ",$S(XT=0&($S("^NOW^STAT^ONCE^ONE-TIME^ONETIME^1TIME^1-TIME^"[(U_$P(X," ")_U):1,X["1 TIME":1,1:X["ONE TIME")):"(ONCE ONLY)",XT>0:"Nonstandard schedule",XT<0:"",1:"(??)") W:XT>0 " (",XT," MINUTES)" 26 Q Q:X="ONE TIME" 27 N I S X0=$P(X," ")_$S($L(X0," ")-1:" ",1:"")_$P(X0," ",2,99) K:XT<0!($L(X0)>22) X S:$D(X) X=X0 K X0 S:$G(P(7)) XT="" Q 28 ;N I S X0=$P(X," ")_$S($L(X0," ")-1:" ",1:"")_$P(X," ",2,99) K:XT<0!($L(X0)>22) X S:$D(X) X=X0 K X0 S:$G(P(7)) XT="" Q 29 ;S X0=X K:XT<0!($L(X0)>22) X S:$D(X) X=X0 K X0 S:$G(P(7)) XT="" Q 30 NEWQ ;N I S X0=$P(X," ")_$S($L(X0," ")-1:" ",1:"")_$P(X0," ",2,99) K:XT<0!($L(X0)>22) X S:$D(X) X=X0 S:P(7) X=X0 K X0 K:XT>0&('P(7)) X Q 31 Q 32 ; 33 ENDL W " Dose limit .... " S PSIVMIN=P(15)*X,PSIVSD=+P(2) 34 I PSIVMIN<0 W !!," --- There is something wrong with this order !!",!," Call inpatient supervisor ....." S Y=-1 K PSIVMIN Q 35 I P(4)="P"!(P(5))!(P(23)="P"),PSIVMIN=0,"^NOW^STAT^ONCE^ONE-TIME^ONE TIME^ON CALL^ONETIME^1TIME^1 TIME^1-TIME^"'[(U_P(9)_U) D DLP G QDL 36 D ENT^PSIVWL 37 QDL I $D(X) S X=Y X ^DD("DD") W $P(Y,"@")," ",$P(Y,"@",2) S Y=X 38 Q 39 DLP ; 40 S X=X+1,$P(PSIVSD,".",2)=$P(PSIVSD,".",2)_$E("0000",1,4-$L($P(PSIVSD,".",2))) D CHK S X2=0,Y=1 I X<2 S Y=+PSIVSD G QDLP 41 I $P(PSIVSD,".",2)>$P(P(11),"-",$L(P(11),"-")) S X2=1 G OV 42 G:$P(P(11),"-")>$P(PSIVSD,".",2) OV 43 F Y=1:1 S X1=$P(P(11),"-",Y) I X1=$P(PSIVSD,".",2)!($P(PSIVSD,".",2)<X1) Q 44 OV I P(11)="" W $C(7)," ???",!?15,"*** You have not defined any administration times !!" K X Q 45 F Y=Y:1 S:$P(P(11),"-",Y)="" X2=X2+1,Y=0,X=X+1 S X=X-1 Q:X<1 46 S X=PSIVSD\1 I X2>0 S X1=PSIVSD D C^%DTC S X=$P(X,".") ; install with version 17.3 of fileman 47 S Y=+(X_"."_$P(P(11),"-",Y)) 48 QDLP K X1,X2 Q 49 ; 50 ENI ; 51 K:$L(X)<1!($L(X)>30)!(X["""")!($A(X)=45) X I '$D(X)!'$D(P(4)) Q 52 I P(4)="P"!(P(5))!(P(23)="P") Q:'X S X="INFUSE OVER "_X_" MIN." W " ",X Q 53 I X'=+X,($P(X,"@",2,999)'=+$P(X,"@",2,999)!(+$P(X,"@",2,999)<0)) K X Q 54 S SPSOL=$O(DRG("SOL",0)) I 'SPSOL K SPSOL,X W " You must define at least one solution !!" Q 55 I X=+X S X=X_" ml/hr" W " ml/hr" D SPSOL S P(15)=$S('X:0,1:SPSOL\X*60+(SPSOL#X/X*60+.5)\1) K SPSOL Q 56 S SPSOL=$P(X,"@",2) S:$P(X,"@")=+X $P(X,"@")=$P(X,"@")_" ml/hr" W " ",+SPSOL," Label",$S(SPSOL'=1:"s",1:"")," per day",!?15,"at an infusion rate of: ",$P(X,"@") S P(15)=$S('SPSOL:0,1:1440/SPSOL\1) K SPSOL 57 Q 58 SPSOL S SPSOL=0 F XXX=0:0 S XXX=$O(DRG("SOL",XXX)) Q:'XXX S SPSOL=SPSOL+$P(DRG("SOL",XXX),U,3) 59 K XXX Q 60 CHK F Y=1:1 Q:$L(P(11))>240!($P(P(11),"-",Y)="") S $P(P(11),"-",Y)=$P(P(11),"-",Y)_$E("0000",1,4-$L($P(P(11),"-",Y))) 61 Q 62 ; 63 DIC ; 51.1 look-up 64 N PSJSCH S PSJSCH=X I '$D(WSCHADM) N VAIP D IN5^VADPT S WSCHADM=VAIP(5),X=PSJSCH 65 K DIC S DIC="^PS(51.1,",DIC(0)=$E("E",'$D(NOECH))_"ISZ" 66 S DIC("W")="W "" "","_$S('$D(WSCHADM):"$P(^(0),""^"",2)",'+WSCHADM:"$P(^(0),""^"",2)",1:"$S($D(^PS(51.1,+Y,1,+WSCHADM,0)):$P(^(0),""^"",2),1:$P(^PS(51.1,+Y,0),""^"",2))"),D="APPSJ" S:$D(PSIVSPQF) DIC(0)=DIC(0)_"O" 67 D IX^DIC K DIC 68 S:$D(DIE)#2 DIC=DIE Q:Y<0 69 S X=Y(0,0),ZZY=Y,(XT,Y)="" I $D(WSCHADM),$D(^PS(51.1,+ZZY,1,+WSCHADM,0)),$P(^(0),"^",2)]"" S (PSIVWAT,Y)=$P(^(0),"^",2) 70 K ZZY,WSCHADM S:Y="" (X,PSIVSC1)=$P(Y(0),U),(PSIVAT,Y)=$P(Y(0),"^",2) S XT=$P(Y(0),"^",3) Q 71 ; 72 ORINF ; OERR input transform for Infusion Rate 73 ; X=data 74 N INFUSE 75 K:$L(X)<1!($L(X)>30)!(X["""")!($A(X)=45) X I '$D(X) Q 76 I X?.E1L.E S INFUSE=$$ENLU^PSGMI(X) Q:(INFUSE="TITRATE")!(INFUSE="BOLUS") 77 Q:(X="TITRATE")!(X="BOLUS") 78 I X["=" D Q ; NOIS LOU-0501-42191 79 .N X2,X1 S X1=$P(X,"="),X2=$P(X,"=",2) 80 .I X1["ML/HR",(+X1=$P(X1,"ML/HR"))!(+X1=$P(X1," ML/HR")) D 81 ..S X1=$TR(X1,"ML/HR","ml/hr") 82 .I X2["ML/HR",(+X2=$P(X2,"ML/HR"))!(+X2=$P(X2," ML/HR")) D 83 ..S X2=$TR(X2,"ML/HR","ml/hr") 84 .I X1[" ml/hr",(+X1=$P(X1," ml/hr")) D 85 ..S X1=$P(X1," ml/hr")_$P(X1," ml/hr",2,9999) 86 .I X2[" ml/hr",(+X2=$P(X2," ml/hr")) D 87 ..S X2=$P(X2," ml/hr")_$P(X2," ml/hr",2,9999) 88 .I X1["ml/hr",(+X1=$P(X1,"ml/hr")) D 89 ..S X1=$P(X1,"ml/hr")_$P(X1,"ml/hr",2,9999) 90 .I X2["ml/hr",(+X2=$P(X2,"ml/hr")) D 91 ..S X2=$P(X2,"ml/hr")_$P(X2,"ml/hr",2,9999) 92 .I X2'=+X2 D 93 ..I ($P(X2,"@",2,999)'=+$P(X2,"@",2,999)!(+$P(X2,"@",2,999)<0)) K X Q 94 .I X1=+X1 S X1=X1_" ml/hr" 95 .I X2=+X2 S X2=X2_" ml/hr" 96 .S:$P(X2,"@")=+X2 $P(X2,"@")=$P(X2,"@")_" ml/hr" 97 .S X=X1_"="_X2 98 I X["ML/HR",(+X=$P(X,"ML/HR"))!(+X=$P(X," ML/HR")) S X=$TR(X,"ML/HR","ml/hr") 99 I X[" ml/hr",+X=$P(X," ml/hr") S X=$P(X," ml/hr")_$P(X," ml/hr",2,9999) 100 I X["ml/hr",+X=$P(X,"ml/hr") S X=$P(X,"ml/hr")_$P(X,"ml/hr",2,9999) 101 I X'=+X,($P(X,"@",2,999)'=+$P(X,"@",2,999)!(+$P(X,"@",2,999)<0)) K X Q 102 I X=+X S X=X_" ml/hr" Q 103 S:$P(X,"@")=+X $P(X,"@")=$P(X,"@")_" ml/hr" 104 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVUTL1.m
r613 r623 1 PSIVUTL1 ;BIR/MLM-IV UTILITIES ;21 MAY 96 / 10:37 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**58,81,111,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(50.7 is supported by DBIA 2180 5 ; Reference to ^PS(51.2 is supported by DBIA 2178 6 ; Reference to ^PS(52.6 is supported by DBIA 1231 7 ; Reference to ^PS(52.7 is supported by DBIA 2173. 8 ; Reference to ^PS(55 is supported by DBIA 2191 9 ; 10 DRGSC(Y,PSJSCT) ; Called to set DIC("S") when selecting orderable item. 11 N OK,ND,NDU,NDI S OK=0 ;* I '$D(^PSDRUG("AP",+Y)) K PSJSCT Q 0 12 S ND=$G(^PS(50.7,+Y,0)) 13 I $P(ND,U,3) S OK=$S('$P(ND,U,4):1,$P(ND,U,4)>DT:1,1:0) 14 Q OK 15 ; 16 IVDRGSC(Y) ; Set DIC("S") for IV additive/solution selection. 17 ; Naked reference below refers to full reference in Y, which is either ^PS(52.6, or ^PS(52.7 18 N Y S Y="S X(1)=$G(^(0)),X(2)=$G(^(""I"")) I $S('X(2):1,X(2)>DT:1,1:0),$D(^PSDRUG(+$P(X(1),U,2),0)) S X(2)=$G(^(""I"")) I $S('X(2):1,X(2)>DT:1,1:0)" 19 Q Y 20 ; 21 ENU(Y) ;Get IV additive strength. 22 N X S X=$P(^PS(52.6,+Y,0),U,3),Y=$$CODES^PSIVUTL(X,52.6,2) 23 Q Y 24 ; 25 CODES(X,Y) ; Get name from code. 26 S Y=$P($P(";"_$P(Y,U,3),";"_X_":",2),";") 27 Q Y 28 ; 29 GTPCI(Y) ; Set up "work" area for provider comments. 30 N DIC,DINUM,DLAYGO,X S DIC="^PS(53.45,",DIC(0)="LNZ",DLAYGO=53.45,(DINUM,X)=+DUZ D ^DIC 31 Q Y 32 ; 33 WDTE(Y) ; Format and print date. 34 I 'Y S Y="******" 35 E X ^DD("DD") S Y=$P(Y,"@")_" "_$P($P(Y,"@",2),":",1,2) 36 Q Y 37 GTOT(DFN,ON) ; Get order type for display. 38 N DRGT,DRGI,Y 39 S X=$P($G(^PS(55,DFN,"IV",ON,0)),U,4) 40 S Y=$S(X="A":"F",X="H":"H",1:"I") 41 I Y="F" F DRGT="AD","SOL" F DRGI=0:0 S DRGI=$O(^PS(55,DFN,"IV",+ON,DRGT,DRGI)) Q:'DRGI I '$P($G(^PS(55,DFN,"IV",+ON,DRGT,DRGI)),U,5) S Y="I" Q 42 Q Y 43 ; 44 PIV(ON) ; Display IV orders. 45 N DRG,ON55,P,PSJORIFN,TYP,X,Y S TYP="?" I ON["V" D 46 .S Y=$G(^PS(55,DFN,"IV",+ON,0)) F X=2,3,4,5,8,9,17,23 S P(X)=$P(Y,U,X) 47 .S TYP=$$ONE^PSJBCMA(DFN,ON,P(9),P(2),P(3)) I TYP'="O" S TYP="C" 48 .S ON55=ON,P("OT")=$S(P(4)="A":"F",P(4)="H":"H",1:"I") D GTDRG^PSIVORFB,GTOT^PSIVUTL(P(4)) 49 I ON'["V" S (P(2),P(3))="",P(17)=$P($G(^PS(53.1,+ON,0)),U,9),Y=$G(^(8)),P(4)=$P(Y,U),P(8)=$P(Y,U,5),P(9)=$P($G(^(2)),U) D GTDRG^PSIVORFA,GTOT^PSIVUTL(P(4)) I $E(P("OT"))="I" D Q 50 .S P("PD")=$P($$DRUGNAME^PSJLMUTL(PSGP,ON),"^"),P("DO")=$S($P(DN,"^",2)=.2:$P($G(^PS(55,PSGP,5,+PSJO,.2)),"^",2),1:$G(^PS(55,PSGP,5,+PSJO,.3))),P("DO")=$P(P("DO"),"^") 51 .S Y=$G(^PS(53.1,+ON,.2)),P("MR")=$P($G(^PS(53.1,+ON,0)),U,3)_U_$P($G(^PS(51.2,+$P($G(^PS(53.1,+ON,0)),U,3),0)),U,3) 52 .W ?9,P("PD") D PIV1 W !?11,"Give: ",P("DO")," ",$P(P("MR"),U,2)," ",$S(P(9)]"":P(9),1:P(8)) 53 S DRG=0 F S DRG=$O(DRG("AD",DRG)) Q:'DRG D PIVAD 54 SOL ; 55 NEW NAME 56 S DRG=0 F S DRG=$O(DRG("SOL",DRG)) Q:'DRG D 57 . D NAME(DRG("SOL",DRG),39,.NAME,0) 58 . W ! W:DRG=1 ?9,"in " 59 . F X=0:0 S X=$O(NAME(X)) Q:'X W ?12 W NAME(X) I X=1,DRG=1,'$D(DRG("AD",1)) D PIV1 60 Q 61 PIVAD ; Print IV Additives. 62 NEW NAME 63 D NAME(DRG("AD",DRG),39,.NAME,1) 64 F X=0:0 S X=$O(NAME(X)) Q:'X W:DRG'=1 ! W ?9,NAME(X) I X=1,DRG=1 D PIV1 65 Q 66 ; 67 PIV1 ; Print Sched type, start/stop dates, and status. 68 F X=2,3 S P(X)=$E($$ENDTC^PSGMI(P(X)),1,$S($D(PSJEXTP):8,1:5)) 69 I '$D(PSJEXTP) W ?50,TYP,?53,P(2),?60,P(3),?67,P(17) Q 70 W ?50,TYP,?53,P(2),?63,P(3),?73,P(17) 71 Q 72 59 ; Validate the Infusion rate entered using IV Quick order code. 73 N I F I=2,3,5,7,8,9,11,15,23 S P(I)="" 74 S P(4)="A",P(8)=$P($G(^PS(57.1,PSJQO,1)),U,5) 75 I $G(^PS(57.1,PSJQO,4,1,0)) S DRG("SOL",1)=^(0),DRG("SOL",0)=1 76 I X["?" S F1=53.1,F2=59 D ENHLP^PSIVORC1 G 59 77 I X]"" D ENI^PSIVSP S:$D(X) P(8)=X 78 Q 79 WRTDRG(X,L) ; Format and print drug name, strength and bottle no. 80 N Y S Y=" "_$P(X,U,3) S:$P(X,U,4) Y=Y_" ("_$P(X,U,4)_")" 81 Q $E($P(X,U,2),1,(L-$L(Y)))_Y 82 NAME(X,L,NAME,AD) ; Format Additive display. 83 ;INPUT : X=DRG("AD",DRG) L=Display length AD=for Addtive(1/0) 84 ;OUTPUT: AD(X) if X=2 that means there is a second line to display 85 K NAME 86 NEW Y S Y=$P(X,U,3) S:(AD&$P(X,U,4)) Y=Y_" ("_$P(X,U,4)_")" 87 S:'AD Y=Y_" "_$S(P(4)="P"!($G(P(23))="P")!$G(P(5)):P(9),1:$P(P(8),"@")) 88 I ($L($P(X,U,2))+$L(Y)+1)>L S NAME(1)=$P(X,U,2),NAME(2)=" "_Y Q 89 S NAME(1)=$P(X,U,2)_" "_Y 90 Q 91 ; 92 CNVTOM(RATE,TVOL) ; Convert volume to minutes 93 ; Input: 94 ; RATE - Infusion Rate 95 ; TVOL - Volume being infused, EX: m100 (100 Milliliters) or l5 (5 Liters) 96 ; Output: 97 ; MINS - Minutes required to infuse volume 98 N DAYS,ML,MLSHR 99 ; Get rate in terms of mils per hour 100 I 'RATE Q 0 101 I RATE<1 S RATE=1 102 S TVOL=$S($E(TVOL)="m":$E(TVOL,2,9),$E(TVOL)="l":$E(TVOL,2,9)*1000,1:0) Q:'TVOL 0 103 ; Find IV duration in minutes 104 S MINS=(TVOL/RATE)*60 105 Q MINS 106 ; 107 GETMIN(LIM,DFN,PSJORD,DAYS) ; 108 N F,DDLX 109 I LIM!(LIM=0) Q LIM 110 S F=$S(PSJORD["P":"^PS(53.1,+PSJORD,",PSJORD["V":"^PS(55,DFN,""IV"",+PSJORD,",1:"") 111 N RATE S RATE=$S(PSJORD["P":+$P($G(@(F_"8)")),"^",5),PSJORD["V":+$P($G(@(F_"0)")),"^",8),1:0) 112 I (",l,m,")[(","_$E(LIM)_",") D 113 .I RATE D 114 ..I RATE<1 S RATE=1 115 ..S MIN=$$CNVTOM(RATE,LIM) I MIN S LIM=MIN 116 .I 'RATE N SOL,SOLVOL,DOSVOL,DUR,STOP,OIX,X S (SOLVOL,DOSVOL)="" D 117 ..S SOL=0 F S SOL=$O(@(F_"""SOL"",SOL)")) Q:'SOL D 118 ...S SOLVOL=$P(@(F_"""SOL"",SOL,0)"),"^",2) I SOLVOL S DOSVOL=DOSVOL+SOLVOL 119 ..S DDLX=$S($E(LIM)["l":(($E(LIM,2,99)*1000)/DOSVOL),1:($E(LIM,2,99)/DOSVOL))_"L" 120 I (",a,")[(","_$E(LIM)_",") S DDLX=$E(LIM,2,99)_"L" 121 I $G(DDLX)>0 D 122 .N STOP,LASTD S DAYS="",STOP="" 123 .S OIX=$P($G(@(F_".2)")),"^") S:(DDLX<1) DDLX="1L" S LASTD=$$DOSES^PSIVCAL(DDLX,.P) 124 .I LASTD,$G(P(2)) S DAYS=$$FMDIFF^XLFDT(LASTD,P(2),2) I DAYS>0 S DAYS=DAYS/86400 125 .I DAYS>0 S LIM=DAYS*1440 126 I (",h,d,")[(","_$E(LIM)_",") S LIM=$S($E(LIM)="d":(1440*$E(LIM,2,99)),1:(60*$E(LIM,2,99))) Q 127 Q LIM 1 PSIVUTL1 ;BIR/MLM-IV UTILITIES ;21 MAY 96 / 10:37 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**58,81,111**;16 DEC 97 3 ; 4 ; Reference to ^PS(50.7 is supported by DBIA 2180 5 ; Reference to ^PS(51.2 is supported by DBIA 2178 6 ; Reference to ^PS(52.6 is supported by DBIA 1231 7 ; Reference to ^PS(55 is supported by DBIA 2191 8 ; 9 DRGSC(Y,PSJSCT) ; Called to set DIC("S") when selecting orderable item. 10 N OK,ND,NDU,NDI S OK=0 ;* I '$D(^PSDRUG("AP",+Y)) K PSJSCT Q 0 11 S ND=$G(^PS(50.7,+Y,0)) 12 I $P(ND,U,3) S OK=$S('$P(ND,U,4):1,$P(ND,U,4)>DT:1,1:0) 13 Q OK 14 ; 15 IVDRGSC(Y) ; Set DIC("S") for IV additive/solution selection. 16 N Y S Y="S X(1)=$G(^(0)),X(2)=$G(^(""I"")) I $S('X(2):1,X(2)>DT:1,1:0),$D(^PSDRUG(+$P(X(1),U,2),0)) S X(2)=$G(^(""I"")) I $S('X(2):1,X(2)>DT:1,1:0)" 17 Q Y 18 ; 19 ENU(Y) ;Get IV additive strength. 20 N X S X=$P(^PS(52.6,+Y,0),U,3),Y=$$CODES^PSIVUTL(X,52.6,2) 21 Q Y 22 ; 23 CODES(X,Y) ; Get name from code. 24 S Y=$P($P(";"_$P(Y,U,3),";"_X_":",2),";") 25 Q Y 26 ; 27 GTPCI(Y) ; Set up "work" area for provider comments. 28 N DIC,DINUM,DLAYGO,X S DIC="^PS(53.45,",DIC(0)="LNZ",DLAYGO=53.45,(DINUM,X)=+DUZ D ^DIC 29 Q Y 30 ; 31 WDTE(Y) ; Format and print date. 32 I 'Y S Y="******" 33 E X ^DD("DD") S Y=$P(Y,"@")_" "_$P($P(Y,"@",2),":",1,2) 34 Q Y 35 GTOT(DFN,ON) ; Get order type for display. 36 N DRGT,DRGI,Y 37 S X=$P($G(^PS(55,DFN,"IV",ON,0)),U,4) 38 S Y=$S(X="A":"F",X="H":"H",1:"I") 39 I Y="F" F DRGT="AD","SOL" F DRGI=0:0 S DRGI=$O(^PS(55,DFN,"IV",+ON,DRGT,DRGI)) Q:'DRGI I '$P($G(^PS(55,DFN,"IV",+ON,DRGT,DRGI)),U,5) S Y="I" Q 40 Q Y 41 ; 42 PIV(ON) ; Display IV orders. 43 N DRG,ON55,P,PSJORIFN,TYP,X,Y S TYP="?" I ON["V" D 44 .S Y=$G(^PS(55,DFN,"IV",+ON,0)) F X=2,3,4,5,8,9,17,23 S P(X)=$P(Y,U,X) 45 .S TYP=$$ONE^PSJBCMA(DFN,ON,P(9),P(2),P(3)) I TYP'="O" S TYP="C" 46 .S ON55=ON,P("OT")=$S(P(4)="A":"F",P(4)="H":"H",1:"I") D GTDRG^PSIVORFB,GTOT^PSIVUTL(P(4)) 47 I ON'["V" S (P(2),P(3))="",P(17)=$P($G(^PS(53.1,+ON,0)),U,9),Y=$G(^(8)),P(4)=$P(Y,U),P(8)=$P(Y,U,5),P(9)=$P($G(^(2)),U) D GTDRG^PSIVORFA,GTOT^PSIVUTL(P(4)) I $E(P("OT"))="I" D Q 48 .S P("PD")=$P($$DRUGNAME^PSJLMUTL(PSGP,ON),"^"),P("DO")=$S($P(DN,"^",2)=.2:$P($G(^PS(55,PSGP,5,+PSJO,.2)),"^",2),1:$G(^PS(55,PSGP,5,+PSJO,.3))),P("DO")=$P(P("DO"),"^") 49 .S Y=$G(^PS(53.1,+ON,.2)),P("MR")=$P($G(^PS(53.1,+ON,0)),U,3)_U_$P($G(^PS(51.2,+$P($G(^PS(53.1,+ON,0)),U,3),0)),U,3) 50 .W ?9,P("PD") D PIV1 W !?11,"Give: ",P("DO")," ",$P(P("MR"),U,2)," ",$S(P(9)]"":P(9),1:P(8)) 51 S DRG=0 F S DRG=$O(DRG("AD",DRG)) Q:'DRG D PIVAD 52 SOL ; 53 NEW NAME 54 S DRG=0 F S DRG=$O(DRG("SOL",DRG)) Q:'DRG D 55 . D NAME(DRG("SOL",DRG),39,.NAME,0) 56 . W ! W:DRG=1 ?9,"in " 57 . F X=0:0 S X=$O(NAME(X)) Q:'X W ?12 W NAME(X) I X=1,DRG=1,'$D(DRG("AD",1)) D PIV1 58 Q 59 PIVAD ; Print IV Additives. 60 NEW NAME 61 D NAME(DRG("AD",DRG),39,.NAME,1) 62 F X=0:0 S X=$O(NAME(X)) Q:'X W:DRG'=1 ! W ?9,NAME(X) I X=1,DRG=1 D PIV1 63 Q 64 ; 65 PIV1 ; Print Sched type, start/stop dates, and status. 66 F X=2,3 S P(X)=$E($$ENDTC^PSGMI(P(X)),1,$S($D(PSJEXTP):8,1:5)) 67 I '$D(PSJEXTP) W ?50,TYP,?53,P(2),?60,P(3),?67,P(17) Q 68 W ?50,TYP,?53,P(2),?63,P(3),?73,P(17) 69 Q 70 59 ; Validate the Infusion rate entered using IV Quick order code. 71 N I F I=2,3,5,7,8,9,11,15,23 S P(I)="" 72 S P(4)="A",P(8)=$P($G(^PS(57.1,PSJQO,1)),U,5) 73 I $G(^PS(57.1,PSJQO,4,1,0)) S DRG("SOL",1)=^(0),DRG("SOL",0)=1 74 I X["?" S F1=53.1,F2=59 D ENHLP^PSIVORC1 G 59 75 I X]"" D ENI^PSIVSP S:$D(X) P(8)=X 76 Q 77 WRTDRG(X,L) ; Format and print drug name, strength and bottle no. 78 N Y S Y=" "_$P(X,U,3) S:$P(X,U,4) Y=Y_" ("_$P(X,U,4)_")" 79 Q $E($P(X,U,2),1,(L-$L(Y)))_Y 80 ;Q $E($$ENPDN^PSGMI($P(X,U,6)),1,(L-$L(Y)))_Y 81 NAME(X,L,NAME,AD) ; Format Additive display. 82 ;INPUT : X=DRG("AD",DRG) L=Display length AD=for Addtive(1/0) 83 ;OUTPUT: AD(X) if X=2 that means there is a second line to display 84 K NAME 85 NEW Y S Y=$P(X,U,3) S:(AD&$P(X,U,4)) Y=Y_" ("_$P(X,U,4)_")" 86 S:'AD Y=Y_" "_$S(P(4)="P"!($G(P(23))="P")!$G(P(5)):P(9),1:$P(P(8),"@")) 87 I ($L($P(X,U,2))+$L(Y)+1)>L S NAME(1)=$P(X,U,2),NAME(2)=" "_Y Q 88 S NAME(1)=$P(X,U,2)_" "_Y 89 Q 90 ; 91 CNVTOM(RATE,TVOL) ; Convert volume to minutes 92 N DAYS,ML,MLSHR 93 ; Get rate in terms of mils per hour 94 I 'RATE Q 0 95 S TVOL=$S($E(TVOL)="m":$E(TVOL,2,9),$E(TVOL)="l":$E(TVOL,2,9)*1000,1:0) Q:'TVOL 0 96 ; Find IV duration in minutes 97 S MINS=(TVOL/RATE)*60 S MINS=MINS+1 98 Q MINS -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJHL2.m
r613 r623 1 PSJHL2 ;BIR/RLW-PATIENT ID AND VISIT SEGMENTS ;22 Nov 1999 9:27 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,18,16,23,28,42,50,70,58,100,102,110,111,112,144,141,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to ^ORERR is supported by DBIA# 2187. 6 ; Reference to ^ORHLESC IS supported by DBIA# 4922. 7 ; 8 EN1(PSJHLDFN,PSOC,PSJORDER,PSREASON) ; start here 9 ; passed in are PSJHLDFN (patient ien) 10 ; PSJORDER* (order_file (N,P,V, etc)) 11 ; PSOC* (order control code - NW for new order, OK to return filler number to OE/RR, OC for order canceled, SC for status change) 12 ; PSREASON* (text reason) 13 ; *=optional, only required if an order segment is also to be generated 14 START ; 15 K ^TMP("PSJHLS",$J,"PS") 16 N CLERK,J,LIMIT,NAME,NEXT,NODE1,NODE2,NODE4,NOO,PSJCLEAR,PSJHINST,PSJHLSDT,PROVIDER,PSJI,ROOMBED,RXORDER,STATUS,UNDO,VERIFY,WARD,PSGST,DUR 17 S RXORDER=PSJORDER,PSJORDER=$S((PSJORDER["N")!(PSJORDER["P"):"^PS(53.1,"_+PSJORDER,PSJORDER["V":"^PS(55,"_PSJHLDFN_",""IV"","_+PSJORDER,1:"^PS(55,"_PSJHLDFN_",5,"_+PSJORDER)_"," 18 I RXORDER["P",$P($G(@(PSJORDER_"0)")),U,15)'=PSJHLDFN S ORDCON="Patient does not match/PSJHL2" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON) Q 19 S UNDO=$S("OC^CR"[PSOC:1,1:0) 20 D INIT,PID,PV1,ORC 21 D @$S("SN^SC^OC^OD^DR^CR^OH^OR^XX^ZC^XR"[PSOC:"EN1^PSJHL3(PSJHLDFN,PSOC,PSJORDER)",1:"CALL^PSJHLU(PSJI)") 22 I UNDO D UNDO 23 K ^TMP("PSJHLS",$J,"PS"),FIELD 24 Q 25 ; 26 INIT ; initialize HL7 variables, set master file identification segment 27 ; PSJHLMTN = message type - ORR for messages sent as a response to an OE/RR event; ORM for "unsolicited" messages. 28 S PSJI=0,PSJHLMTN=$S($G(PSJHLMTN)]"":PSJHLMTN,1:"ORM") 29 D INIT^PSJHLU 30 S LIMIT=17 X PSJCLEAR 31 S FIELD(0)="MSH",FIELD(1)="^~\&",FIELD(2)="PHARMACY",FIELD(3)=$G(PSJHINST),FIELD(8)=PSJHLMTN 32 D SEGMENT^PSJHLU(LIMIT),DISPLAY 33 Q 34 ; 35 PID ; get patient data, format PID SEGMENT 36 S LIMIT=22 X PSJCLEAR 37 S FIELD(0)="PID" 38 S FIELD(3)=PSJHLDFN 39 N DFN S DFN=PSJHLDFN D DEM^VADPT S FIELD(5)=VADM(1) 40 I '$G(PSJBCBU) S FIELD(5)=$$ESC^ORHLESC(FIELD(5)) 41 D SEGMENT^PSJHLU(LIMIT),DISPLAY 42 Q 43 ; 44 PV1 ; get patient visit information, format PV1 segment 45 N PSJAPPT 46 S LIMIT=50 X PSJCLEAR 47 S FIELD(0)="PV1" 48 I PSJHLMTN="ORR" S FIELD(3)=LOC 49 I PSJHLMTN="ORM" D 50 .S LOC="",WARD=$G(^DPT(PSJHLDFN,.1)),LOC=$S($G(WARD)]"":$O(^SC("B",WARD,LOC)),1:LOC) 51 .I $G(LOC)="" D 52 .. N A 53 .. I RXORDER["P",($G(^PS(53.1,+RXORDER,"DSS"))) S A=^("DSS"),LOC=$P(A,"^"),PSJAPPT=$P(A,"^",2) 54 .. I RXORDER["V",($G(^PS(55,PSJHLDFN,"IV",+RXORDER,"DSS"))) S A=^("DSS"),LOC=$P(A,"^"),PSJAPPT=$P(A,"^",2) 55 .. I RXORDER["U",$G(^PS(55,PSJHLDFN,5,+RXORDER,8)) S A=^(8),LOC=$P(A,"^"),PSJAPPT=$P(A,"^",2) 56 .I $G(LOC)]"" S ROOMBED=$G(^DPT(PSJHLDFN,.101)) S LOC=LOC_"^"_$S($G(PSJBCBU):ROOMBED,1:$$ESC^ORHLESC(ROOMBED)) 57 .S FIELD(3)=LOC I $G(PSJAPPT)]"" S FIELD(44)=$$FMTHL7^XLFDT(PSJAPPT) 58 S FIELD(2)=$S($G(CLASS)="O":CLASS,1:"I") 59 I FIELD(2)="I" N DFN S DFN=PSJHLDFN D INP^VADPT S FIELD(19)=VAIN(1) 60 D SEGMENT^PSJHLU(LIMIT),DISPLAY 61 Q 62 ; 63 ORC ; order control segment 64 S LIMIT=18 X PSJCLEAR 65 Q:'$D(PSJORDER)!'$D(PSOC) 66 S NODE1=$G(@(PSJORDER_"0)")),NODE2=$G(@(PSJORDER_"2)")) 67 S NODE4=$G(@(PSJORDER_"4)")) 68 I $G(PSGST)="" N PSGST D 69 .S PSGST=$P($G(NODE1),"^",7) 70 S FIELD(0)="ORC" 71 S FIELD(1)=PSOC 72 S FIELD(2)=$S(PSOC="SN":"",1:$P(NODE1,"^",21))_"^OR" I $P(FIELD(2),"^")=0 S $P(FIELD(2),"^")="" ; IV orders are created with a zero in the oerr order number, for some reason 73 S FIELD(3)=RXORDER_"^PS" 74 ; translate Pharmacy status code to HL7 status code, set in FIELD(5) 75 S STATUS=$S($G(PSJEXPOE):"E",(($P(NODE1,"^",17)]"")&(RXORDER["V")):($P(NODE1,"^",17)),($P(NODE1,"^",9)]""):$P(NODE1,"^",9),$G(PSIVCOPY):"DE",1:"") 76 ;BHW;Remedy HD0000000086717;If the order has a pending number, send pending status even if current status is Active. 77 I STATUS="A",RXORDER["P" S STATUS="N" D @STATUS S STATUS="A" 78 E D @STATUS 79 I STATUS="U",RXORDER["P" S FIELD(3)="^PS" 80 S FIELD(7)="^"_$S(RXORDER["V":$P(NODE1,"^",9)_"&"_$P(NODE1,"^",11),1:$P(NODE2,"^")_"&"_$P(NODE2,"^",5))_"^^^^^"_$G(PSGST) 81 S FIELD(9)=$S(RXORDER["V":$$FMTHL7^XLFDT($P(NODE2,"^")),1:$$FMTHL7^XLFDT($P(NODE1,"^",16))) 82 S CLERK=$S(RXORDER["V":$P(NODE2,"^",11),1:$P(NODE4,"^",7)) 83 S NAME=$P($G(^VA(200,+CLERK,0)),"^") 84 S FIELD(10)=CLERK_"^"_$S($G(PSJBCBU):NAME,1:$$ESC^ORHLESC(NAME)) 85 I PSOC="ZV"!($G(PSJBCBU)) S VERIFY=$P($G(NODE4),"^"),FIELD(11)=VERIFY_"^"_$S($G(PSJBCBU):$P($G(^VA(200,+VERIFY,0)),"^"),1:$$ESC^ORHLESC($P($G(^VA(200,+VERIFY,0)),"^"))),FIELD(9)=$$FMTHL7^XLFDT($P(NODE4,"^",2)) 86 S PROVIDER=$S($G(PSJDCPRV)]"":$G(PSJDCPRV),RXORDER["V":$P(NODE1,"^",6),1:$P(NODE1,"^",2)) K PSJDCPRV 87 S NAME=$P($G(^VA(200,+PROVIDER,0)),"^") 88 S FIELD(12)=PROVIDER_"^"_NAME 89 S FIELD(15)=$S(RXORDER["V":$$FMTHL7^XLFDT($P(NODE1,"^",2)),1:$$FMTHL7^XLFDT($P(NODE2,"^",2))) 90 I $S(RXORDER["V":$P(NODE2,"^",8)="R",1:$P(NODE1,"^",24)="R") 91 ; PSJ*5*141 - If this is a renewal order, update FIELD(10) with the person who entered the renewal order. 92 N FIELD9 S FIELD9=$$FMTHL7^XLFDT($$LASTREN^PSJLMPRI(PSJHLDFN,RXORDER)) I FIELD9>FIELD(9) S FIELD(9)=FIELD9,FIELD(15)=FIELD9,FIELD(10)=$$LASTRNBY^PSJLMPRI(PSJHLDFN,RXORDER) 93 S NOO=$S(PSJORDER["IV":$G(P("NAT")),(($G(PSJNOO)="")&($G(P("NAT"))]"")):$G(P("NAT")),1:$G(PSJNOO)),PSREASON=$S(NOO="D":"",1:$G(PSREASON)) 94 S FIELD(16)=NOO_U_$S(NOO="P":"Telephoned",NOO="D":"Duplicate",NOO="X":"Rejected",NOO="A":"Auto",NOO="S":"Service Correction",NOO="W":"Written",NOO="V":"Verbal",NOO="E":"Physician Entered",NOO="I":"Policy",1:"")_U_"99ORN"_U_U_$G(PSREASON)_U 95 D SEGMENT^PSJHLU(LIMIT),DISPLAY 96 Q 97 ; 98 DISPLAY ; just for testing 99 I $G(MSGTEST) W ! F NEXT=0:1:LIMIT W FIELD(NEXT)_"|" 100 Q 101 UNDO ;Undo Renew if Pending Renewal is dc'd 102 I RXORDER["P",(STATUS="D"),($G(PSJNOO)'="A"),($P(NODE1,U,24)="R") D ENBKOUT^PSJOREN(PSJHLDFN,RXORDER) 103 Q 104 ; 105 A S FIELD(5)="CM" Q ; active 106 D S FIELD(5)="DC" Q ; discontinued 107 I S FIELD(5)="IP" Q ; incomplete 108 N S FIELD(5)="IP" Q ; non-verified 109 U S FIELD(5)="ZX" Q ; unreleased 110 P S FIELD(5)="IP" Q ; pending 111 DE S FIELD(5)="RP" Q ; discontinued (edit) 112 E S FIELD(5)="ZE" Q ; expired 113 H S FIELD(5)="HD" Q ; hold 114 R S FIELD(5)="ZZ" Q ; renewed 115 RE S FIELD(5)="CM" Q ; reinstated 116 DR S FIELD(5)="DC" Q ; discontinued (renewal) 117 O S FIELD(5)="HD" Q ; on call (is this kind of like HOLD?) 1 PSJHL2 ;BIR/RLW-PATIENT ID AND VISIT SEGMENTS ;22 Nov 1999 9:27 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,18,16,23,28,42,50,70,58,100,102,110,111,112,144,141**;16 DEC 97 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to ^ORERR is supported by DBIA# 2187. 6 ; 7 EN1(PSJHLDFN,PSOC,PSJORDER,PSREASON) ; start here 8 ; passed in are PSJHLDFN (patient ien) 9 ; PSJORDER* (order_file (N,P,V, etc)) 10 ; PSOC* (order control code - NW for new order, OK to return filler number to OE/RR, OC for order canceled, SC for status change) 11 ; PSREASON* (text reason) 12 ; *=optional, only required if an order segment is also to be generated 13 START ; 14 K ^TMP("PSJHLS",$J,"PS") 15 N CLERK,J,LIMIT,NAME,NEXT,NODE1,NODE2,NODE4,NOO,PSJCLEAR,PSJHINST,PSJHLSDT,PROVIDER,PSJI,ROOMBED,RXORDER,STATUS,UNDO,VERIFY,WARD 16 S RXORDER=PSJORDER,PSJORDER=$S((PSJORDER["N")!(PSJORDER["P"):"^PS(53.1,"_+PSJORDER,PSJORDER["V":"^PS(55,"_PSJHLDFN_",""IV"","_+PSJORDER,1:"^PS(55,"_PSJHLDFN_",5,"_+PSJORDER)_"," 17 I RXORDER["P",$P($G(@(PSJORDER_"0)")),U,15)'=PSJHLDFN S ORDCON="Patient does not match/PSJHL2" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON) Q 18 S UNDO=$S("OC^CR"[PSOC:1,1:0) 19 D INIT,PID,PV1,ORC 20 D @$S("SN^SC^OC^OD^DR^CR^OH^OR^XX^ZC^XR"[PSOC:"EN1^PSJHL3(PSJHLDFN,PSOC,PSJORDER)",1:"CALL^PSJHLU(PSJI)") 21 I UNDO D UNDO 22 K ^TMP("PSJHLS",$J,"PS"),FIELD 23 Q 24 ; 25 INIT ; initialize HL7 variables, set master file identification segment 26 ; PSJHLMTN = message type - ORR for messages sent as a response to an OE/RR event; ORM for "unsolicited" messages. 27 S PSJI=0,PSJHLMTN=$S($G(PSJHLMTN)]"":PSJHLMTN,1:"ORM") 28 D INIT^PSJHLU 29 S LIMIT=17 X PSJCLEAR 30 S FIELD(0)="MSH",FIELD(1)="^~\&",FIELD(2)="PHARMACY",FIELD(3)=$G(PSJHINST),FIELD(8)=PSJHLMTN 31 D SEGMENT^PSJHLU(LIMIT),DISPLAY 32 Q 33 ; 34 PID ; get patient data, format PID SEGMENT 35 S LIMIT=22 X PSJCLEAR 36 S FIELD(0)="PID" 37 S FIELD(3)=PSJHLDFN 38 N DFN S DFN=PSJHLDFN D DEM^VADPT S FIELD(5)=VADM(1) 39 D SEGMENT^PSJHLU(LIMIT),DISPLAY 40 Q 41 ; 42 PV1 ; get patient visit information, format PV1 segment 43 N PSJAPPT 44 S LIMIT=50 X PSJCLEAR 45 S FIELD(0)="PV1" 46 I PSJHLMTN="ORR" S FIELD(3)=LOC 47 I PSJHLMTN="ORM" D 48 .S LOC="",WARD=$G(^DPT(PSJHLDFN,.1)),LOC=$S($G(WARD)]"":$O(^SC("B",WARD,LOC)),1:LOC) 49 .I $G(LOC)="" D 50 .. N A 51 .. I RXORDER["P",($G(^PS(53.1,+RXORDER,"DSS"))) S A=^("DSS"),LOC=$P(A,"^"),PSJAPPT=$P(A,"^",2) 52 .. I RXORDER["V",($G(^PS(55,PSJHLDFN,"IV",+RXORDER,"DSS"))) S A=^("DSS"),LOC=$P(A,"^"),PSJAPPT=$P(A,"^",2) 53 .. I RXORDER["U",$G(^PS(55,PSJHLDFN,5,+RXORDER,8)) S A=^(8),LOC=$P(A,"^"),PSJAPPT=$P(A,"^",2) 54 .I $G(LOC)]"" S ROOMBED=$G(^DPT(PSJHLDFN,.101)),LOC=LOC_"^"_ROOMBED 55 .S FIELD(3)=LOC I $G(PSJAPPT)]"" S FIELD(44)=$$FMTHL7^XLFDT(PSJAPPT) 56 S FIELD(2)=$S($G(CLASS)="O":CLASS,1:"I") 57 I FIELD(2)="I" N DFN S DFN=PSJHLDFN D INP^VADPT S FIELD(19)=VAIN(1) 58 D SEGMENT^PSJHLU(LIMIT),DISPLAY 59 Q 60 ; 61 ORC ; order control segment 62 S LIMIT=18 X PSJCLEAR 63 Q:'$D(PSJORDER)!'$D(PSOC) 64 S NODE1=$G(@(PSJORDER_"0)")),NODE2=$G(@(PSJORDER_"2)")) 65 S NODE4=$G(@(PSJORDER_"4)")) 66 S FIELD(0)="ORC" 67 S FIELD(1)=PSOC 68 S FIELD(2)=$S(PSOC="SN":"",1:$P(NODE1,"^",21))_"^OR" I $P(FIELD(2),"^")=0 S $P(FIELD(2),"^")="" ; IV orders are created with a zero in the oerr order number, for some reason 69 S FIELD(3)=RXORDER_"^PS" 70 ; translate Pharmacy status code to HL7 status code, set in FIELD(5) 71 S STATUS=$S($G(PSJEXPOE):"E",(($P(NODE1,"^",17)]"")&(RXORDER["V")):($P(NODE1,"^",17)),($P(NODE1,"^",9)]""):$P(NODE1,"^",9),$G(PSIVCOPY):"DE",1:"") 72 ;BHW;Remedy HD0000000086717;If the order has a pending number, send pending status even if current status is Active. 73 I STATUS="A",RXORDER["P" S STATUS="N" D @STATUS S STATUS="A" 74 E D @STATUS 75 I STATUS="U",RXORDER["P" S FIELD(3)="^PS" 76 S FIELD(9)=$S(RXORDER["V":$$FMTHL7^XLFDT($P(NODE2,"^")),1:$$FMTHL7^XLFDT($P(NODE1,"^",16))) 77 S CLERK=$S(RXORDER["V":$P(NODE2,"^",11),1:$P(NODE4,"^",7)) 78 S NAME=$P($G(^VA(200,+CLERK,0)),"^") 79 S FIELD(10)=CLERK_"^"_NAME 80 I PSOC="ZV"!($G(PSJBCBU)) S VERIFY=$P($G(NODE4),"^"),FIELD(11)=VERIFY_"^"_$P($G(^VA(200,+VERIFY,0)),"^"),FIELD(9)=$$FMTHL7^XLFDT($P(NODE4,"^",2)) 81 S PROVIDER=$S($G(PSJDCPRV)]"":$G(PSJDCPRV),RXORDER["V":$P(NODE1,"^",6),1:$P(NODE1,"^",2)) K PSJDCPRV 82 S NAME=$P($G(^VA(200,+PROVIDER,0)),"^") 83 S FIELD(12)=PROVIDER_"^"_NAME 84 S FIELD(15)=$S(RXORDER["V":$$FMTHL7^XLFDT($P(NODE1,"^",2)),1:$$FMTHL7^XLFDT($P(NODE2,"^",2))) 85 I $S(RXORDER["V":$P(NODE2,"^",8)="R",1:$P(NODE1,"^",24)="R") 86 ; PSJ*5*141 - If this is a renewal order, update FIELD(10) with the person who entered the renewal order. 87 N FIELD9 S FIELD9=$$FMTHL7^XLFDT($$LASTREN^PSJLMPRI(PSJHLDFN,RXORDER)) I FIELD9>FIELD(9) S FIELD(9)=FIELD9,FIELD(15)=FIELD9,FIELD(10)=$$LASTRNBY^PSJLMPRI(PSJHLDFN,RXORDER) 88 S NOO=$S(PSJORDER["IV":$G(P("NAT")),(($G(PSJNOO)="")&($G(P("NAT"))]"")):$G(P("NAT")),1:$G(PSJNOO)),PSREASON=$S(NOO="D":"",1:$G(PSREASON)) 89 S FIELD(16)=NOO_U_$S(NOO="P":"Telephoned",NOO="D":"Duplicate",NOO="X":"Rejected",NOO="A":"Auto",NOO="S":"Service Correction",NOO="W":"Written",NOO="V":"Verbal",NOO="E":"Physician Entered",NOO="I":"Policy",1:"")_U_"99ORN"_U_U_$G(PSREASON)_U 90 D SEGMENT^PSJHLU(LIMIT),DISPLAY 91 Q 92 ; 93 DISPLAY ; just for testing 94 I $G(MSGTEST) W ! F NEXT=0:1:LIMIT W FIELD(NEXT)_"|" 95 Q 96 UNDO ;Undo Renew if Pending Renewal is dc'd 97 I RXORDER["P",(STATUS="D"),($G(PSJNOO)'="A"),($P(NODE1,U,24)="R") D ENBKOUT^PSJOREN(PSJHLDFN,RXORDER) 98 Q 99 ; 100 A S FIELD(5)="CM" Q ; active 101 D S FIELD(5)="DC" Q ; discontinued 102 I S FIELD(5)="IP" Q ; incomplete 103 N S FIELD(5)="IP" Q ; non-verified 104 U S FIELD(5)="ZX" Q ; unreleased 105 P S FIELD(5)="IP" Q ; pending 106 DE S FIELD(5)="RP" Q ; discontinued (edit) 107 E S FIELD(5)="ZE" Q ; expired 108 H S FIELD(5)="HD" Q ; hold 109 R S FIELD(5)="ZZ" Q ; renewed 110 RE S FIELD(5)="CM" Q ; reinstated 111 DR S FIELD(5)="DC" Q ; discontinued (renewal) 112 O S FIELD(5)="HD" Q ; on call (is this kind of like HOLD?) -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJHL3.m
r613 r623 1 PSJHL3 ;BIR/RLW-PHARMACY ORDER SEGMENTS ;04 Aug 98 / 10:10 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,11,14,40,42,47,50,56,58,92,101,102,123,110,111,152,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(50.606 is supported by DBIA# 2174. 5 ; Reference to ^PS(50.607 is supported by DBIA# 2221. 6 ; Reference to ^PS(50.7 is supported by DBIA# 2180. 7 ; Reference to ^PS(51.2 is supported by DBIA# 2178. 8 ; Reference to ^PS(52.6 is supported by DBIA# 1231. 9 ; Reference to ^PS(52.7 is supported by DBIA# 2173. 10 ; Reference to ^PS(55 is supported by DBIA# 2191. 11 ; Reference to ^PSDRUG( is supported by DBIA# 2192. 12 ; Reference to ^PSNDF( is supported by DBIA# 2195. 13 ; Reference to ^VA(200 is supported by DBIA# 10060. 14 ; Reference to ^PSNAPIS is supported by DBIA# 2531. 15 ; Reference to ^XLFDT is supported by DBIA# 10103. 16 ; Reference to ^PSSUTIL1 is supported by DBIA# 3179. 17 ; Reference to ^ORHLESC is supported by DBIA# 4922. 18 ; 19 EN1(PSJHLDFN,PSOC,PSJORDER) ; start here 20 ; passed in are PSJHLDFN (patient ien) 21 ; PSJORDER (file root of order) 22 ; OC (order control code - NW for new order, OK for finished order, OC for order canceled) 23 I $G(PSJHLDFN)']""!$G(PSOC)']""!$G(PSJORDER)']"" W !,"INSUFFICIENT DATA FOR ^PSJHL3" Q 24 N COMMENTS,DDIEA,DDNUM,DOSE,DOSEFORM,DOSEOR,NAME,DURATION,IVTYPE,NODE1,NODE2,NDNODE,OINODE,PSGPLS,PSGPLF,PRODNAME,SPDIEN,UNIT,UNITS,CNT,DDIEN,SCHEDULE,PSGST 25 D INIT 26 S IVTYPE=$S(RXORDER["U":"",1:$$IVTYPE^PSJHLU(PSJORDER)) 27 D RXO,RXE,RXR D ZRX 28 D CALL^PSJHLU(PSJI) 29 Q 30 INIT ; initialize HL7 variables 31 D INIT^PSJHLU 32 Q 33 RXO ; pharmacy prescription order segment (used to send Orderable Item to OE/RR) 34 S LIMIT=17 X PSJCLEAR 35 S FIELD(0)="RXO" 36 S OINODE=$G(@(PSJORDER_".2)")) 37 S SPDIEN=+$P(OINODE,"^"),DOSEOR=$$ESC^ORHLESC($P(OINODE,"^",2)),DOSE=$P(OINODE,"^",5),UNIT=$P(OINODE,"^",6) S:'$G(PSJBCBU) UNIT=$$ESC^ORHLESC(UNIT) 38 S FIELD(1)=$S(SPDIEN=0:"^^^^",1:"^^^"_SPDIEN_"^") 39 I SPDIEN S DOSEFORM=$P($G(^PS(50.7,SPDIEN,0)),"^",2),NAME=$P($G(^PS(50.606,+DOSEFORM,0)),"^") S:'$G(PSJBCBU) NAME=$$ESC^ORHLESC(NAME) S FIELD(1)=FIELD(1)_$$ESC^ORHLESC($P($G(^PS(50.7,SPDIEN,0)),"^"))_" "_NAME 40 S FIELD(1)=FIELD(1)_"^99PSP" 41 N IVLNOD S IVLNOD=$G(@(PSJORDER_"2.5)")) D 42 .S IVLIM=$P(IVLNOD,"^",4) I IVLIM?1"a".N S IVLIM="doses"_$P(IVLIM,"a",2) 43 .S $P(FIELD(1),"^",3)=IVLIM 44 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 45 Q 46 RXE ; pharmacy encoded order segment 47 S (UNITS,NDNODE,SPDIEN,PRODNAME,DDNUM,DDIEN,CNT)="",LIMIT=26 X PSJCLEAR 48 S FIELD(0)="RXE" 49 S NODE1=$G(@(PSJORDER_"0)")),NODE2=$G(@(PSJORDER_"2)")),NODEPT2=$G(@(PSJORDER_".2)")) 50 I $G(PSGST)="" N PSGST D 51 .I $G(RXORDER)["V" N X,ZZND,LYN,PSGS0XT,PSGS0Y,PSGOES S PSGOES=1 S X=$G(P(9)) I X]"" D EN^PSGS0 S:$G(ZZND)'="" PSGST=$P(ZZND,"^",5) Q 52 .S PSGST=$P($G(NODE1),"^",7) 53 I RXORDER["V" D IVRXE Q 54 I RXORDER["P",IVTYPE="F" D IVRXE Q 55 I RXORDER["P",$P(NODE1,"^",4)="H" D IVRXE Q 56 N RENEW S RENEW=$$LASTREN^PSJLMPRI(PSJHLDFN,RXORDER) 57 S PSGPLS=$S($G(PSJEXPOE):$P(NODE2,"^",2),RENEW>$P(NODE2,"^",2):RENEW,1:$P(NODE2,"^",2)) 58 S PSGPLF=$S($G(PSJEXPOE):PSJEXPOE,1:$P(NODE2,"^",4)) 59 S FIELD(1)="^"_$S($G(PSJBCBU):$P(NODE2,"^"),1:$$ESC^ORHLESC($P(NODE2,"^")))_"&"_$P(NODE2,"^",5)_"^^"_$$FMTHL7^XLFDT(PSGPLS)_"^"_$$FMTHL7^XLFDT(PSGPLF)_"^"_$P($G(NODEPT2),"^",4)_"^"_$G(PSGST) 60 S FIELD(21)="^"_$P(NODE2,"^",5)_"^99PSA^^^" 61 I ($G(DOSEOR)']"")!($O(@(PSJORDER_"1,"" "")"),-1)=1) D 62 .S (CNT,DDNUM)=0 F S DDNUM=$O(@(PSJORDER_"1,"_DDNUM_")")) Q:'DDNUM Q:CNT=1 S DDIEN=+$G(@(PSJORDER_"1,"_DDNUM_",0)")) D 63 ..S FIELD(1)=$S($P(@(PSJORDER_"1,"_DDNUM_",0)"),"^",2)="":"1",1:$P(@(PSJORDER_"1,"_DDNUM_",0)"),"^",2))_"&"_FIELD(1) 64 ..S FIELD(1)=DOSE_"&"_UNIT_"&"_FIELD(1),$P(FIELD(1),"^",8)=$S($G(DOSEOR)]"":$G(DOSEOR),1:DOSE_UNIT) 65 ..S:$P(FIELD(1),"^",8)="" $P(FIELD(1),"^",8)=$$ESC^ORHLESC($G(@(PSJORDER_".3)"))) 66 ..S NDNODE=$G(^PSDRUG(DDIEN,"ND")) 67 ..; CHANGE FOR NEW NDF CALL 68 ..S PRODNAME=$S($T(^PSNAPIS)]"":$$PROD0^PSNAPIS(+NDNODE,$P(NDNODE,"^",3)),$G(^PSNDF(+NDNODE,5,+$P(NDNODE,"^",3),0))]"":^(0),1:"N/A") 69 ..S:PRODNAME="" PRODNAME="N/A" 70 ..S FIELD(2)=$S(PRODNAME="N/A":"^^",1:+NDNODE_"."_+$P(NDNODE,"^",3)_"^"_$P(NDNODE,"^",2)_"^"_"99NDF")_"^"_DDIEN_"^"_$S($G(PSJBCBU):$P($G(^PSDRUG(DDIEN,0)),"^"),1:$$ESC^ORHLESC($P($G(^PSDRUG(DDIEN,0)),"^")))_"^"_"99PSD" 71 ..S UNITS=$S(PRODNAME="N/A":"N/A",1:$S($T(^PSNAPIS)]"":$P($$DFSU^PSNAPIS(+NDNODE,$P(NDNODE,"^",3)),"^",5),1:$P($G(^PSNDF(+NDNODE,2,+$P(PRODNAME,"^",2),3,+$P(PRODNAME,"^",3),4,+$P(PRODNAME,"^",4),0)),"^"))) 72 ..S FIELD(5)="^^^"_$$ESC^ORHLESC(UNITS)_"^"_$$ESC^ORHLESC($P($G(^PS(50.607,UNITS,0)),"^"))_"^99PSU" 73 ..S FIELD(6)="^^^"_$$ESC^ORHLESC($G(DOSEFORM))_"^"_$$ESC^ORHLESC($P($G(^PS(50.606,+$G(DOSEFORM),0)),"^"))_"^99PSF" 74 ..S FIELD(25)=$$EN^PSSUTIL1(DDIEN),FIELD(26)=$P(FIELD(25),"|",2),FIELD(25)=$P(FIELD(25),"|") 75 ..I $P(FIELD(25),"^",5)]"" S $P(FIELD(25),"^",5)=$$ESC^ORHLESC($P(FIELD(25),"^",5)) 76 ..S CNT=CNT+1 77 E S $P(FIELD(1),"^",8)=$$ESC^ORHLESC(DOSEOR) 78 S NAME=$P($G(^VA(200,DUZ,0)),"^") S:'$G(PSJBCBU) NAME=$$ESC^ORHLESC(NAME) S FIELD(14)=DUZ_"^"_NAME_"^"_"99NP" 79 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 80 D SEGMENT2^PSJHLU 81 Q 82 IVRXE ; RXE segment for IV orders 83 ; If an Inpatient Med IV order, send RXE w/dispense drug info. 84 ; If an IV FLUID order, send start/stop date and duration in the RXE 85 ; and send an RXC for each additive and solution. 86 N ADSNODE 87 I RXORDER["V" S PSGPLS=$P(NODE1,"^",2),PSGPLF=$P(NODE1,"^",3) 88 E S PSGPLS=$P(NODE2,"^",2),PSGPLF=$P(NODE2,"^",4) 89 S FIELD(1)="^"_$S(PSJORDER["IV":($P(NODE1,"^",9)_"&"_$P(NODE1,"^",11)),1:$P(NODE2,"^"))_"^^"_$$FMTHL7^XLFDT(PSGPLS)_"^"_$$FMTHL7^XLFDT(PSGPLF)_"^"_$G(P("PRY")) 90 S FIELD(21)="^"_$S(PSJORDER["IV":$P(NODE1,"^",11),1:$P(NODE2,"^",5))_"^99PSA^^^" 91 S NAME=$P($G(^VA(200,DUZ,0)),"^") S:'$G(PSJBCBU) NAME=$$ESC^ORHLESC(NAME) 92 S FIELD(14)=DUZ_"^"_NAME_"^"_"99NP" 93 N X,Y 94 I RXORDER["V" S INFUSE=$P(NODE1,"^",8) 95 E S INFUSE=$P($G(@(PSJORDER_"8)")),"^",5) 96 I INFUSE?1N.N1" ml/hr" S FIELD(23)=+INFUSE,Y=$P(INFUSE,+INFUSE,2),Y=$$TRIM^XLFSTR(Y,"LR"," "),FIELD(24)="^^^^"_Y_"^PSU" 97 I FIELD(23)="",FIELD(24)="" S FIELD(23)=INFUSE 98 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 99 K SEGMENT I RXORDER["V" S JJ=0 F S JJ=$O(@(PSJORDER_"5,"_JJ_")")) Q:'JJ S SEGMENT(JJ-1)=$S($G(PSJBCBU):$G(@(PSJORDER_"5,"_JJ_",0)")),1:$$ESC^ORHLESC($G(@(PSJORDER_"5,"_JJ_",0)")))) 100 E S JJ=0 F S JJ=$O(@(PSJORDER_"12,"_JJ_")")) Q:'JJ S SEGMENT(JJ-1)=$S($G(PSJBCBU):$G(@(PSJORDER_"12,"_JJ_",0)")),1:$G(@(PSJORDER_"12,"_JJ_",0)"))) 101 I $D(SEGMENT(0)) S SEGMENT(0)="NTE|6|L|"_SEGMENT(0) D 102 .D SET^PSJHLU K SEGMENT,JJ 103 I RXORDER["V",$P($G(@(PSJORDER_"3)")),"^")]"" K SEGMENT D 104 .S SEGMENT(0)="NTE|21|L|"_$S($G(PSJSBCBU):$P($G(@(PSJORDER_"3)")),"^"),1:$$ESC^ORHLESC($P($G(@(PSJORDER_"3)")),"^"))) D 105 .D SET^PSJHLU K SEGMENT 106 I RXORDER["P",$P($G(@(PSJORDER_"9)")),U,2)]"" K SEGMENT D 107 .S SEGMENT(0)="NTE|21|L|"_$S($G(PSJSBCBU):$P($G(@(PSJORDER_"9)")),U,2),1:$$ESC^ORHLESC($P($G(@(PSJORDER_"9)")),U,2))) D 108 .D SET^PSJHLU K SEGMENT 109 RXC ;component segments 110 N ADDITIVE,SOLUTION,SUB,TYPE,AD,SOL,PTR,NUM,UTMP,XTMP 111 S LIMIT=24 X PSJCLEAR 112 S FIELD(0)="RXC" 113 ; In the line below, the naked reference refers to the full global reference represented in PSJORDER_TYPE... 114 ; This could be a reference to either ^PS(53.1 or ^PS(55 115 S AD="AD",SOL="SOL" F TYPE="AD","SOL" S SUB=0 F S SUB=$O(@(PSJORDER_TYPE_","_SUB_")")) Q:SUB="" S NODE1=$G(^(SUB,0)) Q:NODE1="" D 116 .S FIELD(1)=$S(TYPE="AD":"A",1:"B") 117 .S PTR=+$S(TYPE="AD":+$P($G(^PS(52.6,$P(NODE1,"^"),0)),"^",11),1:+$P($G(^PS(52.7,$P(NODE1,"^"),0)),"^",11)) 118 .S FIELD(2)="^^^"_$S($G(PSJBCBU):+$P(NODE1,"^"),1:PTR)_"^"_$S($G(PSJBCBU):$S(TYPE="AD":$P($G(^PS(52.6,+$P(NODE1,"^"),0)),"^"),1:$P($G(^PS(52.7,+$P(NODE1,"^"),0)),"^")_" "_$P($G(^(0)),U,4)),1:$P($G(^PS(50.7,PTR,0)),"^")) 119 .S:(TYPE="AD"&$G(PSJBCBU)) FIELD(2)=FIELD(2)_$S($P(NODE1,"^",3)]"":" BOTTLE: "_$P(NODE1,"^",3),1:"") 120 .S FIELD(2)=FIELD(2)_"^99PSP" 121 .S FIELD(3)=$P($P(NODE1,"^",2)," ") 122 .S FIELD(4)=$P($P(NODE1,"^",2)," ",2) 123 .F XTMP=1:1:14 S UTMP($P("ML^LITER^MCG^MG^GM^UNITS^IU^MEQ^MM^MU^THOUU^MG-PE^NANOGRAM^MMOL","^",XTMP))="PSIV-"_XTMP 124 .S NUM="" S:FIELD(4)'="" NUM=$G(UTMP(FIELD(4))) 125 .S FIELD(4)="^^^"_NUM_"^"_FIELD(4)_"^99OTH" 126 .D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 127 Q 128 RXR ; med route segment 129 S LIMIT=4 X PSJCLEAR 130 S FIELD(0)="RXR" 131 I PSJORDER["IV" S FIELD(1)="^^^"_$P($G(@(PSJORDER_".2)")),"^",3) Q:$P(FIELD(1),U,4)="" D 132 .N PSJUNITS S PSJUNITS=$S($G(PSJBCBU):$P($G(^PS(51.2,+$P(FIELD(1),"^",4),0)),"^"),1:$$ESC^ORHLESC($P($G(^PS(51.2,+$P(FIELD(1),"^",4),0)),"^"))) 133 .S FIELD(1)=FIELD(1)_"^"_PSJUNITS_"^99PSR" 134 .S:$G(PSJBCBU) FIELD(4)="^^^"_$P($G(@(PSJORDER_"0)")),"^",4)_"^"_$$CODES^PSIVUTL($P($G(@(PSJORDER_"0)")),"^",4),55.01,.04)_"^99PSR" 135 I PSJORDER[53.1 S FIELD(1)="^^^"_$P($G(@(PSJORDER_"0)")),"^",3) Q:$P(FIELD(1),U,4)="" D 136 .N PSJUNITS S PSJUNITS=$S($G(PSJBCBU):$P($G(^PS(51.2,+$P(FIELD(1),"^",4),0)),"^"),1:$$ESC^ORHLESC($P($G(^PS(51.2,+$P(FIELD(1),"^",4),0)),"^"))) 137 .S FIELD(1)=FIELD(1)_"^"_PSJUNITS_"^99PSR" 138 .S:$G(PSJBCBU) FIELD(4)="^^^"_$P($G(@(PSJORDER_"0)")),"^",4)_"^"_$$CODES^PSIVUTL($P($G(@(PSJORDER_"0)")),"^",4),53.1,4)_"^99PSR" 139 S:FIELD(1)="" FIELD(1)="^^^"_$P(NODE1,"^",3)_"^"_$S($G(PSJBCBU):$P($G(^PS(51.2,+$P(NODE1,"^",3),0)),"^"),1:$$ESC^ORHLESC($P($G(^PS(51.2,+$P(NODE1,"^",3),0)),"^")))_"^99PSR" 140 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 141 Q 142 ZRX ; pharmacy Z-segment 143 D ZRX^PSJHLU 144 Q 145 CNT ;Count dispense drugs for an order 146 S (CNT,DDNUM)=0 F S DDNUM=$O(@(PSJORDER_"1,"_DDNUM_")")) Q:'DDNUM S CNT=CNT+1 147 Q 1 PSJHL3 ;BIR/RLW-PHARMACY ORDER SEGMENTS ;04 Aug 98 / 10:10 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,11,14,40,42,47,50,56,58,92,101,102,123,110,111,152**;16 DEC 97 3 ; 4 ; Reference to ^PS(50.606 is supported by DBIA# 2174. 5 ; Reference to ^PS(50.607 is supported by DBIA# 2221. 6 ; Reference to ^PS(50.7 is supported by DBIA# 2180. 7 ; Reference to ^PS(51.2 is supported by DBIA# 2178. 8 ; Reference to ^PS(52.6 is supported by DBIA# 1231. 9 ; Reference to ^PS(52.7 is supported by DBIA# 2173. 10 ; Reference to ^PS(55 is supported by DBIA# 2191. 11 ; Reference to ^PSDRUG( is supported by DBIA# 2192. 12 ; Reference to ^PSNDF( is supported by DBIA# 2195. 13 ; Reference to ^VA(200 is supported by DBIA# 10060. 14 ; Reference to ^PSNAPIS is supported by DBIA# 2531. 15 ; Reference to ^XLFDT is supported by DBIA# 10103. 16 ; Reference to ^PSSUTIL1 is supported by DBIA# 3179. 17 ; 18 EN1(PSJHLDFN,PSOC,PSJORDER) ; start here 19 ; passed in are PSJHLDFN (patient ien) 20 ; PSJORDER (file root of order) 21 ; OC (order control code - NW for new order, OK for finished order, OC for order canceled) 22 I $G(PSJHLDFN)']""!$G(PSOC)']""!$G(PSJORDER)']"" W !,"INSUFFICIENT DATA FOR ^PSJHL3" Q 23 N COMMENTS,DDIEA,DDNUM,DOSE,DOSEFORM,DOSEOR,NAME,DURATION,IVTYPE,NODE1,NODE2,NDNODE,OINODE,PSGPLS,PSGPLF,PRODNAME,SPDIEN,UNIT,UNITS,CNT,DDIEN,SCHEDULE 24 D INIT 25 S IVTYPE=$S(RXORDER["U":"",1:$$IVTYPE^PSJHLU(PSJORDER)) 26 D RXO,RXE D:(IVTYPE'="F")!($G(PSJBCBU)) RXR D ZRX 27 D CALL^PSJHLU(PSJI) 28 Q 29 ; 30 INIT ; initialize HL7 variables 31 D INIT^PSJHLU 32 Q 33 ; 34 RXO ; pharmacy prescription order segment (used to send Orderable Item to OE/RR) 35 S LIMIT=17 X PSJCLEAR 36 S FIELD(0)="RXO" 37 S OINODE=$G(@(PSJORDER_".2)")) 38 S SPDIEN=+$P(OINODE,"^"),DOSEOR=$P(OINODE,"^",2),DOSE=$P(OINODE,"^",5),UNIT=$P(OINODE,"^",6) 39 S FIELD(1)=$S(SPDIEN=0:"^^^^",1:"^^^"_SPDIEN_"^") 40 I SPDIEN S DOSEFORM=$P($G(^PS(50.7,SPDIEN,0)),"^",2),NAME=$P($G(^PS(50.606,+DOSEFORM,0)),"^"),FIELD(1)=FIELD(1)_$P($G(^PS(50.7,SPDIEN,0)),"^")_" "_NAME 41 S FIELD(1)=FIELD(1)_"^99PSP" 42 N DURNOD S DURNOD=$G(@(PSJORDER_"2.5)")) I $P(DURNOD,"^",4)]"" S $P(FIELD(1),"^",3)=$P(DURNOD,"^",4) 43 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 44 Q 45 ; 46 RXE ; pharmacy encoded order segment 47 S (UNITS,NDNODE,SPDIEN,PRODNAME,DDNUM,DDIEN,CNT)="",LIMIT=26 X PSJCLEAR 48 S FIELD(0)="RXE" 49 S NODE1=$G(@(PSJORDER_"0)")),NODE2=$G(@(PSJORDER_"2)")) 50 I RXORDER["V" D IVRXE Q 51 I RXORDER["P",IVTYPE="F" D IVRXE Q 52 I RXORDER["P",$P(NODE1,"^",4)="H" D IVRXE Q 53 ;S PSGPLS=$P(NODE2,"^",2),PSGPLF=$P(NODE2,"^",4),X1=PSGPLF,X2=PSGPLS D ^%DTC S DURATION="D"_X 54 N RENEW S RENEW=$$LASTREN^PSJLMPRI(PSJHLDFN,RXORDER) 55 S PSGPLS=$S($G(PSJEXPOE):$P(NODE2,"^",2),RENEW>$P(NODE2,"^",2):RENEW,1:$P(NODE2,"^",2)) 56 S PSGPLF=$S($G(PSJEXPOE):PSJEXPOE,1:$P(NODE2,"^",4)) 57 ;S FIELD(1)="^"_$P(NODE2,"^")_$S($G(PSJBCBU):"&"_$P(NODE2,"^",5),1:"")_"^^"_$$FMTHL7^XLFDT(PSGPLS)_"^"_$$FMTHL7^XLFDT(PSGPLF) 58 S FIELD(1)="^"_$P(NODE2,"^")_"^^"_$$FMTHL7^XLFDT(PSGPLS)_"^"_$$FMTHL7^XLFDT(PSGPLF) 59 S FIELD(21)="^"_$P(NODE2,"^",5)_"^99PSA^^^" 60 I ($G(DOSEOR)']"")!($O(@(PSJORDER_"1,"" "")"),-1)=1) D 61 .S (CNT,DDNUM)=0 F S DDNUM=$O(@(PSJORDER_"1,"_DDNUM_")")) Q:'DDNUM Q:CNT=1 S DDIEN=+$G(@(PSJORDER_"1,"_DDNUM_",0)")) D 62 ..S FIELD(1)=$S($P(@(PSJORDER_"1,"_DDNUM_",0)"),"^",2)="":"1",1:$P(@(PSJORDER_"1,"_DDNUM_",0)"),"^",2))_"&"_FIELD(1) 63 ..S FIELD(1)=DOSE_"&"_UNIT_"&"_FIELD(1),$P(FIELD(1),"^",8)=$S($G(DOSEOR)]"":$G(DOSEOR),1:DOSE_UNIT) 64 ..S:$P(FIELD(1),"^",8)="" $P(FIELD(1),"^",8)=$G(@(PSJORDER_".3)")) 65 ..S NDNODE=$G(^PSDRUG(DDIEN,"ND")) 66 ..; CHANGE FOR NEW NDF CALL 67 ..;S PRODNAME=$S($G(^PSNDF(+NDNODE,5,+$P(NDNODE,"^",3),0))]"":^(0),1:"N/A") 68 ..S PRODNAME=$S($T(^PSNAPIS)]"":$$PROD0^PSNAPIS(+NDNODE,$P(NDNODE,"^",3)),$G(^PSNDF(+NDNODE,5,+$P(NDNODE,"^",3),0))]"":^(0),1:"N/A") 69 ..S:PRODNAME="" PRODNAME="N/A" 70 ..S FIELD(2)=$S(PRODNAME="N/A":"^^",1:+NDNODE_"."_+$P(NDNODE,"^",3)_"^"_$P(NDNODE,"^",2)_"^"_"99NDF")_"^"_DDIEN_"^"_$P($G(^PSDRUG(DDIEN,0)),"^")_"^"_"99PSD" 71 ..;S UNITS=$S(PRODNAME="N/A":"N/A",1:$P($G(^PSNDF(+NDNODE,2,+$P(PRODNAME,"^",2),3,+$P(PRODNAME,"^",3),4,+$P(PRODNAME,"^",4),0)),"^")) 72 ..S UNITS=$S(PRODNAME="N/A":"N/A",1:$S($T(^PSNAPIS)]"":$P($$DFSU^PSNAPIS(+NDNODE,$P(NDNODE,"^",3)),"^",5),1:$P($G(^PSNDF(+NDNODE,2,+$P(PRODNAME,"^",2),3,+$P(PRODNAME,"^",3),4,+$P(PRODNAME,"^",4),0)),"^"))) 73 ..S FIELD(5)="^^^"_UNITS_"^"_$P($G(^PS(50.607,UNITS,0)),"^")_"^99PSU" 74 ..S FIELD(6)="^^^"_$G(DOSEFORM)_"^"_$P($G(^PS(50.606,+$G(DOSEFORM),0)),"^")_"^99PSF" 75 ..S FIELD(25)=$$EN^PSSUTIL1(DDIEN),FIELD(26)=$P(FIELD(25),"|",2),FIELD(25)=$P(FIELD(25),"|") 76 ..S CNT=CNT+1 77 E S $P(FIELD(1),"^",8)=DOSEOR 78 S NAME=$P($G(^VA(200,DUZ,0)),"^"),FIELD(14)=DUZ_"^"_NAME_"^"_"99NP" 79 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 80 K SEGMENT S JJ=0 F S JJ=$O(@(PSJORDER_"12,"_JJ_")")) Q:'JJ S SEGMENT(JJ-1)=$G(@(PSJORDER_"12,"_JJ_",0)")) 81 I $D(SEGMENT(0)) S SEGMENT(0)="NTE|6|L|"_SEGMENT(0) D SET^PSJHLU K SEGMENT,JJ 82 I $P($G(@(PSJORDER_"6)")),"^")]"" K SEGMENT S SEGMENT(0)="NTE|21|L|"_$P($G(@(PSJORDER_"6)")),"^") D SET^PSJHLU K SEGMENT 83 I PSJORDER["P",$P($G(@(PSJORDER_"9)")),"^",2)]"" K SEGMENT S SEGMENT(0)="NTE|21|L|"_$P($G(@(PSJORDER_"9)")),"^",2) D SET^PSJHLU K SEGMENT 84 Q 85 ; 86 IVRXE ; RXE segment for IV orders 87 ; if it's an Inpatient Med IV order, send the RXE with dispense drug 88 ; information. If it's an IV FLUID order, send just the start/stop 89 ; date, duration in the RXE and send an RXC for each additive and 90 ; solution. 91 N ADSNODE 92 I RXORDER["V" S PSGPLS=$P(NODE1,"^",2),PSGPLF=$P(NODE1,"^",3) 93 E S PSGPLS=$P(NODE2,"^",2),PSGPLF=$P(NODE2,"^",4) 94 ;S X1=PSGPLF,X2=PSGPLS D ^%DTC S DURATION=$S(X]"":"D"_X,1:"") 95 S FIELD(1)="^"_$S(PSJORDER["IV":$P(NODE1,"^",9),1:$P(NODE2,"^"))_"^^"_$$FMTHL7^XLFDT(PSGPLS)_"^"_$$FMTHL7^XLFDT(PSGPLF) 96 ;S:$G(PSJBCBU) $P(FIELD(1),"^",2)=$P(FIELD(1),"^",2)_"&"_$S(PSJORDER["IV":$P(NODE1,"^",11),1:$P(NODE2,"^",5)) 97 S FIELD(21)="^"_$S(PSJORDER["IV":$P(NODE1,"^",11),1:$P(NODE2,"^",5))_"^99PSA^^^" 98 S NAME=$P($G(^VA(200,DUZ,0)),"^") 99 S FIELD(14)=DUZ_"^"_NAME_"^"_"99NP" 100 N X,Y 101 I RXORDER["V" S INFUSE=$P(NODE1,"^",8) 102 E S INFUSE=$P($G(@(PSJORDER_"8)")),"^",5) 103 I INFUSE?1N.N1" ml/hr" S FIELD(23)=+INFUSE,Y=$P(INFUSE,+INFUSE,2),Y=$$TRIM^XLFSTR(Y,"LR"," "),FIELD(24)="^^^^"_Y_"^PSU" 104 I FIELD(23)="",FIELD(24)="" S FIELD(23)=INFUSE 105 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 106 K SEGMENT I RXORDER["V" S JJ=0 F S JJ=$O(@(PSJORDER_"5,"_JJ_")")) Q:'JJ S SEGMENT(JJ-1)=$G(@(PSJORDER_"5,"_JJ_",0)")) 107 E S JJ=0 F S JJ=$O(@(PSJORDER_"12,"_JJ_")")) Q:'JJ S SEGMENT(JJ-1)=$G(@(PSJORDER_"12,"_JJ_",0)")) 108 I $D(SEGMENT(0)) S SEGMENT(0)="NTE|6|L|"_SEGMENT(0) D SET^PSJHLU K SEGMENT,JJ 109 I RXORDER["V",$P($G(@(PSJORDER_"3)")),"^")]"" K SEGMENT S SEGMENT(0)="NTE|21|L|"_$P($G(@(PSJORDER_"3)")),"^") D SET^PSJHLU K SEGMENT 110 I RXORDER["P",$P($G(@(PSJORDER_"9)")),U,2)]"" S SEGMENT(0)="NTE|21|L|"_$P($G(@(PSJORDER_"9)")),U,2) D SET^PSJHLU K SEGMENT 111 ; 112 RXC ;component segments 113 N ADDITIVE,SOLUTION,SUB,TYPE,AD,SOL,PTR,NUM,UTMP,XTMP 114 S LIMIT=24 X PSJCLEAR 115 S FIELD(0)="RXC" 116 ; In the line below, the naked reference refers to the full global reference represented in PSJORDER_TYPE... 117 ; This could be a reference to either ^PS(53.1 or ^PS(55 118 S AD="AD",SOL="SOL" F TYPE="AD","SOL" S SUB=0 F S SUB=$O(@(PSJORDER_TYPE_","_SUB_")")) Q:SUB="" S NODE1=$G(^(SUB,0)) Q:NODE1="" D 119 .S FIELD(1)=$S(TYPE="AD":"A",1:"B") 120 .S PTR=+$S(TYPE="AD":+$P($G(^PS(52.6,$P(NODE1,"^"),0)),"^",11),1:+$P($G(^PS(52.7,$P(NODE1,"^"),0)),"^",11)) 121 .S FIELD(2)="^^^"_$S($G(PSJBCBU):+$P(NODE1,"^"),1:PTR)_"^"_$S($G(PSJBCBU):$S(TYPE="AD":$P($G(^PS(52.6,+$P(NODE1,"^"),0)),"^"),1:$P($G(^PS(52.7,+$P(NODE1,"^"),0)),"^")_" "_$P($G(^(0)),U,4)),1:$P($G(^PS(50.7,PTR,0)),"^")) 122 .S:(TYPE="AD"&$G(PSJBCBU)) FIELD(2)=FIELD(2)_$S($P(NODE1,"^",3)]"":" BOTTLE: "_$P(NODE1,"^",3),1:"") 123 .S FIELD(2)=FIELD(2)_"^99PSP" 124 .S FIELD(3)=$P($P(NODE1,"^",2)," ") 125 .S FIELD(4)=$P($P(NODE1,"^",2)," ",2) 126 .F XTMP=1:1:13 S UTMP($P("ML^LITER^MCG^MG^GM^UNITS^IU^MEQ^MM^MU^THOUU^MG-PE^NANOGRAM","^",XTMP))="PSIV-"_XTMP 127 .S NUM="" S:FIELD(4)'="" NUM=$G(UTMP(FIELD(4))) 128 .S FIELD(4)="^^^"_NUM_"^"_FIELD(4)_"^99OTH" 129 .D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 130 Q 131 ; 132 RXR ; med route segment 133 S LIMIT=4 X PSJCLEAR 134 S FIELD(0)="RXR" 135 I PSJORDER["IV" S FIELD(1)="^^^"_$P($G(@(PSJORDER_".2)")),"^",3) Q:$P(FIELD(1),U,4)="" D 136 .S FIELD(1)=FIELD(1)_"^"_$P($G(^PS(51.2,+$P(FIELD(1),"^",4),0)),"^")_"^99PSR" 137 .S:$G(PSJBCBU) FIELD(4)="^^^"_$P($G(@(PSJORDER_"0)")),"^",4)_"^"_$$CODES^PSIVUTL($P($G(@(PSJORDER_"0)")),"^",4),55.01,.04)_"^99PSR" 138 S:FIELD(1)="" FIELD(1)="^^^"_$P(NODE1,"^",3)_"^"_$P($G(^PS(51.2,+$P(NODE1,"^",3),0)),"^")_"^99PSR" 139 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 140 Q 141 ; 142 ZRX ; pharmacy Z-segment 143 S LIMIT=6 X PSJCLEAR 144 S FIELD(0)="ZRX" 145 I '$G(PSJREN) N PREON,PSJREN I $G(PSJORD)["U"&($P(NODE1,"^",24)="R") S PSJREN=1 146 I $G(PSJORD)["V"&($P(NODE2,"^",8)="R") S PSJREN=1 147 S PREON=$S($G(PSJREN):$G(PSJORD),PSJORDER["IV":$P(NODE2,"^",5),1:$P(NODE1,"^",25)) 148 S FIELD(1)=$S(PREON["P":$P($G(^PS(53.1,+PREON,0)),"^",21),PREON["V":$P($G(^PS(55,PSJHLDFN,"IV",+PREON,0)),"^",21),1:$P($G(^PS(55,PSJHLDFN,5,+PREON,0)),"^",21)) 149 S FIELD(2)=$S(PSJORDER["IV":$G(P("NAT")),1:$G(PSJNOO)) 150 S FIELD(3)=$S($G(PSJREN):"R",PSJORDER["IV":$P(NODE2,"^",8),1:$P(NODE1,"^",24)) 151 I FIELD(3)="" I PSOC="SN" S FIELD(3)="N" 152 S NAME=$P($G(^VA(200,DUZ,0)),"^") 153 S FIELD(5)=DUZ_"^"_NAME_"^"_"99NP" 154 S FIELD(6)=$S($G(IVTYPE)="F":"IV",$P($G(@(PSJORDER_"0)")),U,4)="H":"TPN",1:"") 155 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 156 Q 157 ; 158 CNT ;Count dispense drugs for an order 159 S (CNT,DDNUM)=0 F S DDNUM=$O(@(PSJORDER_"1,"_DDNUM_")")) Q:'DDNUM S CNT=CNT+1 160 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJHL4.m
r613 r623 1 PSJHL4 ;BIR/RLW-DECODE HL7 /MESSSAGE FROM OE/RR ;16 Mar 99 / 4:55 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,12,27,34,40,42,55,47,50,56,58,98,85,105,107,110,111,154,134**;16 DEC 97;Build 124 3 ; Reference to $$EN^PSOHLNEW is supported by DBIA# 2188. 4 ; Reference to ^PS(50.7 is supported by DBIA 2180. 5 ; Reference to ^PS(51.2 is supported by DBIA 2178. 6 ; Reference to ^PS(55 is supported by DBIA 2191. 7 ; Reference to ^PS(59.7 supported by DBIA 2181. 8 ; Reference to ^ORHLESC is supported by DBIA 4922. 9 ; 10 EN(PSJMSG) ; Start 11 K ^TMP("PSJNVO",$J) 12 N ADCNT,SOLCNT,OCCNT 13 N ACKDATE,ADDITIVE,ADMINSTR,APPL,COMMENT,PSJHLDFN,DISPENSE,DOSE,DURATION,II,INSTR,J,JJ,JJJ,K,LOGIN,NEWORDER,NURSEACK,OBXFL,OCNARR,OCPROV,OCRSN,ORDER,PRIORITY,PSITEM,ORDCON,PROCOM,PSJORDER,PSREASON 14 N LOC,PROVIDER,PSPR,PSOC,PTR,QQ,REQST,ROUTE,RXON,RXORDER,SCHEDULE,SEGMENT,SOLUTION,STPDT,STRENGTH,TEXT,CLERK,INFRT,IVTYP,SCHTYP,PREON,NOO,ROC,FREQ,CLASS,PSJHLMTN,UNIT,UNITS,QFLG,VOLUME,TVOLUME,PSGP 15 N PSJASTP,FLDATE,FLCMNT,PSJFLAG,PSJYN,PRNTON,APPT,IVLIMIT,IVCAT,INTRMT 16 S (ADCNT,SOLCNT,OCCNT,II,TVOLUME)="",(OBXFL,QFLG)=0,PSJHLMTN="ORR" F S II=$O(PSJMSG(II)) Q:'II D DECODE Q:QFLG D @FIELD(0) Q:$G(CLASS)="O" Q:QFLG 17 I ($G(CLASS)'="I")!(QFLG) G END 18 I ($G(PSOC)="NW")!($G(PSOC)="XO") N DIK,DA S DIK="^PS(53.1,",DA=NEWORDER D EN1^DIK L -^PS(53.1,NEWORDER) 19 I ($G(PSOC)="NW")!($G(PSOC)="XO") D EN1^PSJHL2(PSJHLDFN,$S(PSOC="NW":"OK",1:"XR"),NEWORDER_"P") 20 END ; 21 K ^TMP("PSJNVO",$J) 22 I (",S,A,")[(","_$G(PRIORITY)_",")!($G(SCHEDULE)="NOW")!($G(SCHEDULE)["STAT") D 23 . I $G(PRIORITY)="ZD",$G(PSGORD) D NOTIFY(PSGORD_$S(PSGORD["V":"V",PSGORD["U":"U",1:""),PSJHLDFN,$G(PRIORITY),$G(SCHEDULE)) 24 . I $G(NEWORDER) D NOTIFY(NEWORDER_"P",PSJHLDFN,$G(PRIORITY),$G(SCHEDULE)) 25 Q 26 DECODE ; Parse into fields 27 K FIELD 28 N PSJCTR1 S PSJCTR1="" 29 S SEGMENT=$G(PSJMSG(II)) 30 I $D(PSJMSG(II,1)),$P(SEGMENT,"|",1)="ORC" F S PSJCTR1=$O(PSJMSG(II,PSJCTR1)) Q:PSJCTR1="" D 31 . S SEGMENT=SEGMENT_PSJMSG(II,PSJCTR1) ;Handle CPRS "overflow" ORC nodes 32 S J=0 33 F Q:$G(SEGMENT)="" D 34 .I SEGMENT["|" S FIELD(J)=$P(SEGMENT,"|"),SEGMENT=$E(SEGMENT,$L(FIELD(J))+2,$L(SEGMENT)),J=J+1 Q 35 .I SEGMENT'["|" S FIELD(J)=SEGMENT,SEGMENT="" Q 36 K PSJCTR1 37 Q 38 NOTIFY(ORDER,PSJHLDFN,PRIO,PSJSCHED) ; Send msg 39 N NTFYREAS,WARD,MGROUP,NTFSTAT,DRUG,DRIEN,PNAME,ORDATE,DO,PSG,XMY,VADPT,LASTFOUR,PSJSOK 40 Q:($G(PRIO)=""&($G(PSJSCHED)="")) 41 S DFN=PSJHLDFN D DEM^VADPT S LASTFOUR=$P($P(VADM(2),"^",2),"-",3) 42 S NTFYREAS=$S((",S,A,")[(","_PRIO_","):1,($G(PSJSCHED)="NOW"):2,($G(PSJSCHED)="STAT"):3,1:0) Q:'NTFYREAS 43 S PSJSOK=1 44 I ORDER["P" D PND 45 I ORDER["U" D UD 46 I ORDER["V" D IV 47 Q:PSJSOK=1 48 D XMD^PSJHL4A 49 Q 50 PND ; Pending 51 N WARD,WDPARM,MGRP 52 Q:'$D(^PS(53.1,+ORDER,0)) 53 S WARD=$G(^DPT(PSJHLDFN,.1)) I WARD]"" D 54 .N DIC,X,Y S DIC="^DIC(42,",DIC(0)="BOXZ",X=WARD D ^DIC S WARD=+Y Q:WARD=0 55 .S WARD=$O(^PS(59.6,"B",WARD,0)) Q:+WARD=0 56 .Q:$$SNDTSTW^PSJHL4A(PRIO,PSJSCHED,WARD) 57 .S WDPARM=$G(^PS(59.6,+WARD,0)),MGRP=$P(WDPARM,"^",30) Q:+MGRP=0 58 .S MGRP=$$GET1^DIQ(3.8,MGRP,.01) I MGRP]"" S XMY("G."_MGRP_"@"_$G(^XMB("NETNAME")))="",PSJSOK=0 59 S:'$$SNDTSTP^PSJHL4A(PRIO,PSJSCHED) MGROUP="G.PSJ STAT NOW PENDING ORDER@"_$G(^XMB("NETNAME")),XMY(MGROUP)="",PSJSOK=0 60 S NTFSTAT="PENDING" 61 N NDP2,ND0 S NDP2=$G(^PS(53.1,+ORDER,.2)),ND0=$G(^PS(53.1,+ORDER,0)) 62 S DRIEN=+$P(NDP2,"^"),DO=$P(NDP2,"^",2),RTE=$P(ND0,"^",3),ORDATE=$P(ND0,"^",14) 63 S SCHED=$P($G(^PS(53.1,+ORDER,2)),"^") 64 Q 65 UD ; UD 66 N WARD,WDPARM,MGRP 67 Q:'$D(^PS(55,PSJHLDFN,5,+ORDER,0)) 68 S WARD=$P($G(^PS(55,PSJHLDFN,5,+ORDER,0)),"^",23) I +WARD D 69 .S WARD=$O(^PS(59.6,"B",WARD,0)) Q:+WARD=0 70 .Q:$$SNDTSTW^PSJHL4A(PRIO,PSJSCHED,WARD) 71 .S WDPARM=$G(^PS(59.6,+WARD,0)),MGRP=$P(WDPARM,"^",30) Q:+MGRP=0 72 .S MGRP=$$GET1^DIQ(3.8,MGRP,.01) I MGRP]"" S XMY("G."_MGRP_"@"_$G(^XMB("NETNAME")))="",PSJSOK=0 73 S:'$$SNDTSTA^PSJHL4A(PRIO,PSJSCHED) MGROUP="G.PSJ STAT NOW ACTIVE ORDER@"_$G(^XMB("NETNAME")),XMY(MGROUP)="",PSJSOK=0 74 S NTFSTAT="ACTIVE" 75 N ND2,ND0 S ND0=$G(^PS(55,PSJHLDFN,5,+ORDER,0)),ND2=$G(^PS(55,PSJHLDFN,5,+ORDER,2)),NDP2=$G(^PS(55,PSJHLDFN,5,+ORDER,.2)) 76 S DRIEN=+$P(NDP2,"^"),DO=$P(NDP2,"^",2),RTE=$P(ND0,"^",3),ORDATE=$P(ND0,"^",14) 77 S SCHED=$P(ND2,"^") 78 Q 79 IV ; IV 80 N WARD,WDPARM,MGRP 81 Q:'$D(^PS(55,PSJHLDFN,"IV",+ORDER,0)) 82 S WARD=$P($G(^PS(55,PSJHLDFN,"IV",+ORDER,0)),"^",22) I +WARD D 83 .S WARD=$O(^PS(59.6,"B",WARD,0)) Q:+WARD=0 84 .Q:$$SNDTSTW^PSJHL4A(PRIO,PSJSCHED,WARD) 85 .S WDPARM=$G(^PS(59.6,+WARD,0)),MGRP=$P(WDPARM,"^",30) Q:+MGRP=0 86 .S MGRP=$$GET1^DIQ(3.8,MGRP,.01) I MGRP]"" S XMY("G."_MGRP_"@"_$G(^XMB("NETNAME")))="",PSJSOK=0 87 S:'$$SNDTSTA^PSJHL4A(PRIO,PSJSCHED) MGROUP="G.PSJ STAT NOW ACTIVE ORDER@"_$G(^XMB("NETNAME")),XMY(MGROUP)="",PSJSOK=0 88 S NTFSTAT="ACTIVE" 89 N ND2,NDP2,ND0 S ND0=$G(^PS(55,PSJHLDFN,"IV",+ORDER,0)),ND2=$G(^PS(55,PSJHLDFN,"IV",+ORDER,2)) 90 S NDP2=$G(^PS(55,PSJHLDFN,"IV",+ORDER,.2)) 91 S DRIEN=$P(NDP2,"^"),DO=$P(NDP2,"^",2),RTE=$P(NDP2,"^",3) 92 S ORDATE=$P(ND2,"^"),SCHED=$P(ND0,"^",9) 93 Q 94 MSH ; Header 95 S PSOC=FIELD(8) 96 Q 97 PID ; ID 98 S PSJHLDFN=$$UNESC^ORHLESC(FIELD(3)) 99 Q 100 PV1 ; Visit 101 N A 102 S CLASS=FIELD(2),LOC=$P(FIELD(3),"^"),APPT="" I $G(FIELD(44))]"" S APPT=+$$HL7TFM^XLFDT(FIELD(44)) 103 I "IO"'[CLASS S PSREASON="Invalid patient class" Q 104 N QQ K PSJNVA S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ D Q:$G(PSJNVA) 105 .S X=$G(PSJMSG(QQ)) 106 .I $P(X,"|")="ZRN" S PSJNVA=1,CLASS="O" D EN^PSOHLNEW(.PSJMSG) 107 I $G(PSJNVA) K PSJNVA Q 108 I CLASS="O" N QQ S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ I $P(PSJMSG(QQ),"|")="OBR" D Q:$P(PSJMSG(QQ),"|")="OBR" 109 .S RXON=$P(PSJMSG(QQ),"|",4) I RXON]"" S RXON=$P(RXON,"^") I "ABNPUV"[$E(RXON,$L(RXON)) S CLASS="I" 110 I CLASS="O" N QQ S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ I $P(PSJMSG(QQ),"|")="ORC" D Q:$P(PSJMSG(QQ),"|")="ORC" 111 .S RXON=$P(PSJMSG(QQ),"|",4) I RXON]"" S RXON=$P(RXON,"^") I "ABNPUV"[$E(RXON,$L(RXON)) S CLASS="I" 112 I CLASS="O" N CHK,QQ S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ I $P(PSJMSG(QQ),"|")="RXO" D Q:$P(PSJMSG(QQ),"|")="RXO" 113 .S CHK=$P(PSJMSG(QQ),"|",2),CHK=$S($P(CHK,"^",5)="IV":"IV",1:$P(CHK,"^",4)) 114 .I CHK="IV" S CLASS="I" Q 115 .I 'CHK S PSREASON="Missing or Invalid Orderable Item",CLASS="I" Q 116 .I $P($G(^PS(50.7,CHK,0)),"^",3)=1 S CLASS="I" Q 117 D:CLASS="O" EN^PSOHLNEW(.PSJMSG) 118 Q 119 ORC ; Order 120 S TMPAT="" 121 S PSOC=FIELD(1) 122 S ORDER=FIELD(2) 123 I $G(PSREASON)]"" D ERROR^PSJHL9 Q 124 S PSJORDER=$P(FIELD(2),"^"),RXON=$P(FIELD(3),"^"),RXORDER=$S((RXON["N")!(RXON["P"):"^PS(53.1,"_+RXON_",",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"","_+RXON_",",1:"^PS(55,"_PSJHLDFN_",5,"_+RXON_",") 125 I PSOC="NA" D ASSIGN^PSJHL5 Q 126 S CLERK=+$G(FIELD(10)) 127 S PROVIDER=+$G(FIELD(12)) D:PSOC="NW" 128 .I PROVIDER=0 S PSREASON="Invalid Provider" D ERROR^PSJHL9 Q 129 .I PROVIDER>0 S PSPR=$G(^VA(200,+PROVIDER,"PS")) I '$D(PSPR)!'(PSPR)!$S($P(PSPR,"^",4)="":0,1:$P(PSPR,"^",4)'>DT) S PSREASON="Invalid Provider" D ERROR^PSJHL9 Q 130 S UNITS=$P(FIELD(7),"^"),INSTR=$$UNESC^ORHLESC($P(FIELD(7),"^",8)) 131 S:UNITS["&" DOSE=$P(UNITS,"&"),UNIT=$P(UNITS,"&",2),UNITS=$P(UNITS,"&",3) S:UNITS]"" UNITS=$$UNESC^ORHLESC(UNITS) S:$G(DOSE)]"" DOSE=$$UNESC^ORHLESC(DOSE) 132 S SCHEDULE=$P(FIELD(7),"^",2),PRIORITY=$P(FIELD(7),"^",6) S:SCHEDULE["PRN" SCHTYP="P" 133 I SCHEDULE["&" S ADMINS=$P(SCHEDULE,"&",2),SCHEDULE=$P(SCHEDULE,"&") S ADMINS=$TR(ADMINS," ","") S ADMINS=$S(ADMINS:ADMINS,1:"") 134 S SCHEDULE=$$UNESC^ORHLESC(SCHEDULE) 135 I SCHEDULE["@" S TMPAT=$$TMPAT^PSJHL4A(SCHEDULE) 136 I $G(TMPAT) S $P(SCHEDULE,"@",2)=TMPAT,ADMINS=TMPAT 137 S DURATION=$P(FIELD(7),"^",3),REQST=$P(FIELD(7),"^",4) S:REQST'="" REQST=+$E(+$$HL7TFM^XLFDT(REQST),1,12) S REQST=$$DATE2^PSJUTL2(REQST) 138 S PRIORITY=$S($G(PRIORITY)]"":PRIORITY,1:"R") 139 I $E(SCHEDULE,1)=" " S:$TR(SCHEDULE," ")="PRN" SCHEDULE="PRN" I '(SCHEDULE="PRN") S PSREASON="Invalid Schedule" D ERROR^PSJHL9 Q 140 S SCHTYP=$P(FIELD(7),"^",7) 141 I $G(SCHTYP)="D" S SCHTYP="C" ;Makes CPRS Day of Week consistent in behavior with backdoor order of Day of Week 142 S PRNTON=$P(FIELD(8),"^") 143 S NURSEACK=$G(FIELD(11)) 144 S LOGIN=$G(FIELD(15)) S:LOGIN'="" LOGIN=+$E(+$$HL7TFM^XLFDT(FIELD(15)),1,12) S LOGIN=$$DATE2^PSJUTL2(LOGIN) 145 S:$G(NURSEACK)]"" ACKDATE=LOGIN 146 S ORDCON=$P($G(FIELD(16)),U) I ORDCON="A" S PSJASTP=$G(FIELD(9)) S:$G(PSJASTP)'="" PSJASTP=+$E(+$$HL7TFM^XLFDT(PSJASTP),1,12) S PSJASTP=$$DATE2^PSJUTL2(PSJASTP) 147 I (PSOC="CA")!(PSOC="DC") D CANCEL^PSJHL6 Q 148 I PSOC="HD" D HOLD^PSJHL6 Q 149 I PSOC="RL" D UNHOLD^PSJHL6 Q 150 I PSOC="ZV" D NURSEACK^PSJHL5 Q 151 I PSOC="SS" D STATUS^PSJHL5 Q 152 I PSOC="Z@" N X S X="PSJHL8" X ^%ZOSF("TEST") I D PURGE^PSJHL8 Q 153 I PSOC="DE" S QFLG=1 Q 154 Q 155 OBR ; Flagging from CPRS. 156 S ORDER=FIELD(2) 157 S PSJORDER=$P(FIELD(2),"^"),RXON=$P(FIELD(3),"^"),RXORDER=$S((RXON["N")!(RXON["P"):"^PS(53.1,"_+RXON_",",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"","_+RXON_",",1:"^PS(55,"_PSJHLDFN_",5,"_+RXON_",") 158 S PSJFLAG=FIELD(4) 159 S FLDATE=$G(FIELD(7)) S:FLDATE'="" FLDATE=+$E(+$$HL7TFM^XLFDT(FIELD(7)),1,12) S FLDATE=$$DATE2^PSJUTL2(FLDATE) 160 S CLERK=+$G(FIELD(16)) 161 S PSJYN=$G(FIELD(24)) 162 S FLCMNT=$$UNESC^ORHLESC($G(FIELD(13))) 163 I PSOC="ORU" D FLAG^PSJHL5 164 Q 165 RXC ; IV 166 D RXC^PSJHL4A 167 Q 168 RXO ; OP 169 D RXO^PSJHL4A 170 Q 171 RXR ; Route 172 S ROUTE=$P(FIELD(1),"^",4) 173 Q 174 OBX ; Obs. 175 D OBX^PSJHL4A 176 Q 177 NTE ; Note 178 D NTE^PSJHL4A 179 Q 180 ZRX ; Custom 181 D ZRX^PSJHL4A 182 Q 183 ZSC ;Service Connected - Not Used 184 Q 185 ZRN ;Non-VA Med (Herbal/OTC) 186 S CLASS="O" D EN^PSOHLNEW(.PSJMSG) 187 Q 188 DG1 ;Billing Awareness - Not used 189 Q 1 PSJHL4 ;BIR/RLW-DECODE HL7 /MESSSAGE FROM OE/RR ;16 Mar 99 / 4:55 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,12,27,34,40,42,55,47,50,56,58,98,85,105,107,110,111,154**;16 DEC 97 3 ; 4 ; Reference to $$EN^PSOHLNEW is supported by DBIA# 2188. 5 ; Reference to ^PS(50.7 is supported by DBIA# 2180. 6 ; Reference to ^PS(51.2 is supported by DBIA# 2178. 7 ; Reference to ^PS(55 is supported by DBIA# 2191. 8 ; Reference to ^PS(59.7 supported by DBIA #2181. 9 ; 10 EN(PSJMSG) ; start here 11 K ^TMP("PSJNVO",$J) 12 N ADCNT,SOLCNT,OCCNT 13 N ACKDATE,ADDITIVE,ADMINSTR,APPL,COMMENT,PSJHLDFN,DISPENSE,DOSE,DURATION,II,INSTR,J,JJ,JJJ,K,LOGIN,NEWORDER,NURSEACK,OBXFL,OCNARR,OCPROV,OCRSN,ORDER,PRIORITY,PSITEM,ORDCON,PROCOM,PSJORDER,PSREASON 14 N LOC,PROVIDER,PSPR,PSOC,PTR,QQ,REQST,ROUTE,RXON,RXORDER,SCHEDULE,SEGMENT,SOLUTION,STPDT,STRENGTH,TEXT,CLERK,INFRT,IVTYP,SCHTYP,PREON,NOO,ROC,FREQ,CLASS,PSJHLMTN,UNIT,UNITS,QFLG,VOLUME,TVOLUME,PSGP 15 N PSJASTP,FLDATE,FLCMNT,PSJFLAG,PSJYN,PRNTON,APPT,IVLIMIT 16 S (ADCNT,SOLCNT,OCCNT,II,TVOLUME)="",(OBXFL,QFLG)=0,PSJHLMTN="ORR" F S II=$O(PSJMSG(II)) Q:'II D DECODE Q:QFLG D @FIELD(0) Q:$G(CLASS)="O" Q:QFLG 17 I ($G(CLASS)'="I")!(QFLG) G END 18 I ($G(PSOC)="NW")!($G(PSOC)="XO") N DIK,DA S DIK="^PS(53.1,",DA=NEWORDER D EN1^DIK L -^PS(53.1,NEWORDER) 19 I ($G(PSOC)="NW")!($G(PSOC)="XO") D EN1^PSJHL2(PSJHLDFN,$S(PSOC="NW":"OK",1:"XR"),NEWORDER_"P") 20 END ; 21 K ^TMP("PSJNVO",$J) 22 I (",S,A,")[(","_$G(PRIORITY)_",")!($G(SCHEDULE)="NOW")!($G(SCHEDULE)["STAT") D 23 . I $G(PRIORITY)="ZD",$G(PSGORD) D NOTIFY(PSGORD_$S(PSGORD["V":"V",PSGORD["U":"U",1:""),PSJHLDFN,$G(PRIORITY),$G(SCHEDULE)) 24 . I $G(NEWORDER) D NOTIFY(NEWORDER_"P",PSJHLDFN,$G(PRIORITY),$G(SCHEDULE)) 25 Q 26 ; 27 DECODE ;break segment down into fields 28 K FIELD 29 S SEGMENT=$G(PSJMSG(II)) 30 S J=0 31 F Q:$G(SEGMENT)="" D 32 .;get fields from segment 33 .I SEGMENT["|" S FIELD(J)=$P(SEGMENT,"|"),SEGMENT=$E(SEGMENT,$L(FIELD(J))+2,$L(SEGMENT)),J=J+1 Q 34 .I SEGMENT'["|" S FIELD(J)=SEGMENT,SEGMENT="" Q 35 Q 36 ; 37 NOTIFY(ORDER,PSJHLDFN,PRIO,PSJSCHED) ; 38 N NTFYREAS,WARD,MGROUP,NTFSTAT,DRUG,DRIEN,PNAME,ORDATE,DO,PSG,XMY,VADPT,LASTFOUR,PSJSOK 39 Q:($G(PRIO)=""&($G(PSJSCHED)="")) 40 S DFN=PSJHLDFN D DEM^VADPT S LASTFOUR=$P($P(VADM(2),"^",2),"-",3) 41 S NTFYREAS=$S((",S,A,")[(","_PRIO_","):1,($G(PSJSCHED)="NOW"):2,($G(PSJSCHED)="STAT"):3,1:0) Q:'NTFYREAS 42 S PSJSOK=1 43 I ORDER["P" D PND 44 I ORDER["U" D UD 45 I ORDER["V" D IV 46 Q:PSJSOK=1 47 S PNAME=$P($G(^DPT(+PSJHLDFN,0)),"^") S:$G(RTE) RTE=$P(^PS(51.2,+RTE,0),"^",3) 48 S DRUG=$S(DRIEN:$P($G(^PS(50.7,+DRIEN,0)),"^"),1:""),WARD=$G(^DPT(PSJHLDFN,.1)) 49 S XMDUZ="MEDICATIONS,INPATIENT",XMSUB=$G(WARD) 50 S XMSUB=XMSUB_"-"_NTFSTAT_" "_$S($G(PRIO)="A":"ASAP",$G(PRIO)="S":"STAT",$G(NTFYREAS)=2:"NOW",$G(NTFYREAS)=3:"STAT",1:"")_"-" 51 S XMSUB=XMSUB_$E(PNAME,1,65-$L(XMSUB)) 52 S XMTEXT="PSG(" 53 S PSG(1,0)="Inpatient Medications has received the following "_$S($G(PRIO)="A":"ASAP",$G(PRIO)="S":"STAT",$G(NTFYREAS)=2:"NOW",1:"")_" order ("_NTFSTAT_")" 54 S PSG(2,0)="" 55 S PSG(3,0)=" Patient: "_PNAME I $G(LASTFOUR) S PSG(3,0)=PSG(3,0)_" ("_LASTFOUR_")" 56 S PSG(4,0)="Order Information: "_DRUG_" "_DO_" "_RTE_" "_$G(PSJSCHED) 57 S PSG(5,0)=" Order Date: "_$$ENDTC^PSGMI(ORDATE) 58 D ^XMD 59 Q 60 ; 61 PND ; 62 N WARD,WDPARM,MGRP 63 Q:'$D(^PS(53.1,+ORDER,0)) 64 S WARD=$G(^DPT(PSJHLDFN,.1)) I WARD]"" D 65 .N DIC,X,Y S DIC="^DIC(42,",DIC(0)="BOXZ",X=WARD D ^DIC S WARD=+Y Q:WARD=0 66 .S WARD=$O(^PS(59.6,"B",WARD,0)) Q:+WARD=0 67 .Q:$$SNDTSTW^PSJHL4A(PRIO,PSJSCHED,WARD) 68 .S WDPARM=$G(^PS(59.6,+WARD,0)),MGRP=$P(WDPARM,"^",30) Q:+MGRP=0 69 .S MGRP=$$GET1^DIQ(3.8,MGRP,.01) I MGRP]"" S XMY("G."_MGRP_"@"_$G(^XMB("NETNAME")))="",PSJSOK=0 70 S:'$$SNDTSTP^PSJHL4A(PRIO,PSJSCHED) MGROUP="G.PSJ STAT NOW PENDING ORDER@"_$G(^XMB("NETNAME")),XMY(MGROUP)="",PSJSOK=0 71 S NTFSTAT="PENDING" 72 N NDP2,ND0 S NDP2=$G(^PS(53.1,+ORDER,.2)),ND0=$G(^PS(53.1,+ORDER,0)) 73 S DRIEN=+$P(NDP2,"^"),DO=$P(NDP2,"^",2),RTE=$P(ND0,"^",3),ORDATE=$P(ND0,"^",14) 74 S SCHED=$P($G(^PS(53.1,+ORDER,2)),"^") 75 Q 76 ; 77 UD ; 78 N WARD,WDPARM,MGRP 79 Q:'$D(^PS(55,PSJHLDFN,5,+ORDER,0)) 80 S WARD=$P($G(^PS(55,PSJHLDFN,5,+ORDER,0)),"^",23) I +WARD D 81 .S WARD=$O(^PS(59.6,"B",WARD,0)) Q:+WARD=0 82 .Q:$$SNDTSTW^PSJHL4A(PRIO,PSJSCHED,WARD) 83 .S WDPARM=$G(^PS(59.6,+WARD,0)),MGRP=$P(WDPARM,"^",30) Q:+MGRP=0 84 .S MGRP=$$GET1^DIQ(3.8,MGRP,.01) I MGRP]"" S XMY("G."_MGRP_"@"_$G(^XMB("NETNAME")))="",PSJSOK=0 85 S:'$$SNDTSTA^PSJHL4A(PRIO,PSJSCHED) MGROUP="G.PSJ STAT NOW ACTIVE ORDER@"_$G(^XMB("NETNAME")),XMY(MGROUP)="",PSJSOK=0 86 S NTFSTAT="ACTIVE" 87 N ND2,ND0 S ND0=$G(^PS(55,PSJHLDFN,5,+ORDER,0)),ND2=$G(^PS(55,PSJHLDFN,5,+ORDER,2)),NDP2=$G(^PS(55,PSJHLDFN,5,+ORDER,.2)) 88 S DRIEN=+$P(NDP2,"^"),DO=$P(NDP2,"^",2),RTE=$P(ND0,"^",3),ORDATE=$P(ND0,"^",14) 89 S SCHED=$P(ND2,"^") 90 Q 91 ; 92 IV ; 93 N WARD,WDPARM,MGRP 94 Q:'$D(^PS(55,PSJHLDFN,"IV",+ORDER,0)) 95 S WARD=$P($G(^PS(55,PSJHLDFN,"IV",+ORDER,0)),"^",22) I +WARD D 96 .S WARD=$O(^PS(59.6,"B",WARD,0)) Q:+WARD=0 97 .Q:$$SNDTSTW^PSJHL4A(PRIO,PSJSCHED,WARD) 98 .S WDPARM=$G(^PS(59.6,+WARD,0)),MGRP=$P(WDPARM,"^",30) Q:+MGRP=0 99 .S MGRP=$$GET1^DIQ(3.8,MGRP,.01) I MGRP]"" S XMY("G."_MGRP_"@"_$G(^XMB("NETNAME")))="",PSJSOK=0 100 S:'$$SNDTSTA^PSJHL4A(PRIO,PSJSCHED) MGROUP="G.PSJ STAT NOW ACTIVE ORDER@"_$G(^XMB("NETNAME")),XMY(MGROUP)="",PSJSOK=0 101 S NTFSTAT="ACTIVE" 102 N ND2,NDP2,ND0 S ND0=$G(^PS(55,PSJHLDFN,"IV",+ORDER,0)),ND2=$G(^PS(55,PSJHLDFN,"IV",+ORDER,2)) 103 S NDP2=$G(^PS(55,PSJHLDFN,"IV",+ORDER,.2)) 104 S DRIEN=$P(NDP2,"^"),DO=$P(NDP2,"^",2),RTE=$P(NDP2,"^",3) 105 S ORDATE=$P(ND2,"^"),SCHED=$P(ND0,"^",9) 106 Q 107 ; 108 MSH ; 109 S PSOC=FIELD(8) 110 Q 111 ; 112 PID ; 113 S PSJHLDFN=FIELD(3) 114 Q 115 ; 116 PV1 ; 117 N A 118 S CLASS=FIELD(2),LOC=$P(FIELD(3),"^"),APPT="" I $G(FIELD(44))]"" S APPT=+$$HL7TFM^XLFDT(FIELD(44)) 119 I "IO"'[CLASS S PSREASON="Invalid patient class" Q 120 ;N II K PSJNVA S II="" F S II=$O(PSJMSG(II)) Q:'II D Q:CLASS="O" 121 N QQ K PSJNVA S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ D Q:$G(PSJNVA) 122 .S X=$G(PSJMSG(QQ)) 123 .I $P(X,"|")="ZRN" S PSJNVA=1,CLASS="O" D EN^PSOHLNEW(.PSJMSG) 124 .;I $P(X,"|")="ZRN" S PSJNVA=1 D EN^PSOHLNEW(.PSJMSG) 125 ; OBR check - enable outpatient flagging from backdoor 126 I $G(PSJNVA) K PSJNVA Q 127 I CLASS="O" N QQ S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ I $P(PSJMSG(QQ),"|")="OBR" D Q:$P(PSJMSG(QQ),"|")="OBR" 128 .S RXON=$P(PSJMSG(QQ),"|",4) I RXON]"" S RXON=$P(RXON,"^") I "ABNPUV"[$E(RXON,$L(RXON)) S CLASS="I" 129 I CLASS="O" N QQ S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ I $P(PSJMSG(QQ),"|")="ORC" D Q:$P(PSJMSG(QQ),"|")="ORC" 130 .S RXON=$P(PSJMSG(QQ),"|",4) I RXON]"" S RXON=$P(RXON,"^") I "ABNPUV"[$E(RXON,$L(RXON)) S CLASS="I" 131 I CLASS="O" N CHK,QQ S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ I $P(PSJMSG(QQ),"|")="RXO" D Q:$P(PSJMSG(QQ),"|")="RXO" 132 .S CHK=$P(PSJMSG(QQ),"|",2),CHK=$S($P(CHK,"^",5)="IV":"IV",1:$P(CHK,"^",4)) 133 .I CHK="IV" S CLASS="I" Q 134 .I 'CHK S PSREASON="Missing or Invalid Orderable Item",CLASS="I" Q 135 .I $P($G(^PS(50.7,CHK,0)),"^",3)=1 S CLASS="I" Q 136 D:CLASS="O" EN^PSOHLNEW(.PSJMSG) 137 Q 138 ; 139 ORC ; 140 S PSOC=FIELD(1) 141 S ORDER=FIELD(2) 142 I $G(PSREASON)]"" D ERROR^PSJHL9 Q 143 S PSJORDER=$P(FIELD(2),"^"),RXON=$P(FIELD(3),"^"),RXORDER=$S((RXON["N")!(RXON["P"):"^PS(53.1,"_+RXON_",",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"","_+RXON_",",1:"^PS(55,"_PSJHLDFN_",5,"_+RXON_",") 144 I PSOC="NA" D ASSIGN^PSJHL5 Q 145 S CLERK=+$G(FIELD(10)) 146 S PROVIDER=+$G(FIELD(12)) D:PSOC="NW" 147 .I PROVIDER=0 S PSREASON="Invalid Provider" D ERROR^PSJHL9 Q 148 .I PROVIDER>0 S PSPR=$G(^VA(200,+PROVIDER,"PS")) I '$D(PSPR)!'(PSPR)!$S($P(PSPR,"^",4)="":0,1:$P(PSPR,"^",4)'>DT) S PSREASON="Invalid Provider" D ERROR^PSJHL9 Q 149 S UNITS=$P(FIELD(7),"^"),INSTR=$P(FIELD(7),"^",8) 150 S:UNITS["&" DOSE=$P(UNITS,"&"),UNIT=$P(UNITS,"&",2),UNITS=$P(UNITS,"&",3) 151 S SCHEDULE=$P(FIELD(7),"^",2),PRIORITY=$P(FIELD(7),"^",6) S:SCHEDULE["PRN" SCHTYP="P" 152 S DURATION=$P(FIELD(7),"^",3),REQST=$P(FIELD(7),"^",4) S:REQST'="" REQST=+$E(+$$HL7TFM^XLFDT(REQST),1,12) S REQST=$$DATE2^PSJUTL2(REQST) 153 S PRIORITY=$S($G(PRIORITY)]"":PRIORITY,1:"R") 154 I $E(SCHEDULE,1)=" " S:$TR(SCHEDULE," ")="PRN" SCHEDULE="PRN" I '(SCHEDULE="PRN") S PSREASON="Invalid Schedule" D ERROR^PSJHL9 Q 155 S PRNTON=$P(FIELD(8),"^") 156 S NURSEACK=$G(FIELD(11)) 157 S LOGIN=$G(FIELD(15)) S:LOGIN'="" LOGIN=+$E(+$$HL7TFM^XLFDT(FIELD(15)),1,12) S LOGIN=$$DATE2^PSJUTL2(LOGIN) 158 S:$G(NURSEACK)]"" ACKDATE=LOGIN 159 S ORDCON=$P($G(FIELD(16)),U) I ORDCON="A" S PSJASTP=$G(FIELD(9)) S:$G(PSJASTP)'="" PSJASTP=+$E(+$$HL7TFM^XLFDT(PSJASTP),1,12) S PSJASTP=$$DATE2^PSJUTL2(PSJASTP) 160 I (PSOC="CA")!(PSOC="DC") D CANCEL^PSJHL6 Q 161 I PSOC="HD" D HOLD^PSJHL6 Q 162 I PSOC="RL" D UNHOLD^PSJHL6 Q 163 I PSOC="ZV" D NURSEACK^PSJHL5 Q 164 I PSOC="SS" D STATUS^PSJHL5 Q 165 I PSOC="Z@" N X S X="PSJHL8" X ^%ZOSF("TEST") I D PURGE^PSJHL8 Q 166 I PSOC="DE" S QFLG=1 Q 167 Q 168 OBR ; This segment is used to pass flagging information from CPRS. 169 S ORDER=FIELD(2) 170 S PSJORDER=$P(FIELD(2),"^"),RXON=$P(FIELD(3),"^"),RXORDER=$S((RXON["N")!(RXON["P"):"^PS(53.1,"_+RXON_",",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"","_+RXON_",",1:"^PS(55,"_PSJHLDFN_",5,"_+RXON_",") 171 S PSJFLAG=FIELD(4) 172 S FLDATE=$G(FIELD(7)) S:FLDATE'="" FLDATE=+$E(+$$HL7TFM^XLFDT(FIELD(7)),1,12) S FLDATE=$$DATE2^PSJUTL2(FLDATE) 173 S CLERK=+$G(FIELD(16)) 174 S PSJYN=$G(FIELD(24)) 175 S FLCMNT=$G(FIELD(13)) 176 I PSOC="ORU" D FLAG^PSJHL5 177 Q 178 RXC ; IV order 179 D RXC^PSJHL4A 180 Q 181 ; 182 RXO ; 183 D RXO^PSJHL4A 184 Q 185 ; 186 RXR ; 187 S ROUTE=$P(FIELD(1),"^",4) 188 Q 189 ; 190 OBX ; 191 D OBX^PSJHL4A 192 Q 193 ; 194 NTE ; 195 D NTE^PSJHL4A 196 Q 197 ; 198 ZRX ; 199 D ZRX^PSJHL4A 200 Q 201 ; 202 ZSC ;Service Connected - Not Used by Inpatient 203 Q 204 ; 205 ZRN ;Non-VA Med (Herbal/OTC) 206 S CLASS="O" D EN^PSOHLNEW(.PSJMSG) 207 Q 208 DG1 ;Billing Awareness - Not used by Inpatient 209 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJHL4A.m
r613 r623 1 PSJHL4A ;BIR/RLW-CONTINUE DECODE HL7 /MESSSAGE FROM OE/RR ;16 Mar 99 / 4:55 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**105,111,154,170,159,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(52.6 is supported by DBIA# 1231. 5 ; Reference to ^PS(52.7 is supported by DBIA# 2173. 6 ; Reference to ^PS(55 is supported by DBIA# 2191. 7 ; Reference to ^PS(59.7 supported by DBIA #2181. 8 ; Reference to ^ORHLESC is supported by DBIA# 4922. 9 ; Reference to ^SC( is supported by DBIA# 10040. 10 ; Reference to ^PS(51.1 is supported by DBIA# 2177. 11 ; Reference to ^PS(50.7 is supported by DBIA #2180. 12 ; Reference to ^PS(51.2 is supported by DBIA 2178. 13 ; 14 RXC ; IV order 15 N IVFL 16 S APPL=FIELD(1) 17 I APPL["B" S SOLCNT=SOLCNT+1,PTR=$P(FIELD(2),"^",4) Q:'PTR S VOLUME=+FIELD(3)_" ML" D I '$D(^TMP("PSJNVO",$J,"SOL",SOLCNT,0)) D SOLSRCH 18 .S SOLUTION="" F S SOLUTION=$O(^PS(52.7,"AOI",PTR,SOLUTION)) Q:'SOLUTION S INACT=$G(^PS(52.7,SOLUTION,"I")) I 'INACT!(INACT>DT) I VOLUME=$P(^PS(52.7,SOLUTION,0),U,3) D 19 ..S ^TMP("PSJNVO",$J,"SOL",0)=SOLCNT 20 ..S ^TMP("PSJNVO",$J,"SOL",SOLCNT,0)=SOLUTION_"^"_VOLUME,TVOLUME=TVOLUME+(+VOLUME) 21 I $G(INFRT)]"" S X=INFRT D ENI^PSJHLU S INFRT=$G(X) 22 I APPL="A" S ADCNT=ADCNT+1,PTR=$P(FIELD(2),"^",4) Q:'PTR S STRENGTH=$G(FIELD(3))_" "_$P($G(FIELD(4)),"^",5) D I '$D(^TMP("PSJNVO",$J,"AD",ADCNT,0)) S PSREASON="Can't find matching additive" D ERROR^PSJHL9 Q 23 .S ADDITIVE="" F S ADDITIVE=$O(^PS(52.6,"AOI",PTR,ADDITIVE)) Q:'ADDITIVE S INACT=$G(^PS(52.6,ADDITIVE,"I")),IVFL=$P($G(^(0)),"^",13) I 'INACT!(INACT>DT),IVFL'=0 Q:$G(^PS(52.6,ADDITIVE,0))']"" D Q:ADDITIVE 24 ..I $G(PSITEM)="" S PSITEM=PTR 25 ..S ^TMP("PSJNVO",$J,"AD",0)=ADCNT 26 ..S ^TMP("PSJNVO",$J,"AD",ADCNT,0)=ADDITIVE_"^"_STRENGTH 27 Q 28 ; 29 RXO ; 30 I $O(PSJMSG(II,0)) D 31 .K SEGMENT 32 .N KK,JJ,XX 33 .S SEGMENT(1)=$G(PSJMSG(II)) 34 .S KK=1,JJ="" F S JJ=$O(PSJMSG(II,JJ)) Q:'JJ S KK=KK+1,SEGMENT(KK)=$G(PSJMSG(II,JJ)) 35 .S KK=1,JJ=0 36 .F Q:'$D(SEGMENT(KK)) D 37 ..I SEGMENT(KK)["|" S FIELD(JJ)=$P(SEGMENT(KK),"|"),SEGMENT(KK)=$E(SEGMENT(KK),$L(FIELD(JJ))+2,$L(SEGMENT(KK))),JJ=JJ+1 Q 38 ..I SEGMENT(KK)'["|" S FIELD(JJ)=SEGMENT(KK),KK=KK+1 Q:'$D(SEGMENT(KK)) D 39 ...S XX=$P(SEGMENT(KK),"|"),SEGMENT(KK)=$E(SEGMENT(KK),$L(X)+2,$L(SEGMENT(KK))),FIELD(JJ)=FIELD(JJ)_XX,JJ=JJ+1 40 S APPL="",PSITEM=$S($P(FIELD(1),"^",5)="IV":"",1:$P(FIELD(1),"^",4)) 41 S:$P(FIELD(1),"^",6)="ORD" PSITEM="" 42 S:$P(FIELD(1),"^",5)="IV" IVTYP="A",SCHTYP="C",INFRT=$G(FIELD(2)) 43 S DISPENSE=$P($G(FIELD(10)),"^",4) 44 S IVLIMIT=$P($G(PSJMSG(II)),"^",3) 45 S:IVLIMIT["doses" IVLIMIT=$TR(IVLIMIT,"doses","a") 46 Q 47 ; 48 OBX ; 49 S OBXFL=1,OCNARR=FIELD(5),OCPROV=CLERK,OCCNT=OCCNT+1 50 S ^TMP("PSJNVO",$J,10,0)=OCCNT 51 S ^TMP("PSJNVO",$J,10,OCCNT,0)=OCNARR 52 S ^TMP("PSJNVO",$J,10,OCCNT,1)=$$UNESC^ORHLESC($P($G(^VA(200,+OCPROV,0)),"^")) 53 Q 54 ; 55 NTE ; 56 S TEXT=$S((FIELD(1)=6)&('OBXFL):"PROCOM",(FIELD(1)=7)&('OBXFL):"ADMINSTR",1:"OCRSN") 57 S @TEXT@(1)=$$UNESC^ORHLESC($G(FIELD(3))) 58 S K=1,J="" F S J=$O(PSJMSG(II,J)) Q:'J S K=K+1,@TEXT@(K)=$G(PSJMSG(II,J)) 59 D:$D(OCRSN) 60 .S QQ=0 F S QQ=$O(OCRSN(QQ)) Q:'QQ S ^TMP("PSJNVO",$J,10,OCCNT,2,QQ,0)=OCRSN(QQ) 61 S OBXFL=0 62 Q 63 ; 64 ZRX ; 65 N ND,ND2,CHK,FOLOR,STDT 66 S PREON=$G(FIELD(1)),ROC=$G(FIELD(3)),IVCAT=$G(FIELD(6)) 67 S IVCAT=$S(",I,C,"[(","_IVCAT_","):IVCAT,1:"") I 'PREON S IVTYP=$S($G(PSGS0XT):"P",1:"A") S IVTYP=$S(IVCAT="I":"P",IVCAT="C":"A",1:$G(IVTYP)) 68 S ND=$S((PREON["N")!(PREON["P"):$G(^PS(53.1,+PREON,0)),PREON["V":$G(^PS(55,PSJHLDFN,"IV",+PREON,0)),1:$G(^PS(55,PSJHLDFN,5,+PREON,0))) 69 S ND2=$S((PREON["N")!(PREON["P"):$G(^PS(53.1,+PREON,2)),PREON["V":$G(^PS(55,PSJHLDFN,"IV",+PREON,2)),1:$G(^PS(55,PSJHLDFN,5,+PREON,2))) 70 I 'ND I ROC'="N" S PSREASON="Invalid Pharmacy order number" D ERROR^PSJHL9 Q 71 I ND I ROC="R" S FOLOR=$S(PREON["V":$P(ND2,U,6),1:$P(ND,U,26)) I FOLOR S PSREASON="Duplicate Renewal Request" D ERROR^PSJHL9 Q 72 I ND I ROC="R" S CHK=$S(PREON["V":$P(ND,U,17),1:$P(ND,U,9)) I "AE"'[CHK S PSREASON="Pharmacy orders with a status of "_CHK_" may not be renewed" D ERROR^PSJHL9 Q 73 I $G(CHK)="E" I PREON'["V" D NOW^%DTC S X1=+$E(%,1,12),X2=-4 D C^%DTC S STDT=$S(PREON["V":$P(ND,U,3),1:$P(ND2,U,4)) I STDT'>X S PSREASON="Pharmacy orders expired longer than 4 days may not be renewed" D ERROR^PSJHL9 Q 74 I ND I ROC="E" S FOLOR=$S(PREON["V":$P(ND2,U,6),1:$P(ND,U,26)) I FOLOR S PSREASON="Pharmacy orders may only be edited ONCE" D ERROR^PSJHL9 Q 75 I ND I ROC="E" S CHK=$S(PREON["V":$P(ND,U,17),1:$P(ND,U,9)) I "DEHO"[CHK N CHKRTN S CHKRTN=CHK_"^PSJHL6" D @CHKRTN S PSREASON=PSREASON_" orders may not be edited" D ERROR^PSJHL9 Q 76 D:ROC'="R" VALID^PSJHL9 Q:QFLG 77 I $G(PSITEM)="",$D(^TMP("PSJNVO",$J,"SOL",1,0)) S PSITEM=$P($G(^PS(52.7,+^TMP("PSJNVO",$J,"SOL",1,0),0)),"^",11) 78 I PRIORITY="ZD" D VALID^PSJHL10 S QFLG=1 Q 79 I (PREON]"")&(ROC="E") D EDITCK^PSJHL5 Q:QFLG 80 D NVO^PSJHL9 81 I (PREON]"")&(ROC="R") D RENEW^PSJHL7 Q 82 I (PREON]"")&(ROC="E") D EDIT^PSJHL5 83 Q 84 ; 85 SOLSRCH ;Find solution 86 N SSSS,SEG,ON,ROC,SOL,SOL2 87 F SSSS=II:0 S SSSS=$O(PSJMSG(SSSS)) Q:'SSSS I $P(PSJMSG(SSSS),"|")="ZRX" D Q 88 .S SEG=$G(PSJMSG(SSSS)),ON=$P(SEG,"|",2),ROC=$P(SEG,"|",4) 89 I $G(ROC)'="N" F SOL=0:0 S SOL=$O(^PS(55,PSJHLDFN,"IV",+ON,"SOL",SOL)) Q:'SOL S SOL2=$G(^PS(55,PSJHLDFN,"IV",+ON,"SOL",SOL,0)) I $D(^PS(52.7,"AOI",PTR,+SOL2))&($P(SOL2,U,2)=VOLUME) S SOLUTION=+SOL2 D SET Q 90 I 'SOLUTION S SOLUTION=$O(^PS(52.7,"AOI",PTR,SOLUTION)) D SET 91 Q 92 SET ;Set solution tmp nodes 93 Q:'+SOLUTION 94 S ^TMP("PSJNVO",$J,"SOL",0)=SOLCNT 95 S ^TMP("PSJNVO",$J,"SOL",SOLCNT,0)=SOLUTION_"^"_VOLUME,TVOLUME=TVOLUME+(+VOLUME) 96 Q 97 ; 98 SNDTSTW(PRIO,PSJSCHED,WARD) ; Test to determine if mail message should be sent. 99 N SNPRIO,SNSCHD,SNOPT 100 S SNPRIO=$S(PRIO="S":"S",PRIO="A":"A",1:"R") 101 S SNSCHD=$S(PSJSCHED="STAT":"S",PSJSCHED="NOW":"N",1:"R") 102 S SNOPT=$P($G(^PS(59.6,WARD,0)),"^",32) 103 S:SNOPT="" SNOPT=$P($G(^PS(59.7,1,27)),"^",1) 104 Q:SNOPT="" 0 105 Q:SNOPT[SNPRIO 0 106 Q:SNOPT[SNSCHD 0 107 Q 1 108 ; 109 SNDTSTP(PRIO,PSJSCHED) ; Test to determine if mail message should be sent. 110 N SNPRIO,SNSCHD,SNOPT 111 S SNPRIO=$S(PRIO="S":"S",PRIO="A":"A",1:"R") 112 S SNSCHD=$S(PSJSCHED="STAT":"S",PSJSCHED="NOW":"N",1:"R") 113 S SNOPT=$P($G(^PS(59.7,1,27)),"^",1) 114 Q:SNOPT="" 1 115 Q:SNOPT[SNPRIO 0 116 Q:SNOPT[SNSCHD 0 117 Q 1 118 ; 119 SNDTSTA(PRIO,PSJSCHED) ; Test to determine if mail message should be sent. 120 N SNPRIO,SNSCHD,SNOPT 121 S SNPRIO=$S(PRIO="S":"S",PRIO="A":"A",1:"R") 122 S SNSCHD=$S(PSJSCHED="STAT":"S",PSJSCHED="NOW":"N",1:"R") 123 S SNOPT=$P($G(^PS(59.7,1,27)),"^",2) 124 S:SNOPT="" SNOPT=$P($G(^PS(59.7,1,27)),"^",1) 125 Q:SNOPT="" 1 126 Q:SNOPT[SNPRIO 0 127 Q:SNOPT[SNSCHD 0 128 Q 1 129 ; 130 TMPAT(SCHEDULE) ; Extract admin times from schedule in format schedule@schedule 131 S TMPAT="" I SCHEDULE'["@" Q TMPAT 132 S TMPAT=$P(SCHEDULE,"@",2) I TMPAT]"" D 133 .N WARD S WARD=$G(^DPT(PSJHLDFN,.1)) I WARD]"" D 134 ..N DIC,X,Y S DIC="^DIC(42,",DIC(0)="BOXZ",X=WARD D ^DIC S WARD=+Y Q:WARD=0 135 ..S WARD=$O(^PS(59.6,"B",WARD,0)) 136 .I '$D(^PS(51.1,"AC","PSJ",TMPAT)) S TMPAT="" Q 137 .N II I '$$DOW^PSIVUTL($P(SCHEDULE,"@")) S TMPAT="" Q 138 .N TMPIEN S TMPIEN=$O(^PS(51.1,"AC","PSJ",TMPAT,0)),TMPAT=$P($G(^PS(51.1,+TMPIEN,0)),"^",2) D 139 ..I $P($G(^PS(51.1,+TMPIEN,1,+$G(WARD),0)),"^",2) S TMPAT=$P($G(^(0)),"^",2) 140 Q TMPAT 141 ; 142 XMD ; Mailman call for NOTIFY^PSJHL4 143 ; Input - PNAME = Patient Name 144 ; RTE = Route 145 ; DRUG = Drug Name 146 ; WARD = Ward Name 147 ; PRIO = CPRS Order Priority 148 S PNAME=$P($G(^DPT(+PSJHLDFN,0)),"^") S:$G(RTE) RTE=$P(^PS(51.2,+RTE,0),"^",3) 149 S DRUG=$S(DRIEN:$P($G(^PS(50.7,+DRIEN,0)),"^"),1:""),WARD=$G(^DPT(PSJHLDFN,.1)) 150 S XMDUZ="MEDICATIONS,INPATIENT",XMSUB=$G(WARD) 151 S XMSUB=XMSUB_"-"_NTFSTAT_" "_$S($G(PRIO)="A":"ASAP",$G(PRIO)="S":"STAT",$G(NTFYREAS)=2:"NOW",$G(NTFYREAS)=3:"STAT",1:"")_"-" 152 S XMSUB=XMSUB_$E(PNAME,1,65-$L(XMSUB)) 153 S XMTEXT="PSG(" 154 S PSG(1,0)="Inpatient Medications has received the following "_$S($G(PRIO)="A":"ASAP",$G(PRIO)="S":"STAT",$G(NTFYREAS)=2:"NOW",1:"")_" order ("_NTFSTAT_")" 155 S PSG(2,0)="" 156 S PSG(3,0)=" Patient: "_PNAME I $G(LASTFOUR) S PSG(3,0)=PSG(3,0)_" ("_LASTFOUR_")" 157 S PSG(4,0)="Order Information: "_DRUG_" "_DO_" "_RTE_" "_$G(PSJSCHED) 158 S PSG(5,0)=" Order Date: "_$$ENDTC^PSGMI(ORDATE) 159 D ^XMD 160 Q 1 PSJHL4A ;BIR/RLW-CONTINUE DECODE HL7 /MESSSAGE FROM OE/RR ;16 Mar 99 / 4:55 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**105,111,154,170,159**;16 DEC 97;Build 15 3 ; 4 ; Reference to ^PS(52.6 is supported by DBIA# 1231. 5 ; Reference to ^PS(52.7 is supported by DBIA# 2173. 6 ; Reference to ^PS(55 is supported by DBIA# 2191. 7 ; Reference to ^PS(59.7 supported by DBIA #2181. 8 ; 9 RXC ; IV order 10 N IVFL 11 S APPL=FIELD(1) 12 I APPL["B" S SOLCNT=SOLCNT+1,PTR=$P(FIELD(2),"^",4) Q:'PTR S VOLUME=+FIELD(3)_" ML" D I '$D(^TMP("PSJNVO",$J,"SOL",SOLCNT,0)) D SOLSRCH 13 .S SOLUTION="" F S SOLUTION=$O(^PS(52.7,"AOI",PTR,SOLUTION)) Q:'SOLUTION S INACT=$G(^PS(52.7,SOLUTION,"I")) I 'INACT!(INACT>DT) I VOLUME=$P(^PS(52.7,SOLUTION,0),U,3) D 14 ..S ^TMP("PSJNVO",$J,"SOL",0)=SOLCNT 15 ..S ^TMP("PSJNVO",$J,"SOL",SOLCNT,0)=SOLUTION_"^"_VOLUME,TVOLUME=TVOLUME+(+VOLUME) 16 I $G(INFRT)]"" S X=INFRT D ENI^PSJHLU S INFRT=$G(X) 17 I APPL="A" S ADCNT=ADCNT+1,PTR=$P(FIELD(2),"^",4) Q:'PTR S STRENGTH=$G(FIELD(3))_" "_$P($G(FIELD(4)),"^",5) D I '$D(^TMP("PSJNVO",$J,"AD",ADCNT,0)) S PSREASON="Can't find matching additive" D ERROR^PSJHL9 Q 18 .S ADDITIVE="" F S ADDITIVE=$O(^PS(52.6,"AOI",PTR,ADDITIVE)) Q:'ADDITIVE S INACT=$G(^PS(52.6,ADDITIVE,"I")),IVFL=$P($G(^(0)),"^",13) I 'INACT!(INACT>DT),IVFL'=0 Q:$G(^PS(52.6,ADDITIVE,0))']"" D Q:ADDITIVE 19 ..I $G(PSITEM)="" S PSITEM=PTR 20 ..S ^TMP("PSJNVO",$J,"AD",0)=ADCNT 21 ..S ^TMP("PSJNVO",$J,"AD",ADCNT,0)=ADDITIVE_"^"_STRENGTH 22 Q 23 ; 24 RXO ; 25 I $O(PSJMSG(II,0)) D 26 .K SEGMENT 27 .N KK,JJ,XX 28 .S SEGMENT(1)=$G(PSJMSG(II)) 29 .S KK=1,JJ="" F S JJ=$O(PSJMSG(II,JJ)) Q:'JJ S KK=KK+1,SEGMENT(KK)=$G(PSJMSG(II,JJ)) 30 .S KK=1,JJ=0 31 .F Q:'$D(SEGMENT(KK)) D 32 ..I SEGMENT(KK)["|" S FIELD(JJ)=$P(SEGMENT(KK),"|"),SEGMENT(KK)=$E(SEGMENT(KK),$L(FIELD(JJ))+2,$L(SEGMENT(KK))),JJ=JJ+1 Q 33 ..I SEGMENT(KK)'["|" S FIELD(JJ)=SEGMENT(KK),KK=KK+1 Q:'$D(SEGMENT(KK)) D 34 ...S XX=$P(SEGMENT(KK),"|"),SEGMENT(KK)=$E(SEGMENT(KK),$L(X)+2,$L(SEGMENT(KK))),FIELD(JJ)=FIELD(JJ)_XX,JJ=JJ+1 35 S APPL="",PSITEM=$S($P(FIELD(1),"^",5)="IV":"",1:$P(FIELD(1),"^",4)) 36 S:$P(FIELD(1),"^",6)="ORD" PSITEM="" 37 S:$P(FIELD(1),"^",5)="IV" IVTYP="A",SCHTYP="C",INFRT=$G(FIELD(2)) 38 S DISPENSE=$P($G(FIELD(10)),"^",4) 39 S IVLIMIT=$P($G(PSJMSG(II)),"^",3) 40 Q 41 ; 42 OBX ; 43 S OBXFL=1,OCNARR=FIELD(5),OCPROV=CLERK,OCCNT=OCCNT+1 44 S ^TMP("PSJNVO",$J,10,0)=OCCNT 45 S ^TMP("PSJNVO",$J,10,OCCNT,0)=OCNARR 46 S ^TMP("PSJNVO",$J,10,OCCNT,1)=$P($G(^VA(200,+OCPROV,0)),"^") 47 Q 48 ; 49 NTE ; 50 S TEXT=$S((FIELD(1)=6)&('OBXFL):"PROCOM",(FIELD(1)=7)&('OBXFL):"ADMINSTR",1:"OCRSN") 51 S @TEXT@(1)=$G(FIELD(3)) 52 S K=1,J="" F S J=$O(PSJMSG(II,J)) Q:'J S K=K+1,@TEXT@(K)=$G(PSJMSG(II,J)) 53 D:$D(OCRSN) 54 .S QQ=0 F S QQ=$O(OCRSN(QQ)) Q:'QQ S ^TMP("PSJNVO",$J,10,OCCNT,2,QQ,0)=OCRSN(QQ) 55 S OBXFL=0 56 Q 57 ; 58 ZRX ; 59 N ND,ND2,CHK,FOLOR,STDT 60 S PREON=$G(FIELD(1)),ROC=$G(FIELD(3)) 61 S ND=$S((PREON["N")!(PREON["P"):$G(^PS(53.1,+PREON,0)),PREON["V":$G(^PS(55,PSJHLDFN,"IV",+PREON,0)),1:$G(^PS(55,PSJHLDFN,5,+PREON,0))) 62 S ND2=$S((PREON["N")!(PREON["P"):$G(^PS(53.1,+PREON,2)),PREON["V":$G(^PS(55,PSJHLDFN,"IV",+PREON,2)),1:$G(^PS(55,PSJHLDFN,5,+PREON,2))) 63 I 'ND I ROC'="N" S PSREASON="Invalid Pharmacy order number" D ERROR^PSJHL9 Q 64 I ND I ROC="R" S FOLOR=$S(PREON["V":$P(ND2,U,6),1:$P(ND,U,26)) I FOLOR S PSREASON="Duplicate Renewal Request" D ERROR^PSJHL9 Q 65 I ND I ROC="R" S CHK=$S(PREON["V":$P(ND,U,17),1:$P(ND,U,9)) I "AE"'[CHK S PSREASON="Pharmacy orders with a status of "_CHK_" may not be renewed" D ERROR^PSJHL9 Q 66 I $G(CHK)="E" I PREON'["V" D NOW^%DTC S X1=+$E(%,1,12),X2=-4 D C^%DTC S STDT=$S(PREON["V":$P(ND,U,3),1:$P(ND2,U,4)) I STDT'>X S PSREASON="Pharmacy orders expired longer than 4 days may not be renewed" D ERROR^PSJHL9 Q 67 I ND I ROC="E" S FOLOR=$S(PREON["V":$P(ND2,U,6),1:$P(ND,U,26)) I FOLOR S PSREASON="Pharmacy orders may only be edited ONCE" D ERROR^PSJHL9 Q 68 I ND I ROC="E" S CHK=$S(PREON["V":$P(ND,U,17),1:$P(ND,U,9)) I "DEHO"[CHK N CHKRTN S CHKRTN=CHK_"^PSJHL6" D @CHKRTN S PSREASON=PSREASON_" orders may not be edited" D ERROR^PSJHL9 Q 69 D:ROC'="R" VALID^PSJHL9 Q:QFLG 70 I $G(PSITEM)="",$D(^TMP("PSJNVO",$J,"SOL",1,0)) S PSITEM=$P($G(^PS(52.7,+^TMP("PSJNVO",$J,"SOL",1,0),0)),"^",11) 71 I PRIORITY="ZD" D VALID^PSJHL10 S QFLG=1 Q 72 I (PREON]"")&(ROC="E") D EDITCK^PSJHL5 Q:QFLG 73 D NVO^PSJHL9 74 I (PREON]"")&(ROC="R") D RENEW^PSJHL7 Q 75 I (PREON]"")&(ROC="E") D EDIT^PSJHL5 76 Q 77 ; 78 SOLSRCH ;Find solution 79 N SSSS,SEG,ON,ROC,SOL,SOL2 80 F SSSS=II:0 S SSSS=$O(PSJMSG(SSSS)) Q:'SSSS I $P(PSJMSG(SSSS),"|")="ZRX" D Q 81 .S SEG=$G(PSJMSG(SSSS)),ON=$P(SEG,"|",2),ROC=$P(SEG,"|",4) 82 I $G(ROC)'="N" F SOL=0:0 S SOL=$O(^PS(55,PSJHLDFN,"IV",+ON,"SOL",SOL)) Q:'SOL S SOL2=$G(^PS(55,PSJHLDFN,"IV",+ON,"SOL",SOL,0)) I $D(^PS(52.7,"AOI",PTR,+SOL2))&($P(SOL2,U,2)=VOLUME) S SOLUTION=+SOL2 D SET Q 83 I 'SOLUTION S SOLUTION=$O(^PS(52.7,"AOI",PTR,SOLUTION)) D SET 84 Q 85 SET ;Set solution tmp nodes 86 Q:'+SOLUTION 87 S ^TMP("PSJNVO",$J,"SOL",0)=SOLCNT 88 S ^TMP("PSJNVO",$J,"SOL",SOLCNT,0)=SOLUTION_"^"_VOLUME,TVOLUME=TVOLUME+(+VOLUME) 89 Q 90 ; 91 SNDTSTW(PRIO,PSJSCHED,WARD) ; Test to determine if mail message should be sent. 92 N SNPRIO,SNSCHD,SNOPT 93 S SNPRIO=$S(PRIO="S":"S",PRIO="A":"A",1:"R") 94 S SNSCHD=$S(PSJSCHED="STAT":"S",PSJSCHED="NOW":"N",1:"R") 95 S SNOPT=$P($G(^PS(59.6,WARD,0)),"^",32) 96 S:SNOPT="" SNOPT=$P($G(^PS(59.7,1,27)),"^",1) 97 Q:SNOPT="" 0 98 Q:SNOPT[SNPRIO 0 99 Q:SNOPT[SNSCHD 0 100 Q 1 101 ; 102 SNDTSTP(PRIO,PSJSCHED) ; Test to determine if mail message should be sent. 103 N SNPRIO,SNSCHD,SNOPT 104 S SNPRIO=$S(PRIO="S":"S",PRIO="A":"A",1:"R") 105 S SNSCHD=$S(PSJSCHED="STAT":"S",PSJSCHED="NOW":"N",1:"R") 106 S SNOPT=$P($G(^PS(59.7,1,27)),"^",1) 107 Q:SNOPT="" 1 108 Q:SNOPT[SNPRIO 0 109 Q:SNOPT[SNSCHD 0 110 Q 1 111 ; 112 SNDTSTA(PRIO,PSJSCHED) ; Test to determine if mail message should be sent. 113 N SNPRIO,SNSCHD,SNOPT 114 S SNPRIO=$S(PRIO="S":"S",PRIO="A":"A",1:"R") 115 S SNSCHD=$S(PSJSCHED="STAT":"S",PSJSCHED="NOW":"N",1:"R") 116 S SNOPT=$P($G(^PS(59.7,1,27)),"^",2) 117 S:SNOPT="" SNOPT=$P($G(^PS(59.7,1,27)),"^",1) 118 Q:SNOPT="" 1 119 Q:SNOPT[SNPRIO 0 120 Q:SNOPT[SNSCHD 0 121 Q 1 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJHL5.m
r613 r623 1 PSJHL5 ;BIR/LDT-ACTIONS ON HL7 MESSAGES FROM OE/RR ;28 Jan 98 / 3:34 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,28,39,40,42,84,85,95,80,173,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to EN^ORERR is supported by DBIA# 2187. 6 ; Reference to NURV^ALPBCBU is supported by DBIA# 4120. 7 ; Reference to UNESC^ORHLESC is supported by DBIA# 4922 8 ; 9 ASSIGN ; number assigned, update ORDERS FILE ENTRY 10 S RXORDER=RXORDER_"0)" 11 I '$P($G(@RXORDER),U) S ORDCON="Invalid Pharmacy order number/Number Assign Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 12 Q:'$P($G(@RXORDER),U) 13 I RXON["P",PSJHLDFN'=$P($G(@(RXORDER)),U,15) S ORDCON="Patient does not match/Number Assign Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 14 I RXON["P",PSJHLDFN'=$P($G(@(RXORDER)),U,15) Q 15 S $P(@RXORDER,"^",21)=PSJORDER 16 Q 17 ; 18 NURSEACK ;Nurse Acknowledgement of Pending Orders 19 I '$P($G(@(RXORDER_"0)")),U) S ORDCON="Invalid Pharmacy order number/Nurse Acknowledgement Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 20 Q:'$P($G(@(RXORDER_"0)")),U) 21 I RXON["P",PSJHLDFN'=$P($G(@(RXORDER_"0)")),U,15) S ORDCON="Patient does not match/Nurse Acknowledgement Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 22 I RXON["P",PSJHLDFN'=$P($G(@(RXORDER_"0)")),U,15) Q 23 I RXON["P" N STATUS S STATUS=$P($G(@(RXORDER_"0)")),U,9) D:STATUS="N" EN^PSJHLV(PSJHLDFN,RXON) 24 I RXON["P" N STATUS S STATUS=$P($G(@(RXORDER_"0)")),U,9) Q:STATUS="A" 25 N DIE,DA 26 S DIE=$S(RXON["N"!(RXON["P"):"^PS(53.1,",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"",",1:"^PS(55,"_PSJHLDFN_",5,"),DA=+RXON,DA(1)=PSJHLDFN 27 S DR="16////"_NURSEACK_";17////"_ACKDATE S:RXON["U" DR=DR_";51////1" S:RXON["V" DR=DR_";143////1",PSIVACT="" 28 I RXON["U" D NEWUDAL^PSGAL5(PSJHLDFN,RXON,22010) 29 I RXON["P" D NEWNVAL^PSGAL5(RXON,22010) 30 S PSGNVF=1 D ^DIE 31 I RXON["V" NEW ON55,DFN,PSIVAL,PSIVREA,PSIVLN K PSIVACT D 32 . S ON55=RXON,DFN=PSJHLDFN,PSIVAL="ORDER VERIFIED BY NURSE",PSIVALT="",PSIVREA="V" 33 . D LOG^PSIVORAL 34 D:RXON["P" EN^PSJLOI(PSJHLDFN,RXON) D:RXON["U" EN2^PSJLOI(PSJHLDFN,RXON) 35 K:RXON["U" ^PS(55,"ANV",PSJHLDFN,+RXON) 36 I $T(NURV^ALPBCBU)'="" D NURV^ALPBCBU(PSJHLDFN,RXON) 37 Q 38 ; 39 EDIT ;Edit orders thru OE/RR 40 N DA,DR,DIE,PREORDER,STPDT,PSIVACT,PSIVALT,ON55,PSIVREA,PSIVALCK,P 41 S PREORDER=$S((PREON["N")!(PREON["P"):"^PS(53.1,"_+PREON_",2)",PREON["V":"^PS(55,"_PSJHLDFN_",""IV"","_+PREON_",0)",1:"^PS(55,"_PSJHLDFN_",5,"_+PREON_",2)") 42 S STPDT=$S(PREON["V":$P($G(@PREORDER),"^",3),1:$P($G(@PREORDER),"^",4)) 43 D NOW^%DTC 44 S DIE=$S(PREON["N"!(PREON["P"):"^PS(53.1,",PREON["V":"^PS(55,"_PSJHLDFN_",""IV"",",1:"^PS(55,"_PSJHLDFN_",5,"),DA=+PREON,DA(1)=+PSJHLDFN 45 S DR=$S(PREON["V":"100////D;116////^S X=STPDT;123////E;114////"_PSJORDER_";.03////"_%,((PREON["P")!(PREON["N")):"25////"_%_";28////DE;107////E;105////"_PSJORDER_";32////"_STPDT,1:"25////"_STPDT_";28////DE;107////E;105////"_PSJORDER_";34////"_%) 46 I PREON["U"!(PREON["A") S PSGAL("C")=4100 D ^PSGAL5 47 I PREON["V" S PSIVACT=1,PSIVALT=2,ON55=PREON,PSIVREA="D",PSIVALCK="STOP",P(3)=STPDT 48 D ^DIE,AUE^PSJHL6(PSJHLDFN,PREON) 49 I PREON["V" N DFN S DFN=PSJHLDFN D LOG^PSIVORAL 50 S PSJHLMTN="ORM",PSOC=$S((PREON["N")!(PREON["P"):"OC",1:"OD") D EN1^PSJHL2(PSJHLDFN,PSOC,PREON) S PSJHLMTN="ORR",PSOC="XO" 51 Q 52 ; 53 EDITCK ;Check to see if PSJHLDFN passed matches PSJHLDFN in pending order. 54 I (PREON["N")!(PREON["P"),PSJHLDFN'=$P($G(^PS(53.1,+PREON,0)),U,15) D 55 . S ORDCON="Patient does not match/Edit Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) 56 . D EN1^PSJHLERR(PSJHLDFN,"UX",$P(ORDER,"^"),ORDCON) S QFLG=1 57 Q 58 ; 59 STATUS ;Check status of an order in response to a send order status request from CPRS. 60 N STATUS,STPDT,NODE,NODE2 61 S NODE=$G(@(RXORDER_"0)")),NODE2=$G(@(RXORDER_"2)")) 62 I 'NODE S PSREASON="Invalid Pharmacy order number" D Q 63 .S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(PSREASON_"/Status Check",.PSJMSG) 64 .D EN1^PSJHLERR(PSJHLDFN,"DE",$P(ORDER,U),PSREASON) 65 S $P(@(RXORDER_"0)"),"^",21)=$P(ORDER,"^") 66 S STATUS=$S(RXON["V":$P(NODE,"^",17),1:$P(NODE,"^",9)) 67 S STPDT=$S(RXON["V":$P(NODE,"^",3),1:$P(NODE2,"^",4)) 68 D NOW^%DTC I RXON'["P" I "DEH"'[STATUS I STPDT<% D EXPIR^PSJHL6 Q 69 D EN1^PSJHL2(PSJHLDFN,"SC",RXON) 70 Q 71 ; 72 FLAG ;Flag/Unflag orders 73 I '$P($G(@(RXORDER_"0)")),U) S ORDCON="Invalid Pharmacy order number/Flag Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 74 Q:'$P($G(@(RXORDER_"0)")),U) 75 S DIE=$S(RXON["N"!(RXON["P"):"^PS(53.1,",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"",",1:"^PS(55,"_PSJHLDFN_",5,"),DA=+RXON,DA(1)=PSJHLDFN 76 S DR=$S(PSJFLAG="FL":$S(RXON["V":"148////1",1:"124////1"),1:$S(RXON["V":"148////@",1:"124////@")) 77 D ^DIE 78 I $G(FLCMNT)]"" S FLCMNT=$$UNESC^ORHLESC(FLCMNT) 79 I RXON["U" D 80 . S ^PS(55,PSJHLDFN,5,+RXON,13)=FLCMNT 81 . S FLCMNT="COMMENTS: "_FLCMNT S:$L(FLCMNT)>52 FLCMNT=$E(FLCMNT,1,49)_"..." 82 . D NEWUDAL^PSGAL5(PSJHLDFN,+RXON,$S((PSJFLAG="FL")&(PSJYN="PHR"):7000,(PSJFLAG="UF")&(PSJYN="PHR"):7010,(PSJFLAG="FL")&(PSJYN=""):7020,1:7030),FLCMNT) 83 I RXON["V" N DFN,ON55,PSIVREA,PSIVAL S DFN=PSJHLDFN S PSIVALT="",ON55=RXON,PSIVREA=$S(PSJFLAG="FL":"G",1:"UG"),PSIVAL=$S(PSJYN="PHR":"FLAGGED BY PHARMACIST ",1:"FLAGGED BY CPRS ")_FLCMNT D LOG^PSIVORAL 84 I RXON["P" D 85 . S ^PS(53.1,+RXON,13)=FLCMNT 86 . S FLCMNT="COMMENTS: "_FLCMNT S:$L(FLCMNT)>52 FLCMNT=$E(FLCMNT,1,49)_"..." 87 . D NEWNVAL^PSGAL5(+RXON,$S((PSJFLAG="FL")&(PSJYN="PHR"):7000,(PSJFLAG="UF")&(PSJYN="PHR"):7010,(PSJFLAG="FL")&(PSJYN=""):7020,1:7030),FLCMNT) 88 ;The ... on Unit Dose and Pending orders is because of the limitations in the DD of 53.1. 89 Q 1 PSJHL5 ;BIR/LDT-ACTIONS ON HL7 MESSAGES FROM OE/RR ;28 Jan 98 / 3:34 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,28,39,40,42,84,85,95,80,173**;16 DEC 97;Build 4 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to EN^ORERR is supported by DBIA# 2187. 6 ; Reference to NURV^ALPBCBU is supported by DBIA# 4120. 7 ; 8 ASSIGN ; number assigned, update ORDERS FILE ENTRY 9 S RXORDER=RXORDER_"0)" 10 I '$P($G(@RXORDER),U) S ORDCON="Invalid Pharmacy order number/Number Assign Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 11 Q:'$P($G(@RXORDER),U) 12 I RXON["P",PSJHLDFN'=$P($G(@(RXORDER)),U,15) S ORDCON="Patient does not match/Number Assign Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 13 I RXON["P",PSJHLDFN'=$P($G(@(RXORDER)),U,15) Q 14 S $P(@RXORDER,"^",21)=PSJORDER 15 Q 16 ; 17 NURSEACK ;Nurse Acknowledgement of Pending Orders 18 I '$P($G(@(RXORDER_"0)")),U) S ORDCON="Invalid Pharmacy order number/Nurse Acknowledgement Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 19 Q:'$P($G(@(RXORDER_"0)")),U) 20 I RXON["P",PSJHLDFN'=$P($G(@(RXORDER_"0)")),U,15) S ORDCON="Patient does not match/Nurse Acknowledgement Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 21 I RXON["P",PSJHLDFN'=$P($G(@(RXORDER_"0)")),U,15) Q 22 I RXON["P" N STATUS S STATUS=$P($G(@(RXORDER_"0)")),U,9) D:STATUS="N" EN^PSJHLV(PSJHLDFN,RXON) 23 I RXON["P" N STATUS S STATUS=$P($G(@(RXORDER_"0)")),U,9) Q:STATUS="A" 24 N DIE,DA 25 S DIE=$S(RXON["N"!(RXON["P"):"^PS(53.1,",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"",",1:"^PS(55,"_PSJHLDFN_",5,"),DA=+RXON,DA(1)=PSJHLDFN 26 S DR="16////"_NURSEACK_";17////"_ACKDATE S:RXON["U" DR=DR_";51////1" S:RXON["V" DR=DR_";143////1",PSIVACT="" 27 I RXON["U" D NEWUDAL^PSGAL5(PSJHLDFN,RXON,22010) 28 I RXON["P" D NEWNVAL^PSGAL5(RXON,22010) 29 S PSGNVF=1 D ^DIE 30 I RXON["V" NEW ON55,DFN,PSIVAL,PSIVREA,PSIVLN K PSIVACT D 31 . S ON55=RXON,DFN=PSJHLDFN,PSIVAL="ORDER VERIFIED BY NURSE",PSIVALT="",PSIVREA="V" 32 . D LOG^PSIVORAL 33 D:RXON["P" EN^PSJLOI(PSJHLDFN,RXON) D:RXON["U" EN2^PSJLOI(PSJHLDFN,RXON) 34 K:RXON["U" ^PS(55,"ANV",PSJHLDFN,+RXON) 35 I $T(NURV^ALPBCBU)'="" D NURV^ALPBCBU(PSJHLDFN,RXON) 36 Q 37 ; 38 EDIT ;Edit orders thru OE/RR 39 N DA,DR,DIE,PREORDER,STPDT,PSIVACT,PSIVALT,ON55,PSIVREA,PSIVALCK,P 40 S PREORDER=$S((PREON["N")!(PREON["P"):"^PS(53.1,"_+PREON_",2)",PREON["V":"^PS(55,"_PSJHLDFN_",""IV"","_+PREON_",0)",1:"^PS(55,"_PSJHLDFN_",5,"_+PREON_",2)") 41 S STPDT=$S(PREON["V":$P($G(@PREORDER),"^",3),1:$P($G(@PREORDER),"^",4)) 42 D NOW^%DTC 43 S DIE=$S(PREON["N"!(PREON["P"):"^PS(53.1,",PREON["V":"^PS(55,"_PSJHLDFN_",""IV"",",1:"^PS(55,"_PSJHLDFN_",5,"),DA=+PREON,DA(1)=+PSJHLDFN 44 S DR=$S(PREON["V":"100////D;116////^S X=STPDT;123////E;114////"_PSJORDER_";.03////"_%,((PREON["P")!(PREON["N")):"25////"_%_";28////DE;107////E;105////"_PSJORDER_";32////"_STPDT,1:"25////"_STPDT_";28////DE;107////E;105////"_PSJORDER_";34////"_%) 45 I PREON["U"!(PREON["A") S PSGAL("C")=4100 D ^PSGAL5 46 I PREON["V" S PSIVACT=1,PSIVALT=2,ON55=PREON,PSIVREA="D",PSIVALCK="STOP",P(3)=STPDT 47 D ^DIE,AUE^PSJHL6(PSJHLDFN,PREON) 48 I PREON["V" N DFN S DFN=PSJHLDFN D LOG^PSIVORAL 49 S PSJHLMTN="ORM",PSOC=$S((PREON["N")!(PREON["P"):"OC",1:"OD") D EN1^PSJHL2(PSJHLDFN,PSOC,PREON) S PSJHLMTN="ORR",PSOC="XO" 50 Q 51 ; 52 EDITCK ;Check to see if PSJHLDFN passed matches PSJHLDFN in pending order. 53 I (PREON["N")!(PREON["P"),PSJHLDFN'=$P($G(^PS(53.1,+PREON,0)),U,15) D 54 . S ORDCON="Patient does not match/Edit Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) 55 . D EN1^PSJHLERR(PSJHLDFN,"UX",$P(ORDER,"^"),ORDCON) S QFLG=1 56 Q 57 ; 58 STATUS ;Check status of an order in response to a send order status request from CPRS. 59 N STATUS,STPDT,NODE,NODE2 60 S NODE=$G(@(RXORDER_"0)")),NODE2=$G(@(RXORDER_"2)")) 61 I 'NODE S PSREASON="Invalid Pharmacy order number" D Q 62 .S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(PSREASON_"/Status Check",.PSJMSG) 63 .D EN1^PSJHLERR(PSJHLDFN,"DE",$P(ORDER,U),PSREASON) 64 S $P(@(RXORDER_"0)"),"^",21)=$P(ORDER,"^") 65 S STATUS=$S(RXON["V":$P(NODE,"^",17),1:$P(NODE,"^",9)) 66 S STPDT=$S(RXON["V":$P(NODE,"^",3),1:$P(NODE2,"^",4)) 67 D NOW^%DTC I RXON'["P" I "DEH"'[STATUS I STPDT<% D EXPIR^PSJHL6 Q 68 D EN1^PSJHL2(PSJHLDFN,"SC",RXON) 69 Q 70 ; 71 FLAG ;Flag/Unflag orders 72 I '$P($G(@(RXORDER_"0)")),U) S ORDCON="Invalid Pharmacy order number/Flag Msg" S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG) Q 73 Q:'$P($G(@(RXORDER_"0)")),U) 74 S DIE=$S(RXON["N"!(RXON["P"):"^PS(53.1,",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"",",1:"^PS(55,"_PSJHLDFN_",5,"),DA=+RXON,DA(1)=PSJHLDFN 75 S DR=$S(PSJFLAG="FL":$S(RXON["V":"148////1",1:"124////1"),1:$S(RXON["V":"148////@",1:"124////@")) 76 D ^DIE 77 I RXON["U" D 78 . S ^PS(55,PSJHLDFN,5,+RXON,13)=FLCMNT 79 . S FLCMNT="COMMENTS: "_FLCMNT S:$L(FLCMNT)>52 FLCMNT=$E(FLCMNT,1,49)_"..." 80 . D NEWUDAL^PSGAL5(PSJHLDFN,+RXON,$S((PSJFLAG="FL")&(PSJYN="PHR"):7000,(PSJFLAG="UF")&(PSJYN="PHR"):7010,(PSJFLAG="FL")&(PSJYN=""):7020,1:7030),FLCMNT) 81 I RXON["V" N DFN,ON55,PSIVREA,PSIVAL S DFN=PSJHLDFN S PSIVALT="",ON55=RXON,PSIVREA=$S(PSJFLAG="FL":"G",1:"UG"),PSIVAL=$S(PSJYN="PHR":"FLAGGED BY PHARMICIST ",1:"FLAGGED BY CPRS ")_FLCMNT D LOG^PSIVORAL 82 I RXON["P" D 83 . S ^PS(53.1,+RXON,13)=FLCMNT 84 . S FLCMNT="COMMENTS: "_FLCMNT S:$L(FLCMNT)>52 FLCMNT=$E(FLCMNT,1,49)_"..." 85 . D NEWNVAL^PSGAL5(+RXON,$S((PSJFLAG="FL")&(PSJYN="PHR"):7000,(PSJFLAG="UF")&(PSJYN="PHR"):7010,(PSJFLAG="FL")&(PSJYN=""):7020,1:7030),FLCMNT) 86 ;The ... on Unit Dose and Pending orders is because of the limitations in the DD of 53.1. 87 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJHL9.m
r613 r623 1 PSJHL9 ;BIR/LDT-VALIDATE INCOMING HL7 DATA/CREATE NEW ORDER ;08 Jul 99 / 10:50 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,18,31,42,47,50,63,72,75,58,80,110,111,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PSDRUG is supported by DBIA# 2192. 5 ; Reference to ^PS(50.7 is supported by DBIA# 2180. 6 ; Reference to ^PS(51.2 is supported by DBIA# 2178. 7 ; Reference to ^PS(55 is supported by DBIA# 2191. 8 ; Reference to ^ORERR is supported by DBIA# 2187. 9 ; Reference to ^ORHLESC is supported by DBIA# 4922. 10 ; 11 VALID ; 12 I APPL="",PSITEM="" S PSREASON="Missing or invalid Orderable Item" D ERROR Q 13 I PSITEM]"",'$D(^PS(50.7,+PSITEM,0)) S PSREASON="Missing or invalid Orderable Item" D ERROR Q 14 I $G(APPL)'["B",$G(APPL)'["A",+$G(ROUTE)'>0 S PSREASON="Missing or invalid Med Route" D ERROR Q 15 S APPL=$S($G(APPL)["B":"F",$G(APPL)["A":"F",$G(DISPENSE)]"":$$ORTYP(ROUTE,DISPENSE),1:$$TRYAGAIN(ROUTE,PSITEM)) 16 S:APPL="" APPL="IP" 17 I APPL'="F" D 18 .I $G(SCHEDULE)]"" N X S X=SCHEDULE D S SCHEDULE=X 19 ..I X[""""!($A(X)=45)!(X?.E1C.E)!($L(X," ")>3)!($L($P(X,"@"))>70)!($L($P(X,"@",2))>119)!($L(X)<1)!(X["P RN")!(X["PR N") S X="" Q 20 ..I X?.E1L.E S X=$$ENLU^PSGMI(X) 21 ..S X=$$TRIM^XLFSTR(X,"R"," ") 22 ..I X["Q0" S X="" Q 23 .I APPL["U",$G(SCHEDULE)="" S PSREASON="Missing or invalid schedule" D ERROR Q 24 .N DFN S DFN=PSJHLDFN D IN5^VADPT I 'VAIP(5) D:APPT="" I APPL="UN",APPT="" S PSREASON="Cannot place Unit Dose orders for an Outpatient" D ERROR Q 25 .. I APPL="UP" S APPL="IN" Q 26 .. I APPL="IP" S APPL="IN" Q 27 .I $G(ROC)'="R",$G(ROUTE)'>0 S PSREASON="Missing or invalid Med Route" D ERROR Q 28 I APPL="F" D 29 .I '$O(^TMP("PSJNVO",$J,"SOL",0))&('$O(^TMP("PSJNVO",$J,"AD",0))) S PSREASON="IV Fluid orders must have at least one additive or solution" D ERROR Q 30 .I $G(IVCAT)="I",$G(INFRT)="" Q ;Allow intermittent IV orders to have a null infusion rate. 31 .I $G(INFRT)="" S PSREASON="Invalid Infusion Rate" D ERROR Q 32 Q 33 ; 34 ERROR ;Sends error msg to CPRS, logs error in OE/RR Errors file 35 S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(PSREASON,.PSJMSG) 36 D EN1^PSJHLERR(PSJHLDFN,$S(PSOC="XO":"UX",1:"OC"),$P(ORDER,U),PSREASON) S QFLG=1 K ^TMP("PSJNVO",$J) 37 Q 38 ; 39 NVO ; put new orders in non-verified orders file 40 I '$D(ROUTE) S ROUTE="" 41 I $G(ROUTE)="" S:APPL="F" ROUTE=$O(^PS(51.2,"B","INTRAVENOUS",0)) 42 N DA,DR,DIE D ENGNN^PSGOETO S DIE="^PS(53.1," 43 S DR="1////"_PROVIDER_";3////"_$$ESC^ORHLESC(ROUTE)_";4////"_$E(APPL)_";28////P"_";108////"_PSITEM_";27.1////"_LOGIN_";27////"_LOGIN_";.5////"_PSJHLDFN_";.24////"_PRIORITY_";125////"_$G(PRNTON) 44 I $G(LOC)]"" S:$P($G(^SC(+LOC,0)),U,3)="C" DR=DR_";113////"_LOC_";126////"_$G(APPT) 45 I $G(IVCAT)]"" S DR=DR_";128////"_IVCAT S ADMINS="" 46 S:$G(SCHTYP)]"" DR=DR_";7////"_SCHTYP 47 D ^DIE K PSJHLSKP S NEWORDER=DA,PSJORDER=DA_"P" 48 S $P(^PS(55,PSJHLDFN,5.1),"^",2)=PROVIDER 49 S:$G(ORDER)]"" $P(^PS(53.1,DA,0),"^",21)=$P(ORDER,"^") 50 S:$G(APPL)["P" $P(^PS(53.1,DA,0),"^",13)=1 51 S $P(^PS(53.1,DA,0),"^",18)=DA 52 S:$G(ROC)]"" $P(^PS(53.1,DA,0),"^",24)=ROC 53 S:$G(PREON)]"" $P(^PS(53.1,DA,0),"^",25)=PREON 54 S:$G(ADMINS) $P(^PS(53.1,DA,2),"^",5)=ADMINS 55 S:$G(REQST)]"" $P(^PS(53.1,DA,2.5),"^")=REQST 56 ; Transform duration units of doses to a for administrations 57 S:$E(DURATION,1,5)="doses" DURATION=$TR(DURATION,"doses","a") 58 S:$G(DURATION)]"" $P(^PS(53.1,DA,2.5),"^",2)=DURATION 59 S:$G(IVLIMIT)]"" $P(^PS(53.1,DA,2.5),"^",4)=IVLIMIT 60 I $G(REQST)]"",$G(DURATION)]"" S $P(^PS(53.1,DA,2.5),"^",3)=$$STOP(REQST,DURATION) 61 S:$G(INSTR)]"" $P(^PS(53.1,DA,.3),"^")=INSTR 62 I $G(INFRT)]"" D 63 .I INFRT S:(INFRT["Minutes"!(INFRT["Hours")) INFRT="INFUSE OVER "_INFRT 64 .S ^PS(53.1,DA,8)=IVTYP_"^^^^"_INFRT 65 S:$G(FREQ)]"" $P(^PS(53.1,DA,2),"^",6)=FREQ 66 S:$G(SCHTYP)]"" $P(^PS(53.1,DA,0),"^",7)=SCHTYP 67 I $G(APPL)'="I" I $G(INSTR)]"" N X S X=INSTR D STRIP I $S(X?.E1C.E:0,$L(X)>60:0,X="":0,X["^":0,X?1.P:1,1:1) S $P(^PS(53.1,DA,.2),"^",2)=X,$P(^PS(53.1,DA,.2),"^",5,6)=$G(DOSE)_"^"_$$UNESC^ORHLESC($G(UNIT)) 68 S $P(^PS(53.1,DA,.2),"^",3)=ORDCON 69 I $G(SCHEDULE)]"" S $P(^PS(53.1,DA,2),"^")=$$UNESC^ORHLESC(SCHEDULE) 70 I $G(APPL)="I" I $G(UNITS)]"" S $P(^PS(53.1,DA,.3),"^")=$$UNESC^ORHLESC(UNITS) 71 S ^PS(53.1,DA,4)="^^^^^^"_CLERK 72 I $G(DISPENSE) S ^PS(53.1,DA,1,0)="^53.11P^1^1",^PS(53.1,DA,1,1,0)=DISPENSE_"^"_$$UNESC^ORHLESC(UNITS),^PS(53.1,DA,1,"B",$E(DISPENSE,1,30),1)="" 73 I $D(PROCOM) D 74 .I '$D(^PS(53.1,DA,12,0)) S ^(0)="^53.1012^0^0" 75 .S JJ=0 F S JJ=$O(PROCOM(JJ)) Q:'JJ S $P(^PS(53.1,DA,12,0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,12,JJ,0)=$$UNESC^ORHLESC(PROCOM(JJ)) 76 I $D(ADMINSTR) D 77 .I '$D(^PS(53.1,DA,3,0)) S ^(0)="^53.12^0^0" 78 .S JJ=0 F S JJ=$O(ADMINSTR(JJ)) Q:'JJ S $P(^PS(53.1,DA,3,0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,3,JJ,0)=ADMINSTR(JJ) 79 I $D(^TMP("PSJNVO",$J,"AD")) D 80 .S ^PS(53.1,DA,"AD",0)="^53.157PA^0^0" 81 .S JJ=0 F S JJ=$O(^TMP("PSJNVO",$J,"AD",JJ)) Q:'JJ S $P(^PS(53.1,DA,"AD",0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,"AD",JJ,0)=^TMP("PSJNVO",$J,"AD",JJ,0),^PS(53.1,DA,"AD","B",$$UNESC^ORHLESC($P(^TMP("PSJNVO",$J,"AD",JJ,0),"^")),JJ)="" 82 I $D(^TMP("PSJNVO",$J,"SOL")) D 83 .S ^PS(53.1,DA,"SOL",0)="^53.158PA^0^0" 84 .S JJ=0 F S JJ=$O(^TMP("PSJNVO",$J,"SOL",JJ)) Q:'JJ S $P(^PS(53.1,DA,"SOL",0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,"SOL",JJ,0)=^TMP("PSJNVO",$J,"SOL",JJ,0),^PS(53.1,DA,"SOL","B",$P(^TMP("PSJNVO",$J,"SOL",JJ,0),"^"),JJ)="" 85 I $O(^TMP("PSJNVO",$J,10,0)) D 86 .S ^PS(53.1,DA,10,0)="^53.1112A^0^0" 87 .S JJ=0 F S JJ=$O(^TMP("PSJNVO",$J,10,JJ)) Q:'JJ S $P(^PS(53.1,DA,10,0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,10,JJ,0)=$$UNESC^ORHLESC(^TMP("PSJNVO",$J,10,JJ,0)),^PS(53.1,DA,10,"B",$$UNESC^ORHLESC($E(^TMP("PSJNVO",$J,10,JJ,0),1,30)),JJ)="" D 88 ..S ^PS(53.1,DA,10,JJ,1)=$P($G(^VA(200,+CLERK,0)),"^") 89 ..I $O(^TMP("PSJNVO",$J,10,JJ,2,0)) S ^PS(53.1,DA,10,JJ,2,0)="^53.11122^0^0" D 90 ...S QQ=0 F S QQ=$O(^TMP("PSJNVO",$J,10,JJ,2,QQ)) Q:'QQ S $P(^PS(53.1,DA,10,JJ,2,0),"^",3,4)=QQ_"^"_QQ,^PS(53.1,DA,10,JJ,2,QQ,0)=$$UNESC^ORHLESC(^TMP("PSJNVO",$J,10,JJ,2,QQ,0)) 91 Q 92 STRIP ;Strips spaces off the end of instructions. 93 I $E(X,$L(X))=" " F S X=$E(X,1,$L(X)-1) Q:$E(X,$L(X))'=" " 94 Q 95 ; 96 ORTYP(MDRT,DDRG) ;Entry point to determine order type for 53.1 97 ;MDRT=Med Route from 51.2, DDRG=Dispense Drug 98 I '$G(DDRG) S ORTYP="" Q ORTYP 99 I '$D(^PSDRUG(+DDRG,2)) S ORTYP="" Q ORTYP 100 I $P(^PSDRUG(DDRG,2),"^",3)'["I",$P(^PSDRUG(DDRG,2),"^",3)'["U" S ORTYP="" Q ORTYP 101 I '$G(MDRT) S ORTYP="" Q ORTYP 102 I '$D(^PS(51.2,+MDRT,0)) S ORTYP="" Q ORTYP 103 I $P(^PSDRUG(DDRG,2),"^",3)["I",$P(^PSDRUG(DDRG,2),"^",3)'["U",$P(^PS(51.2,MDRT,0),"^",6)=1 S ORTYP="IN" Q ORTYP 104 I $P(^PSDRUG(DDRG,2),"^",3)'["I",$P(^PS(51.2,MDRT,0),"^",6)=1 S ORTYP="UP" Q ORTYP 105 I $P(^PSDRUG(DDRG,2),"^",3)["I",$P(^PS(51.2,MDRT,0),"^",6)=1 S ORTYP="IP" Q ORTYP 106 I $P(^PSDRUG(DDRG,2),"^",3)["I",$P(^PSDRUG(DDRG,2),"^",3)'["U",$P(^PS(51.2,MDRT,0),"^",6)'=1 S ORTYP="IP" Q ORTYP 107 I $P(^PSDRUG(DDRG,2),"^",3)["U",$P(^PSDRUG(DDRG,2),"^",3)'["I",$P(^PS(51.2,MDRT,0),"^",6)'=1 S ORTYP="UN" Q ORTYP 108 I $P(^PSDRUG(DDRG,2),"^",3)["U",$P(^PS(51.2,MDRT,0),"^",6)'=1 S ORTYP="UP" Q ORTYP 109 S ORTYP="" Q ORTYP 110 ; 111 TRYAGAIN(MDRT,OI) ; 112 ;MDRT=Med Route from 51.2, OI=Orderable Item 113 N ORTYPI,ORTYPU,ORTYPP 114 S ORTYP="",ORTYPI=0,ORTYPU=0,ORTYPP=0 115 N DDRG S DDRG=0 F S DDRG=$O(^PSDRUG("ASP",OI,DDRG)) Q:'DDRG D 116 .I $G(^PSDRUG(DDRG,"I"))]"" Q:^PSDRUG(DDRG,"I")'>DT 117 .S ORTYP=$$ORTYP(MDRT,DDRG) D 118 ..I ORTYP["I" S ORTYPI=ORTYPI+1 119 ..I ORTYP["U" S ORTYPU=ORTYPU+1 120 ..I ORTYP["P" S ORTYPP=ORTYPP+1 121 S ORTYP=$S(ORTYPU>ORTYPI:"U",1:"I") S ORTYP=ORTYP_$S(ORTYPP>0:"P",1:"N") 122 Q ORTYP 123 ; 124 STOP(REQST,DURA) ; 125 ;REQST=Requested start date, DURA=Duration from CPRS 126 I DURA["L",DURA?1A1".".N S DAYS=$$DAY($E(REQST,1,5)),DURA="H"_((DAYS*$P(DURA,"L",2))*24) 127 I DURA["L",DURA?1A.1N.N1"."1N.N D Q STOP 128 .S NUM=$E(REQST,4,5)+$P($P(DURA,"."),"L",2),NUM=$S(NUM<10:"0"_NUM,NUM<13:NUM,1:$S((NUM-12)<10:"0"_(NUM-12),1:(NUM-12))),DATE=$E(REQST,1,3)_NUM 129 .S DAYS=$$DAY(DATE),STOP=$$SCH^XLFDT($P($P(DURA,"."),"L",2)_"M",$P(REQST,"."))_"."_$P(REQST,".",2),DEL=$P($P(DURA,"L",2),"."),STOP=$$FMADD^XLFDT(STOP,"",((DAYS*$P(DURA,DEL,2))*24)) 130 I DURA["L" S STOP=$P($$SCH^XLFDT($P(DURA,"L",2)_"M",$P(REQST,".")),".")_"."_$P(REQST,".",2) Q STOP 131 I DURA["W",DURA["." S DURA="H"_(($P(DURA,"W",2)*7)*24) 132 I DURA["D",DURA["." S DURA="H"_($P(DURA,"D",2)*24) 133 I +DURA=DURA,DURA["." S DURA="H"_(DURA*24) 134 S STOP=$$FMADD^XLFDT(REQST,$S(DURA["W":$P(DURA,"W",2)*7,DURA["D":$P(DURA,"D",2),+DURA=DURA:+DURA,1:""),$S(DURA["H":$P(DURA,"H",2),1:""),$S(DURA["M":$P(DURA,"M",2),1:""),$S(DURA["S":$P(DURA,"S",2),1:"")) 135 Q STOP 136 ZQDATE(DATE,MONTHS) ;BUMP DATE BY A MONTH (OR SO) 137 ;; 138 S X=$E($P(DATE,"."),1,5)+($E($P(DATE,"."),4,5)>(12-MONTHS)*88+MONTHS)_$E($P(DATE,"."),6,7) F D ^%DT Q:Y>0 S X=X-1 139 S NEWDATE=X_"."_$P(DATE,".",2) 140 Q NEWDATE 141 DAY(DATE) ;DATE=FIRST FIVE DIGITS OF FM DATE 142 N X 143 I DATE'?5N Q -1 144 S X=$E(DATE,4,5) I X<1!(X>12) Q -1 145 S X=DATE+1+(X=12*88)_"01" 146 Q $E($$FMADD^XLFDT(X,-1),6,7) 1 PSJHL9 ;BIR/LDT-VALIDATE INCOMING HL7 DATA/CREATE NEW ORDER ;08 Jul 99 / 10:50 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,18,31,42,47,50,63,72,75,58,80,110,111**;16 DEC 97 3 ; 4 ; Reference to ^PSDRUG is supported by DBIA# 2192. 5 ; Reference to ^PS(50.7 is supported by DBIA# 2180. 6 ; Reference to ^PS(51.2 is supported by DBIA# 2178. 7 ; Reference to ^PS(55 is supported by DBIA# 2191. 8 ; Reference to ^ORERR is supported by DBIA# 2187. 9 ; 10 VALID ; 11 I APPL="",PSITEM="" S PSREASON="Missing or invalid Orderable Item" D ERROR Q 12 I PSITEM]"",'$D(^PS(50.7,+PSITEM,0)) S PSREASON="Missing or invalid Orderable Item" D ERROR Q 13 I $G(APPL)'["B",$G(APPL)'["A",+$G(ROUTE)'>0 S PSREASON="Missing or invalid Med Route" D ERROR Q 14 S APPL=$S($G(APPL)["B":"F",$G(APPL)["A":"F",$G(DISPENSE)]"":$$ORTYP(ROUTE,DISPENSE),1:$$TRYAGAIN(ROUTE,PSITEM)) 15 S:APPL="" APPL="IP" 16 I APPL'="F" D 17 .I $G(SCHEDULE)]"" N X S X=SCHEDULE D S SCHEDULE=X 18 ..I X[""""!($A(X)=45)!(X?.E1C.E)!($L(X," ")>3)!($L(X)>70)!($L(X)<1)!(X["P RN")!(X["PR N") S X="" Q 19 ..I X?.E1L.E S X=$$ENLU^PSGMI(X) 20 ..S X=$$TRIM^XLFSTR(X,"R"," ") 21 ..I X["Q0" S X="" Q 22 .I APPL["U",$G(SCHEDULE)="" S PSREASON="Missing or invalid schedule" D ERROR Q 23 .N DFN S DFN=PSJHLDFN D IN5^VADPT I 'VAIP(5) D:APPT="" I APPL="UN",APPT="" S PSREASON="Cannot place Unit Dose orders for an Outpatient" D ERROR Q 24 .. I APPL="UP" S APPL="IN" Q 25 .. I APPL="IP" S APPL="IN" Q 26 .I $G(ROC)'="R",$G(ROUTE)'>0 S PSREASON="Missing or invalid Med Route" D ERROR Q 27 I APPL="F" D 28 .I '$O(^TMP("PSJNVO",$J,"SOL",0))&('$O(^TMP("PSJNVO",$J,"AD",0))) S PSREASON="IV Fluid orders must have at least one additive or solution" D ERROR Q 29 .I $G(INFRT)="" S PSREASON="Invalid Infusion Rate" D ERROR Q 30 Q 31 ; 32 ERROR ;Sends error msg to CPRS, logs error in OE/RR Errors file 33 S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(PSREASON,.PSJMSG) 34 D EN1^PSJHLERR(PSJHLDFN,$S(PSOC="XO":"UX",1:"OC"),$P(ORDER,U),PSREASON) S QFLG=1 K ^TMP("PSJNVO",$J) 35 Q 36 ; 37 NVO ; put new orders in non-verified orders file 38 I '$D(ROUTE) S ROUTE="" 39 S:APPL="F" ROUTE=$O(^PS(51.2,"B","INTRAVENOUS",0)) 40 N DA,DR,DIE D ENGNN^PSGOETO S DIE="^PS(53.1," 41 S DR="1////"_PROVIDER_";3////"_ROUTE_";4////"_$E(APPL)_";28////P"_";108////"_PSITEM_";27.1////"_LOGIN_";27////"_LOGIN_";.5////"_PSJHLDFN_";.24////"_PRIORITY_";125////"_$G(PRNTON) 42 I $G(LOC)]"" S:$P($G(^SC(+LOC,0)),U,3)="C" DR=DR_";113////"_LOC_";126////"_$G(APPT) 43 D ^DIE K PSJHLSKP S NEWORDER=DA,PSJORDER=DA_"P" 44 S $P(^PS(55,PSJHLDFN,5.1),"^",2)=PROVIDER 45 S:$G(ORDER)]"" $P(^PS(53.1,DA,0),"^",21)=$P(ORDER,"^") 46 S:$G(APPL)["P" $P(^PS(53.1,DA,0),"^",13)=1 47 S $P(^PS(53.1,DA,0),"^",18)=DA 48 S:$G(ROC)]"" $P(^PS(53.1,DA,0),"^",24)=ROC 49 S:$G(PREON)]"" $P(^PS(53.1,DA,0),"^",25)=PREON 50 S:$G(REQST)]"" $P(^PS(53.1,DA,2.5),"^")=REQST 51 S:$G(DURATION)]"" $P(^PS(53.1,DA,2.5),"^",2)=DURATION 52 S:$G(IVLIMIT)]"" $P(^PS(53.1,DA,2.5),"^",4)=IVLIMIT 53 I $G(REQST)]"",$G(DURATION)]"" S $P(^PS(53.1,DA,2.5),"^",3)=$$STOP(REQST,DURATION) 54 S:$G(INSTR)]"" $P(^PS(53.1,DA,.3),"^")=INSTR 55 S:$G(INFRT)]"" ^PS(53.1,DA,8)=IVTYP_"^^^^"_INFRT 56 S:$G(FREQ)]"" $P(^PS(53.1,DA,2),"^",6)=FREQ 57 S:$G(SCHTYP)]"" $P(^PS(53.1,DA,0),"^",7)=SCHTYP 58 I $G(APPL)'="I" I $G(INSTR)]"" N X S X=INSTR D STRIP I $S(X?.E1C.E:0,$L(X)>60:0,X="":0,X["^":0,X?1.P:1,1:1) S $P(^PS(53.1,DA,.2),"^",2)=X,$P(^PS(53.1,DA,.2),"^",5,6)=$G(DOSE)_"^"_$G(UNIT) 59 S $P(^PS(53.1,DA,.2),"^",3)=ORDCON 60 I $G(SCHEDULE)]"" S ^PS(53.1,DA,2)=SCHEDULE 61 I $G(APPL)="I" I $G(UNITS)]"" S $P(^PS(53.1,DA,.3),"^")=UNITS 62 S ^PS(53.1,DA,4)="^^^^^^"_CLERK 63 I $G(DISPENSE) S ^PS(53.1,DA,1,0)="^53.11P^1^1",^PS(53.1,DA,1,1,0)=DISPENSE_"^"_UNITS,^PS(53.1,DA,1,"B",$E(DISPENSE,1,30),1)="" 64 I $D(PROCOM) D 65 .I '$D(^PS(53.1,DA,12,0)) S ^(0)="^53.1012^0^0" 66 .S JJ=0 F S JJ=$O(PROCOM(JJ)) Q:'JJ S $P(^PS(53.1,DA,12,0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,12,JJ,0)=PROCOM(JJ) 67 I $D(ADMINSTR) D 68 .I '$D(^PS(53.1,DA,3,0)) S ^(0)="^53.12^0^0" 69 .S JJ=0 F S JJ=$O(ADMINSTR(JJ)) Q:'JJ S $P(^PS(53.1,DA,3,0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,3,JJ,0)=ADMINSTR(JJ) 70 I $D(^TMP("PSJNVO",$J,"AD")) D 71 .S ^PS(53.1,DA,"AD",0)="^53.157PA^0^0" 72 .S JJ=0 F S JJ=$O(^TMP("PSJNVO",$J,"AD",JJ)) Q:'JJ S $P(^PS(53.1,DA,"AD",0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,"AD",JJ,0)=^TMP("PSJNVO",$J,"AD",JJ,0),^PS(53.1,DA,"AD","B",$P(^TMP("PSJNVO",$J,"AD",JJ,0),"^"),JJ)="" 73 I $D(^TMP("PSJNVO",$J,"SOL")) D 74 .S ^PS(53.1,DA,"SOL",0)="^53.158PA^0^0" 75 .S JJ=0 F S JJ=$O(^TMP("PSJNVO",$J,"SOL",JJ)) Q:'JJ S $P(^PS(53.1,DA,"SOL",0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,"SOL",JJ,0)=^TMP("PSJNVO",$J,"SOL",JJ,0),^PS(53.1,DA,"SOL","B",$P(^TMP("PSJNVO",$J,"SOL",JJ,0),"^"),JJ)="" 76 I $O(^TMP("PSJNVO",$J,10,0)) D 77 .S ^PS(53.1,DA,10,0)="^53.1112A^0^0" 78 .S JJ=0 F S JJ=$O(^TMP("PSJNVO",$J,10,JJ)) Q:'JJ S $P(^PS(53.1,DA,10,0),"^",3,4)=JJ_"^"_JJ,^PS(53.1,DA,10,JJ,0)=^TMP("PSJNVO",$J,10,JJ,0),^PS(53.1,DA,10,"B",$E(^TMP("PSJNVO",$J,10,JJ,0),1,30),JJ)="" D 79 ..S ^PS(53.1,DA,10,JJ,1)=$P($G(^VA(200,+CLERK,0)),"^") 80 ..I $O(^TMP("PSJNVO",$J,10,JJ,2,0)) S ^PS(53.1,DA,10,JJ,2,0)="^53.11122^0^0" D 81 ...S QQ=0 F S QQ=$O(^TMP("PSJNVO",$J,10,JJ,2,QQ)) Q:'QQ S $P(^PS(53.1,DA,10,JJ,2,0),"^",3,4)=QQ_"^"_QQ,^PS(53.1,DA,10,JJ,2,QQ,0)=^TMP("PSJNVO",$J,10,JJ,2,QQ,0) 82 Q 83 STRIP ;Strips spaces off the end of instructions. 84 I $E(X,$L(X))=" " F S X=$E(X,1,$L(X)-1) Q:$E(X,$L(X))'=" " 85 Q 86 ; 87 ORTYP(MDRT,DDRG) ;Entry point to determine order type for 53.1 88 ;MDRT=Med Route from 51.2, DDRG=Dispense Drug 89 I $P(^PSDRUG(DDRG,2),"^",3)'["I",$P(^PSDRUG(DDRG,2),"^",3)'["U" S ORTYP="" Q ORTYP 90 I $P(^PSDRUG(DDRG,2),"^",3)["I",$P(^PSDRUG(DDRG,2),"^",3)'["U",$P(^PS(51.2,MDRT,0),"^",6)=1 S ORTYP="IN" Q ORTYP 91 I $P(^PSDRUG(DDRG,2),"^",3)'["I",$P(^PS(51.2,MDRT,0),"^",6)=1 S ORTYP="UP" Q ORTYP 92 I $P(^PSDRUG(DDRG,2),"^",3)["I",$P(^PS(51.2,MDRT,0),"^",6)=1 S ORTYP="IP" Q ORTYP 93 I $P(^PSDRUG(DDRG,2),"^",3)["I",$P(^PSDRUG(DDRG,2),"^",3)'["U",$P(^PS(51.2,MDRT,0),"^",6)'=1 S ORTYP="IP" Q ORTYP 94 I $P(^PSDRUG(DDRG,2),"^",3)["U",$P(^PSDRUG(DDRG,2),"^",3)'["I",$P(^PS(51.2,MDRT,0),"^",6)'=1 S ORTYP="UN" Q ORTYP 95 I $P(^PSDRUG(DDRG,2),"^",3)["U",$P(^PS(51.2,MDRT,0),"^",6)'=1 S ORTYP="UP" Q ORTYP 96 S ORTYP="" Q ORTYP 97 ; 98 TRYAGAIN(MDRT,OI) ; 99 ;MDRT=Med Route from 51.2, OI=Orderable Item 100 N ORTYPI,ORTYPU,ORTYPP 101 S ORTYP="",ORTYPI=0,ORTYPU=0,ORTYPP=0 102 N DDRG S DDRG=0 F S DDRG=$O(^PSDRUG("ASP",OI,DDRG)) Q:'DDRG D 103 .I $G(^PSDRUG(DDRG,"I"))]"" Q:^PSDRUG(DDRG,"I")'>DT 104 .S ORTYP=$$ORTYP(MDRT,DDRG) D 105 ..I ORTYP["I" S ORTYPI=ORTYPI+1 106 ..I ORTYP["U" S ORTYPU=ORTYPU+1 107 ..I ORTYP["P" S ORTYPP=ORTYPP+1 108 S ORTYP=$S(ORTYPU>ORTYPI:"U",1:"I") S ORTYP=ORTYP_$S(ORTYPP>0:"P",1:"N") 109 Q ORTYP 110 ; 111 STOP(REQST,DURA) ; 112 ;REQST=Requested start date, DURA=Duration from CPRS 113 I DURA["L",DURA?1A1".".N S DAYS=$$DAY($E(REQST,1,5)),DURA="H"_((DAYS*$P(DURA,"L",2))*24) 114 I DURA["L",DURA?1A.1N.N1"."1N.N D Q STOP 115 .S NUM=$E(REQST,4,5)+$P($P(DURA,"."),"L",2),NUM=$S(NUM<10:"0"_NUM,NUM<13:NUM,1:$S((NUM-12)<10:"0"_(NUM-12),1:(NUM-12))),DATE=$E(REQST,1,3)_NUM 116 .S DAYS=$$DAY(DATE),STOP=$$SCH^XLFDT($P($P(DURA,"."),"L",2)_"M",$P(REQST,"."))_"."_$P(REQST,".",2),DEL=$P($P(DURA,"L",2),"."),STOP=$$FMADD^XLFDT(STOP,"",((DAYS*$P(DURA,DEL,2))*24)) 117 I DURA["L" S STOP=$P($$SCH^XLFDT($P(DURA,"L",2)_"M",$P(REQST,".")),".")_"."_$P(REQST,".",2) Q STOP 118 I DURA["W",DURA["." S DURA="H"_(($P(DURA,"W",2)*7)*24) 119 I DURA["D",DURA["." S DURA="H"_($P(DURA,"D",2)*24) 120 I +DURA=DURA,DURA["." S DURA="H"_(DURA*24) 121 S STOP=$$FMADD^XLFDT(REQST,$S(DURA["W":$P(DURA,"W",2)*7,DURA["D":$P(DURA,"D",2),+DURA=DURA:+DURA,1:""),$S(DURA["H":$P(DURA,"H",2),1:""),$S(DURA["M":$P(DURA,"M",2),1:""),$S(DURA["S":$P(DURA,"S",2),1:"")) 122 Q STOP 123 ZQDATE(DATE,MONTHS) ;BUMP DATE BY A MONTH (OR SO) 124 ;; 125 S X=$E($P(DATE,"."),1,5)+($E($P(DATE,"."),4,5)>(12-MONTHS)*88+MONTHS)_$E($P(DATE,"."),6,7) F D ^%DT Q:Y>0 S X=X-1 126 S NEWDATE=X_"."_$P(DATE,".",2) 127 Q NEWDATE 128 DAY(DATE) ;DATE=FIRST FIVE DIGITS OF FM DATE 129 N X 130 I DATE'?5N Q -1 131 S X=$E(DATE,4,5) I X<1!(X>12) Q -1 132 S X=DATE+1+(X=12*88)_"01" 133 Q $E($$FMADD^XLFDT(X,-1),6,7) -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJHLU.m
r613 r623 1 PSJHLU ;BIR/RLW-UTILITIES USED IN BUILDING HL7 SEGMENTS ;20 Apr 98 / 9:58 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,56,72,102,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(52.6 is supported by DBIA# 1231. 5 ; Reference to ^PS(52.7 is supported by DBIA# 2173. 6 ; Reference to ^VA(200 is supported by DBIA 10060. 7 ; Reference to ^PS(55 is supported by DBIA# 2191. 8 ; 9 INIT ; set up HL7 application variables 10 S PSJHLSDT="PS",PSJHINST=$P($$SITE^VASITE(),"^") 11 S PSJCLEAR="K FIELD F J=0:1:LIMIT S FIELD(J)=""""" 12 Q 13 ; 14 SEGMENT(LIMIT) ; 15 K SEGMENT 16 N SUBSEG,SEGLENGT S SUBSEG=0,SEGMENT="" F J=0:1:LIMIT D 17 .I SEGMENT']"" S SEGMENT=FIELD(J) Q 18 .S SEGMENT=SEGMENT_"|"_FIELD(J) 19 F S SEGLENGT=$L(SEGMENT) D Q:$L(SEGMENT)'>246 20 .I SEGLENGT'>246 S SEGMENT(SUBSEG)=SEGMENT 21 .I SEGLENGT>245 S SEGMENT(SUBSEG)=$E(SEGMENT,1,245),SUBSEG=SUBSEG+1 D 22 ..S SEGMENT=$E(SEGMENT,246,SEGLENGT),SEGMENT(SUBSEG)=$E(SEGMENT,1,245) 23 SET S PSJI=PSJI+1,^TMP("PSJHLS",$J,PSJHLSDT,PSJI)=SEGMENT(0) 24 F J=1:1 Q:'$D(SEGMENT(J)) S ^TMP("PSJHLS",$J,PSJHLSDT,PSJI,J)=SEGMENT(J) 25 Q 26 ; 27 SEGMENT2 ; Retrieve text fields 28 K SEGMENT S JJ=0 F S JJ=$O(@(PSJORDER_"12,"_JJ_")")) Q:'JJ S SEGMENT(JJ-1)=$G(@(PSJORDER_"12,"_JJ_",0)")) 29 I $D(SEGMENT(0)) S SEGMENT(0)="NTE|6|L|"_$S($G(PSJBCBU):SEGMENT(0),1:$$ESC^ORHLESC(SEGMENT(0))) D 30 .D SET^PSJHLU K SEGMENT,JJ 31 I $P($G(@(PSJORDER_"6)")),"^")]"" K SEGMENT S SEGMENT(0)="NTE|21|L|"_$S($G(PSJBCBU):$P($G(@(PSJORDER_"6)")),"^"),1:$$ESC^ORHLESC($P($G(@(PSJORDER_"6)")),"^"))) D 32 .D SET^PSJHLU K SEGMENT 33 I PSJORDER["P",$P($G(@(PSJORDER_"9)")),"^",2)]"" K SEGMENT S SEGMENT(0)="NTE|21|L|"_$S($G(PSJBCBU):$P($G(@(PSJORDER_"9)")),"^",2),1:$$ESC^ORHLESC($P($G(@(PSJORDER_"9)")),"^",2))) D 34 .D SET^PSJHLU K SEGMENT 35 Q 36 ; 37 CALL(HLEVN) ; call DHCP HL7 package -or- protocol, to pass Orders 38 ; HLEVN = number of segments in message 39 K CLERK,DDIEN,DDNUM,DOSEFORM,DOSEOR,FIELD,IVTYPE,LIMIT,NAME,NDNODE,NODE1,NODE2,PRODNAME,PROVIDER,PSGS0Y,PSJHINST,PSJHLSDT,PSJI,PSJORDER,PSOC,PSREASON,ROOMBED,SPDIEN,SEGMENT 40 I $G(PSJBCBU)=1 M PSJNAME=^TMP("PSJHLS",$J,"PS") Q 41 S PSJMSG="^TMP(""PSJHLS"",$J,""PS"")" 42 D MSG^XQOR("PS EVSEND OR",.PSJMSG) 43 Q 44 ; 45 IVTYPE(PSJORDER) ; check whether a back-door order is Inpatient IV or IV fluid 46 I RXORDER["V",$P($G(@(PSJORDER_"0)")),"^",4)'="A" Q "I" 47 I RXORDER["P" I $P($G(@(PSJORDER_"0)")),"^",4)'="F" S IVTYPE="" Q IVTYPE 48 N SUB,AD,SOL,IVTYPE,NODE1 S SUB=0,IVTYPE="F" 49 ;naked reference on line below refers to the full indirect reference of PSJORDER_ which is from ^PS(55,DFN,"IV",PSJORD 50 F TYPE="AD","SOL" S SUB=0 F S SUB=$O(@(PSJORDER_""""_TYPE_""""_","_SUB_")")) Q:(SUB="")!(IVTYPE="I") S NODE1=$G(^(SUB,0)) Q:NODE1="" D Q:IVTYPE="I" 51 .I TYPE="AD" D 52 ..I '$P($G(^PS(52.6,$P(NODE1,"^"),0)),"^",13) S IVTYPE="I" 53 .D:TYPE="SOL" 54 ..S:'$P($G(^PS(52.7,$P(NODE1,"^"),0)),"^",13) IVTYPE="I" 55 Q IVTYPE 56 ENI ;Calculate Frequency for IV orders 57 N INFUSE 58 I X?.E1L.E S INFUSE=$$ENLU^PSGMI(X) Q:(INFUSE="TITRATE")!(INFUSE="BOLUS")!($P(INFUSE," ")="INFUSE")!($P(INFUSE," ")="Infuse") 59 Q:(X="TITRATE")!(X="BOLUS")!($P(X," ")="INFUSE")!($P(X," ")="Infuse") 60 Q:$$INTRMT(X) 61 K:$L(X)<1!($L(X)>30)!(X["""")!($A(X)=45) X I '$D(X) Q 62 I X["=" D Q ; NOIS LOU-0501-42191 63 .N X2,X1 S X1=$P(X,"="),X2=$P(X,"=",2) 64 .I X1["ML/HR",(+X1=$P(X1,"ML/HR"))!(+X1=$P(X1," ML/HR")) D 65 ..S X1=$TR(X1,"ML/HR","ml/hr") 66 .I X2["ML/HR",(+X2=$P(X2,"ML/HR"))!(+X2=$P(X2," ML/HR")) D 67 ..S X2=$TR(X2,"ML/HR","ml/hr") 68 .I X1[" ml/hr",(+X1=$P(X1," ml/hr")) D 69 ..S X1=$P(X1," ml/hr")_$P(X1," ml/hr",2,9999) 70 .I X2[" ml/hr",(+X2=$P(X2," ml/hr")) D 71 ..S X2=$P(X2," ml/hr")_$P(X2," ml/hr",2,9999) 72 .I X1["ml/hr",(+X1=$P(X1,"ml/hr")) D 73 ..S X1=$P(X1,"ml/hr")_$P(X1,"ml/hr",2,9999) 74 .I X2["ml/hr",(+X2=$P(X2,"ml/hr")) D 75 ..S X2=$P(X2,"ml/hr")_$P(X2,"ml/hr",2,9999) 76 .I X2'=+X2 D 77 ..I ($P(X2,"@",2,999)'=+$P(X2,"@",2,999)!(+$P(X2,"@",2,999)<0)) K X Q 78 .I X1=+X1 S X1=X1_" ml/hr" 79 .I X2=+X2 S X2=X2_" ml/hr" 80 .S:$P(X2,"@")=+X2 $P(X2,"@")=$P(X2,"@")_" ml/hr" 81 .S X=X1_"="_X2 82 I X'=+X,($P($TR(X," ml/hr",""),"@",2,999)'=+$P($TR(X," ml/hr",""),"@",2,999)!(+$P(X,"@",2,999)<0)),($P(X," ml/hr")'=+$P(X," ml/hr")!(+$P(X," ml/hr")<0)) Q:(X>0&($E(X)=0)) K X Q 83 I X=+X!(X>0&($E(X)=0)) S X=X_" ml/hr" D SPSOL S FREQ=$S('X:0,1:SPSOL\X*60+(SPSOL#X/X*60+.5)\1) K SPSOL Q 84 I X[" ml/hr" D SPSOL S FREQ=$S('X:0,1:SPSOL\X*60+(SPSOL#X/X*60+.5)\1) K SPSOL Q 85 S SPSOL=$P(X,"@",2) S:$P(X,"@")=+X $P(X,"@")=$P(X,"@")_" ml/hr" S FREQ=$S('SPSOL:0,1:1440/SPSOL\1) K SPSOL 86 Q 87 SPSOL S SPSOL=+TVOLUME Q 88 INTRMT(X) ; 89 Q:'$P(X," ") 0 90 Q:$P(X," ",2)="Minutes" 1 91 Q:$P(X," ",2)="Hours" 1 92 Q 0 93 IVCAT(DFN,PSJORD,PARRAY) ; This returns the IV CATEGORY based on the IV TYPE and CHEMO TYPE (not what is already in the IV CATEGORY field) 94 ; Passed in: PSJORDER (file root of order) 95 N NODE,TYP,CHEMTYP,INTSYR,ND2P5 96 S (CHEMTYP,INTSYR)="" 97 S TYP=$G(P(4)),INTSYR=$G(P(5)),CHEMTYP=$G(P(23)) 98 I TYP="",$G(PSJORD)["V" S NODE=$G(^PS(55,DFN,"IV",+PSJORD,0)) S TYP=$P(NODE,"^",4),INTSYR=$P(NODE,"^",5),CHEMTYP=$P(NODE,"^",23) 99 I TYP="",$G(PSJORD)["P" S NODE=$G(^PS(53.1,+PSJORD,8)) S TYP=$P(NODE,"^"),INTSYR=$P(NODE,"^",4),CHEMTYP=$P(NODE,"^",2) 100 I TYP="" S TYP=$G(PARRAY(4)),INTSYR=$G(PARRAY(5)),CHEMTYP=$G(PARRAY(23)) 101 Q:$G(TYP)="" "" 102 S CAT=$S(",A,H,"[(","_TYP_","):"C",TYP="C"&(",A,H,S,"[(","_CHEMTYP_",")&'INTSYR):"C",TYP="C"&(CHEMTYP="P"):"I",TYP="S"&'INTSYR:"C",TYP="P":"I",$G(INTSYR):"I",1:"") 103 Q CAT 104 ZRX ; Perform outbound processing 105 S LIMIT=6 X PSJCLEAR 106 S FIELD(0)="ZRX" 107 I '$G(PSJREN) N PREON,PSJREN I $G(PSJORD)["U"&($P(NODE1,"^",24)="R") S PSJREN=1 108 I $G(PSJORD)["V"&($P(NODE2,"^",8)="R") S PSJREN=1 109 S PREON=$S($G(PSJREN):$G(PSJORD),PSJORDER["IV":$P(NODE2,"^",5),1:$P(NODE1,"^",25)) 110 S FIELD(1)=$S(PREON["P":$P($G(^PS(53.1,+PREON,0)),"^",21),PREON["V":$P($G(^PS(55,PSJHLDFN,"IV",+PREON,0)),"^",21),1:$P($G(^PS(55,PSJHLDFN,5,+PREON,0)),"^",21)) 111 S FIELD(2)=$S(PSJORDER["IV":$G(P("NAT")),1:$G(PSJNOO)) 112 S FIELD(3)=$S($G(PSJREN):"R",PSJORDER["IV":$P(NODE2,"^",8),1:$P(NODE1,"^",24)) 113 I FIELD(3)="" I PSOC="SN" S FIELD(3)="N" 114 I $D(P)>1 S FIELD(6)=$$IVCAT^PSJHLU(PSJHLDFN,RXORDER,.P) 115 S NAME=$P($G(^VA(200,DUZ,0)),"^") 116 S FIELD(5)=DUZ_"^"_$S($G(PSJBCBU):NAME,1:$$ESC^ORHLESC(NAME))_"^"_"99NP" 117 D SEGMENT^PSJHLU(LIMIT),DISPLAY^PSJHL2 118 Q 1 PSJHLU ;BIR/RLW-UTILITIES USED IN BUILDING HL7 SEGMENTS ;20 Apr 98 / 9:58 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**1,56,72,102**;16 DEC 97 3 ; 4 ; Reference to ^PS(52.6 is supported by DBIA# 1231. 5 ; Reference to ^PS(52.7 is supported by DBIA# 2173. 6 ; 7 INIT ; set up HL7 application variables 8 S PSJHLSDT="PS",PSJHINST=$P($$SITE^VASITE(),"^") 9 S PSJCLEAR="K FIELD F J=0:1:LIMIT S FIELD(J)=""""" 10 Q 11 ; 12 SEGMENT(LIMIT) ; 13 K SEGMENT 14 N SUBSEG,SEGLENGT S SUBSEG=0,SEGMENT="" F J=0:1:LIMIT D 15 .I SEGMENT']"" S SEGMENT=FIELD(J) Q 16 .S SEGMENT=SEGMENT_"|"_FIELD(J) 17 F S SEGLENGT=$L(SEGMENT) D Q:$L(SEGMENT)'>246 18 .I SEGLENGT'>246 S SEGMENT(SUBSEG)=SEGMENT 19 .I SEGLENGT>245 S SEGMENT(SUBSEG)=$E(SEGMENT,1,245),SUBSEG=SUBSEG+1 D 20 ..S SEGMENT=$E(SEGMENT,246,SEGLENGT),SEGMENT(SUBSEG)=$E(SEGMENT,1,245) 21 SET S PSJI=PSJI+1,^TMP("PSJHLS",$J,PSJHLSDT,PSJI)=SEGMENT(0) 22 F J=1:1 Q:'$D(SEGMENT(J)) S ^TMP("PSJHLS",$J,PSJHLSDT,PSJI,J)=SEGMENT(J) 23 Q 24 ; 25 CALL(HLEVN) ; call DHCP HL7 package -or- protocol, to pass Orders 26 ; HLEVN = number of segments in message 27 K CLERK,DDIEN,DDNUM,DOSEFORM,DOSEOR,FIELD,IVTYPE,LIMIT,NAME,NDNODE,NODE1,NODE2,PRODNAME,PROVIDER,PSGS0Y,PSJHINST,PSJHLSDT,PSJI,PSJORDER,PSOC,PSREASON,ROOMBED,SPDIEN,SEGMENT 28 I $G(PSJBCBU)=1 M PSJNAME=^TMP("PSJHLS",$J,"PS") Q 29 S PSJMSG="^TMP(""PSJHLS"",$J,""PS"")" 30 D MSG^XQOR("PS EVSEND OR",.PSJMSG) 31 Q 32 ; 33 IVTYPE(PSJORDER) ; check whether a back-door order is Inpatient IV or IV fluid 34 I RXORDER["V",$P($G(@(PSJORDER_"0)")),"^",4)'="A" Q "I" 35 I RXORDER["P" I $P($G(@(PSJORDER_"0)")),"^",4)'="F" S IVTYPE="" Q IVTYPE 36 N SUB,AD,SOL,IVTYPE,NODE1 S SUB=0,IVTYPE="F" 37 ;naked reference on line below refers to the full indirect reference of PSJORDER_... 38 F TYPE="AD","SOL" S SUB=0 F S SUB=$O(@(PSJORDER_""""_TYPE_""""_","_SUB_")")) Q:(SUB="")!(IVTYPE="I") S NODE1=$G(^(SUB,0)) Q:NODE1="" D Q:IVTYPE="I" 39 .I TYPE="AD" D 40 ..I '$P($G(^PS(52.6,$P(NODE1,"^"),0)),"^",13) S IVTYPE="I" 41 .D:TYPE="SOL" 42 ..S:'$P($G(^PS(52.7,$P(NODE1,"^"),0)),"^",13) IVTYPE="I" 43 Q IVTYPE 44 ENI ;Calculate Frequency for IV orders 45 N INFUSE 46 K:$L(X)<1!($L(X)>30)!(X["""")!($A(X)=45) X I '$D(X) Q 47 I X?.E1L.E S INFUSE=$$ENLU^PSGMI(X) Q:(INFUSE="TITRATE")!(INFUSE="BOLUS") 48 Q:(X="TITRATE")!(X="BOLUS") 49 I X["=" D Q ; NOIS LOU-0501-42191 50 .N X2,X1 S X1=$P(X,"="),X2=$P(X,"=",2) 51 .I X1["ML/HR",(+X1=$P(X1,"ML/HR"))!(+X1=$P(X1," ML/HR")) D 52 ..S X1=$TR(X1,"ML/HR","ml/hr") 53 .I X2["ML/HR",(+X2=$P(X2,"ML/HR"))!(+X2=$P(X2," ML/HR")) D 54 ..S X2=$TR(X2,"ML/HR","ml/hr") 55 .I X1[" ml/hr",(+X1=$P(X1," ml/hr")) D 56 ..S X1=$P(X1," ml/hr")_$P(X1," ml/hr",2,9999) 57 .I X2[" ml/hr",(+X2=$P(X2," ml/hr")) D 58 ..S X2=$P(X2," ml/hr")_$P(X2," ml/hr",2,9999) 59 .I X1["ml/hr",(+X1=$P(X1,"ml/hr")) D 60 ..S X1=$P(X1,"ml/hr")_$P(X1,"ml/hr",2,9999) 61 .I X2["ml/hr",(+X2=$P(X2,"ml/hr")) D 62 ..S X2=$P(X2,"ml/hr")_$P(X2,"ml/hr",2,9999) 63 .I X2'=+X2 D 64 ..I ($P(X2,"@",2,999)'=+$P(X2,"@",2,999)!(+$P(X2,"@",2,999)<0)) K X Q 65 .I X1=+X1 S X1=X1_" ml/hr" 66 .I X2=+X2 S X2=X2_" ml/hr" 67 .S:$P(X2,"@")=+X2 $P(X2,"@")=$P(X2,"@")_" ml/hr" 68 .S X=X1_"="_X2 69 I X'=+X,($P(X,"@",2,999)'=+$P(X,"@",2,999)!(+$P(X,"@",2,999)<0)),($P(X," ml/hr")'=+$P(X," ml/hr")!(+$P(X," ml/hr")<0)) K X Q 70 I X=+X S X=X_" ml/hr" D SPSOL S FREQ=$S('X:0,1:SPSOL\X*60+(SPSOL#X/X*60+.5)\1) K SPSOL Q 71 I X[" ml/hr" D SPSOL S FREQ=$S('X:0,1:SPSOL\X*60+(SPSOL#X/X*60+.5)\1) K SPSOL Q 72 S SPSOL=$P(X,"@",2) S:$P(X,"@")=+X $P(X,"@")=$P(X,"@")_" ml/hr" S FREQ=$S('SPSOL:0,1:1440/SPSOL\1) K SPSOL 73 Q 74 SPSOL S SPSOL=+TVOLUME Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJLIACT.m
r613 r623 1 PSJLIACT ;BIR/MV-IV ACTION ;28 Jul 98 / 8:50 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**15,47,62,58,82,97,80,110,111,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191. 5 ; Reference to MAIN^TIUEDIT is supported by DBIA 2410. 6 ; 7 DC ; Discontinue order 8 D HOLDHDR^PSJOE 9 S PSJCOM=+$S(PSJORD["V":$P($G(^PS(55,DFN,"IV",+PSJORD,.2)),"^",8),1:$P($G(^PS(53.1,+PSJORD,.2)),"^",8)) 10 I PSJCOM W !!,"This order is part of a complex order. If you discontinue this order the",!,"following orders will be discontinued too (unless the stop date has already",!,"been reached)." D CMPLX^PSJCOM1(PSGP,PSJCOM,PSJORD) 11 I PSJCOM F W !!,"Do you want to discontinue this order" S %=1 D YN^DICN Q:% D ENCOM^PSGOEM 12 I PSJCOM,%'=1 S VALMBK="" Q 13 I PSJORD["V" D DC^PSIVORA,EN^PSJLIORD(DFN,ON) Q 14 D:PSJORD["P" DISCONT^PSIVORC 15 S VALMBCK="Q" 16 Q 17 ACEDIT ; Display LM screen and AC and EDit actions 18 D EN^PSJLIVMD 19 S VALMBCK=$S($G(PSIVACEP):"Q",1:"R") 20 Q 21 AEEXIT ; Call for EXIT CODE in PSJ LM IV AC/EDIT 22 D:ON["V" GT55^PSIVORFB 23 I ON["P" D GT531^PSIVORFA(DFN,ON) D:P("OT")'="I" GTDATA^PSJLIFN 24 D EN^PSJLIVMD 25 K PSIVENO 26 Q 27 EDIT ; Edit order 28 K PSIVFN1 NEW PSIVNBD 29 I $D(PSGACT),PSGACT'["E" W !,"This order may not be edited." D PAUSE^VALM1 Q 30 D EDIT1 31 Q:$D(PSIVNBD)!($G(PSIVCOPY)&'$G(PSIVENO)) 32 D EN^PSJLIVMD 33 S VALMBCK=$S($G(PSIVFN1):"Q",1:"R") 34 Q 35 EDIT1 ; 36 ;Ensure P() is defined 37 I $D(P)<10 S XQORQUIT=1,P("PON")="",PSIVNBD=1 D Q 38 .W !,"WARNING: An error has occurred. Changes will not be saved" 39 .D PAUSE^VALM1 40 .S VALMBCK="Q" 41 I "ANP"'[P(17) W !,"You cannot edit an inactive order" D PAUSE^VALM1 Q 42 S:$G(ON55)="" ON55=$G(PSJORD) 43 D HOLDHDR^PSJOE 44 ;* Edit a new back door order 45 I ($G(ON55)["V"&($G(P("21FLG"))="")) D Q 46 . D GSTRING^PSIVORE1,GTFLDS^PSIVORFE 47 . I $G(ON55)["V",'$G(DONE) D OK^PSIVORE 48 . S VALMBCK="Q",PSIVNBD=1 49 ;* Edit an active order 50 I $G(ON55)["V" NEW PSJEDIT1 D E^PSIVOPT1 D Q 51 . I $G(PSJIVBD) K PSJIVBD D EN^PSJLIORD(DFN,ON) 52 I $G(ON55)["P" D EDIT^PSIVORC ;Edit incomplete order. 53 K P("OVRIDE") 54 Q 55 ACCEPT ; Accept order 56 D HOLDHDR^PSJOE 57 ;Accept IV from back door. 58 I $G(PSJIVBD) K PSJIVBD D OK^PSIVORE S VALMBCK="Q" Q 59 I ON["V" D ACCEPT^PSIVOPT1 Q 60 S PSIVFN1=1 61 D COMPLTE^PSIVORC1 62 S VALMBCK="Q" 63 Q 64 R ; Renewal 65 S PSJREN=1 66 D HOLDHDR^PSJOE 67 NEW PSIVAC S PSIVAC="PR" K PSGFDX 68 D R^PSIVOPT 69 D EN^PSJLIORD(DFN,ON) 70 K PSJREN 71 Q 72 H ; Hold 73 NEW TEX S TEX="Active order ***" 74 D HOLDHDR^PSJOE 75 D H^PSIVOPT(DFN,ON,P(17),P(3)) 76 D:P(17)="A" PAUSE^VALM1 77 D EN^PSJLIORD(DFN,ON) 78 Q 79 L ; Activity Log 80 NEW PSIVLAB,PSIVLOG,PSJHIS S (PSIVLAB,PSIVLOG)=1 81 D EN^PSIVVW1 82 D EN^PSJLIVMD 83 S VALMBCK="R" 84 Q 85 O ; On Call 86 NEW TEX S TEX="Active order ***" 87 D HOLDHDR^PSJOE 88 D O^PSIVOPT(DFN,ON,P(17),P(3)) 89 D:P(17)="A" PAUSE^VALM1 90 D EN^PSJLIORD(DFN,ON) 91 Q 92 VF ; Make the order active 93 NEW PSIVCHG S PSIVCHG=0 94 I ON["V" S ON55=ON D VF1("V","ORDER VERIFIED BY ",1) Q 95 D ACTIVE^PSIVORC2 96 Q 97 VF1(PSIVREA,PSIVAL,PSIVLOG) ; 98 ;Update 4 node and set activity log. 99 ;PSIVREA: the reason use by LOG^PSIVORAL 100 ;PSIVAL : the description reason 101 ;PSIVLOG: Log an activity if = 1 102 I '+$G(OD)!($L($G(OD))>16) K OD 103 D:+PSJSYSU=3 ^PSIVORE1 104 NEW DIE,DA,DR,PSJX,XX,PSIVACT,PSJRQND 105 S PSIVACT=1 106 S PSJX=$G(^PS(55,DFN,"IV",+ON55,4)),XX="" 107 I $P(PSJX,U)="" S XX=";143////0" 108 I $P(PSJX,U,4)="" S XX=XX_U_";142////0" 109 D NOW^%DTC 110 S DIE="^PS(55,"_DFN_",""IV"",",DA=+ON55,DA(1)=DFN 111 I +PSJSYSU=3 S DR="140////"_DUZ_";141////"_$E(%,1,12)_";142////1"_$P(XX,U) 112 I +PSJSYSU=1 S DR="16////"_DUZ_";17////"_$E(%,1,12)_";143////1"_$P(XX,U,2) 113 I $G(P("PRY"))="D" S DR=DR_";.22////"_+P("IVRM") 114 D ^DIE 115 ; If pending IV renew is edited during finish, go back and DE the original active order left in RENEWED status 116 S PREREN=$S(ON55["V":$G(@(DIE_"+ON55,2)")),1:""),PREREN=$P(PREREN,"^",5) I PREREN D K PREREN 117 . I PREREN["P" S PREREN=$G(@("^PS(53.1,+PREREN,0)")),PREREN=$P(PREREN,"^",25) 118 . I PREREN["V" N PRERENOD S PRERENOD=$G(@("^PS(55,DFN,""IV"",+PREREN,0)")) I $P(PRERENOD,"^",17)="R",($G(P("RES"))="E") D 119 .. S DIE="^PS(55,"_DFN_",""IV"",",DA=+PREREN,DA(1)=DFN 120 .. S DR="100////D;.03////"_PSGDT S ORIGSTOP=$P($G(@("^PS(55,DFN,""IV"",+PREREN,2)")),"^",3) I ORIGSTOP S DR=DR_";116////"_ORIGSTOP 121 .. D ^DIE D EN1^PSJHL2(DFN,"SC",PREREN) 122 K DR,DIE,DA 123 I (+PSJSYSU=3)&($G(P("PRY"))="D") D 124 .N DIR W ! S DIR(0)="S^Y:Yes;N:No",DIR("A")="Do you want to enter a Progress Note",DIR("B")="No" D ^DIR 125 .Q:Y="N" 126 .D MAIN^TIUEDIT(3,.TIUDA,DFN,"","","","",1) 127 Q:'$G(PSIVLOG) 128 I $G(P("PACT"))]"",+$P(P("PACT"),U,2),+$P(P("PACT"),U,3) D 129 . NEW DIC,DA,X,Y,XX,DO D NAME^PSJBCMA1($P(P("PACT"),U,2),.XX) 130 . S DIC(0)="L",DA(1)=DFN,DA(2)=+ON55,X=1 131 . S DIC="^PS(55,"_DA(1)_",""IV"","_DA(2)_",""A""," 132 . S DIC("DR")=".02////F;.03////"_XX_";.04////"_$P($G(^PS(53.3,+$P(P("PACT"),U,3),0)),U)_";.05////"_$P(P("PACT"),U)_";.06////"_$P(P("PACT"),U,2) 133 . D FILE^DICN 134 NEW PSIVALCK 135 S PSIVREA="V",PSIVALT="" 136 S PSIVAL=PSIVAL_$S(+PSJSYSU=3:"PHARMACIST",1:"NURSE") 137 D LOG^PSIVORAL K PSIVAL,PSIVREA,PSIVLN 138 I $G(PSJORD)["P" S PSIVREA="V",PSIVALT="",PSGRDTX=$G(^PS(53.1,+PSJORD,2.5)) D 139 . I $G(PSGRDTX) S PSIVAL="Requested Start Date: "_$$ENDTC^PSGMI($$DATE2^PSJUTL2($P(PSGRDTX,U))) D LOG^PSIVORAL 140 . I $P(PSGRDTX,U,3) S PSIVREA="V",PSIVALT="" S PSIVAL="Requested Stop Date: "_$$ENDTC^PSGMI($$DATE2^PSJUTL2($P(PSGRDTX,U,3))) D LOG^PSIVORAL 141 N DUR I $G(PSJORD) S DUR=$$GETDUR^PSJLIVMD(DFN,+PSJORD,$S(PSJORD["P":"P",1:"IV"),1) I DUR]"" D 142 . K DR S DIE="^PS(55,"_DFN_",""IV"",",DA=+ON55,DA(1)=DFN 143 . S DR=$S($G(IVLIMIT):"152////"_DUR,1:"151////"_DUR) K IVLIMIT 144 . D ^DIE 145 D EN1^PSJHL2(DFN,"SC",ON55) 146 D:+PSJSYSU=1 EN1^PSJHL2(DFN,"ZV",ON55) 147 D GT55^PSIVORFB S OLDON=$P($G(^PS(55,DFN,"IV",+ON55,2)),"^",5),P("OLDON")=OLDON 148 N PSJPRIO,PSJSCH,NODE0,NODEP2 S NODE0=$G(^PS(55,DFN,"IV",+ON55,0)),NODEP2=$G(^PS(55,DFN,"IV",+ON55,.2)) 149 S PSJPRIO=$P(NODEP2,"^",4),PSJSCH=$P(NODE0,"^",9) 150 I (",S,A,")[(","_$G(PSJPRIO)_",")!($G(PSJSCH)="NOW")!($G(PSJSCH)["STAT") D NOTIFY^PSJHL4(ON55,DFN,$G(PSJPRIO),$G(PSJSCH)) 151 Q 1 PSJLIACT ;BIR/MV-IV ACTION ;28 Jul 98 / 8:50 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**15,47,62,58,82,97,80,110,111**;16 DEC 97 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191. 5 ; Reference to MAIN^TIUEDIT is supported by DBIA 2410. 6 ; 7 DC ; Discontinue order 8 D HOLDHDR^PSJOE 9 S PSJCOM=+$S(PSJORD["V":$P($G(^PS(55,DFN,"IV",+PSJORD,.2)),"^",8),1:$P($G(^PS(53.1,+PSJORD,.2)),"^",8)) 10 I PSJCOM W !!,"This order is part of a complex order. If you discontinue this order the",!,"following orders will be discontinued too (unless the stop date has already",!,"been reached)." D CMPLX^PSJCOM1(PSGP,PSJCOM,PSJORD) 11 I PSJCOM F W !!,"Do you want to discontinue this order" S %=1 D YN^DICN Q:% D ENCOM^PSGOEM 12 I PSJCOM,%'=1 S VALMBK="" Q 13 I PSJORD["V" D DC^PSIVORA,EN^PSJLIORD(DFN,ON) Q 14 D:PSJORD["P" DISCONT^PSIVORC 15 S VALMBCK="Q" 16 Q 17 ACEDIT ; Display LM screen and AC and EDit actions 18 ;K PSIVFN1 ; if not set display the second screen when finish. 19 D EN^PSJLIVMD 20 S VALMBCK=$S($G(PSIVACEP):"Q",1:"R") 21 Q 22 AEEXIT ; Call for EXIT CODE in PSJ LM IV AC/EDIT 23 D:ON["V" GT55^PSIVORFB 24 I ON["P" D GT531^PSIVORFA(DFN,ON) D:P("OT")'="I" GTDATA^PSJLIFN 25 D EN^PSJLIVMD 26 K PSIVENO 27 Q 28 EDIT ; Edit order 29 K PSIVFN1 NEW PSIVNBD 30 I $D(PSGACT),PSGACT'["E" W !,"This order may not be edited." D PAUSE^VALM1 Q 31 D EDIT1 32 ;Q:$D(PSIVNBD) 33 Q:$D(PSIVNBD)!($G(PSIVCOPY)&'$G(PSIVENO)) 34 D EN^PSJLIVMD 35 S VALMBCK=$S($G(PSIVFN1):"Q",1:"R") 36 Q 37 EDIT1 ; 38 ;Ensure P() is defined 39 I $D(P)<10 S XQORQUIT=1,P("PON")="",PSIVNBD=1 D Q 40 .W !,"WARNING: An error has occurred. Changes will not be saved" 41 .D PAUSE^VALM1 42 .S VALMBCK="Q" 43 I "ANP"'[P(17) W !,"You cannot edit an inactive order" D PAUSE^VALM1 Q 44 S:$G(ON55)="" ON55=$G(PSJORD) 45 D HOLDHDR^PSJOE 46 ;* Edit a new back door order 47 ;;I ($G(ON55)["V"&($G(P(21))="")) D Q 48 I ($G(ON55)["V"&($G(P("21FLG"))="")) D Q 49 . D GSTRING^PSIVORE1,GTFLDS^PSIVORFE 50 . I $G(ON55)["V",'$G(DONE) D OK^PSIVORE 51 . S VALMBCK="Q",PSIVNBD=1 52 ;* Edit an active order 53 I $G(ON55)["V" NEW PSJEDIT1 D E^PSIVOPT1 D Q 54 . I $G(PSJIVBD) K PSJIVBD D EN^PSJLIORD(DFN,ON) 55 I $G(ON55)["P" D EDIT^PSIVORC ;Edit incomplete order. 56 Q 57 ACCEPT ; Accept order 58 D HOLDHDR^PSJOE 59 ;Accept IV from back door. 60 I $G(PSJIVBD) K PSJIVBD D OK^PSIVORE S VALMBCK="Q" Q 61 I ON["V" D ACCEPT^PSIVOPT1 Q 62 S PSIVFN1=1 63 D COMPLTE^PSIVORC1 64 S VALMBCK="Q" 65 Q 66 R ; Renewal 67 S PSJREN=1 68 D HOLDHDR^PSJOE 69 NEW PSIVAC S PSIVAC="PR" K PSGFDX 70 D R^PSIVOPT 71 D EN^PSJLIORD(DFN,ON) 72 K PSJREN 73 Q 74 H ; Hold 75 NEW TEX S TEX="Active order ***" 76 D HOLDHDR^PSJOE 77 D H^PSIVOPT(DFN,ON,P(17),P(3)) 78 D:P(17)="A" PAUSE^VALM1 79 D EN^PSJLIORD(DFN,ON) 80 Q 81 L ; Activity Log 82 NEW PSIVLAB,PSIVLOG,PSJHIS S (PSIVLAB,PSIVLOG)=1 83 D EN^PSIVVW1 84 D EN^PSJLIVMD 85 S VALMBCK="R" 86 Q 87 O ; On Call 88 NEW TEX S TEX="Active order ***" 89 D HOLDHDR^PSJOE 90 D O^PSIVOPT(DFN,ON,P(17),P(3)) 91 D:P(17)="A" PAUSE^VALM1 92 D EN^PSJLIORD(DFN,ON) 93 Q 94 VF ; Make the order active 95 NEW PSIVCHG S PSIVCHG=0 96 I ON["V" S ON55=ON D VF1("V","ORDER VERIFIED BY ",1) Q 97 D ACTIVE^PSIVORC2 98 Q 99 VF1(PSIVREA,PSIVAL,PSIVLOG) ; 100 ;Update 4 node and set activity log. 101 ;PSIVREA: the reason use by LOG^PSIVORAL 102 ;PSIVAL : the description reason 103 ;PSIVLOG: Log an activity if = 1 104 I '+$G(OD)!($L($G(OD))>16) K OD 105 D:+PSJSYSU=3 ^PSIVORE1 106 NEW DIE,DA,DR,PSJX,XX,PSIVACT,PSJRQND 107 S PSIVACT=1 108 S PSJX=$G(^PS(55,DFN,"IV",+ON55,4)),XX="" 109 I $P(PSJX,U)="" S XX=";143////0" 110 I $P(PSJX,U,4)="" S XX=XX_U_";142////0" 111 D NOW^%DTC 112 S DIE="^PS(55,"_DFN_",""IV"",",DA=+ON55,DA(1)=DFN 113 I +PSJSYSU=3 S DR="140////"_DUZ_";141////"_$E(%,1,12)_";142////1"_$P(XX,U) 114 I +PSJSYSU=1 S DR="16////"_DUZ_";17////"_$E(%,1,12)_";143////1"_$P(XX,U,2) 115 I $G(P("PRY"))="D" S DR=DR_";.22////"_+P("IVRM") 116 D ^DIE 117 ; If pending IV renew is edited during finish, go back and DE the original active order left in RENEWED status 118 S PREREN=$S(ON55["V":$G(@(DIE_"+ON55,2)")),1:""),PREREN=$P(PREREN,"^",5) I PREREN D K PREREN 119 . I PREREN["P" S PREREN=$G(@("^PS(53.1,+PREREN,0)")),PREREN=$P(PREREN,"^",25) 120 . I PREREN["V" N PRERENOD S PRERENOD=$G(@("^PS(55,DFN,""IV"",+PREREN,0)")) I $P(PRERENOD,"^",17)="R",($G(P("RES"))="E") D 121 .. S DIE="^PS(55,"_DFN_",""IV"",",DA=+PREREN,DA(1)=DFN 122 .. S DR="100////D;.03////"_PSGDT S ORIGSTOP=$P($G(@("^PS(55,DFN,""IV"",+PREREN,2)")),"^",3) I ORIGSTOP S DR=DR_";116////"_ORIGSTOP 123 .. D ^DIE D EN1^PSJHL2(DFN,"SC",PREREN) 124 K DR,DIE,DA 125 ;I ((+PSJSYSU=3)&($G(PSJPRI)="D"))!((+PSJSYSU=3)&($G(P("PRY"))="D")) D 126 I (+PSJSYSU=3)&($G(P("PRY"))="D") D 127 .N DIR W ! S DIR(0)="S^Y:Yes;N:No",DIR("A")="Do you want to enter a Progress Note",DIR("B")="No" D ^DIR 128 .Q:Y="N" 129 .D MAIN^TIUEDIT(3,.TIUDA,DFN,"","","","",1) 130 Q:'$G(PSIVLOG) 131 I $G(P("PACT"))]"",+$P(P("PACT"),U,2),+$P(P("PACT"),U,3) D 132 . NEW DIC,DA,X,Y,XX,DO D NAME^PSJBCMA1($P(P("PACT"),U,2),.XX) 133 . S DIC(0)="L",DA(1)=DFN,DA(2)=+ON55,X=1 134 . S DIC="^PS(55,"_DA(1)_",""IV"","_DA(2)_",""A""," 135 . S DIC("DR")=".02////F;.03////"_XX_";.04////"_$P($G(^PS(53.3,+$P(P("PACT"),U,3),0)),U)_";.05////"_$P(P("PACT"),U)_";.06////"_$P(P("PACT"),U,2) 136 . D FILE^DICN 137 NEW PSIVALCK 138 S PSIVREA="V",PSIVALT="" 139 S PSIVAL=PSIVAL_$S(+PSJSYSU=3:"PHARMACIST",1:"NURSE") 140 D LOG^PSIVORAL K PSIVAL,PSIVREA,PSIVLN 141 I $G(PSJORD)["P" S PSIVREA="V",PSIVALT="",PSGRDTX=$G(^PS(53.1,+PSJORD,2.5)) D 142 . I $G(PSGRDTX) S PSIVAL="Requested Start Date: "_$$ENDTC^PSGMI($$DATE2^PSJUTL2($P(PSGRDTX,U))) D LOG^PSIVORAL 143 . I $P(PSGRDTX,U,3) S PSIVREA="V",PSIVALT="" S PSIVAL="Requested Stop Date: "_$$ENDTC^PSGMI($$DATE2^PSJUTL2($P(PSGRDTX,U,3))) D LOG^PSIVORAL 144 N DUR I $G(PSJORD) S DUR=$$GETDUR^PSJLIVMD(DFN,+PSJORD,$S(PSJORD["P":"P",1:"IV"),1) I DUR]"" D 145 . K DR S DIE="^PS(55,"_DFN_",""IV"",",DA=+ON55,DA(1)=DFN 146 . S DR=$S($G(IVLIMIT):"152////"_DUR,1:"151////"_DUR) K IVLIMIT 147 . D ^DIE 148 D EN1^PSJHL2(DFN,"SC",ON55) 149 D:+PSJSYSU=1 EN1^PSJHL2(DFN,"ZV",ON55) 150 D GT55^PSIVORFB S OLDON=$P($G(^PS(55,DFN,"IV",+ON55,2)),"^",5),P("OLDON")=OLDON 151 N PSJPRIO,PSJSCH,NODE0,NODEP2 S NODE0=$G(^PS(55,DFN,"IV",+ON55,0)),NODEP2=$G(^PS(55,DFN,"IV",+ON55,.2)) 152 S PSJPRIO=$P(NODEP2,"^",4),PSJSCH=$P(NODE0,"^",9) 153 I (",S,A,")[(","_$G(PSJPRIO)_",")!($G(PSJSCH)="NOW")!($G(PSJSCH)["STAT") D NOTIFY^PSJHL4(ON55,DFN,$G(PSJPRIO),$G(PSJSCH)) 154 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJLIVFD.m
r613 r623 1 PSJLIVFD ;BIR/MV-SETUP LM TEMPLATE FOR IV FLUID ;4 Aug 00 / 2:37 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**7,50,63,64,58,81,91,80,116,110,111,180,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^VALM0 is supported by DBIA # 2615. 5 ; 6 ;NFI changes for FR# 3@AD+4 7 ; 8 EN ; Build LM template to display IV order. 9 K ^TMP("PSJI",$J) 10 S UL80="",$P(UL80,"=",80)="" 11 S PSJLN=1 12 AD ; 13 NEW VALMEVL S VALMEVL=1 14 S PSJL="" D FLDNO^PSJLIUTL("(1)",1) 15 S PSJL=PSJL_"Additives:" 16 S:$G(P("PON"))["V"&(P(17)'="N") PSJL=$$SETSTR^VALM1("Order number:",PSJL,30,14)_+P("PON") 17 S PSJL=$$SETSTR^VALM1("Type:",PSJL,57,6)_$$TYPE^PSJLIUTL 18 NEW PSJVD S PSJVD=$$DINFLIV^PSJDIN(.DRG) 19 S PSJL=$$SETSTR^VALM1(PSJVD,PSJL,75,6) 20 I '$D(IORVON),$D(IOST(0)) D ENS^%ZISS,TERM^VALM0 21 I $D(IORVON),(PSJVD]"") D CNTRL^VALM10(1,76,5,IORVON,IORVOFF,0) K PSJVD 22 D SETTMP^PSJLMPRU("PSJI",PSJL) 23 D:+$G(PSJLMX) CLRDSPL^PSJLIVMD 24 ;PSJLMX count number of lines needed to display the add/sol 25 S PSJLMX=0 D WRTDRG^PSJLIUTL("AD") 26 SOL ; 27 S PSJL="" D FLDNO^PSJLIUTL("(2)",1) 28 S PSJL=PSJL_"Solutions:" 29 I P("SYRS")]"" D 30 . S PSJL=$$SETSTR^VALM1("Syr. Size:",PSJL,52,10)_$E(P("SYRS"),1,13) 31 . S:$L(P("SYRS"))>13 PSJL=PSJL_"..." 32 D SETTMP^PSJLMPRU("PSJI",PSJL) 33 D WRTDRG^PSJLIUTL("SOL") 34 DUR ; 35 S PSJL="" 36 N DUROUT,IVLIMIT S DUROUT=$$GETDUR^PSJLIVMD(PSGP,+PSJORD,$S(PSJORD["P":"P",1:"IV")) 37 I $G(PSJORD)["P" N ND25 S ND25=$G(^PS(53.1,+PSJORD,2.5)),IVLIMIT=$P(ND25,"^",4) D 38 .S IVLIMIT=$S(IVLIMIT]"":$$FMTDUR^PSJLIVMD(IVLIMIT),1:"") S:IVLIMIT]"" DUROUT=IVLIMIT 39 S LABEL=$S($G(IVLIMIT):"IV Limit: ",1:"Duration: ") K IVLIMIT 40 S PSJL=$$SETSTR^VALM1(LABEL,PSJL,12,10) 41 S PSJL=PSJL_DUROUT 42 START ; 43 D FLDNO^PSJLIUTL("(4)",47) 44 S PSJL=$$SETSTR^VALM1("Start:",PSJL,56,7)_$$STARTDT^PSJLIUTL 45 D SETTMP^PSJLMPRU("PSJI",PSJL) 46 NEW PSGRSD,PSGRSDN,PSGRFD,PSGRFDN 47 S PSJL="" I $G(PSJORD)["P",$G(PSGRDTX) D 48 . N RSDLABL,PSJRQB,PSJRQL,PSGRSD,PSGSRSDN 49 . S RSDLABL=" REQUESTED START: ",PSJRQB=41,PSJRQL=39,PSGRSD="",PSGRSDN="" 50 . I $G(PSGRDTX(+$G(PSJORD),"PSGRSD")),$G(P(2)) S PSJRQB=51,PSJRQL=29 D 51 .. S PSGRSD=PSGRDTX(+$G(PSJORD),"PSGRSD"),PSGRSDN=$$ENDTC^PSGMI(+PSGRSD),RSDLABL="Calc Start: " 52 . I '$G(P(2)),'$P(PSGRDTX,U,3) S PSGRSD=+PSGRDTX,PSGRSDN=$$ENDTC^PSGMI(PSGRSD) 53 . I $G(PSGRSD),($G(PSGRSDN)]"") D DSPLYDT^PSJLIVMD(PSJLMX+5,.PSGRSD,.PSGRSDN,RSDLABL,1,PSJRQB,PSJRQL),SETTMP^PSJLMPRU("PSJI",PSJL) 54 INFRATE ; 55 S PSJL="" D FLDNO^PSJLIUTL("(3)",1) 56 S PSJL=$$SETSTR^VALM1("Infusion Rate:",PSJL,7,15) 57 D LONG^PSJLIUTL(P(8),22,24) 58 LASTREN ; 59 N PSGRNDT S PSGRNDT=$$LASTREN^PSJLMPRI(DFN,$S($G(PSJORD):PSJORD,1:$G(ON))) I PSGRNDT D 60 . S PSGRNDT=$$ENDTC^PSGMI(+PSGRNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,54,32) 61 D SETTMP^PSJLMPRU("PSJI",PSJL) 62 MR ; 63 S PSJL="" D FLDNO^PSJLIUTL("(5)",1) 64 S PSJL=$$SETSTR^VALM1("Med Route:",PSJL,11,11) 65 S PSJL=PSJL_$P(P("MR"),U,2) 66 STOP ; 67 D FLDNO^PSJLIUTL("(6)",47) 68 ;PSJ*5*180 - If Invalid Duration/Limit - Cannot Calculate Stop Date 69 S PSJL=$$SETSTR^VALM1("Stop:",PSJL,57,6)_$S($G(PSJBADD)=1:"CANNOT CALCULATE",1:$$STOPDT^PSJLIUTL) 70 D SETTMP^PSJLMPRU("PSJI",PSJL) 71 S PSJL="" 72 N PSJBCMA S PSJBCMA=$$BCMALG^PSJUTL2(DFN,PSJORD) 73 I $G(PSJBCMA)]"" S PSJL=$$SETSTR^VALM1(PSJBCMA,PSJL,1,52) 74 I $G(PSGRDTX(+PSJORD,"PSGRFD")) S PSGRFD=PSGRDTX(+PSJORD,"PSGRFD"),PSGRFDN=$$ENDTC^PSGMI(PSGRFD) D 75 . D DSPLYDT^PSJLIVMD(PSJLMX+7,.PSGRFD,.PSGRFDN," Calc Stop: ",0,51,29) 76 D:($G(PSJBCMA)]"")!($G(PSGRFD)]"") SETTMP^PSJLMPRU("PSJI",PSJL) 77 SCH ; 78 S PSJL="" D FLDNO^PSJLIUTL("(7)",1) 79 S PSJL=$$SETSTR^VALM1("Schedule:",PSJL,12,11) 80 D LONG^PSJLIUTL(P(9),22,32) S PSJL=PSJL_$S(P(7):"@0 labels a day",1:"") 81 LASTFL ; 82 S PSJL=$$SETSTR^VALM1("Last Fill:",PSJL,52,11) 83 S PSJL=PSJL_$$ENDTC^PSGMI(P("LF")) 84 D SETTMP^PSJLMPRU("PSJI",PSJL) 85 ADM ; 86 S PSJL="" D FLDNO^PSJLIUTL("(8)",1) 87 S PSJL=$$SETSTR^VALM1("Admin Times:",PSJL,9,14) 88 D LONG^PSJLIUTL(P(11),22,30) 89 QTY ; 90 S PSJL=$$SETSTR^VALM1("Quantity:",PSJL,53,10)_+P("LFA") 91 D SETTMP^PSJLMPRU("PSJI",PSJL) 92 PROVIDER ; 93 S PSJL="" D FLDNO^PSJLIUTL("(9)",1) 94 S PSJL=$$SETSTR^VALM1("Provider:",PSJL,12,10)_$$PROVIDER^PSJLIUTL 95 CUMDOSES ; 96 S PSJL=$$SETSTR^VALM1("Cum. Doses:",PSJL,51,12)_P("CUM") 97 D SETTMP^PSJLMPRU("PSJI",PSJL) 98 OPI ; 99 S PSJL="" D FLDNO^PSJLIUTL("(10)",1) 100 S PSJL=$$SETSTR^VALM1("Other Print"_$S($P(P("OPI"),"^",2)=1:"!: ",1:": "),PSJL,9,13)_$P(P("OPI"),"^") 101 D SETTMP^PSJLMPRU("PSJI",PSJL) 102 PC ; 103 S PSJL="" 104 S PSJL=$$SETSTR^VALM1("Provider Comments:",PSJL,3,18) D WTPC^PSJLIUTL 105 REMARK ; 106 D SETTMP^PSJLMPRU("PSJI","") 107 S PSJL="" D FLDNO^PSJLIUTL("(11)",1) 108 S PSJL=$$SETSTR^VALM1("Remarks :",PSJL,8,10) 109 D LONG^PSJLIUTL(P("REM"),18,62) 110 D SETTMP^PSJLMPRU("PSJI",PSJL) 111 IVROOM ; 112 S PSJL="" 113 S PSJL=$$SETSTR^VALM1("IV Room:",PSJL,9,9)_$P(P("IVRM"),U,2) 114 D SETTMP^PSJLMPRU("PSJI",PSJL) 115 ENTRY ; 116 S PSJL="",PSJL=$$SETSTR^VALM1("Entry By:",PSJL,8,10) 117 S PSJL=PSJL_$S($P(P("CLRK"),U,2)]"":$E($P(P("CLRK"),U,2),1,18),1:"*** Undefined") 118 S PSJL=$$SETSTR^VALM1("Entry Date:",PSJL,51,12)_$$ENDTC^PSGMI(P("LOG")) 119 D SETTMP^PSJLMPRU("PSJI",PSJL) 120 S PSJL="" S PSGLRN=$$LASTRNBY^PSJLMPRI(DFN,$S($G(PSJORD):PSJORD,1:$G(ON))) I PSGLRN D 121 . S PSJL=$$SETSTR^VALM1("Renewed By: ",PSJL,6,12)_$$ENNPN^PSGMI(PSGLRN) D SETTMP^PSJLMPRU("PSJI",PSJL) K PSGLRN 122 S VALM("TITLE")=$$CODES^PSIVUTL(P(17),$S($G(ON)["P":53.1,1:55.01),$S(ON["P":28,1:100))_" IV " 123 I $G(P("PRY"))="D"!($G(P("PON"))["P") S VALM("TITLE")=VALM("TITLE")_$S($G(P("PRY"))="":"",1:"("_$$CODES^PSIVUTL(P("PRY"),53.1,.24)_")") 124 I $G(P("PON"))["P" D ORDCHK 125 S VALMCNT=PSJLN-1,^TMP("PSJI",$J,0)=VALMCNT 126 Q 127 ; 128 ORDCHK ;Display order check for pending order 129 Q:'$O(^PS(53.1,+ON,10,0)) 130 NEW PSJIVX,PSJIVXX 131 F PSJIVX=0:0 S PSJIVX=$O(^PS(53.1,+ON,10,PSJIVX)) Q:'PSJIVX D 132 . D SETTMP^PSJLMPRU("PSJI","") 133 . S PSJL="Order Checks :" D LONG^PSJLIUTL($G(^PS(53.1,+ON,10,PSJIVX,0)),22,60) 134 . D SETTMP^PSJLMPRU("PSJI",PSJL) 135 . S PSJL="Overriding Provider: "_$P($G(^PS(53.1,+ON,10,PSJIVX,1)),U) 136 . D SETTMP^PSJLMPRU("PSJI",PSJL) 137 . S PSJL="Overriding Reason : " 138 . F PSJIVXX=0:0 S PSJIVXX=$O(^PS(53.1,+ON,10,PSJIVX,2,PSJIVXX)) Q:'PSJIVXX D 139 .. D LONG^PSJLIUTL($G(^PS(53.1,+ON,10,PSJIVX,2,PSJIVXX,0)),22,60) 140 .. D SETTMP^PSJLMPRU("PSJI",PSJL) S PSJL="" 141 Q 142 ; 143 SCHREQ(IVAR) ; 144 I $G(IVAR(4))="P"!($G(IVAR(23))="P")!($G(IVAR(5))) Q 1 145 Q 0 1 PSJLIVFD ;BIR/MV-SETUP LM TEMPLATE FOR IV FLUID ;4 Aug 00 / 2:37 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**7,50,63,64,58,81,91,80,116,110,111,180**;16 DEC 97;Build 5 3 ; 4 ; Reference to ^VALM0 is supported by DBIA # 2615. 5 ; 6 ;NFI changes for FR# 3@AD+4 7 ; 8 EN ; Build LM template to display IV order. 9 K ^TMP("PSJI",$J) 10 S UL80="",$P(UL80,"=",80)="" 11 S PSJLN=1 12 AD ; 13 NEW VALMEVL S VALMEVL=1 14 S PSJL="" D FLDNO^PSJLIUTL("(1)",1) 15 S PSJL=PSJL_"Additives:" 16 S:$G(P("PON"))["V"&(P(17)'="N") PSJL=$$SETSTR^VALM1("Order number:",PSJL,30,14)_+P("PON") 17 S PSJL=$$SETSTR^VALM1("Type:",PSJL,57,6)_$$TYPE^PSJLIUTL 18 NEW PSJVD S PSJVD=$$DINFLIV^PSJDIN(.DRG) 19 S PSJL=$$SETSTR^VALM1(PSJVD,PSJL,75,6) 20 I '$D(IORVON),$D(IOST(0)) D ENS^%ZISS,TERM^VALM0 21 I $D(IORVON),(PSJVD]"") D CNTRL^VALM10(1,76,5,IORVON,IORVOFF,0) K PSJVD 22 D SETTMP^PSJLMPRU("PSJI",PSJL) 23 D:+$G(PSJLMX) CLRDSPL^PSJLIVMD 24 ;PSJLMX count number of lines needed to display the add/sol 25 S PSJLMX=0 D WRTDRG^PSJLIUTL("AD") 26 SOL ; 27 S PSJL="" D FLDNO^PSJLIUTL("(2)",1) 28 S PSJL=PSJL_"Solutions:" 29 I P("SYRS")]"" D 30 . S PSJL=$$SETSTR^VALM1("Syr. Size:",PSJL,52,10)_$E(P("SYRS"),1,13) 31 . S:$L(P("SYRS"))>13 PSJL=PSJL_"..." 32 D SETTMP^PSJLMPRU("PSJI",PSJL) 33 D WRTDRG^PSJLIUTL("SOL") 34 DUR ; 35 S PSJL="" 36 N DUROUT,IVLIMIT S DUROUT=$$GETDUR^PSJLIVMD(PSGP,+PSJORD,$S(PSJORD["P":"P",1:"IV")) 37 S LABEL=$S($G(IVLIMIT):"IV Limit: ",1:"Duration: ") K IVLIMIT 38 S PSJL=$$SETSTR^VALM1(LABEL,PSJL,12,10) 39 S PSJL=PSJL_DUROUT 40 START ; 41 D FLDNO^PSJLIUTL("(4)",47) 42 S PSJL=$$SETSTR^VALM1("Start:",PSJL,56,7)_$$STARTDT^PSJLIUTL 43 D SETTMP^PSJLMPRU("PSJI",PSJL) 44 NEW PSGRSD,PSGRSDN,PSGRFD,PSGRFDN 45 S PSJL="" I $G(PSJORD)["P",$G(PSGRDTX) D 46 . N RSDLABL,PSJRQB,PSJRQL,PSGRSD,PSGSRSDN 47 . S RSDLABL=" REQUESTED START: ",PSJRQB=41,PSJRQL=39,PSGRSD="",PSGRSDN="" 48 . I $G(PSGRDTX(+$G(PSJORD),"PSGRSD")),$G(P(2)) S PSJRQB=51,PSJRQL=29 D 49 .. S PSGRSD=PSGRDTX(+$G(PSJORD),"PSGRSD"),PSGRSDN=$$ENDTC^PSGMI(+PSGRSD),RSDLABL="Calc Start: " 50 . I '$G(P(2)),'$P(PSGRDTX,U,3) S PSGRSD=+PSGRDTX,PSGRSDN=$$ENDTC^PSGMI(PSGRSD) 51 . I $G(PSGRSD),($G(PSGRSDN)]"") D DSPLYDT^PSJLIVMD(PSJLMX+5,.PSGRSD,.PSGRSDN,RSDLABL,1,PSJRQB,PSJRQL),SETTMP^PSJLMPRU("PSJI",PSJL) 52 INFRATE ; 53 S PSJL="" D FLDNO^PSJLIUTL("(3)",1) 54 S PSJL=$$SETSTR^VALM1("Infusion Rate:",PSJL,7,15) 55 D LONG^PSJLIUTL(P(8),22,24) 56 LASTREN ; 57 N PSGRNDT S PSGRNDT=$$LASTREN^PSJLMPRI(DFN,$S($G(PSJORD):PSJORD,1:$G(ON))) I PSGRNDT D 58 . S PSGRNDT=$$ENDTC^PSGMI(+PSGRNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,54,32) 59 D SETTMP^PSJLMPRU("PSJI",PSJL) 60 MR ; 61 S PSJL="" D FLDNO^PSJLIUTL("(5)",1) 62 S PSJL=$$SETSTR^VALM1("Med Route:",PSJL,11,11) 63 S PSJL=PSJL_$P(P("MR"),U,2) 64 STOP ; 65 D FLDNO^PSJLIUTL("(6)",47) 66 ;PSJ*5*180 - If Invalid Duration/Limit - Cannot Calculate Stop Date 67 S PSJL=$$SETSTR^VALM1("Stop:",PSJL,57,6)_$S($G(PSJBADD)=1:"CANNOT CALCULATE",1:$$STOPDT^PSJLIUTL) 68 D SETTMP^PSJLMPRU("PSJI",PSJL) 69 S PSJL="" 70 N PSJBCMA S PSJBCMA=$$BCMALG^PSJUTL2(DFN,PSJORD) 71 I $G(PSJBCMA)]"" S PSJL=$$SETSTR^VALM1(PSJBCMA,PSJL,1,52) 72 ;D:$G(PSGRFD) DSPLYDT^PSJLIVMD(PSJLMX+7,.PSGRFD,.PSGRFDN," REQUESTED STOP: ",P(3)'=PSGRFD) 73 I $G(PSGRDTX(+PSJORD,"PSGRFD")) S PSGRFD=PSGRDTX(+PSJORD,"PSGRFD"),PSGRFDN=$$ENDTC^PSGMI(PSGRFD) D 74 . D DSPLYDT^PSJLIVMD(PSJLMX+7,.PSGRFD,.PSGRFDN," Calc Stop: ",0,51,29) 75 D:($G(PSJBCMA)]"")!($G(PSGRFD)]"") SETTMP^PSJLMPRU("PSJI",PSJL) 76 SCH ; 77 S PSJL="" D FLDNO^PSJLIUTL("(7)",1) 78 S PSJL=$$SETSTR^VALM1("Schedule:",PSJL,12,11) 79 D LONG^PSJLIUTL(P(9),22,32) S PSJL=PSJL_$S(P(7):"@0 labels a day",1:"") 80 LASTFL ; 81 S PSJL=$$SETSTR^VALM1("Last Fill:",PSJL,52,11) 82 S PSJL=PSJL_$$ENDTC^PSGMI(P("LF")) 83 D SETTMP^PSJLMPRU("PSJI",PSJL) 84 ADM ; 85 S PSJL="" D FLDNO^PSJLIUTL("(8)",1) 86 S PSJL=$$SETSTR^VALM1("Admin Times:",PSJL,9,14) 87 D LONG^PSJLIUTL(P(11),22,30) 88 QTY ; 89 S PSJL=$$SETSTR^VALM1("Quantity:",PSJL,53,10)_+P("LFA") 90 D SETTMP^PSJLMPRU("PSJI",PSJL) 91 PROVIDER ; 92 S PSJL="" D FLDNO^PSJLIUTL("(9)",1) 93 S PSJL=$$SETSTR^VALM1("Provider:",PSJL,12,10)_$$PROVIDER^PSJLIUTL 94 CUMDOSES ; 95 ;S PSJL=$$SETSTR^VALM1("Cumulative Doses:",PSJL,45,17)_P("CUM") 96 S PSJL=$$SETSTR^VALM1("Cum. Doses:",PSJL,51,12)_P("CUM") 97 D SETTMP^PSJLMPRU("PSJI",PSJL) 98 OPI ; 99 S PSJL="" D FLDNO^PSJLIUTL("(10)",1) 100 S PSJL=$$SETSTR^VALM1("Other Print"_$S($P(P("OPI"),"^",2)=1:"!: ",1:": "),PSJL,9,13)_$P(P("OPI"),"^") 101 D SETTMP^PSJLMPRU("PSJI",PSJL) 102 PC ; 103 S PSJL="" 104 ;S PSJL=$$SETSTR^VALM1("Provider Comments:",PSJL,3,18) D SETTMP^PSJLMPRU("PSJI",PSJL) D WTPC^PSJLIUTL 105 S PSJL=$$SETSTR^VALM1("Provider Comments:",PSJL,3,18) D WTPC^PSJLIUTL 106 REMARK ; 107 D SETTMP^PSJLMPRU("PSJI","") 108 S PSJL="" D FLDNO^PSJLIUTL("(11)",1) 109 S PSJL=$$SETSTR^VALM1("Remarks :",PSJL,8,10) 110 D LONG^PSJLIUTL(P("REM"),18,62) 111 D SETTMP^PSJLMPRU("PSJI",PSJL) 112 IVROOM ; 113 S PSJL="" 114 S PSJL=$$SETSTR^VALM1("IV Room:",PSJL,9,9)_$P(P("IVRM"),U,2) 115 D SETTMP^PSJLMPRU("PSJI",PSJL) 116 ENTRY ; 117 S PSJL="",PSJL=$$SETSTR^VALM1("Entry By:",PSJL,8,10) 118 S PSJL=PSJL_$S($P(P("CLRK"),U,2)]"":$E($P(P("CLRK"),U,2),1,18),1:"*** Undefined") 119 S PSJL=$$SETSTR^VALM1("Entry Date:",PSJL,51,12)_$$ENDTC^PSGMI(P("LOG")) 120 D SETTMP^PSJLMPRU("PSJI",PSJL) 121 S PSJL="" S PSGLRN=$$LASTRNBY^PSJLMPRI(DFN,$S($G(PSJORD):PSJORD,1:$G(ON))) I PSGLRN D 122 . S PSJL=$$SETSTR^VALM1("Renewed By: ",PSJL,6,12)_$$ENNPN^PSGMI(PSGLRN) D SETTMP^PSJLMPRU("PSJI",PSJL) K PSGLRN 123 S VALM("TITLE")=$$CODES^PSIVUTL(P(17),$S($G(ON)["P":53.1,1:55.01),$S(ON["P":28,1:100))_" IV " 124 I $G(P("PRY"))="D"!($G(P("PON"))["P") S VALM("TITLE")=VALM("TITLE")_$S($G(P("PRY"))="":"",1:"("_$$CODES^PSIVUTL(P("PRY"),53.1,.24)_")") 125 I $G(P("PON"))["P" D ORDCHK 126 S VALMCNT=PSJLN-1,^TMP("PSJI",$J,0)=VALMCNT 127 Q 128 ; 129 ORDCHK ;Display order check for pending order 130 Q:'$O(^PS(53.1,+ON,10,0)) 131 NEW PSJIVX,PSJIVXX 132 F PSJIVX=0:0 S PSJIVX=$O(^PS(53.1,+ON,10,PSJIVX)) Q:'PSJIVX D 133 . D SETTMP^PSJLMPRU("PSJI","") 134 . S PSJL="Order Checks :" D LONG^PSJLIUTL($G(^PS(53.1,+ON,10,PSJIVX,0)),22,60) 135 . D SETTMP^PSJLMPRU("PSJI",PSJL) 136 . S PSJL="Overriding Provider: "_$P($G(^PS(53.1,+ON,10,PSJIVX,1)),U) 137 . D SETTMP^PSJLMPRU("PSJI",PSJL) 138 . S PSJL="Overriding Reason : " 139 . F PSJIVXX=0:0 S PSJIVXX=$O(^PS(53.1,+ON,10,PSJIVX,2,PSJIVXX)) Q:'PSJIVXX D 140 .. D LONG^PSJLIUTL($G(^PS(53.1,+ON,10,PSJIVX,2,PSJIVXX,0)),22,60) 141 .. D SETTMP^PSJLMPRU("PSJI",PSJL) S PSJL="" 142 Q 143 ; 144 SCHREQ(IVAR) ; 145 I $G(IVAR(4))="P"!($G(IVAR(23))="P")!($G(IVAR(5))) Q 1 146 Q 0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJLIVMD.m
r613 r623 1 PSJLIVMD ;BIR/MV-SETUP LM TEMPLATE FOR INPT MED. IV ;4 Aug 00 / 4:29 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**37,50,63,58,81,91,80,116,110,111,180,134**;16 DEC 97;Build 124 3 ; 4 ;Reference to ^PS(55 is supported by DBIA #2191. 5 ; 6 EN ; Build LM template to display IV order. 7 D GTOT^PSIVUTL(P(4)) 8 S:'$D(PSJSTAR) PSJSTAR="" S:'$D(PSGP) PSGP=DFN 9 I $E(P("OT"))'="I" D EN^PSJLIVFD Q 10 K ^TMP("PSJI",$J) 11 S UL80="",$P(UL80,"=",80)="" 12 S PSJLN=1 13 I $G(PSIV531),P("PON")["P" S (P(2),P(3),P(4))="" 14 AD ; 15 NEW VALMEVL S VALMEVL=1 16 S PSJL="" D FLDNO^PSJLIUTL("(1)",1) 17 S PSJL=PSJL_" Additives:" 18 S:$G(P("PON"))["V"&(P(17)'="N") PSJL=$$SETSTR^VALM1("Order number:",PSJL,28,14)_+P("PON") 19 S PSJL=$$SETSTR^VALM1("Type:",PSJL,57,6)_$$TYPE^PSJLIUTL 20 NEW PSJVD S PSJVD=$$DINFLIV^PSJDIN(.DRG) 21 S PSJL=$$SETSTR^VALM1(PSJVD,PSJL,75,6) 22 I $D(IORVON),(PSJVD]"") D CNTRL^VALM10(1,76,5,IORVON,IORVOFF,0) K PSJVD 23 D SETTMP^PSJLMPRU("PSJI",PSJL) 24 D:+$G(PSJLMX) CLRDSPL 25 ;PSJLMX count number of lines needed to display the add/sol 26 S PSJLMX=0 D WRTDRG^PSJLIUTL("AD") 27 SOL ; 28 S PSJL="" D FLDNO^PSJLIUTL("(2)",1) 29 S PSJL=PSJL_" Solutions:" 30 I P("SYRS")]"" D 31 . S PSJL=$$SETSTR^VALM1("Syr. Size:",PSJL,52,11)_$E(P("SYRS"),1,13) 32 . S:$L(P("SYRS"))>13 PSJL=PSJL_"..." 33 D SETTMP^PSJLMPRU("PSJI",PSJL) 34 D WRTDRG^PSJLIUTL("SOL") 35 D DUR 36 START ; 37 NEW PSGRSD,PSGRSDN,PSGRFD,PSGRFDN 38 I $G(P("OT"))="I",$G(P(4))]"" D 39 .Q:$G(ON)["V" I $G(PSIVAC)="" N PSIVAC S PSIVAC="CF" 40 .Q:$G(P(3)) 41 .D ENT^PSIVCAL,ENSTOP^PSIVCAL 42 D REQDT(ON) 43 D FLDNO^PSJLIUTL("(4)",47) 44 S PSJL=$$SETSTR^VALM1("Start:",PSJL,56,7)_$$STARTDT^PSJLIUTL 45 D SETTMP^PSJLMPRU("PSJI",PSJL) 46 INFRATE ; 47 S PSJL="" D FLDNO^PSJLIUTL("(3)",1) 48 S PSJL=$$SETSTR^VALM1("Infusion Rate:",PSJL,7,15) 49 D LONG^PSJLIUTL(P(8),22,23) 50 RSTART ; 51 I $G(ON)["P" N PSGNDT S PSGRNDT=$$LASTREN^PSJLMPRI(DFN,ON) D 52 . I PSGRNDT S PSGRNDT=$$ENDTC^PSGMI(+PSGRNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,54,32) Q 53 . Q:'$G(PSGRDTX) N PSJRQB,PSJRQL,RSDLABL,PSGRSD,PSGRSDN 54 . S RSDLABL=" REQUESTED START: ",PSJRQB=41,PSJRQL=39,PSGRSD="",PSGRSDN="" 55 . I $G(PSGRDTX(+$G(PSJORD),"PSGRSD")),$G(P(2)) S PSJRQB=51,PSJRQL=29 D 56 .. S PSGRSD=PSGRDTX(+$G(PSJORD),"PSGRSD"),PSGRSDN=$$ENDTC^PSGMI(+PSGRSD),RSDLABL="Calc Start: " 57 . I '$G(P(2)),'$P(PSGRDTX,U,3) S PSGRSD=+PSGRDTX,PSGRSDN=$$ENDTC^PSGMI(PSGRSD) 58 . I $G(PSGRSD),($G(PSGRSDN)]"") D DSPLYDT(PSJLMX+5,.PSGRSD,.PSGRSDN,RSDLABL,1,PSJRQB,PSJRQL) ;,SETTMP^PSJLMPRU("PSJI",PSJL) 59 I $G(ON)["V" N PSGRNDT S PSGRNDT=$$LASTREN^PSJLMPRI(DFN,ON) I PSGRNDT S PSGRNDT=$$ENDTC^PSGMI(+PSGRNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,54,32) 60 I PSJL]"" D SETTMP^PSJLMPRU("PSJI",PSJL) 61 ; 62 MR ; 63 S PSJL="" D FLDNO^PSJLIUTL("(5)",1) 64 S PSJL=$$SETSTR^VALM1("Med Route:",PSJL,11,11) 65 S PSJL=PSJL_$P(P("MR"),U,2) 66 STOP ; 67 S:'$D(PSGP) PSGP=DFN 68 D FLDNO^PSJLIUTL("(6)",47) 69 ;PSJ*5*180 - If CPRS sends invalid duration/limit - Cannot Calculate Stop Date. 70 S PSJL=$$SETSTR^VALM1("Stop:",PSJL,57,6)_$S($G(PSJBADD)=1:"CANNOT CALCULATE",1:$$STOPDT^PSJLIUTL) 71 D SETTMP^PSJLMPRU("PSJI",PSJL) 72 S PSJL="" 73 N PSJBCMA S PSJBCMA=$$BCMALG^PSJUTL2(PSGP,PSJORD) 74 I $G(PSJBCMA)]"",$G(DFN) S PSJL=$$SETSTR^VALM1(PSJBCMA,PSJL,1,52) 75 I $G(PSJORD)["P",$G(PSGRDTX(+$G(PSJORD),"PSGRFD")),$G(P(3)) S PSGRFDN=$$ENDTC^PSGMI(PSGRDTX(+PSJORD,"PSGRFD")) D 76 . D DSPLYDT(PSJLMX+7,.PSGRFD,.PSGRFDN," Calc Stop: ",1,51,29) 77 I ($G(PSJBCMA)]"")!($G(PSGRDTX(+$G(PSJORD),"PSGRFD"))&$G(P(3))) D SETTMP^PSJLMPRU("PSJI",PSJL) 78 SCH ; 79 S PSJL="" D FLDNO^PSJLIUTL("(7)",1) 80 S PSJL=$$SETSTR^VALM1("Schedule:",PSJL,12,11) 81 D LONG^PSJLIUTL(P(9)_$S(P(7):"@0 labels a day",1:"")_$G(SCHMSG),22,31) 82 LASTFL ; 83 S PSJL=$$SETSTR^VALM1("Last Fill:",PSJL,52,11) 84 S PSJL=PSJL_$$ENDTC^PSGMI(P("LF")) 85 D SETTMP^PSJLMPRU("PSJI",PSJL) 86 ADM ; 87 S PSJL="" D FLDNO^PSJLIUTL("(8)",1) 88 S PSJL=$$SETSTR^VALM1("Admin Times:",PSJL,9,14) 89 NEW NOECH 90 D LONG^PSJLIUTL(P(11),22,29) 91 QTY ; 92 S PSJL=$$SETSTR^VALM1("Quantity:",PSJL,53,10)_+P("LFA") 93 D SETTMP^PSJLMPRU("PSJI",PSJL) 94 PROVIDER ; 95 S PSJL="" D FLDNO^PSJLIUTL("(9)",1) 96 S PSJL=$$SETSTR^VALM1("Provider:",PSJL,12,10)_$$PROVIDER^PSJLIUTL 97 CUMDOSES ; 98 S PSJL=$$SETSTR^VALM1("Cum. Doses:",PSJL,51,12)_P("CUM") 99 D SETTMP^PSJLMPRU("PSJI",PSJL) 100 OI ; 101 S PSJL="" D FLDNO^PSJLIUTL("(10)",1) 102 S PSJL=$$SETSTR^VALM1("Orderable Item:",PSJL,6,16)_$P(P("PD"),U,2)_$$OINF^PSJDIN(+P("PD")) 103 D SETTMP^PSJLMPRU("PSJI",PSJL) 104 INS ; 105 S PSJL="" 106 S PSJL=$$SETSTR^VALM1("Instructions:",PSJL,8,14) 107 D LONG^PSJLIUTL(P("INS"),22,58) 108 D SETTMP^PSJLMPRU("PSJI",PSJL) 109 OPI ; 110 S PSJL="" D FLDNO^PSJLIUTL("(11)",1) 111 S PSJL=$$SETSTR^VALM1("Other Print"_$S($P(P("OPI"),"^",2)=1:"!: ",1:": "),PSJL,9,13)_$P(P("OPI"),"^") 112 D SETTMP^PSJLMPRU("PSJI",PSJL) 113 PC ; 114 S PSJL="" 115 S PSJL=$$SETSTR^VALM1("Provider Comments:",PSJL,3,18) D WTPC^PSJLIUTL 116 REMARK ; 117 D SETTMP^PSJLMPRU("PSJI","") 118 S PSJL="" D FLDNO^PSJLIUTL("(12)",1) 119 S PSJL=$$SETSTR^VALM1("Remarks :",PSJL,8,10) 120 D LONG^PSJLIUTL(P("REM"),18,62) 121 D SETTMP^PSJLMPRU("PSJI",PSJL) 122 IVROOM ; 123 S PSJL="" 124 S PSJL=$$SETSTR^VALM1("IV Room:",PSJL,9,9)_$P(P("IVRM"),U,2) 125 D SETTMP^PSJLMPRU("PSJI",PSJL) 126 ENTRY ; 127 S PSJL="",PSJL=$$SETSTR^VALM1("Entry By:",PSJL,8,10) 128 S PSJL=PSJL_$S($P(P("CLRK"),U,2)]"":$E($P(P("CLRK"),U,2),1,24),1:"*** Undefined") 129 S PSJL=$$SETSTR^VALM1("Entry Date:",PSJL,51,12)_$$ENDTC^PSGMI(P("LOG")) 130 D SETTMP^PSJLMPRU("PSJI",PSJL) 131 S PSJL="" S PSGLRN=$$LASTRNBY^PSJLMPRI(DFN,$S($G(PSJORD):PSJORD,1:$G(ON))) I PSGLRN D 132 . S PSJL=$$SETSTR^VALM1("Renewed By: ",PSJL,6,12)_$$ENNPN^PSGMI(PSGLRN) D SETTMP^PSJLMPRU("PSJI",PSJL) K PSGLRN 133 S VALM("TITLE")=$$CODES^PSIVUTL(P(17),$S($G(ON)["P":53.1,1:55.01),$S($G(ON)["P":28,1:100))_" IV " 134 I $G(P("PRY"))="D"!($G(P("PON"))["P") S VALM("TITLE")=VALM("TITLE")_$S($G(P("PRY"))="":"",1:"("_$$CODES^PSIVUTL(P("PRY"),53.1,.24)_")") 135 I $G(P("PON"))["P" D ORDCHK^PSJLIVFD 136 S VALMCNT=PSJLN-1,^TMP("PSJI",$J,0)=VALMCNT 137 Q 138 DSPLYDT(PSJLN,PSGRDT,PSGRDTN,TXT,PSJFSH,PSJRDBEG,PSJRDLEN) ; 139 ;LINE : Line number the Requested Start and Stop dates are display in 140 ;PSGRDT : Either it is the requested start or stop date in FM format 141 ;PSGRDTN: Either it is the requested start or stop date in IPM format 142 ;TXT : The display text 143 ;PSJFSH : if it is 1 then flash 144 ; 145 S:'$G(PSJRDBEG) PSJRDBEG=41,PSJRDLEN=39 146 S PSJL=$$SETSTR^VALM1(TXT_PSGRDTN,PSJL,PSJRDBEG,PSJRDLEN) 147 Q 148 CLRDSPL ; 149 ;Clear the blinking after edit the pending order. 150 ;Without it more than the requested start and stop dates are blinking at the ac/edit screen 151 ;PSJLMX: # ad/sol counted in WRTDRG^PSJLIUTL 152 Q:'$D(IOBOFF) 153 NEW PSJX 154 F PSJX=5:1:PSJLMX+7 D CNTRL^VALM10(PSJX,36,80,IOBOFF,IOINORM) 155 Q 156 REQDT(ORDER) ;Get requested date if it is a pending order 157 ;ORDER : Pending Order Number (PSJORD or PSGORD) 158 Q:ORDER'["P" D REQDT^PSJLIUTL(ORDER) 159 Q 160 ; 161 GETDUR(PAT,ORD,PKG,RAW) ; 162 ; PAT= Patient DFN 163 ; ORD= Order # 164 ; PKG= 5(UD), "IV"(IV), "P"(Pending) 165 N ACT,DUR,ND,ND25,F25,ND0,ND2,OLDORD S DUR="",ORD=+ORD K IVLIMIT 166 S:PKG="V" PKG="IV" 167 I PKG="P" S ND=$G(^PS(53.1,+ORD,0)) D I '$G(OLDORD) Q DUR 168 . I $G(P("OVRIDE")) S DUR="" Q 169 . D PENDING(ORD) Q:DUR]"" 170 . S ND0=$G(^PS(53.1,ORD,0)) I $P(ND0,U,24)="E" S OLDORD=$P(ND0,U,25) I OLDORD S PKG=$S(OLDORD["V":"IV",OLDORD["U":5,OLDORD["P":"P",1:"") 171 . Q:($G(OLDORD)'["P") 172 . D PENDING(OLDORD) S OLDORD="" 173 I PKG="IV" S ND2=$G(^PS(55,PAT,PKG,ORD,2)) I $P(ND2,U,8)="E" S OLDORD=$P(ND2,U,5) S:OLDORD'["V" OLDORD="" I OLDORD D 174 .N ACTND S ACTND=0 F S ACTND=$O(^PS(55,PAT,"IV",ORD,"A",ACTND)) Q:'ACTND D 175 ..I $G(^PS(55,PAT,"IV",ORD,"A",ACTND,0))["IV LIMIT OVERRIDDEN" S OLDORD="" 176 I $G(P("LIMIT"))]"" S DUR=P("LIMIT"),IVLIMIT=1 I '$G(RAW) S DUR=$$FMTDUR(DUR) Q DUR 177 I PKG=5 S ND0=$G(^PS(55,PAT,PKG,ORD,0)) I $P(ND0,U,24)="E" S OLDORD=$P(ND0,U,25) S:OLDORD'["U" OLDORD="" 178 S F25="^PS(55,PAT,PKG,ORD,2.5)" I '$G(OLDORD) Q:'$D(@(F25)) DUR 179 S ND25=$G(@(F25)) S DUR=$P(ND25,U,2) I DUR="" S DUR=$P(ND25,U,4) I DUR]"" S IVLIMIT=1 180 I DUR="",$G(OLDORD) S ORD=+OLDORD Q:'$D(@(F25)) DUR D 181 . S ND25=$G(@(F25)) S DUR=$P(ND25,U,2) I DUR="" S DUR=$P(ND25,U,4) I DUR]"" S IVLIMIT=1 182 I '$G(RAW),DUR]"" S DUR=$$FMTDUR(DUR) 183 Q DUR 184 ; 185 PENDING(PNDON) ; 186 S ND=$G(^PS(53.1,+ORD,0)) 187 I ND S ND25=$S(($P(ND,U,15)=PAT):$G(^PS(53.1,+ORD,2.5)),1:"") 188 S DUR=$P(ND25,U,4) I DUR]"" D Q 189 .S:($E(DUR)="s")!($E(DUR)="m")!($E(DUR)="l")!($E(DUR)="d")!($E(DUR)="h")!($E(DUR)="a") IVLIMIT=1 S DUR=$S($G(RAW):DUR,1:$$FMTDUR(DUR)) 190 S DUR=$P(ND25,U,2) I DUR]"" S DUR=$S($G(RAW):DUR,1:$$FMTDUR(DUR)) 191 Q 192 ; 193 FMTDUR(DURCODE) ; 194 N DUNIT,DNUM,BAD S BAD=0 195 ;PSJ*5*180 - Add PSJBADD variable 196 K PSJBADD S PSJBADD=0 197 S DUNIT=$E(DURCODE),DNUM=$P(DURCODE,DUNIT,2) I 'DNUM S BAD=1 198 I DUNIT'="",DUNIT'?1(1U,1L) S PSJBADD=1 199 S DUNIT=$S(DUNIT="D"!(DUNIT="d"):" day",DUNIT="H"!(DUNIT="h"):" hour",DUNIT="W":" week",DUNIT="L":" month",DUNIT="M":" minute",DUNIT="S":" second",DUNIT="m":" ml",DUNIT="l":" liter",DUNIT="a":" dose",1:"") 200 S:DUNIT="" BAD=1 I (DNUM'=1),(DUNIT'["ml") S DUNIT=DUNIT_"s" 201 I PSJBADD=1 S PSGACT=$TR($G(PSGACT),"F") 202 Q $S(PSJBADD=1:"*INVALID DURATION/LIMIT*",BAD:"",1:DNUM_DUNIT) 203 ; 204 DURMIN(DCOD) ; 205 N DUR,DMIN,CHR S DUR="" F I=1:1:$L(DCOD) S CHR=$E(DCOD,I) I CHR?1N S DUR=DUR_CHR 206 S DMIN=DUR*$S(DCOD["L":43200,DCOD["W":10080,DCOD["M":1,DCOD["S":(1/60),DCOD["D":1440,1:0) S DMIN=+$FN(DMIN,"",1) 207 Q DMIN 208 ; 209 DUR ; 210 N DUROUT,LABEL,IVLIMIT 211 Q:'$G(PSJORD) S PSJL="" 212 S DUROUT=$$GETDUR^PSJLIVMD(PSGP,+PSJORD,$S(PSJORD["P":"P",1:"IV")) 213 S LABEL=$S($G(IVLIMIT):"IV Limit: ",1:"Duration: ") K IVLIMIT 214 S PSJL=$$SETSTR^VALM1(LABEL,PSJL,12,10) 215 S PSJL=PSJL_DUROUT 216 Q 1 PSJLIVMD ;BIR/MV-SETUP LM TEMPLATE FOR INPT MED. IV ;4 Aug 00 / 4:29 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**37,50,63,58,81,91,80,116,110,111,180**;16 DEC 97;Build 5 3 ; 4 ;Reference to ^PS(55 is supported by DBIA #2191. 5 ; 6 EN ; Build LM template to display IV order. 7 D GTOT^PSIVUTL(P(4)) 8 S:'$D(PSJSTAR) PSJSTAR="" S:'$D(PSGP) PSGP=DFN 9 I $E(P("OT"))'="I" D EN^PSJLIVFD Q 10 K ^TMP("PSJI",$J) 11 S UL80="",$P(UL80,"=",80)="" 12 S PSJLN=1 13 I $G(PSIV531),P("PON")["P" S (P(2),P(3),P(4))="" 14 AD ; 15 NEW VALMEVL S VALMEVL=1 16 S PSJL="" D FLDNO^PSJLIUTL("(1)",1) 17 S PSJL=PSJL_" Additives:" 18 S:$G(P("PON"))["V"&(P(17)'="N") PSJL=$$SETSTR^VALM1("Order number:",PSJL,28,14)_+P("PON") 19 S PSJL=$$SETSTR^VALM1("Type:",PSJL,57,6)_$$TYPE^PSJLIUTL 20 NEW PSJVD S PSJVD=$$DINFLIV^PSJDIN(.DRG) 21 S PSJL=$$SETSTR^VALM1(PSJVD,PSJL,75,6) 22 I $D(IORVON),(PSJVD]"") D CNTRL^VALM10(1,76,5,IORVON,IORVOFF,0) K PSJVD 23 D SETTMP^PSJLMPRU("PSJI",PSJL) 24 D:+$G(PSJLMX) CLRDSPL 25 ;PSJLMX count number of lines needed to display the add/sol 26 S PSJLMX=0 D WRTDRG^PSJLIUTL("AD") 27 SOL ; 28 S PSJL="" D FLDNO^PSJLIUTL("(2)",1) 29 S PSJL=PSJL_" Solutions:" 30 I P("SYRS")]"" D 31 . S PSJL=$$SETSTR^VALM1("Syr. Size:",PSJL,52,11)_$E(P("SYRS"),1,13) 32 . S:$L(P("SYRS"))>13 PSJL=PSJL_"..." 33 D SETTMP^PSJLMPRU("PSJI",PSJL) 34 D WRTDRG^PSJLIUTL("SOL") 35 D DUR 36 START ; 37 NEW PSGRSD,PSGRSDN,PSGRFD,PSGRFDN 38 D REQDT(ON) 39 D FLDNO^PSJLIUTL("(4)",47) 40 S PSJL=$$SETSTR^VALM1("Start:",PSJL,56,7)_$$STARTDT^PSJLIUTL 41 D SETTMP^PSJLMPRU("PSJI",PSJL) 42 INFRATE ; 43 S PSJL="" D FLDNO^PSJLIUTL("(3)",1) 44 S PSJL=$$SETSTR^VALM1("Infusion Rate:",PSJL,7,15) 45 D LONG^PSJLIUTL(P(8),22,23) 46 RSTART ; 47 I $G(ON)["P" N PSGNDT S PSGRNDT=$$LASTREN^PSJLMPRI(DFN,ON) D 48 . I PSGRNDT S PSGRNDT=$$ENDTC^PSGMI(+PSGRNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,54,32) Q 49 . Q:'$G(PSGRDTX) N PSJRQB,PSJRQL,RSDLABL,PSGRSD,PSGRSDN 50 . S RSDLABL=" REQUESTED START: ",PSJRQB=41,PSJRQL=39,PSGRSD="",PSGRSDN="" 51 . I $G(PSGRDTX(+$G(PSJORD),"PSGRSD")),$G(P(2)) S PSJRQB=51,PSJRQL=29 D 52 .. S PSGRSD=PSGRDTX(+$G(PSJORD),"PSGRSD"),PSGRSDN=$$ENDTC^PSGMI(+PSGRSD),RSDLABL="Calc Start: " 53 . I '$G(P(2)),'$P(PSGRDTX,U,3) S PSGRSD=+PSGRDTX,PSGRSDN=$$ENDTC^PSGMI(PSGRSD) 54 . I $G(PSGRSD),($G(PSGRSDN)]"") D DSPLYDT(PSJLMX+5,.PSGRSD,.PSGRSDN,RSDLABL,1,PSJRQB,PSJRQL) ;,SETTMP^PSJLMPRU("PSJI",PSJL) 55 I $G(ON)["V" N PSGRNDT S PSGRNDT=$$LASTREN^PSJLMPRI(DFN,ON) I PSGRNDT S PSGRNDT=$$ENDTC^PSGMI(+PSGRNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,54,32) 56 I PSJL]"" D SETTMP^PSJLMPRU("PSJI",PSJL) 57 ; 58 MR ; 59 S PSJL="" D FLDNO^PSJLIUTL("(5)",1) 60 S PSJL=$$SETSTR^VALM1("Med Route:",PSJL,11,11) 61 S PSJL=PSJL_$P(P("MR"),U,2) 62 STOP ; 63 S:'$D(PSGP) PSGP=DFN 64 D FLDNO^PSJLIUTL("(6)",47) 65 ;PSJ*5*180 - If CPRS sends invalid duration/limit - Cannot Calculate Stop Date. 66 S PSJL=$$SETSTR^VALM1("Stop:",PSJL,57,6)_$S($G(PSJBADD)=1:"CANNOT CALCULATE",1:$$STOPDT^PSJLIUTL) 67 D SETTMP^PSJLMPRU("PSJI",PSJL) 68 S PSJL="" 69 N PSJBCMA S PSJBCMA=$$BCMALG^PSJUTL2(PSGP,PSJORD) 70 I $G(PSJBCMA)]"",$G(DFN) S PSJL=$$SETSTR^VALM1(PSJBCMA,PSJL,1,52) 71 I $G(PSJORD)["P",$G(PSGRDTX(+$G(PSJORD),"PSGRFD")),$G(P(3)) S PSGRFDN=$$ENDTC^PSGMI(PSGRDTX(+PSJORD,"PSGRFD")) D 72 . D DSPLYDT(PSJLMX+7,.PSGRFD,.PSGRFDN," Calc Stop: ",1,51,29) 73 I ($G(PSJBCMA)]"")!($G(PSGRDTX(+$G(PSJORD),"PSGRFD"))&$G(P(3))) D SETTMP^PSJLMPRU("PSJI",PSJL) 74 SCH ; 75 S PSJL="" D FLDNO^PSJLIUTL("(7)",1) 76 S PSJL=$$SETSTR^VALM1("Schedule:",PSJL,12,11) 77 D LONG^PSJLIUTL(P(9)_$S(P(7):"@0 labels a day",1:"")_$G(SCHMSG),22,31) 78 LASTFL ; 79 S PSJL=$$SETSTR^VALM1("Last Fill:",PSJL,52,11) 80 S PSJL=PSJL_$$ENDTC^PSGMI(P("LF")) 81 D SETTMP^PSJLMPRU("PSJI",PSJL) 82 ADM ; 83 S PSJL="" D FLDNO^PSJLIUTL("(8)",1) 84 S PSJL=$$SETSTR^VALM1("Admin Times:",PSJL,9,14) 85 NEW NOECH 86 D LONG^PSJLIUTL(P(11),22,29) 87 QTY ; 88 S PSJL=$$SETSTR^VALM1("Quantity:",PSJL,53,10)_+P("LFA") 89 D SETTMP^PSJLMPRU("PSJI",PSJL) 90 PROVIDER ; 91 S PSJL="" D FLDNO^PSJLIUTL("(9)",1) 92 S PSJL=$$SETSTR^VALM1("Provider:",PSJL,12,10)_$$PROVIDER^PSJLIUTL 93 CUMDOSES ; 94 S PSJL=$$SETSTR^VALM1("Cum. Doses:",PSJL,51,12)_P("CUM") 95 D SETTMP^PSJLMPRU("PSJI",PSJL) 96 OI ; 97 S PSJL="" D FLDNO^PSJLIUTL("(10)",1) 98 S PSJL=$$SETSTR^VALM1("Orderable Item:",PSJL,6,16)_$P(P("PD"),U,2)_$$OINF^PSJDIN(+P("PD")) 99 D SETTMP^PSJLMPRU("PSJI",PSJL) 100 INS ; 101 S PSJL="" 102 S PSJL=$$SETSTR^VALM1("Instructions:",PSJL,8,14) 103 D LONG^PSJLIUTL(P("INS"),22,58) 104 D SETTMP^PSJLMPRU("PSJI",PSJL) 105 OPI ; 106 S PSJL="" D FLDNO^PSJLIUTL("(11)",1) 107 S PSJL=$$SETSTR^VALM1("Other Print"_$S($P(P("OPI"),"^",2)=1:"!: ",1:": "),PSJL,9,13)_$P(P("OPI"),"^") 108 D SETTMP^PSJLMPRU("PSJI",PSJL) 109 PC ; 110 S PSJL="" 111 S PSJL=$$SETSTR^VALM1("Provider Comments:",PSJL,3,18) D WTPC^PSJLIUTL 112 REMARK ; 113 D SETTMP^PSJLMPRU("PSJI","") 114 S PSJL="" D FLDNO^PSJLIUTL("(12)",1) 115 S PSJL=$$SETSTR^VALM1("Remarks :",PSJL,8,10) 116 D LONG^PSJLIUTL(P("REM"),18,62) 117 D SETTMP^PSJLMPRU("PSJI",PSJL) 118 IVROOM ; 119 S PSJL="" 120 S PSJL=$$SETSTR^VALM1("IV Room:",PSJL,9,9)_$P(P("IVRM"),U,2) 121 D SETTMP^PSJLMPRU("PSJI",PSJL) 122 ENTRY ; 123 S PSJL="",PSJL=$$SETSTR^VALM1("Entry By:",PSJL,8,10) 124 S PSJL=PSJL_$S($P(P("CLRK"),U,2)]"":$E($P(P("CLRK"),U,2),1,24),1:"*** Undefined") 125 S PSJL=$$SETSTR^VALM1("Entry Date:",PSJL,51,12)_$$ENDTC^PSGMI(P("LOG")) 126 D SETTMP^PSJLMPRU("PSJI",PSJL) 127 S PSJL="" S PSGLRN=$$LASTRNBY^PSJLMPRI(DFN,$S($G(PSJORD):PSJORD,1:$G(ON))) I PSGLRN D 128 . S PSJL=$$SETSTR^VALM1("Renewed By: ",PSJL,6,12)_$$ENNPN^PSGMI(PSGLRN) D SETTMP^PSJLMPRU("PSJI",PSJL) K PSGLRN 129 S VALM("TITLE")=$$CODES^PSIVUTL(P(17),$S($G(ON)["P":53.1,1:55.01),$S($G(ON)["P":28,1:100))_" IV " 130 I $G(P("PRY"))="D"!($G(P("PON"))["P") S VALM("TITLE")=VALM("TITLE")_$S($G(P("PRY"))="":"",1:"("_$$CODES^PSIVUTL(P("PRY"),53.1,.24)_")") 131 I $G(P("PON"))["P" D ORDCHK^PSJLIVFD 132 S VALMCNT=PSJLN-1,^TMP("PSJI",$J,0)=VALMCNT 133 Q 134 DSPLYDT(PSJLN,PSGRDT,PSGRDTN,TXT,PSJFSH,PSJRDBEG,PSJRDLEN) ; 135 ;LINE : Line number the Requested Start and Stop dates are display in 136 ;PSGRDT : Either it is the requested start or stop date in FM format 137 ;PSGRDTN: Either it is the requested start or stop date in IPM format 138 ;TXT : The display text 139 ;PSJFSH : if it is 1 then flash 140 ; 141 S:'$G(PSJRDBEG) PSJRDBEG=41,PSJRDLEN=39 142 S PSJL=$$SETSTR^VALM1(TXT_PSGRDTN,PSJL,PSJRDBEG,PSJRDLEN) 143 Q 144 CLRDSPL ; 145 ;Clear the blinking after edit the pending order. 146 ;Without it more than the requested start and stop dates are blinking at the ac/edit screen 147 ;PSJLMX: # ad/sol counted in WRTDRG^PSJLIUTL 148 Q:'$D(IOBOFF) 149 NEW PSJX 150 F PSJX=5:1:PSJLMX+7 D CNTRL^VALM10(PSJX,36,80,IOBOFF,IOINORM) 151 Q 152 REQDT(ORDER) ;Get requested date if it is a pending order 153 ;ORDER : Pending Order Number (PSJORD or PSGORD) 154 Q:ORDER'["P" D REQDT^PSJLIUTL(ORDER) 155 Q 156 ; 157 GETDUR(PAT,ORD,PKG,RAW) ; 158 ; PAT= Patient DFN 159 ; ORD= Order # 160 ; PKG= 5(UD), "IV"(IV), "P"(Pending) 161 N ACT,DUR,ND,ND25,F25,ND0,ND2,OLDORD S DUR="",ORD=+ORD K IVLIMIT 162 S:PKG="V" PKG="IV" 163 I PKG="P" S ND=$G(^PS(53.1,+ORD,0)) D I '$G(OLDORD) Q DUR 164 . D PENDING(ORD) Q:DUR]"" 165 . S ND0=$G(^PS(53.1,ORD,0)) I $P(ND0,U,24)="E" S OLDORD=$P(ND0,U,25) I OLDORD S PKG=$S(OLDORD["V":"IV",OLDORD["U":5,OLDORD["P":"P",1:"") 166 . Q:($G(OLDORD)'["P") 167 . D PENDING(OLDORD) S OLDORD="" 168 I PKG="IV" S ND2=$G(^PS(55,PAT,PKG,ORD,2)) I $P(ND2,U,8)="E" S OLDORD=$P(ND2,U,5) S:OLDORD'["V" OLDORD="" 169 I PKG=5 S ND0=$G(^PS(55,PAT,PKG,ORD,0)) I $P(ND0,U,24)="E" S OLDORD=$P(ND0,U,25) S:OLDORD'["U" OLDORD="" 170 S F25="^PS(55,PAT,PKG,ORD,2.5)" I '$G(OLDORD) Q:'$D(@(F25)) DUR 171 S ND25=$G(@(F25)) S DUR=$P(ND25,U,2) I DUR="" S DUR=$P(ND25,U,4) I DUR]"" S IVLIMIT=1 172 I DUR="",$G(OLDORD) S ORD=+OLDORD Q:'$D(@(F25)) DUR D 173 . S ND25=$G(@(F25)) S DUR=$P(ND25,U,2) I DUR="" S DUR=$P(ND25,U,4) I DUR]"" S IVLIMIT=1 174 I '$G(RAW),DUR]"" S DUR=$$FMTDUR(DUR) 175 Q DUR 176 ; 177 PENDING(PNDON) ; 178 S ND=$G(^PS(53.1,+ORD,0)) 179 I ND S ND25=$S(($P(ND,U,15)=PAT):$G(^PS(53.1,+ORD,2.5)),1:"") 180 S DUR=$P(ND25,U,4) I DUR]"" S:$E(DUR)="m"!($E(DUR)="l")!($E(DUR)="d")!($E(DUR)="h") IVLIMIT=1 S DUR=$S($G(RAW):DUR,1:$$FMTDUR(DUR)) Q 181 S DUR=$P(ND25,U,2) I DUR]"" S DUR=$S($G(RAW):DUR,1:$$FMTDUR(DUR)) 182 Q 183 ; 184 FMTDUR(DURCODE) ; 185 N DUNIT,DNUM,BAD S BAD=0 186 ;PSJ*5*180 - Add PSJBADD variable 187 K PSJBADD S PSJBADD=0 188 S DUNIT=$E(DURCODE),DNUM=$P(DURCODE,DUNIT,2) I 'DNUM S BAD=1 189 I DUNIT'="",DUNIT'?1(1U,1L) S PSJBADD=1 190 S DUNIT=$S(DUNIT="D"!(DUNIT="d"):" day",DUNIT="H"!(DUNIT="h"):" hour",DUNIT="W":" week",DUNIT="L":" month",DUNIT="M":" minute",DUNIT="S":" second",DUNIT="m":" ml",DUNIT="l":" liter",1:"") 191 S:DUNIT="" BAD=1 I (DNUM'=1),(DUNIT'["ml") S DUNIT=DUNIT_"s" 192 I PSJBADD=1 S PSGACT=$TR($G(PSGACT),"F") 193 Q $S(PSJBADD=1:"*INVALID DURATION/LIMIT*",BAD:"",1:DNUM_DUNIT) 194 ; 195 DURMIN(DCOD) ; 196 N DUR,DMIN,CHR S DUR="" F I=1:1:$L(DCOD) S CHR=$E(DCOD,I) I CHR?1N S DUR=DUR_CHR 197 S DMIN=DUR*$S(DCOD["L":43200,DCOD["W":10080,DCOD["M":1,DCOD["S":(1/60),DCOD["D":1440,1:0) S DMIN=+$FN(DMIN,"",1) 198 Q DMIN 199 ; 200 DUR ; 201 N DUROUT,LABEL,IVLIMIT 202 Q:'$G(PSJORD) S PSJL="" 203 S DUROUT=$$GETDUR^PSJLIVMD(PSGP,+PSJORD,$S(PSJORD["P":"P",1:"IV")) 204 S LABEL=$S($G(IVLIMIT):"IV Limit: ",1:"Duration: ") K IVLIMIT 205 S PSJL=$$SETSTR^VALM1(LABEL,PSJL,12,10) 206 S PSJL=PSJL_DUROUT 207 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJLMPRU.m
r613 r623 1 PSJLMPRU ;BIR/MLM-INPATIENT LISTMAN UD PROFILE UTILITIES ;27 Aug 98 / 8:45 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**16,58,85,110,185**;16 DEC 97;Build 6 3 ; 4 ; Reference to ^PSDRUG is supported by DBIA 2192. 5 ; Reference to ^PS(55 is supported by DBIA 2191. 6 ; 7 PUD(DFN,ON,PSJF,DN) ; Setup LM profile view for UD 8 N PSJFLAG,PSJV 9 ; Naked references on the two lines below refer to full reference ^PS(55,DFN,5,+ON in PSJF using indirection. 10 S ND=$G(@(PSJF_+ON_",0)")),SCH=$G(^(2)),ND4=$G(^(4)),ND6=$G(^(6)),NDP2=$G(^(.2)),PSJFLAG=$P(NDP2,U,7),X=$P(DN,U,2),DO=$S('X:"",1:$G(^(+X))) S:X=.2 DO=$P(DO,U,2) 11 S ND14=$G(@(PSJF_+ON_",14,0)")),RNDT="" I $P(ND14,"^",3) S ND14=$G(^($P(ND14,"^",3),0)),RNDT=$P(ND14,"^") 12 I "AO"[PSJC D 13 .;S V='$P(ND4,"^",UDU),PSJL=$$SETSTR^VALM1($S(ND4="":" ",$P(ND4,"^",12):"D",$P(ND4,"^",18)&($P(ND4,"^",19)!V):"H",$P(ND4,"^",22)&($P(ND4,"^",23)!V):"H",$P(ND4,"^",15)&($P(ND4,"^",16)!V):"R",1:" "),PSJL,5,1) 14 .S V='$P(ND4,"^",UDU),PSJL=$$SETSTR^VALM1($S(ND4="":" ",$P(ND4,"^",12):"D",$P(ND4,"^",19)&$P(ND4,"^",18):"H",$P(ND4,"^",23)&$P(ND4,"^",22):"H",$P(ND4,"^",15)&($P(ND4,"^",16)!V):"R",1:" "),PSJL,5,1) 15 .;S X=$S(+PSJSYSU=1&V:1,+PSJSYSU=3&V:1,1:0) 16 .S PSJV=$S($P(NDP2,U,4)="D":"d",1:" ")_$S(+PSJSYSU=1&V:"->",+PSJSYSU=3&V:"->",1:" ") I PSJFLAG D CNTRL^VALM10(PSJLN,1,4,IORVON,IORVOFF,0) 17 .S PSJL=$$SETSTR^VALM1(PSJV,PSJL,6,3) 18 ;I $S(PSJC["C":0,1:PSJC["B") S PSJL=$$SETSTR^VALM1($S($P(ND4,"^",12):"D",1:" ")_$S($P(ND,U,4)="I":"",PSJSYSU:"->",1:""),PSJL,6,3) 19 ;I $S(PSJC["C":0,1:PSJC["B") S PSJL=$$SETSTR^VALM1($S($P(ND4,"^",12):"D",1:" ") 20 S RTE=$P(ND,"^",3),SM=$S('$P(ND,"^",5):0,$P(ND,"^",6):1,1:2),STAT=$S($P(ND,"^",9)]"":$P(ND,"^",9),1:"NF"),PF=$E("*",$P(ND,"^",20)>0),PSGID=$P(SCH,"^",2),SD=$P(SCH,"^",4),SCH=$P(SCH,"^") 21 I STAT="A",$P(ND,U,27)="R" S STAT="R" 22 ;S NF=$P(DN,"^",3),WS=$S(PSJPWD:$$WS^PSJO(PSJPWD,PSGP,PSJF,+ON),1:0) 23 S NF="",WS=$S(PSJPWD:$$WS^PSJO(PSJPWD,PSGP,PSJF,+ON),1:0) 24 N PSJDISP F PSJDISP=0:0 S PSJDISP=$O(@(PSJF_+ON_",1,"_PSJDISP_")")) Q:'PSJDISP D 25 .I $P($G(^PSDRUG(+$P($G(@(PSJF_+ON_",1,"_PSJDISP_",0)")),"^"),0)),"^",9)=1 S NF=1 26 NEW DRUGNAME,PSGID1,SD1,LEN,PSGID1,SD1 S LEN=$S($D(PSJEXPT):8,1:5) 27 F X="PSGID","SD" S @(X_1)=$S(PSJC["C":"*****",1:$E($$ENDTC^PSGMI(@X),1,LEN)) 28 D DRGDISP^PSJLMUT1(PSGP,ON,39,54,.DRUGNAME,0) 29 F PSJX=0:0 S PSJX=$O(DRUGNAME(PSJX)) Q:'PSJX D 30 . I PSJX=1 D 31 ..I PSJFLAG D CNTRL^VALM10(PSJLN,1,4,IORVON,IORVOFF,0) 32 ..S PSJL=$$SETSTR^VALM1($S($E(PSJS)="*":$P(PSJS,"^"),1:DRUGNAME(PSJX)),PSJL,9,39) 33 ..S PSJL=$$SETSTR^VALM1($S(PSJC["C":"?",PSJSCHT'="z":PSJSCHT,1:"?"),PSJL,50,3) 34 ..S PSJL=PSJL_PSGID1_" "_SD1_" "_$E(STAT,1)_" "_$S($G(RNDT):$E($$ENDTC^PSGMI(RNDT),1,LEN),1:"") 35 ..I NF!WS!SM!PF S PSJL=$$SETSTR^VALM1($S(NF:"NF ",WS:"WS ",SM:$E("HSM",SM,3),1:""),PSJL,69,3) S:PF PSJL=$$SETSTR^VALM1("*",PSJL,79,1) 36 . I PSJX>1 S PSJL="",PSJL=$$SETSTR^VALM1(DRUGNAME(PSJX),PSJL,11,66) 37 . D SETTMP("PSJPRO",PSJL) I ($P(NDP2,U,4)="S"),STAT="P" D CNTRL^VALM10((PSJLN-1),9,9+$L(PSJL),IOINHI_IOBON,IOINORM,0) 38 D:$P(ND6,"^")]"" PTXT($P(ND6,"^"),"PSJPRO",10,66) 39 Q 40 ; 41 PTXT(TXT,SUB,LM,RM) ; Display Instructions/dosage ordered. 42 ;* Input: TXT = Text to display. 43 ; SUB = First subscript for ^TMP node, ** MUST be PSJ namespace ** 44 ; LM = Begin display of text after LM spaces. 45 ; RM = Length of display text. 46 ; 47 ;BHW;PSJ*5*185;Extra spaces causes display to "skip" part of the field. 48 ;S PSJL="",$P(PSJL," ",LM)="" F X=1:1 S WRD=$P(TXT," ",X) Q:WRD="" D 49 S PSJL="",$P(PSJL," ",LM)="" 50 F X=1:1:$L(TXT," ") S WRD=$P(TXT," ",X) D 51 .;BHW;PSJ*5*185;check if end of string or just extra space. 52 .I WRD="" S PSJL=PSJL_" " Q 53 .I $L(PSJL_" "_WRD)'<RM D SETTMP(SUB,PSJL) S PSJL="",$P(PSJL," ",10)="" 54 .I $L(PSJL_" "_WRD)'<RM S PSJL=PSJL_" "_$E(WRD,1,(RM-10)) D SETTMP(SUB,PSJL) S PSJL="",$P(PSJL," ",10)="",WRD=$E(WRD,(RM-9),$L(WRD)) 55 .S PSJL=PSJL_" "_WRD 56 D SETTMP(SUB,PSJL) 57 Q 58 SETTMP(SUB,PSJL) ; 59 S ^TMP(SUB,$J,PSJLN,0)=PSJL,PSJLN=PSJLN+1 60 Q 1 PSJLMPRU ;BIR/MLM-INPATIENT LISTMAN UD PROFILE UTILITIES ;27 Aug 98 / 8:45 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**16,58,85,110**;16 DEC 97 3 ; 4 ; Reference to ^PSDRUG is supported by DBIA 2192. 5 ; Reference to ^PS(55 is supported by DBIA 2191. 6 ; 7 PUD(DFN,ON,PSJF,DN) ; Setup LM profile view for UD 8 N PSJFLAG,PSJV 9 ; Naked references on the two lines below refer to full reference ^PS(55,DFN,5,+ON in PSJF using indirection. 10 S ND=$G(@(PSJF_+ON_",0)")),SCH=$G(^(2)),ND4=$G(^(4)),ND6=$G(^(6)),NDP2=$G(^(.2)),PSJFLAG=$P(NDP2,U,7),X=$P(DN,U,2),DO=$S('X:"",1:$G(^(+X))) S:X=.2 DO=$P(DO,U,2) 11 S ND14=$G(@(PSJF_+ON_",14,0)")),RNDT="" I $P(ND14,"^",3) S ND14=$G(^($P(ND14,"^",3),0)),RNDT=$P(ND14,"^") 12 I "AO"[PSJC D 13 .;S V='$P(ND4,"^",UDU),PSJL=$$SETSTR^VALM1($S(ND4="":" ",$P(ND4,"^",12):"D",$P(ND4,"^",18)&($P(ND4,"^",19)!V):"H",$P(ND4,"^",22)&($P(ND4,"^",23)!V):"H",$P(ND4,"^",15)&($P(ND4,"^",16)!V):"R",1:" "),PSJL,5,1) 14 .S V='$P(ND4,"^",UDU),PSJL=$$SETSTR^VALM1($S(ND4="":" ",$P(ND4,"^",12):"D",$P(ND4,"^",19)&$P(ND4,"^",18):"H",$P(ND4,"^",23)&$P(ND4,"^",22):"H",$P(ND4,"^",15)&($P(ND4,"^",16)!V):"R",1:" "),PSJL,5,1) 15 .;S X=$S(+PSJSYSU=1&V:1,+PSJSYSU=3&V:1,1:0) 16 .S PSJV=$S($P(NDP2,U,4)="D":"d",1:" ")_$S(+PSJSYSU=1&V:"->",+PSJSYSU=3&V:"->",1:" ") I PSJFLAG D CNTRL^VALM10(PSJLN,1,4,IORVON,IORVOFF,0) 17 .S PSJL=$$SETSTR^VALM1(PSJV,PSJL,6,3) 18 ;I $S(PSJC["C":0,1:PSJC["B") S PSJL=$$SETSTR^VALM1($S($P(ND4,"^",12):"D",1:" ")_$S($P(ND,U,4)="I":"",PSJSYSU:"->",1:""),PSJL,6,3) 19 ;I $S(PSJC["C":0,1:PSJC["B") S PSJL=$$SETSTR^VALM1($S($P(ND4,"^",12):"D",1:" ") 20 S RTE=$P(ND,"^",3),SM=$S('$P(ND,"^",5):0,$P(ND,"^",6):1,1:2),STAT=$S($P(ND,"^",9)]"":$P(ND,"^",9),1:"NF"),PF=$E("*",$P(ND,"^",20)>0),PSGID=$P(SCH,"^",2),SD=$P(SCH,"^",4),SCH=$P(SCH,"^") 21 I STAT="A",$P(ND,U,27)="R" S STAT="R" 22 ;S NF=$P(DN,"^",3),WS=$S(PSJPWD:$$WS^PSJO(PSJPWD,PSGP,PSJF,+ON),1:0) 23 S NF="",WS=$S(PSJPWD:$$WS^PSJO(PSJPWD,PSGP,PSJF,+ON),1:0) 24 N PSJDISP F PSJDISP=0:0 S PSJDISP=$O(@(PSJF_+ON_",1,"_PSJDISP_")")) Q:'PSJDISP D 25 .I $P($G(^PSDRUG(+$P($G(@(PSJF_+ON_",1,"_PSJDISP_",0)")),"^"),0)),"^",9)=1 S NF=1 26 NEW DRUGNAME,PSGID1,SD1,LEN,PSGID1,SD1 S LEN=$S($D(PSJEXPT):8,1:5) 27 F X="PSGID","SD" S @(X_1)=$S(PSJC["C":"*****",1:$E($$ENDTC^PSGMI(@X),1,LEN)) 28 D DRGDISP^PSJLMUT1(PSGP,ON,39,54,.DRUGNAME,0) 29 F PSJX=0:0 S PSJX=$O(DRUGNAME(PSJX)) Q:'PSJX D 30 . I PSJX=1 D 31 ..I PSJFLAG D CNTRL^VALM10(PSJLN,1,4,IORVON,IORVOFF,0) 32 ..S PSJL=$$SETSTR^VALM1($S($E(PSJS)="*":$P(PSJS,"^"),1:DRUGNAME(PSJX)),PSJL,9,39) 33 ..S PSJL=$$SETSTR^VALM1($S(PSJC["C":"?",PSJSCHT'="z":PSJSCHT,1:"?"),PSJL,50,3) 34 ..S PSJL=PSJL_PSGID1_" "_SD1_" "_$E(STAT,1)_" "_$S($G(RNDT):$E($$ENDTC^PSGMI(RNDT),1,LEN),1:"") 35 ..I NF!WS!SM!PF S PSJL=$$SETSTR^VALM1($S(NF:"NF ",WS:"WS ",SM:$E("HSM",SM,3),1:""),PSJL,69,3) S:PF PSJL=$$SETSTR^VALM1("*",PSJL,79,1) 36 . I PSJX>1 S PSJL="",PSJL=$$SETSTR^VALM1(DRUGNAME(PSJX),PSJL,11,66) 37 . D SETTMP("PSJPRO",PSJL) I ($P(NDP2,U,4)="S"),STAT="P" D CNTRL^VALM10((PSJLN-1),9,9+$L(PSJL),IOINHI_IOBON,IOINORM,0) 38 D:$P(ND6,"^")]"" PTXT($P(ND6,"^"),"PSJPRO",10,66) 39 Q 40 ; 41 PTXT(TXT,SUB,LM,RM) ; Display Instructions/dosage ordered. 42 ;* Input: TXT = Text to display. 43 ; SUB = First subscript for ^TMP node, ** MUST be PSJ namespace ** 44 ; LM = Begin display of text after LM spaces. 45 ; RM = Length of display text. 46 ; 47 S PSJL="",$P(PSJL," ",LM)="" F X=1:1 S WRD=$P(TXT," ",X) Q:WRD="" D 48 .I $L(PSJL_" "_WRD)'<RM D SETTMP(SUB,PSJL) S PSJL="",$P(PSJL," ",10)="" 49 .I $L(PSJL_" "_WRD)'<RM S PSJL=PSJL_" "_$E(WRD,1,(RM-10)) D SETTMP(SUB,PSJL) S PSJL="",$P(PSJL," ",10)="",WRD=$E(WRD,(RM-9),$L(WRD)) 50 .S PSJL=PSJL_" "_WRD 51 D SETTMP(SUB,PSJL) 52 Q 53 SETTMP(SUB,PSJL) ; 54 S ^TMP(SUB,$J,PSJLN,0)=PSJL,PSJLN=PSJLN+1 55 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJLMUDE.m
r613 r623 1 PSJLMUDE ;BIR/MLM-SHOW FIELDS FOR EDIT (LISTMAN STYLE) ;01 JUNE 00 / 2:40 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**7,47,50,63,64,58,80,116,110,111,164,175,201**;16 DEC 97;Build 2 3 ;NFI-UD Fr#:2 chgs@init+4 to display non-formulary (N/F) 4 ;also chgs @init+23 5 ; 6 ; Reference to ^PS(55 is supported by DBIA# 2191 7 ; Reference to ^PSDRUG is supported by DBIA 2192 8 ; 9 INIT(PSGP,PSGORD) ; 10 N D,ND,PSJBCMA,PSJL,PSJLM,PSJLN,Q,QQ,PSJDUR K ^TMP("PSJUDE",$J) 11 K:$G(PSJNORD) PSGOEEF S PSJLN=1 12 D CLEAN^VALM10 13 S PSJL=$S($D(PSGEFN(1)):$E(" *",PSGEFN(1)+1)_"(1)",1:" "),PSJL=$$SETSTR^VALM1("Orderable Item: "_PSGPDN_$$OINF^PSJDIN(PSGPD),PSJL,5,74) D D SETTMP D:$G(PSGOEEF(108))!($G(PSGOEEF(101))) HILITE(1) 14 . NEW Q,PSJDDA,PSJVD F Q=0:0 S Q=$O(^PS(53.45,PSJSYSP,2,Q)) Q:'Q S PSJDDA(+$G(^(Q,0)))="" 15 . S PSJVD=$$DINFLUD^PSJDIN(PSGPD,.PSJDDA) 16 . S PSJL=$$SETSTR^VALM1(PSJVD,PSJL,75,80) 17 . D:PSJVD]"" CNTRL^VALM10(1,75,5,IORVON,IORVOFF,0) 18 I $G(PSJORD)["P" D REQDT^PSJLIVMD(PSJORD) 19 S PSJL="Instructions: "_PSGOINST D PTXT^PSJLMPRU(PSJL,"PSJUDE",6,80) 20 S PSJL=$S($D(PSGEFN(2)):$E(" *",PSGEFN(2)+1)_"(2)",1:" "),PSJL=$$SETSTR^VALM1("Dosage Ordered: "_PSGDO,PSJL,5,76) D SETTMP D:$G(PSGOEEF(109)) HILITE(2) 21 I $G(PSGRDTX) S PSJDUR=$$FMTDUR^PSJLIVMD($P($G(PSGRDTX),U,2)) 22 I $G(PSJORD),($G(PSJDUR)="") S P=$S(PSJORD["U":5,PSJORD["V":"IV",PSJORD["P":"P",1:-1) S PSJDUR=$$GETDUR^PSJLIVMD(PSGP,+PSJORD,P) 23 S PSJL=$$SETSTR^VALM1("Duration: "_$G(PSJDUR),PSJL,11,25) 24 S PSJL=$$SETSTR^VALM1($S($D(PSGEFN(3)):$E(" *",PSGEFN(3)+1)_"(3)",1:" ")_"Start: "_$P(PSGSDN,U,2),PSJL,54,26) D:$G(PSGOEEF(10)) HILITE(3) 25 I $G(PSGORD)["P" N ND0,OLDO S ND0=@(PSGOEEWF_"0)") I $P(ND0,"^",24)="R" S OLDO=$P(ND0,"^",25) I OLDO,(OLDO["U") D 26 . N OSTRT,OSTRTN S OSTRT=$G(@("^PS(55,"_PSGP_",5,"_+OLDO_",2)")),OSTRT=$P(OSTRT,"^",2) Q:'OSTRT S OSTRTN=$$ENDTC^PSGMI(+OSTRT) 27 . S PSJL=$$SETSTR^VALM1($S($D(PSGEFN(3)):$E(" *",PSGEFN(3)+1)_"(3)",1:" ")_"Start: "_OSTRTN,PSJL,54,26) 28 D SETTMP 29 S PSJL=$S($D(PSGEFN(4)):$E(" *",PSGEFN(4)+1)_"(4)",1:" "),PSJL=$$SETSTR^VALM1("Med Route: "_PSGMRN,PSJL,10,35) D:$G(PSGOEEF(3)) HILITE(4) 30 I $G(PSJORD)["P" N PSGRNDT S PSGRNDT=$$LASTREN^PSJLMPRI(DFN,PSGORD) S:PSGRNDT PSGRNDT=$$ENDTC^PSGMI(+PSGRNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,56,32) 31 I '$G(PSGRNDT),$G(PSGRDTX) D 32 . I $D(PSGRDTX)<10 S PSGRSDN=$$ENDTC^PSGMI(+PSGRDTX),PSJL=$$SETSTR^VALM1("REQUESTED START: "_PSGRSDN,PSJL,48,32) Q 33 . I $G(PSGRDTX(+$G(PSJORD),"PSGRSD")),$P($G(PSGSDN),U,2) S PSGRSDN=$$ENDTC^PSGMI(PSGRDTX(+PSJORD,"PSGRSD")),PSJL=$$SETSTR^VALM1("Calc Start: "_PSGRSDN,PSJL,53,32) D 34 .. I PSGSD'=PSGRDTX(+PSJORD,"PSGRSD") D CNTRL^VALM10(5,53,80,IORVON,IORVOFF) 35 ; Indirect reference in PSGOEEWF below refers to either ^PS(53.1 or ^PS(55,DFN,5,. Naked reference refers to full indirect reference 36 I $G(PSJORD)["U" N ND14 S ND14=$G(@(PSGOEEWF_"14,0)")) I ND14]"" S ND14=$G(^($P(ND14,"^",3),0)),RNDT=$P(ND14,"^") I RNDT D 37 . N PSGRNDT S PSGRNDT=$$ENDTC^PSGMI(+RNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,56,32) 38 D SETTMP 39 I PSGORD]"" S PSJBCMA=$$BCMALG^PSJUTL2(PSGP,PSGORD) 40 I $G(PSJBCMA)]"" S PSJL=$$SETSTR^VALM1(PSJBCMA,PSJL,1,52) 41 S PSJL=$$SETSTR^VALM1($S($D(PSGEFN(5)):$E(" *",PSGEFN(5)+1)_"(5)",1:" ")_" Stop: "_$P(PSGFDN,U,2),PSJL,54,26) D SETTMP D:$G(PSGOEEF(25))!($G(PSGOEEF(34))) HILITE(5) 42 S PSJL=$S($D(PSGEFN(6)):$E(" *",PSGEFN(6)+1)_"(6)",1:" "),PSJL=$$SETSTR^VALM1("Schedule Type: "_PSGSTN,PSJL,6,45) D:$G(PSGOEEF(7)) HILITE(6) 43 I $G(PSJORD)["P",$G(PSGRDTX(+$G(PSJORD),"PSGRFD")),$P($G(PSGFDN),U,2) S PSGRFDN=$$ENDTC^PSGMI(PSGRDTX(+PSJORD,"PSGRFD")),PSJL=$$SETSTR^VALM1("Calc Stop: "_PSGRFDN,PSJL,54,26) D 44 . I PSGFD'=PSGRDTX(+PSJORD,"PSGRFD") D CNTRL^VALM10(7,54,80,IORVON,IORVOFF) 45 D SETTMP 46 S PSGSMN=$P("NO^YES",U,PSGSM+1) 47 S PSJL=$S($D(PSGEFN(8)):$E(" *",PSGEFN(8)+1)_"(8)",1:" "),PSJL=$$SETSTR^VALM1("Schedule: "_PSGSCH_$G(SCHMSG),PSJL,11,68) D SETTMP D:$G(PSGOEEF(26)) HILITE(8) 48 S PSJL=$S($D(PSGEFN(9)):$E(" *",PSGEFN(9)+1)_"(9)",1:" "),PSJL=$$SETSTR^VALM1("Admin Times: "_PSGAT,PSJL,8,71) D SETTMP D:$G(PSGOEEF(39))!($G(PSGOEEF(41))) HILITE(9) 49 S PSJL=$S($D(PSGEFN(10)):$E(" *",PSGEFN(10)+1)_"(10)",1:" "),PSJL=$$SETSTR^VALM1("Provider: "_PSGPRN,PSJL,11,68) D:$G(PSGOEEF(1)) HILITE(10) D SETTMP 50 ;S PSJL=$$SETSTR^VALM1($S($D(PSGEFN(7)):$E(" *",PSGEFN(7)+1)_"(7)",1:" ")_"Self Med: "_PSGSMN,PSJL,56,24) S:PSGSM&PSGHSM PSJL=$$SETSTR^VALM1(" (HS)",PSJL,71,7) D SETTMP D:$G(PSGOEEF(5)) HILITE(7) 51 S PSJL=$S($D(PSGEFN(11)):$E(" *",PSGEFN(11))_"(11)",1:" ")_" Special Instructions"_$S($P(PSGSI,"^",2)=1:"!: ",1:": ")_$P(PSGSI,"^") D PTXT^PSJLMPRU(PSJL,"PSJUDE",1,80) 52 S PSJL="" D SETTMP D:$G(PSGOEEF(8)) HILITE(11) 53 ; E3R 16130 54 I $O(^PS(53.45,PSJSYSP,2,1)) F S PSJL="" D SETTMP Q:PSJLN>15 55 S PSJL=$S($D(PSGEFN(12)):$E(" *",PSGEFN(12))_" (12)",1:" ")_" Dispense Drug",PSJL=$$SETSTR^VALM1("U/D",PSJL,54,60),PSJL=$$SETSTR^VALM1("Inactive Date",PSJL,65,16) D SETTMP,CNTRL^VALM10(13,1,80,IOUON,IOUOFF,0) 56 ;S $P(PSJL,"-",80)="" D SETTMP 57 NEW PSJX 58 F Q=0:0 S Q=$O(^PS(53.45,PSJSYSP,2,Q)) Q:'Q S ND=$G(^(Q,0)) D 59 .S D=$P(ND,"^"),PSGID=$P(ND,"^",3) I PSGID S PSGID=$$ENDTC^PSGMI(PSGID) 60 .S D=$S(D="":"NOT FOUND",'$D(^PSDRUG(D,0)):D,$P(^(0),"^")]"":$P(^(0),"^"),1:D_";PSDRUG(") 61 .S PSJL=" "_D_$$DDNF^PSJDIN(+ND),PSJL=$$SETSTR^VALM1($S($P(ND,"^",2):$S($P(ND,"^",2)=.5:"1/2",$P(ND,"^",2)=.25:"1/4",1:$P(ND,"^",2)),$P(ND,"^",2)=0:0,1:1),PSJL,54,63) S:PSGID PSJL=$$SETSTR^VALM1(PSGID,PSJL,65,16) D D SETTMP 62 ..S PSJX=$G(PSJX)+1 63 ..I $G(PSGOEEF(109)) D CNTRL^VALM10(13+PSJX,7,73,IORVON_IOBON,IORVOFF_IOBOFF,0) 64 I $S(PSGORD["P":$O(^PS(53.1,+$G(PSGORD),12,0)),1:$O(^PS(55,PSGP,5,+PSGORD,12,0))) S PSJL="Provider Comments:" D SETTMP S PSJL="" D 65 .F Q=0:0 S Q=$S(PSGORD["P":$O(^PS(53.1,+$G(PSGORD),12,Q)),1:$O(^PS(55,PSGP,5,+PSGORD,12,Q))) Q:'Q S PSJL=$G(^(Q,0)) D SETTMP 66 D SETTMP S PSJL=$$SETSTR^VALM1($S($D(PSGEFN(7)):$E(" *",PSGEFN(7)+1)_"(7)",1:" ")_"Self Med: "_PSGSMN,PSJL,1,24) 67 S:PSGSM&PSGHSM PSJL=$$SETSTR^VALM1(" (HS)",PSJL,16,7) D SETTMP D:$G(PSGOEEF(5)) HILITE(7) 68 D SETTMP S PSJL="Entry By: "_PSGEBN,PSJL=$$SETSTR^VALM1("Entry Date: "_$P(PSGLIN,U,2),PSJL,51,39) D SETTMP 69 I $G(PSGLRN) D SETTMP S PSJL="Renewed By: "_$$ENNPN^PSGMI($P(PSGLRN,"^",2)) D SETTMP 70 D SETTMP S PSJL="(13)"_" Comments:" 71 D:'$O(^PS(53.45,PSJSYSP,1,0)) SETTMP 72 D SETTMP F Q=0:0 S Q=$O(^PS(53.45,PSJSYSP,1,Q)) Q:'Q S PSJWPL=PSJL_$S($E(PSJL)=" ":"",1:" ")_$G(^(Q,0)),PSJL="" D DISPLAY 73 D SETTMP 74 I PSGORD["P",($P($G(^PS(53.1,+PSGORD,0)),U,9)="P"),$O(^PS(53.1,+PSGORD,10,0)) D 75 .D SETTMP S PSJL="Order Checks:" D SETTMP 76 .F Q=0:0 S Q=$O(^PS(53.1,+PSGORD,10,Q)) Q:'Q D 77 ..S PSJL="" D SETTMP S PSJL=$G(^PS(53.1,+PSGORD,10,Q,0)) D SETTMP 78 ..S PSJL="Overriding Provider: "_$P($G(^PS(53.1,+PSGORD,10,Q,1)),U) D SETTMP 79 ..S PSJL="Overriding Reason: " F X=0:0 S X=$O(^PS(53.1,+PSGORD,10,Q,2,X)) Q:'X D 80 ...S PSJL=PSJL_$G(^PS(53.1,+PSGORD,10,Q,2,X,0)) D SETTMP S PSJL=" " 81 ACTFLG ; 82 S ND4=$S(PSGORD["P":$G(^PS(53.1,+PSGORD,4)),1:$G(^PS(55,PSGP,5,+PSGORD,4))) 83 S AT="",Y="12,13,D,18,19,H1,22,23,H0,15,16,R" F X=1:3:12 I $P(ND4,"^",$P(Y,",",X)),$P(ND4,"^",$P(Y,",",X+1)) S AT=$P(Y,",",X+2) Q 84 I AT="",'$P(ND4,"^",$S($P(PSJSYSU,";",3)>1:3,1:1)) S AT="V"_$S($P(ND4,"^",18):"H1",$P(ND4,"^",22):"H0",$P(ND4,"^",15):"R",1:"") 85 I AT]"" D 86 .S PSJL="" D SETTMP 87 .S PSJL="ORDER "_$S(AT["V":"NOT VERIFIED"_$S($P(AT,"V",2)="":"",1:" ("_$S(AT["H1":"ON HOLD",AT["H0":"OFF HOLD",1:"RENEWAL")_")"),1:"MARKED TO BE "_$S(AT["D":"CANCELLED",AT["H1":"PLACED ON HOLD",AT["H0":"TAKEN OFF OF HOLD",1:"RENEWED")) 88 I AT'["V",AT["H1",$D(^PS(55,PSGP,5.1)) S AT=^(5.1) I $P(AT,"^",7),$P(AT,"^",10)]"" S PSJL=PSJL_" ("_$P(AT,"^",10)_")" 89 D SETTMP 90 S VALMCNT=PSJLN-1 91 K PSGSMN,Q,Y,Y1,Y2,PSGLRN 92 S VALM("TITLE")=PSGSTAT_" UNIT DOSE "_$S((PSGSTAT="PENDING")&($G(PSGPRIO)]""):"("_PSGPRIO_")",$G(PSGPRIO)="DONE":"("_PSGPRIO_")",1:"") I $D(PSJLMP2) S VALMBG=16 K PSJLMP2 93 TEST ; 94 I $G(PSGPFLG) S VALMSG="INVALID ORDERABLE ITEM" 95 I $G(PSGDI) S VALMSG=$S($G(VALMSG)="":"INVALID",1:VALMSG_",")_" DISPENSE DRUG" 96 I $G(PSGPI) S VALMSG=$S($G(VALMSG)="":"INVALID",1:VALMSG_",")_" PROVIDER" 97 Q 98 DISPLAY ; 99 S PSJL=PSJWPL D SETTMP 100 ;F X=1:1 S WRD=$P(PSJWPL," ",X) Q:WRD="" D 101 ;.I $L(PSJL_" "_WRD)'<80 D SETTMP S PSJL=$P(PSJWPL,PSJL,2) S:$E(PSJL,1)=" " PSJL=$E(PSJL,2,999),PSJWPL="" Q 102 ;.S PSJL=PSJL_$S(PSJL="":"",1:" ")_WRD 103 Q 104 ; 105 SETTMP ; 106 S ^TMP("PSJUDE",$J,PSJLN,0)=PSJL,PSJLN=PSJLN+1,PSJL="" 107 Q 108 ; 109 HILITE(FLD) ; 110 N COL,LIN,WID,X 111 ;Q:'$G(PSGOEENO) 112 S X="$T("_FLD_"^PSJLMUDE)",@("X="_X),X=$P(X,";;",2),LIN=+X,COL=$P(X,",",2),LAB=$P(X,",",3),X=$P(X,",",4),WID=(LAB+$L(@X)) 113 ;D CNTRL^VALM10(LIN,COL,WID,IORVON_IOBON,IOINORM,0) 114 I FLD=7 S LIN=+$G(PSJLN)-1 Q:LIN<13 115 D CNTRL^VALM10(LIN,COL,WID,IORVON_IOBON,IORVOFF_IOBOFF,0) 116 Q 117 ; 118 1 ;;1,5,16,PSGPDN 119 2 ;;3,5,16,PSGDO 120 3 ;;4,58,7,PSGSDN 121 4 ;;5,10,11,PSGMRN 122 5 ;;6,59,6,PSGFDN 123 6 ;;7,6,15,PSGSTN 124 7 ;;18,5,14,PSGSMN 125 8 ;;8,11,12,PSGSCH 126 9 ;;9,8,13,PSGAT 127 10 ;;10,11,10,PSGPRN 128 11 ;;11,7,22,PSGSI 129 ENKILL ; 130 K PSGAT,PSGEB,PSGEFN,PSGFD,PSGHSM,PSGNEFD,PSGNESD,PSGOEEF,PSGOEER,PSGOFD,PSGOHSM,PSGOMR,PSGOMRN,PSGOPD,PSGOPDN,PSGOPR,PSGOSCH,PSGOSD,PSGOSM,PSGOST,PSGPD,PSGPDN,PSGPR,PSGSD,PSGSM Q 1 PSJLMUDE ;BIR/MLM-SHOW FIELDS FOR EDIT (LISTMAN STYLE) ;01 JUNE 00 / 2:40 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**7,47,50,63,64,58,80,116,110,111,164,175**;16 DEC 97;Build 18 3 ;NFI-UD Fr#:2 chgs@init+4 to display non-formulary (N/F) 4 ;also chgs @init+23 5 ; 6 ; Reference to ^PS(55 is supported by DBIA# 2191 7 ; Reference to ^PSDRUG is supported by DBIA 2192 8 ; 9 INIT(PSGP,PSGORD) ; 10 N D,ND,PSJBCMA,PSJL,PSJLM,PSJLN,Q,QQ,PSJDUR K ^TMP("PSJUDE",$J) 11 K:$G(PSJNORD) PSGOEEF S PSJLN=1 12 D CLEAN^VALM10 13 S PSJL=$S($D(PSGEFN(1)):$E(" *",PSGEFN(1)+1)_"(1)",1:" "),PSJL=$$SETSTR^VALM1("Orderable Item: "_PSGPDN_$$OINF^PSJDIN(PSGPD),PSJL,5,74) D D SETTMP D:$G(PSGOEEF(108))!($G(PSGOEEF(101))) HILITE(1) 14 . N Q,PSJDDA,PSJVD F Q=0:0 S Q=$O(^PS(53.45,PSJSYSP,2,Q)) Q:'Q S PSJDDA(+$G(^(Q,0)))="" 15 . S PSJVD=$$DINFLUD^PSJDIN(PSGPD,.PSJDDA) 16 . S PSJL=$$SETSTR^VALM1(PSJVD,PSJL,75,80) 17 . D:PSJVD]"" CNTRL^VALM10(1,75,5,IORVON,IORVOFF,0) 18 I $G(PSJORD)["P" D REQDT^PSJLIVMD(PSJORD) 19 S PSJL="Instructions: "_PSGOINST D PTXT^PSJLMPRU(PSJL,"PSJUDE",6,120) 20 S PSJL=$S($D(PSGEFN(2)):$E(" *",PSGEFN(2)+1)_"(2)",1:" "),PSJL=$$SETSTR^VALM1("Dosage Ordered: "_PSGDO,PSJL,5,76) D SETTMP D:$G(PSGOEEF(109)) HILITE(2) 21 I $G(PSGRDTX) S PSJDUR=$$FMTDUR^PSJLIVMD($P($G(PSGRDTX),U,2)) 22 I $G(PSJORD),($G(PSJDUR)="") S P=$S(PSJORD["U":5,PSJORD["V":"IV",PSJORD["P":"P",1:-1) S PSJDUR=$$GETDUR^PSJLIVMD(PSGP,+PSJORD,P) 23 S PSJL=$$SETSTR^VALM1("Duration: "_$G(PSJDUR),PSJL,11,25) 24 S PSJL=$$SETSTR^VALM1($S($D(PSGEFN(3)):$E(" *",PSGEFN(3)+1)_"(3)",1:" ")_"Start: "_$P(PSGSDN,U,2),PSJL,54,26) D:$G(PSGOEEF(10)) HILITE(3) 25 I $G(PSGORD)["P" N ND0,OLDO S ND0=@(PSGOEEWF_"0)") I $P(ND0,"^",24)="R" S OLDO=$P(ND0,"^",25) I OLDO,(OLDO["U") D 26 . N OSTRT,OSTRTN S OSTRT=$G(@("^PS(55,"_PSGP_",5,"_+OLDO_",2)")),OSTRT=$P(OSTRT,"^",2) Q:'OSTRT S OSTRTN=$$ENDTC^PSGMI(+OSTRT) 27 . S PSJL=$$SETSTR^VALM1($S($D(PSGEFN(3)):$E(" *",PSGEFN(3)+1)_"(3)",1:" ")_"Start: "_OSTRTN,PSJL,54,26) 28 D SETTMP 29 S PSJL=$S($D(PSGEFN(4)):$E(" *",PSGEFN(4)+1)_"(4)",1:" "),PSJL=$$SETSTR^VALM1("Med Route: "_PSGMRN,PSJL,10,35) D:$G(PSGOEEF(3)) HILITE(4) 30 I $G(PSJORD)["P" N PSGRNDT S PSGRNDT=$$LASTREN^PSJLMPRI(DFN,PSGORD) S:PSGRNDT PSGRNDT=$$ENDTC^PSGMI(+PSGRNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,56,32) 31 I '$G(PSGRNDT),$G(PSGRDTX) D 32 . I $D(PSGRDTX)<10 S PSGRSDN=$$ENDTC^PSGMI(+PSGRDTX),PSJL=$$SETSTR^VALM1("REQUESTED START: "_PSGRSDN,PSJL,48,32) Q 33 . I $G(PSGRDTX(+$G(PSJORD),"PSGRSD")),$P($G(PSGSDN),U,2) S PSGRSDN=$$ENDTC^PSGMI(PSGRDTX(+PSJORD,"PSGRSD")),PSJL=$$SETSTR^VALM1("Calc Start: "_PSGRSDN,PSJL,53,32) D 34 .. I PSGSD'=PSGRDTX(+PSJORD,"PSGRSD") D CNTRL^VALM10(5,53,80,IORVON,IORVOFF) 35 ; Indirect reference in PSGOEEWF below refers to either ^PS(53.1 or ^PS(55,DFN,5,. Naked reference refers to full indirect reference 36 I $G(PSJORD)["U" N ND14 S ND14=$G(@(PSGOEEWF_"14,0)")) I ND14]"" S ND14=$G(^($P(ND14,"^",3),0)),RNDT=$P(ND14,"^") I RNDT D 37 . N PSGRNDT S PSGRNDT=$$ENDTC^PSGMI(+RNDT),PSJL=$$SETSTR^VALM1("Renewed: "_PSGRNDT,PSJL,56,32) 38 D SETTMP 39 I PSGORD]"" S PSJBCMA=$$BCMALG^PSJUTL2(PSGP,PSGORD) 40 I $G(PSJBCMA)]"" S PSJL=$$SETSTR^VALM1(PSJBCMA,PSJL,1,52) 41 S PSJL=$$SETSTR^VALM1($S($D(PSGEFN(5)):$E(" *",PSGEFN(5)+1)_"(5)",1:" ")_" Stop: "_$P(PSGFDN,U,2),PSJL,54,26) D SETTMP D:$G(PSGOEEF(25))!($G(PSGOEEF(34))) HILITE(5) 42 S PSJL=$S($D(PSGEFN(6)):$E(" *",PSGEFN(6)+1)_"(6)",1:" "),PSJL=$$SETSTR^VALM1("Schedule Type: "_PSGSTN,PSJL,6,45) D:$G(PSGOEEF(7)) HILITE(6) 43 I $G(PSJORD)["P",$G(PSGRDTX(+$G(PSJORD),"PSGRFD")),$P($G(PSGFDN),U,2) S PSGRFDN=$$ENDTC^PSGMI(PSGRDTX(+PSJORD,"PSGRFD")),PSJL=$$SETSTR^VALM1("Calc Stop: "_PSGRFDN,PSJL,54,26) D 44 . I PSGFD'=PSGRDTX(+PSJORD,"PSGRFD") D CNTRL^VALM10(7,54,80,IORVON,IORVOFF) 45 D SETTMP 46 S PSGSMN=$P("NO^YES",U,PSGSM+1) 47 S PSJL=$S($D(PSGEFN(8)):$E(" *",PSGEFN(8)+1)_"(8)",1:" "),PSJL=$$SETSTR^VALM1("Schedule: "_PSGSCH_$G(SCHMSG),PSJL,11,68) D SETTMP D:$G(PSGOEEF(26)) HILITE(8) 48 S PSJL=$S($D(PSGEFN(9)):$E(" *",PSGEFN(9)+1)_"(9)",1:" "),PSJL=$$SETSTR^VALM1("Admin Times: "_PSGAT,PSJL,8,71) D SETTMP D:$G(PSGOEEF(39))!($G(PSGOEEF(41))) HILITE(9) 49 S PSJL=$S($D(PSGEFN(10)):$E(" *",PSGEFN(10)+1)_"(10)",1:" "),PSJL=$$SETSTR^VALM1("Provider: "_PSGPRN,PSJL,11,68) D:$G(PSGOEEF(1)) HILITE(10) D SETTMP 50 S PSJL=$S($D(PSGEFN(11)):$E(" *",PSGEFN(11))_"(11)",1:" ")_" Special Instructions"_$S($P(PSGSI,"^",2)=1:"!: ",1:": ")_$P(PSGSI,"^") D PTXT^PSJLMPRU(PSJL,"PSJUDE",1,80) 51 S PSJL="" D SETTMP D:$G(PSGOEEF(8)) HILITE(11) 52 ; E3R 16130 53 I $O(^PS(53.45,PSJSYSP,2,1)) F S PSJL="" D SETTMP Q:PSJLN>15 54 S PSJL=$S($D(PSGEFN(12)):$E(" *",PSGEFN(12))_" (12)",1:" ")_" Dispense Drug",PSJL=$$SETSTR^VALM1("U/D",PSJL,54,60),PSJL=$$SETSTR^VALM1("Inactive Date",PSJL,65,16) D SETTMP,CNTRL^VALM10(13,1,80,IOUON,IOUOFF,0) 55 N PSJX,PSGID 56 F Q=0:0 S Q=$O(^PS(53.45,PSJSYSP,2,Q)) Q:'Q S ND=$G(^(Q,0)) D 57 .S D=$P(ND,"^"),PSGID=$P(ND,"^",3) I PSGID S PSGID=$$ENDTC^PSGMI(PSGID) 58 .S D=$S(D="":"NOT FOUND",'$D(^PSDRUG(D,0)):D,$P(^(0),"^")]"":$P(^(0),"^"),1:D_";PSDRUG(") 59 .S PSJL=" "_D_$$DDNF^PSJDIN(+ND),PSJL=$$SETSTR^VALM1($S($P(ND,"^",2):$S($P(ND,"^",2)=.5:"1/2",$P(ND,"^",2)=.25:"1/4",1:$P(ND,"^",2)),$P(ND,"^",2)=0:0,1:1),PSJL,54,63) S:PSGID PSJL=$$SETSTR^VALM1(PSGID,PSJL,65,16) D D SETTMP 60 ..S PSJX=$G(PSJX)+1 61 ..I $G(PSGOEEF(109)) D CNTRL^VALM10(13+PSJX,7,73,IORVON_IOBON,IORVOFF_IOBOFF,0) 62 I $S(PSGORD["P":$O(^PS(53.1,+$G(PSGORD),12,0)),1:$O(^PS(55,PSGP,5,+PSGORD,12,0))) S PSJL="Provider Comments:" D SETTMP S PSJL="" D 63 .F Q=0:0 S Q=$S(PSGORD["P":$O(^PS(53.1,+$G(PSGORD),12,Q)),1:$O(^PS(55,PSGP,5,+PSGORD,12,Q))) Q:'Q S PSJL=$G(^(Q,0)) D SETTMP 64 D SETTMP S PSJL=$$SETSTR^VALM1($S($D(PSGEFN(7)):$E(" *",PSGEFN(7)+1)_"(7)",1:" ")_"Self Med: "_PSGSMN,PSJL,1,24) 65 S:PSGSM&PSGHSM PSJL=$$SETSTR^VALM1(" (HS)",PSJL,16,7) D SETTMP D:$G(PSGOEEF(5)) HILITE(7) 66 D SETTMP S PSJL="Entry By: "_PSGEBN,PSJL=$$SETSTR^VALM1("Entry Date: "_$P(PSGLIN,U,2),PSJL,51,39) D SETTMP 67 I $G(PSGLRN) D SETTMP S PSJL="Renewed By: "_$$ENNPN^PSGMI($P(PSGLRN,"^",2)) D SETTMP 68 D SETTMP S PSJL="(13)"_" Comments:" 69 D:'$O(^PS(53.45,PSJSYSP,1,0)) SETTMP 70 D SETTMP F Q=0:0 S Q=$O(^PS(53.45,PSJSYSP,1,Q)) Q:'Q S PSJWPL=PSJL_$S($E(PSJL)=" ":"",1:" ")_$G(^(Q,0)),PSJL="" D DISPLAY 71 D SETTMP 72 I PSGORD["P",($P($G(^PS(53.1,+PSGORD,0)),U,9)="P"),$O(^PS(53.1,+PSGORD,10,0)) D 73 .D SETTMP S PSJL="Order Checks:" D SETTMP 74 .F Q=0:0 S Q=$O(^PS(53.1,+PSGORD,10,Q)) Q:'Q D 75 ..S PSJL="" D SETTMP S PSJL=$G(^PS(53.1,+PSGORD,10,Q,0)) S PSJWPL=PSJL D DISPLAY 76 ..S PSJL="Overriding Provider: "_$P($G(^PS(53.1,+PSGORD,10,Q,1)),U) D SETTMP 77 ..S PSJL="Overriding Reason: " F X=0:0 S X=$O(^PS(53.1,+PSGORD,10,Q,2,X)) Q:'X D 78 ...S PSJL=PSJL_$G(^PS(53.1,+PSGORD,10,Q,2,X,0)) D SETTMP S PSJL=" " 79 ACTFLG ; 80 N ND4,AT,Y,X 81 S ND4=$S(PSGORD["P":$G(^PS(53.1,+PSGORD,4)),1:$G(^PS(55,PSGP,5,+PSGORD,4))) 82 S AT="",Y="12,13,D,18,19,H1,22,23,H0,15,16,R" F X=1:3:12 I $P(ND4,"^",$P(Y,",",X)),$P(ND4,"^",$P(Y,",",X+1)) S AT=$P(Y,",",X+2) Q 83 I AT="",'$P(ND4,"^",$S($P(PSJSYSU,";",3)>1:3,1:1)) S AT="V"_$S($P(ND4,"^",18):"H1",$P(ND4,"^",22):"H0",$P(ND4,"^",15):"R",1:"") 84 I AT]"" D 85 .S PSJL="" D SETTMP 86 .S PSJL="ORDER "_$S(AT["V":"NOT VERIFIED"_$S($P(AT,"V",2)="":"",1:" ("_$S(AT["H1":"ON HOLD",AT["H0":"OFF HOLD",1:"RENEWAL")_")"),1:"MARKED TO BE "_$S(AT["D":"CANCELLED",AT["H1":"PLACED ON HOLD",AT["H0":"TAKEN OFF OF HOLD",1:"RENEWED")) 87 I AT'["V",AT["H1",$D(^PS(55,PSGP,5.1)) S AT=^(5.1) I $P(AT,"^",7),$P(AT,"^",10)]"" S PSJL=PSJL_" ("_$P(AT,"^",10)_")" 88 D SETTMP 89 S VALMCNT=PSJLN-1 90 K PSGSMN,Q,Y,Y1,Y2,PSGLRN 91 S VALM("TITLE")=PSGSTAT_" UNIT DOSE "_$S((PSGSTAT="PENDING")&($G(PSGPRIO)]""):"("_PSGPRIO_")",$G(PSGPRIO)="DONE":"("_PSGPRIO_")",1:"") I $D(PSJLMP2) S VALMBG=16 K PSJLMP2 92 TEST ; 93 I $G(PSGPFLG) S VALMSG="INVALID ORDERABLE ITEM" 94 I $G(PSGDI) S VALMSG=$S($G(VALMSG)="":"INVALID",1:VALMSG_",")_" DISPENSE DRUG" 95 I $G(PSGPI) S VALMSG=$S($G(VALMSG)="":"INVALID",1:VALMSG_",")_" PROVIDER" 96 Q 97 ; 98 DISPLAY ; 99 N X,LEN,LIM,PCS 100 S LIM=$L(PSJWPL," "),PCS=1 101 F X=1:1:LIM S LEN=$L($P(PSJWPL," ",PCS,X)) D 102 . I LEN'<72!(X=LIM) D 103 .. S PSJL=$P(PSJWPL," ",PCS,X) 104 .. I PCS>1 S PSJL=" "_PSJL 105 .. S PCS=X+1 106 .. D SETTMP 107 Q 108 ; 109 SETTMP ; 110 S ^TMP("PSJUDE",$J,PSJLN,0)=PSJL,PSJLN=PSJLN+1,PSJL="" 111 Q 112 ; 113 HILITE(FLD) ; 114 N COL,LAB,LIN,WID,X 115 S X="$T("_FLD_"^PSJLMUDE)",@("X="_X),X=$P(X,";;",2),LIN=+X,COL=$P(X,",",2),LAB=$P(X,",",3),X=$P(X,",",4),WID=(LAB+$L(@X)) 116 I FLD=7 S LIN=+$G(PSJLN)-1 Q:LIN<13 117 D CNTRL^VALM10(LIN,COL,WID,IORVON_IOBON,IORVOFF_IOBOFF,0) 118 Q 119 ; 120 1 ;;1,5,16,PSGPDN 121 2 ;;3,5,16,PSGDO 122 3 ;;4,58,7,PSGSDN 123 4 ;;5,10,11,PSGMRN 124 5 ;;6,59,6,PSGFDN 125 6 ;;7,6,15,PSGSTN 126 7 ;;18,5,14,PSGSMN 127 8 ;;8,11,12,PSGSCH 128 9 ;;9,8,13,PSGAT 129 10 ;;10,11,10,PSGPRN 130 11 ;;11,7,22,PSGSI 131 ENKILL ; 132 K PSGAT,PSGDO,PSGEB,PSGEFN,PSGFD,PSGFDN,PSGHSM,PSGNEFD,PSGNESD,PSGOEEF,PSGOEER,PSGOFD,PSGOHSM,PSGOMR,PSGMRN,PSGOPD,PSGOPDN,PSGOPR,PSGOSCH,PSGOSD 133 K PSGOSM,PSGOST,PSGPD,PSGPDN,PSGPR,PSGSD,PSGSM,PSGOINST,PSGPRN,PSGRFDN,PSGRSDN,PSGSCH,PSGSDN,PSGSI,PSGSTN,PSJWPL,RNDT 134 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJLMUT1.m
r613 r623 1 PSJLMUT1 ;BIR/MLM-DRUG NAME DISPLAY ;05 Feb 98 / 1:39 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**4,27,29,49,58,107,110,146,175,201**;16 DEC 97;Build 2 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to ^PS(50.7 is supported by DBIA# 2180. 6 ; Reference to ^PS(50.606 is supported by DBIA# 2174. 7 ; Reference to EN^PSODRDU2 is supported by DBIA# 2189. 8 ; Reference to ^PSDRUG( is supported by DBIA 2192. 9 ; 10 DRGDISP(DFN,ON,NL,GL,NAME,DRUGONLY) ; 11 ;; DRUGONLY = 1/0 - Only the drug name will be returned. 12 ;; NL = The drug name display length 13 ;; GL = The give line display length, total length-6 ("Give: ") 14 ;; NAME(X) = Drug name and give line in displayable format. 15 ;; ON = IEN#_U/P (U=Unit Dose; P=Pending) 16 ; 17 NEW F,OIND,MARX,MR,NOTGV,SCH,PSGUPDDO,PSGGV,X,PSGX,PSGINS,DRUGNAME 18 K NAME S PSGINS="" 19 S:ON["U" F="^PS(55,DFN,5,+ON," 20 I ON["P" S F="^PS(53.1,+ON,",X=$G(@(F_".3)")),PSGINS=$S(X]"":X,1:"") 21 I $G(@(F_"0)"))="" S NAME(1)="NOT FOUND" Q 22 S OIND=$G(@(F_".2)")),PSGUPDDO=$P(OIND,U,2),X=@(F_"0)"),NOTGV=$P(X,U,22),MR=$$ENMRN^PSGMI(+$P(X,U,3)) 23 I '+OIND,($P(X,U,4)'="U") NEW DRG D GTDRG^PSIVORFA F X="AD","SOL" Q:+OIND F PSGX=0:0 S PSGX=$O(DRG(X,PSGX)) Q:'PSGX S OIND=$P(DRG(X,PSGX),U,6) Q:+OIND 24 S SCH=$P($G(@(F_"2)")),U) 25 I +$O(@(F_"1,0)")),'+$O(@(F_"1,1)")),PSGUPDDO="" D DD(F,.DRUGNAME) 26 S:($G(DRUGNAME)=""!($G(DRUGNAME)["NOT FOUND")) DRUGNAME=$$OIDF(OIND) 27 ;S PSGGV=$S(NOTGV:"*** NOT TO BE GIVEN *** ",1:"")_PSGINS_PSGUPDDO_" "_MR_" "_SCH 28 S PSGGV=$S(NOTGV:"*** NOT TO BE GIVEN *** ",1:"")_$S(('$D(PSJPDDDP)&('$L(PSGUPDDO))):PSGINS,1:PSGUPDDO)_" "_MR_" "_SCH 29 S PSGX=0 K PSJPDDDP 30 D TXT^PSGMUTL(DRUGNAME,NL) F X=0:0 S X=$O(MARX(X)) Q:'X S NAME(X)=$S(X>1:" ",1:"")_MARX(X),PSGX=X 31 Q:+DRUGONLY 32 D TXT^PSGMUTL(PSGGV,GL) F X=0:0 S X=$O(MARX(X)) Q:'X D 33 . I X=1 S NAME(PSGX+X)="Give: "_MARX(X) Q 34 . S NAME(PSGX+X)=$S(X>1:" ",1:"")_MARX(X) 35 Q 36 OIDF(OIND) ; Return Orderable Item name and Dosage form. 37 ;; +OIND = orderable item IEN 38 NEW X,NAME 39 S X=$G(^PS(50.7,+OIND,0)) 40 S:$P(X,U)]"" NAME=$P(X,U)_" "_$P($G(^PS(50.606,+$P(X,U,2),0)),U) 41 Q $S($G(NAME)]"":NAME,1:"NOT FOUND "_+OIND_";PS(50.7") 42 ; 43 DD(F,NAME) ; Return Dispense drug name. 44 ;; F = "^PS(55,DFN,5,+ON," or "^PS(53.1,+ON," 45 NEW X K NAME 46 S X=$O(@(F_"1,0)")),X=$G(@(F_"1,"_+X_",0)")) 47 I $P(X,U)]"" S NAME=$P($G(^PSDRUG(+X,0)),U) 48 E S NAME="NOT FOUND "_+X_";PSDRUG" 49 I '$O(@(F_"1,1)")),+$P(X,U,2)>1 S PSGUPDDO=+$P(X,U,2) 50 S PSJPDDDP=1 51 Q 52 DSPLORDU(PSGP,ON) ; Display UD order for order check as in the Inpat Profile. 53 NEW DRUGNAME,F,NODE0,NODE2,PSJID,PSJX,SCH,SD,STAT,X,Y 54 S F=$S(ON["U":"^PS(55,PSGP,5,"_+ON_",",1:"^PS(53.1,"_+ON_",") 55 S NODE0=$G(@(F_"0)")),NODE2=$G(@(F_"2)")) 56 D DRGDISP^PSJLMUT1(PSGP,ON,39,54,.DRUGNAME,0) 57 I ON["P",$P(NODE0,U,4)="F" D DSPLORDV(PSGP,ON) Q 58 S SCH=$P(NODE0,U,7) 59 S STAT=$P(NODE0,U,9) I STAT="A",$P(NODE0,U,27)="R" S STAT="R" 60 I STAT'="P" S PSJID=$E($$ENDTC^PSGMI($P(NODE2,U,2)),1,5),SD=$E($$ENDTC^PSGMI($P(NODE2,U,4)),1,5) 61 I STAT="P" S (PSJID,SD)="*****",SCH="?" 62 F PSJX=0:0 S PSJX=$O(DRUGNAME(PSJX)) Q:'PSJX D 63 . S:PSJX=1 X=SCH_" "_PSJID_" "_SD_" "_$E(STAT,1) 64 . S:PSJX=1 DRUGNAME(1)=$$SETSTR^VALM1(X,$E(DRUGNAME(1),1,40),42,20) 65 . S PSJOC(ON,PSJLINE)=" "_DRUGNAME(PSJX) 66 . S PSJLINE=PSJLINE+1 67 Q 68 DSPLORDV(DFN,ON) ; Display IV order for order check as in the Inpat Profile. 69 N DRG,DRGI,DRGT,DRGX,FIL,ND,ON55,P,PSJIVFLG,PSJORIFN,TYP,X,Y 70 S TYP="?" I ON["V" D 71 .S Y=$G(^PS(55,DFN,"IV",+ON,0)) F X=2,3,4,5,8,9,17,23 S P(X)=$P(Y,U,X) 72 .S TYP=$$ONE^PSJBCMA(DFN,ON,P(9),P(2),P(3)) I TYP'="O" S TYP="C" 73 .S ON55=ON,P("OT")=$S(P(4)="A":"F",P(4)="H":"H",1:"I") D GTDRG^PSIVORFB,GTOT^PSIVUTL(P(4)) 74 S PSJCT=0,PSJL="" 75 I ON'["V" S (P(2),P(3))="",P(17)=$P($G(^PS(53.1,+ON,0)),U,9),Y=$G(^(8)),P(4)=$P(Y,U),P(8)=$P(Y,U,5),P(9)=$P($G(^(2)),U) D GTDRG^PSIVORFA,GTOT^PSIVUTL(P(4)) 76 S PSJIVFLG=1 D PIVAD,SOL 77 Q 78 SOL ; 79 S PSJL=$S($G(PSJIVFLG):PSJL,1:"")_" in" 80 S DRG=0 F S DRG=+$O(DRG("SOL",DRG)) Q:'DRG D NAME^PSIVUTL(DRG("SOL",DRG),39,.NAME,0) S DRGX=0 F S DRGX=$O(NAME(DRGX)) Q:'DRGX S PSJL=$$SETSTR^VALM1(NAME(DRGX),PSJL,12,60) D:$G(PSJIVFLG) PIV1 D SETTMP S PSJL=" " 81 Q 82 PIVAD ; Print IV Additives. 83 F DRG=0:0 S DRG=$O(DRG("AD",DRG)) Q:'DRG D NAME^PSIVUTL(DRG("AD",DRG),39,.NAME,1) F DRGX=0:0 S DRGX=$O(NAME(DRGX)) Q:'DRGX S PSJL=$$SETSTR^VALM1(NAME(DRGX),PSJL,9,60) D:$G(PSJIVFLG) PIV1 D SETTMP 84 Q 85 ; 86 PIV1 ; Print Sched type, start/stop dates, and status. 87 K PSJIVFLG 88 F X=2,3 S P(X)=$E($$ENDTC^PSGMI(P(X)),1,$S($D(PSJEXTP):8,1:5)) 89 I '$D(PSJEXTP) S PSJL=$$SETSTR^VALM1(TYP,PSJL,50,1),PSJL=$$SETSTR^VALM1(P(2),PSJL,53,7),PSJL=$$SETSTR^VALM1(P(3),PSJL,60,7),PSJL=$$SETSTR^VALM1(P(17),PSJL,67,1) 90 E S PSJL=$$SETSTR^VALM1(TYP,PSJL,50,1),PSJL=$$SETSTR^VALM1(P(2),53,7),PSJL=$$SETSTR^VALM1(P(3),PSJL,63,7),PSJL=$$SETSTR^VALM1(P(17),PSJL,73,1) 91 Q 92 SETTMP ; 93 S PSJOC(ON,PSJLINE)=PSJL,PSJLINE=PSJLINE+1 94 Q 95 ORDCHK(DFN,TYPE,PIECE) ; 96 ;TYPE ="DD" - Duplicate drug 97 ; ="DC" - Duplicate class 98 ; -"DI" - Drug Interaction 99 ;PIECE = The piece order number is return from ^TMP($J,"DD"... 100 ;PSJOC(ON,x) = Array of inpatient orders to be displayed 101 ; 102 NEW ON,PSJL,PSIVX,PSJOC,PSJORIEN,PSJPACK,PSJLINE 103 S PSJOC=0,PSJLINE=1 104 F PSIVX=0:0 S PSIVX=$O(^TMP($J,TYPE,PSIVX)) Q:'PSIVX D 105 . S PSJPACK=$P(^TMP($J,TYPE,PSIVX,0),U,PIECE) 106 . I $G(PSGORD) S PSJORD=PSGORD ; Set PSJORD if PSGORD exists and is not Null 107 . I $G(PSJORD)]"" I $S($D(PSJORD):$G(PSJORD),1:$G(PSGORD))'["V",$P(PSJPACK,";")=$S($D(PSJORD):$G(PSJORD),1:$G(PSGORD)) Q ; don't flag order that is being renewed as duplicate, only checks Unit Dose orders 108 . I $G(PSJCOM),($G(PSJORD)["P") Q:$D(^PS(53.1,"ACX",PSJCOM,+PSJPACK)) 109 . ; Don't flag if pending renewal from CPRS 110 . I $G(PSJORD)]"",(PSJORD["P"),($P($G(^PS(53.1,+PSJORD,0)),"^",24)="R"),($P(PSJPACK,";")["U"),($P($G(^PS(55,DFN,5,+$P(PSJPACK,";"),0)),"^",27)="R"),($P($G(^PS(55,DFN,5,+$P(PSJPACK,";"),0)),"^",26)=PSJORD) Q 111 . I $G(PSIVRNFG),$G(ON55)["V",$P(PSJPACK,";")=$G(ON55) Q ;PSIVRNFG set and kill in R+2^PSIVOPT2. Needed to do dupl. check on new order but not renew. 112 . S PSJORIEN=$P(^TMP($J,TYPE,PSIVX,0),U,PIECE-1) 113 . I TYPE="DI",($P(^TMP($J,TYPE,PSIVX,0),U,4)="CRITICAL") S PSJIREQ=1 114 . ; Adding Drug Interactions check for use in Intervention defaults in PSJRXI. 115 . I TYPE="DI" S PSJRXREQ=$S($P(^TMP($J,TYPE,PSIVX,0),U,4)="CRITICAL":1,1:2) 116 . ;I $P(PSJPACK,";",2)["O" D Q 117 . N X S X=$P(PSJPACK,";",2) I X["O" D Q 118 .. D:PSJFST=1 PAUSE 119 .. W !!,"The patient has this "_$S($P(PSJPACK,";")["N":"Non-VA Meds",$P(PSJPACK,";",2)["O":"Outpatient",1:"")_" order:",! 120 .. I $D(^TMP($J,TYPE,PSIVX,1)) D SHOR^PSJLMUT2(TYPE,PSIVX),PAUSE S PSJFST=$S(PSJFST=0:PSJFST+2,1:PSJFST+1) Q 121 .. D EN^PSODRDU2(DFN,PSJPACK),PAUSE S PSJPDRG=1,PSJFST=$S(PSJFST=0:PSJFST+2,1:PSJFST+1) 122 . S ON=$P(PSJPACK,";") Q:$D(PSJOC(ON)) 123 . I ON=$G(PSIVOCON),+PSJORIEN Q 124 . I ON=$G(PSIVOCON),'+PSJORIEN D SETPSJOC Q 125 . ;S PSJOC=PSJOC+1,PSJPDRG=1 D:PSJOC=1 WRITE(TYPE) 126 . I ON["V" D 127 .. I '$O(^PS(55,DFN,"IV",+ON,0)) D SETPSJOC Q 128 .. D DSPLORDV(DFN,ON) S PSJOC=PSJOC+1 129 . I ON'["V" D DSPLORDU(DFN,ON) S PSJOC=PSJOC+1 130 . S PSJOC(ON,PSJLINE)="",PSJLINE=PSJLINE+1 131 D:PSJOC WRITE(TYPE) 132 S ON="" F S ON=$O(PSJOC(ON)) Q:ON="" W ! S PSJLINE=PSJLINE+1,PSJFST=PSJFST+1 D 133 . F PSIVX=0:0 S PSIVX=$O(PSJOC(ON,PSIVX)) Q:'PSIVX W !,PSJOC(ON,PSIVX) S PSJLINE=PSJLINE+1 D:'(PSIVX#6) PAUSE 134 W ! 135 Q 136 SETPSJOC ;Set PSJOC array to be displayed later 137 NEW PIECE S PIECE=$S(TYPE="DC":4,1:2) 138 S X=$$SETSTR^VALM1($P(^TMP($J,TYPE,PSIVX,0),U,PIECE),"",9,40) 139 S X=$$SETSTR^VALM1("* EXISTS IN CURRENT ORDER *",X,50,27) 140 S PSJOC(ON,PSJLINE)=X,PSJLINE=PSJLINE+1,PSJOC=PSJOC+1 141 Q 142 WRITE(TYPE) ;Display order check description 143 S PSJPDRG=1 144 I TYPE="DD" W !!,"This patient is already receiving the following order",$S(PSJOC>1:"s",1:"")," for ",$S($G(PSJDD)]"":$P($G(^PSDRUG(PSJDD,0)),U),1:"this drug"),":",! 145 I TYPE="DC" W !!,"This patient is already receiving ",$S(PSJOC>1:"orders",1:"an order")," for the following drug",$S(PSJOC>1:"s",1:"")," in the same",!,"class as ",$S($G(PSJDD)]"":$P($G(^PSDRUG(PSJDD,0)),U),1:"the drug selected"),":",! 146 I TYPE="DI" W !!,"This patient is receiving the following medication",$S(PSJOC>1:"s",1:"")," that ha",$S(PSJOC>1:"ve",1:"s")," an interaction",!,"with ",$P($G(^PSDRUG(PSJDD,0)),U),":",! 147 Q 148 PAUSE ; 149 K DIR W ! S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR W ! 150 Q 1 PSJLMUT1 ;BIR/MLM-DRUG NAME DISPLAY ;05 Feb 98 / 1:39 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**4,27,29,49,58,107,110,146,175**;16 DEC 97;Build 18 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to ^PS(50.7 is supported by DBIA# 2180. 6 ; Reference to ^PS(50.606 is supported by DBIA# 2174. 7 ; Reference to EN^PSODRDU2 is supported by DBIA# 2189. 8 ; Reference to ^PSDRUG( is supported by DBIA 2192. 9 ; 10 DRGDISP(DFN,ON,NL,GL,NAME,DRUGONLY) ; 11 ;; DRUGONLY = 1/0 - Only the drug name will be returned. 12 ;; NL = The drug name display length 13 ;; GL = The give line display length, total length-6 ("Give: ") 14 ;; NAME(X) = Drug name and give line in displayable format. 15 ;; ON = IEN#_U/P (U=Unit Dose; P=Pending) 16 ; 17 NEW F,OIND,MARX,MR,NOTGV,SCH,PSGUPDDO,PSGGV,X,PSGX,PSGINS,DRUGNAME 18 K NAME S PSGINS="" 19 S:ON["U" F="^PS(55,DFN,5,+ON," 20 I ON["P" S F="^PS(53.1,+ON,",X=$G(@(F_".3)")),PSGINS=$S(X]"":X,1:"") 21 I $G(@(F_"0)"))="" S NAME(1)="NOT FOUND" Q 22 S OIND=$G(@(F_".2)")),PSGUPDDO=$P(OIND,U,2),X=@(F_"0)"),NOTGV=$P(X,U,22),MR=$$ENMRN^PSGMI(+$P(X,U,3)) 23 I '+OIND,($P(X,U,4)'="U") NEW DRG D GTDRG^PSIVORFA F X="AD","SOL" Q:+OIND F PSGX=0:0 S PSGX=$O(DRG(X,PSGX)) Q:'PSGX S OIND=$P(DRG(X,PSGX),U,6) Q:+OIND 24 S SCH=$P($G(@(F_"2)")),U) 25 I +$O(@(F_"1,0)")),'+$O(@(F_"1,1)")),PSGUPDDO="" D DD(F,.DRUGNAME) 26 S:($G(DRUGNAME)=""!($G(DRUGNAME)["NOT FOUND")) DRUGNAME=$$OIDF(OIND) 27 S PSGGV=$S(NOTGV:"*** NOT TO BE GIVEN *** ",1:"")_$S(('$D(PSJPDDDP)&('$L(PSGUPDDO))):PSGINS,1:PSGUPDDO)_" "_MR_" "_SCH 28 S PSGX=0 K PSJPDDDP 29 D TXT^PSGMUTL(DRUGNAME,NL) F X=0:0 S X=$O(MARX(X)) Q:'X S NAME(X)=$S(X>1:" ",1:"")_MARX(X),PSGX=X 30 Q:+DRUGONLY 31 D TXT^PSGMUTL(PSGGV,GL) F X=0:0 S X=$O(MARX(X)) Q:'X D 32 . I X=1 S NAME(PSGX+X)="Give: "_MARX(X) Q 33 . S NAME(PSGX+X)=$S(X>1:" ",1:"")_MARX(X) 34 Q 35 ; 36 OIDF(OIND) ; Return Orderable Item name and Dosage form. 37 ;; +OIND = orderable item IEN 38 NEW X,NAME 39 S X=$G(^PS(50.7,+OIND,0)) 40 S:$P(X,U)]"" NAME=$P(X,U)_" "_$P($G(^PS(50.606,+$P(X,U,2),0)),U) 41 Q $S($G(NAME)]"":NAME,1:"NOT FOUND "_+OIND_";PS(50.7") 42 ; 43 DD(F,NAME) ; Return Dispense drug name. 44 ;; F = "^PS(55,DFN,5,+ON," or "^PS(53.1,+ON," 45 NEW X K NAME 46 S X=$O(@(F_"1,0)")),X=$G(@(F_"1,"_+X_",0)")) 47 I $P(X,U)]"" S NAME=$P($G(^PSDRUG(+X,0)),U) 48 E S NAME="NOT FOUND "_+X_";PSDRUG" 49 I '$O(@(F_"1,1)")),+$P(X,U,2)>1 S PSGUPDDO=+$P(X,U,2) 50 S PSJPDDDP=1 51 Q 52 ; 53 DSPLORDU(PSGP,ON) ; Display UD order for order check as in the Inpat Profile. 54 NEW DRUGNAME,F,NODE0,NODE2,PSJID,PSJX,SCH,SD,STAT,X,Y 55 S F=$S(ON["U":"^PS(55,PSGP,5,"_+ON_",",1:"^PS(53.1,"_+ON_",") 56 S NODE0=$G(@(F_"0)")),NODE2=$G(@(F_"2)")) 57 D DRGDISP^PSJLMUT1(PSGP,ON,39,54,.DRUGNAME,0) 58 I ON["P",$P(NODE0,U,4)="F" D DSPLORDV(PSGP,ON) Q 59 S SCH=$P(NODE0,U,7) 60 S STAT=$P(NODE0,U,9) I STAT="A",$P(NODE0,U,27)="R" S STAT="R" 61 I STAT'="P" S PSJID=$E($$ENDTC^PSGMI($P(NODE2,U,2)),1,5),SD=$E($$ENDTC^PSGMI($P(NODE2,U,4)),1,5) 62 I STAT="P" S (PSJID,SD)="*****",SCH="?" 63 F PSJX=0:0 S PSJX=$O(DRUGNAME(PSJX)) Q:'PSJX D 64 . S:PSJX=1 X=SCH_" "_PSJID_" "_SD_" "_$E(STAT,1) 65 . S:PSJX=1 DRUGNAME(1)=$$SETSTR^VALM1(X,$E(DRUGNAME(1),1,40),42,20) 66 . S PSJOC(ON,PSJLINE)=" "_DRUGNAME(PSJX) 67 . S PSJLINE=PSJLINE+1 68 Q 69 ; 70 DSPLORDV(DFN,ON) ; Display IV order for order check as in the Inpat Profile. 71 N DRG,DRGI,DRGT,DRGX,FIL,ND,ON55,P,PSJCT,PSJIVFLG,PSJORIFN,TYP,X,Y 72 S TYP="?" I ON["V" D 73 .S Y=$G(^PS(55,DFN,"IV",+ON,0)) F X=2,3,4,5,8,9,17,23 S P(X)=$P(Y,U,X) 74 .S TYP=$$ONE^PSJBCMA(DFN,ON,P(9),P(2),P(3)) I TYP'="O" S TYP="C" 75 .S ON55=ON,P("OT")=$S(P(4)="A":"F",P(4)="H":"H",1:"I") D GTDRG^PSIVORFB,GTOT^PSIVUTL(P(4)) 76 S PSJCT=0,PSJL="" 77 I ON'["V" S (P(2),P(3))="",P(17)=$P($G(^PS(53.1,+ON,0)),U,9),Y=$G(^(8)),P(4)=$P(Y,U),P(8)=$P(Y,U,5),P(9)=$P($G(^(2)),U) D GTDRG^PSIVORFA,GTOT^PSIVUTL(P(4)) 78 S PSJIVFLG=1 D PIVAD,SOL 79 Q 80 ; 81 SOL ; 82 S PSJL=$S($G(PSJIVFLG):PSJL,1:"")_" in" 83 S DRG=0 F S DRG=+$O(DRG("SOL",DRG)) Q:'DRG D NAME^PSIVUTL(DRG("SOL",DRG),39,.NAME,0) S DRGX=0 F S DRGX=$O(NAME(DRGX)) Q:'DRGX S PSJL=$$SETSTR^VALM1(NAME(DRGX),PSJL,12,60) D:$G(PSJIVFLG) PIV1 D SETTMP S PSJL=" " 84 Q 85 ; 86 PIVAD ; Print IV Additives. 87 F DRG=0:0 S DRG=$O(DRG("AD",DRG)) Q:'DRG D NAME^PSIVUTL(DRG("AD",DRG),39,.NAME,1) F DRGX=0:0 S DRGX=$O(NAME(DRGX)) Q:'DRGX S PSJL=$$SETSTR^VALM1(NAME(DRGX),PSJL,9,60) D:$G(PSJIVFLG) PIV1 D SETTMP 88 Q 89 ; 90 PIV1 ; Print Sched type, start/stop dates, and status. 91 K PSJIVFLG 92 F X=2,3 S P(X)=$E($$ENDTC^PSGMI(P(X)),1,$S($D(PSJEXTP):8,1:5)) 93 I '$D(PSJEXTP) S PSJL=$$SETSTR^VALM1(TYP,PSJL,50,1),PSJL=$$SETSTR^VALM1(P(2),PSJL,53,7),PSJL=$$SETSTR^VALM1(P(3),PSJL,60,7),PSJL=$$SETSTR^VALM1(P(17),PSJL,67,1) 94 E S PSJL=$$SETSTR^VALM1(TYP,PSJL,50,1),PSJL=$$SETSTR^VALM1(P(2),53,7),PSJL=$$SETSTR^VALM1(P(3),PSJL,63,7),PSJL=$$SETSTR^VALM1(P(17),PSJL,73,1) 95 Q 96 ; 97 SETTMP ; 98 S PSJOC(ON,PSJLINE)=PSJL,PSJLINE=PSJLINE+1 99 Q 100 ; 101 ORDCHK(DFN,TYPE,PIECE) ; 102 ;TYPE ="DD" - Duplicate drug 103 ; ="DC" - Duplicate class 104 ; -"DI" - Drug Interaction 105 ;PIECE = The piece order number is return from ^TMP($J,"DD"... 106 ;PSJOC(ON,x) = Array of inpatient orders to be displayed 107 ; 108 NEW ON,PSJL,PSIVX,PSJOC,PSJORIEN,PSJPACK,PSJLINE 109 S PSJOC=0,PSJLINE=1 110 F PSIVX=0:0 S PSIVX=$O(^TMP($J,TYPE,PSIVX)) Q:'PSIVX D 111 . S PSJPACK=$P(^TMP($J,TYPE,PSIVX,0),U,PIECE) 112 . I $G(PSGORD) S PSJORD=PSGORD ; Set PSJORD if PSGORD exists and is not Null 113 . I $G(PSJORD)]"" I $S($D(PSJORD):$G(PSJORD),1:$G(PSGORD))'["V",$P(PSJPACK,";")=$S($D(PSJORD):$G(PSJORD),1:$G(PSGORD)) Q ; don't flag order that is being renewed as duplicate, only checks Unit Dose orders 114 . I $G(PSJCOM),($G(PSJORD)["P") Q:$D(^PS(53.1,"ACX",PSJCOM,+PSJPACK)) 115 . ; Don't flag if pending renewal from CPRS 116 . I $G(PSJORD)]"",(PSJORD["P"),($P($G(^PS(53.1,+PSJORD,0)),"^",24)="R"),($P(PSJPACK,";")["U"),($P($G(^PS(55,DFN,5,+$P(PSJPACK,";"),0)),"^",27)="R"),($P($G(^PS(55,DFN,5,+$P(PSJPACK,";"),0)),"^",26)=PSJORD) Q 117 . I $G(PSIVRNFG),$G(ON55)["V",$P(PSJPACK,";")=$G(ON55) Q ;PSIVRNFG set and kill in R+2^PSIVOPT2. Needed to do dupl. check on new order but not renew. 118 . S PSJORIEN=$P(^TMP($J,TYPE,PSIVX,0),U,PIECE-1) 119 . I TYPE="DI",($P(^TMP($J,TYPE,PSIVX,0),U,4)="CRITICAL") S PSJIREQ=1 120 . ; Adding Drug Interactions check for use in Intervention defaults in PSJRXI. 121 . I TYPE="DI" S PSJRXREQ=$S($P(^TMP($J,TYPE,PSIVX,0),U,4)="CRITICAL":1,1:2) 122 . N X S X=$P(PSJPACK,";",2) I X["O" D Q 123 .. D:PSJFST=1 PAUSE 124 .. W !!,"The patient has this "_$S($P(PSJPACK,";")["N":"Non-VA Meds",$P(PSJPACK,";",2)["O":"Outpatient",1:"")_" order:",! 125 .. I $D(^TMP($J,TYPE,PSIVX,1)) D SHOR^PSJLMUT2(TYPE,PSIVX),PAUSE S PSJFST=$S(PSJFST=0:PSJFST+2,1:PSJFST+1) Q 126 .. D EN^PSODRDU2(DFN,PSJPACK),PAUSE S PSJPDRG=1,PSJFST=$S(PSJFST=0:PSJFST+2,1:PSJFST+1) 127 . S ON=$P(PSJPACK,";") Q:$D(PSJOC(ON)) 128 . I ON=$G(PSIVOCON),+PSJORIEN Q 129 . I ON=$G(PSIVOCON),'+PSJORIEN D SETPSJOC Q 130 . I ON["V" D 131 .. I '$O(^PS(55,DFN,"IV",+ON,0)) D SETPSJOC Q 132 .. D DSPLORDV(DFN,ON) S PSJOC=PSJOC+1 133 . I ON'["V" D DSPLORDU(DFN,ON) S PSJOC=PSJOC+1 134 . S PSJOC(ON,PSJLINE)="",PSJLINE=PSJLINE+1 135 ; DEM - If TYPE="DI", and there are "DI" orders, 136 ; then display "DI" orders. 137 I TYPE="DI",PSJOC D WRITE(TYPE) D ;DEM 138 . S ON="" F S ON=$O(PSJOC(ON)) Q:ON="" S PSJLINE=PSJLINE+1,PSJFST=PSJFST+1 D ;DEM 139 .. F PSIVX=0:0 S PSIVX=$O(PSJOC(ON,PSIVX)) Q:'PSIVX W !,PSJOC(ON,PSIVX) S PSJLINE=PSJLINE+1 ;DEM 140 Q:(TYPE="DI") ;DEM - Don't continue if TYPE="DI". Code that follows is for TYPEs "DD" and "DC" only. 141 Q:'PSJOC ;DEM - No need to continue if no "DD", or "DC" orders. 142 ; DEM - If we are here, then there are "DD", or "DC" orders in 143 ; PSJOC array. Loop on PSJOC array and set orders into 144 ; ^TMP($J,"DUPDRG",TYPE) global. The ^TMP($J,"DUPDRG",TYPE) 145 ; global will be used for display of "DD" and "DC" orders 146 ; for possible discontinuation of the "DD", or "DC" orders. 147 ; See subroutine DUPDRG and calling routine ENDDC^PSGSICHK 148 ; for details. 149 S ON="" F S ON=$O(PSJOC(ON)) Q:ON="" D ;DEM 150 . F PSIVX=0:0 S PSIVX=$O(PSJOC(ON,PSIVX)) Q:'PSIVX S ^TMP($J,"DUPDRG",TYPE,ON,PSIVX)=PSJOC(ON,PSIVX) ;DEM 151 Q 152 ; 153 SETPSJOC ;Set PSJOC array to be displayed later 154 NEW PIECE S PIECE=$S(TYPE="DC":4,1:2) 155 S X=$$SETSTR^VALM1($P(^TMP($J,TYPE,PSIVX,0),U,PIECE),"",9,40) 156 S X=$$SETSTR^VALM1("* EXISTS IN CURRENT ORDER *",X,50,27) 157 S PSJOC(ON,PSJLINE)=X,PSJLINE=PSJLINE+1,PSJOC=PSJOC+1 158 Q 159 ; 160 WRITE(TYPE) ;Display order check description 161 S PSJPDRG=1 162 I TYPE="DD" W !!,"This patient is already receiving the following order",$S(PSJOC>1:"s",1:"")," for ",$S($G(PSJDD)]"":$P($G(^PSDRUG(PSJDD,0)),U),1:"this drug"),":",! 163 I TYPE="DC" W !!,"This patient is already receiving ",$S(PSJOC>1:"orders",1:"an order")," for the following drug",$S(PSJOC>1:"s",1:"")," in the same",!,"class as ",$S($G(PSJDD)]"":$P($G(^PSDRUG(PSJDD,0)),U),1:"the drug selected"),":",! 164 I TYPE="DI" W !!,"This patient is receiving the following medication",$S(PSJOC>1:"s",1:"")," that ha",$S(PSJOC>1:"ve",1:"s")," an interaction",!,"with ",$P($G(^PSDRUG(PSJDD,0)),U),":",! 165 Q 166 ; 167 PAUSE ; 168 K DIR W ! S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR W ! 169 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJLMUT2.m
r613 r623 1 PSJLMUT2 ;BIR/JLC-DISPLAY UTILITIES ;22 Jun 05 2 ;;5.0; INPATIENT MEDICATIONS ;**146,175,201**;16 DEC 97;Build 2 3 ; 4 SHOR(PSJT,PSJI) ;Display outpatient remote order checks. 5 ;; PSJT = Type of order check in ^TMP 6 ;; PSJI = Index to ^TMP to find order check detail 7 ; 8 N PSJD0,PSJD1,PSJRX,PSJRS,FSIG,PSJULN,PSJLF,PSJDN 9 S PSJD0=^TMP($J,PSJT,PSJI,0),PSJD1=^(1) 10 I PSJT="DD" S PSJRX=$P($P(PSJD0,"^",4),";"),PSJRS=$P(PSJD0,"^",5),PSJDN=$P(PSJD0,"^",2) 11 I PSJT="DC" S PSJRX=$P($P(PSJD0,"^",6),";"),PSJRS=$P(PSJD0,"^",7),PSJDN=$P(PSJD0,"^",4) 12 I PSJT="DI" S PSJRX=$P($P(PSJD0,"^",8),";"),PSJRS=$P(PSJD0,"^",9),PSJDN=$P(PSJD0,"^",2) 13 S PSJLF=$P(PSJD1,"^",3),$P(PSJULN,"-",79)="" 14 W !,PSJULN,! 15 W PSJRS I $L(PSJRS)>13 W ! 16 W ?14,"Rx #: ",$E(PSJRX,1,$L(PSJRX)-1) I $A($L(PSJRX))<54 W $E(PSJRX,$L(PSJRX)) 17 W ?39,PSJDN,! I PSJT="DI" W ?39,$P(PSJD0,"^",4)," INTERACTION",! 18 W $J("Status: ",20),$P(PSJD1,"^",2),?40,$J("Issued: ",20),$P(PSJD1,"^",9) 19 D FSIG(.FSIG) 20 W !,$J("SIG: ",20) F I=1:1 Q:'$D(FSIG(I)) W ?20,FSIG(I),! 21 W $J("QTY: ",20)_$P(PSJD1,"^",5) 22 W !,$J("Provider: ",20),$P(PSJD1,"^",8),?40,$J("Refills remaining: ",20),$P(PSJD1,"^",6) 23 W !?40,$J("Last filled on: ",20),PSJLF 24 W !?40,$J("Days Supply: ",20)_$P(PSJD1,"^",4) 25 W !,PSJULN 26 Q 27 FSIG(FSIG) ;Format sig from remote site 28 ;returned in the FSIG array 29 N FFF,NNN,CNT,FVAR,FVAR1,FLIM,HSIG,II,I 30 F I=0:1 Q:'$D(^TMP($J,PSJT,PSJI,1,I)) S HSIG(I+1)=^(I) 31 FSTART S (FVAR,FVAR1)="",II=1 32 F FFF=0:0 S FFF=$O(HSIG(FFF)) Q:'FFF S CNT=0 F NNN=1:1:$L(HSIG(FFF)) I $E(HSIG(FFF),NNN)=" "!($L(HSIG(FFF))=NNN) S CNT=CNT+1 D I $L(FVAR)>52 S FSIG(II)=FLIM_" ",II=II+1,FVAR=FVAR1 33 .S FVAR1=$P(HSIG(FFF)," ",(CNT)) 34 .S FLIM=FVAR 35 .S FVAR=$S(FVAR="":FVAR1,1:FVAR_" "_FVAR1) 36 I $G(FVAR)'="" S FSIG(II)=FVAR 37 I $G(FSIG(1))=""!($G(FSIG(1))=" ") S FSIG(1)=$G(FSIG(2)) K FSIG(2) 38 FQUIT Q 39 PAUSE ; 40 K DIR W ! S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR W ! 41 Q 1 PSJLMUT2 ;BIR/JLC-DISPLAY UTILITIES ;22 Jun 05 2 ;;5.0; INPATIENT MEDICATIONS ;**146,175**;16 DEC 97;Build 18 3 ; 4 ; Reference to ^PS(55 is supported by DBIA# 2191. 5 ; Reference to ^PSDRUG is supported by DBIA# 2192. 6 ; Reference to ^PSSLOCK is supported by DBIA# 2789. 7 ; Reference to ^VA(200 is supported by DBIA# 10060. 8 ; 9 SHOR(PSJT,PSJI) ;Display outpatient remote order checks. 10 ;; PSJT = Type of order check in ^TMP 11 ;; PSJI = Index to ^TMP to find order check detail 12 ; 13 N PSJD0,PSJD1,PSJRX,PSJRS,FSIG,PSJULN,PSJLF,PSJDN 14 S PSJD0=^TMP($J,PSJT,PSJI,0),PSJD1=^(1) 15 I PSJT="DD" S PSJRX=$P($P(PSJD0,"^",4),";"),PSJRS=$P(PSJD0,"^",5),PSJDN=$P(PSJD0,"^",2) 16 I PSJT="DC" S PSJRX=$P($P(PSJD0,"^",6),";"),PSJRS=$P(PSJD0,"^",7),PSJDN=$P(PSJD0,"^",4) 17 I PSJT="DI" S PSJRX=$P($P(PSJD0,"^",8),";"),PSJRS=$P(PSJD0,"^",9),PSJDN=$P(PSJD0,"^",2) 18 S PSJLF=$P(PSJD1,"^",3),$P(PSJULN,"-",79)="" 19 W !,PSJULN,! 20 W PSJRS I $L(PSJRS)>13 W ! 21 W ?14,"Rx #: ",$E(PSJRX,1,$L(PSJRX)-1) I $A($L(PSJRX))<54 W $E(PSJRX,$L(PSJRX)) 22 W ?39,PSJDN,! I PSJT="DI" W ?39,$P(PSJD0,"^",4)," INTERACTION",! 23 W $J("Status: ",20),$P(PSJD1,"^",2),?40,$J("Issued: ",20),$P(PSJD1,"^",9) 24 D FSIG(.FSIG) 25 W !,$J("SIG: ",20) F I=1:1 Q:'$D(FSIG(I)) W ?20,FSIG(I),! 26 W $J("QTY: ",20)_$P(PSJD1,"^",5) 27 W !,$J("Provider: ",20),$P(PSJD1,"^",8),?40,$J("Refills remaining: ",20),$P(PSJD1,"^",6) 28 W !?40,$J("Last filled on: ",20),PSJLF 29 W !?40,$J("Days Supply: ",20)_$P(PSJD1,"^",4) 30 W !,PSJULN 31 Q 32 ; 33 FSIG(FSIG) ;Format sig from remote site 34 ;returned in the FSIG array 35 N FFF,NNN,CNT,FVAR,FVAR1,FLIM,HSIG,II,I 36 F I=0:1 Q:'$D(^TMP($J,PSJT,PSJI,1,I)) S HSIG(I+1)=^(I) 37 FSTART S (FVAR,FVAR1)="",II=1 38 F FFF=0:0 S FFF=$O(HSIG(FFF)) Q:'FFF S CNT=0 F NNN=1:1:$L(HSIG(FFF)) I $E(HSIG(FFF),NNN)=" "!($L(HSIG(FFF))=NNN) S CNT=CNT+1 D I $L(FVAR)>52 S FSIG(II)=FLIM_" ",II=II+1,FVAR=FVAR1 39 .S FVAR1=$P(HSIG(FFF)," ",(CNT)) 40 .S FLIM=FVAR 41 .S FVAR=$S(FVAR="":FVAR1,1:FVAR_" "_FVAR1) 42 I $G(FVAR)'="" S FSIG(II)=FVAR 43 I $G(FSIG(1))=""!($G(FSIG(1))=" ") S FSIG(1)=$G(FSIG(2)) K FSIG(2) 44 FQUIT Q 45 ; 46 DUPDRG(DFN) ;DEM - Duplicate Drug Check Ehancement 47 ; 48 ; Note: Display of Drug Interaction, Non-VA Meds, and Outpatient 49 ; orders is done by ORDCHK^PSJLMUT1. ORDCHK is called by 50 ; routine ENDDC^PSGSICHK before routine ENDDC^PSGSICHK calls 51 ; DUPDRG^PSJLMUT2. If ORDCHK finds "DD", or "DC" orders, 52 ; then ORDCHK will set "DD", or "DC" orders into 53 ; ^TMP($J,"DUPDRG",TYPE) global. 54 ; 55 K PSJDDCON ;Order continuation flag used by routine PSGSICHK. 56 S:$D(^TMP($J,"DI")) PSJDDCON("DI")=1 ;Order continuation flag used by routine PSGSICHK. 57 ; Quit if no duplicate drug orders(s), or duplicate drug class 58 ; order(s) found. 59 Q:'$D(^TMP($J,"DUPDRG","DD"))&'$D(^TMP($J,"DUPDRG","DC")) 60 S PSJDDCON("DD")=0 ;Order continuation flag used by routine PSGSICHK. 61 ; 62 ; Display orders in ^TMP($J,"DUPDRG",DUPLICATE_TYPE,ON,LINE_#) 63 ; (DUPLICATE TYPEs: "DD" - "Duplicate Drug" 64 ; "DC" - "Duplicate Drug Class" 65 ; 66 S PSJPDRG=1 ;If we are here, then set PSJPDRG=1. ORDCHK^PSJLMUT1 addresses this variable for Outpatient orders and "DI" orders. 67 N X,Y,DIR,TYPE,ON,PSJOC,PSJOCPOP,PSJSYSL 68 W !!,"This patient is already receiving the following INPATIENT order(s) for the same drug or in the same drug class as "_$S($G(PSJDD)]"":$P($G(^PSDRUG(PSJDD,0)),U),1:"the drug selected"),":",!! 69 D DSPLDD ;Display patients orders for the same drug or same drug class as drug selected. 70 ; Ask user if they wish to continue in spite of an order check. 71 S DIR(0)="Y",DIR("A")="Do you wish to continue with the current order",DIR("?",1)="Enter ""N"" if you wish to exit without creating a new order," 72 S DIR("?")="or ""Y"" to continue with the order entry process.",DIR("B")="YES" D ^DIR I 'Y S PSGORQF=1,COMQUIT=1 K X,Y,DIR W ! Q 73 K X,Y,DIR 74 S PSJDDCON("DD")=1,PSJSYSL=0 ;Order continuation flag used by routine PSGSICHK. 75 W ! 76 F D Q:('PSJOC)!(PSJOCPOP) ;Order discontinuation loop. 77 . N TYPE,ON,PSJOCSEQ 78 . S PSJOCPOP=0 79 . ; Ask user if they wish to discontinue any of the listed orders. 80 . S DIR(0)="Y",DIR("A")="Do you wish to DISCONTINUE any of the listed orders",DIR("?",1)="Enter ""N"" if you wish to exit without discontinuing any of the listed orders," 81 . S DIR("?")="or ""Y"" to discontinue any of the listed orders.",DIR("B")="NO" D ^DIR I 'Y K X,Y,DIR S PSJOCPOP=1 W ! Q 82 . K X,Y,DIR 83 . W ! 84 . ; Choose for DISCONTINUE 1-PSJOC (PSJOC is the total number of duplicate and duplicate class orders). 85 . S DIR(0)="N^1:"_PSJOC,DIR("A")="Choose for DISCONTINUE",DIR("?")="Choose an order 1-"_PSJOC D ^DIR I 'Y K X,Y,DIR S PSJOCPOP=1 W ! Q 86 . S PSJOCSEQ=+Y 87 . K X,Y,DIR 88 . ; 89 . ; *** Discontinue order *** 90 . S ON=$P(PSJOC(PSJOCSEQ),"^",2) 91 . I '$$LS^PSSLOCK(DFN,ON) S PSJOCPOP=1 Q 92 . S PSGSTAT=$$GTSTATUS^PSJOE(DFN,ON) 93 . D ;Set PSGOEEWF for order being discontinued - DRF 94 .. I ON["P" S PSGOEEWF="^PS(53.1,"_+ON_"," Q 95 .. I ON["U" S PSGOEEWF="^PS(55,"_DFN_",5,"_+ON_"," Q 96 .. S PSGOEEWF="^PS(55,"_DFN_",""IV"","_+ON_"," 97 . D ;The following variables must be newed or they are stomped on by the discontinue code 98 .. N %DT,CF,D,D0,DA,DI,DIC,DIE,DISYS,DQ,DR,DRG,DRGT,DRGTMP,DRGX 99 .. N DTIME,FIL,I,JJ,LOC,OCXDT,OCXI,OCXSEG,ORIFN,ORO,POP,PSGALR 100 .. N PSGDT,PSGOEAV,PSJNOO,PSGOEDMR,PSGOEPR,PSGPDRG,PSGTOO,PSGTOL 101 .. N PSGUOW,PSIVOI,PSIVX,PSJCOM,PSJDD,PSJHLMTN,PSJMSG,PSJQO,PSOC 102 .. N Q,QQ,T,VA,VADM,VAERR,VAIN,XPARSYS,XQXFLG,Y,PSJRQPND 103 .. D 104 ... S PSJRQPND=1 105 ... I ON["V" D Q ;IV order 106 .... N PSJORD 107 .... S PSJORD=ON 108 .... D DC^PSJLIACT 109 ... D DC^PSJOE(DFN,ON) ;UD order 110 .. I $$GTSTATUS^PSJOE(DFN,ON)="D" D ; Clean up PSJOC and ^TMP($J,"DUPDRG") arrays, and reset PSJOC counter IF and after selected order has been discontinued. 111 ... S TYPE=$P(PSJOC(PSJOCSEQ),"^",1),ON=$P(PSJOC(PSJOCSEQ),"^",2),PSJOC=PSJOC-1 112 ... K PSJOC(PSJOCSEQ),^TMP($J,"DUPDRG",TYPE,ON),PSJOCSEQ 113 . D UNL^PSSLOCK(DFN,ON) 114 . Q:'PSJOC 115 . W !!,"Now, this patient is already receiving the following INPATIENT order(s) for the same drug or in the same drug class as "_$S($G(PSJDD)]"":$P($G(^PSDRUG(PSJDD,0)),U),1:"the drug selected"),":",!! 116 . D DSPLDD 117 . Q 118 W ! 119 K PSJOCPOP,PSGSTAT 120 Q 121 ; 122 DSPLDD ; 123 ; Display patients orders for the same drug or same drug class as drug selected. 124 N X,REQPROV,PSJLINE,PSJFLN 125 K PSJOC 126 ; Requesting Provider 127 S PSJOC=0 128 F TYPE="DD","DC" S ON="" F S ON=$O(^TMP($J,"DUPDRG",TYPE,ON)) Q:ON="" S PSJFLN=1 D 129 . I ON["U" S REQPROV=$P(^PS(55,DFN,5,+ON,0),"^",2) 130 . I ON["V" S REQPROV=$P(^PS(55,DFN,"IV",+ON,0),"^",6) 131 . I ON["P" S REQPROV=$P(^PS(53.1,+ON,0),"^",2) 132 . S REQPROV=$S(REQPROV>0:$P($G(^VA(200,REQPROV,0)),"^",1),1:"") S:REQPROV="" REQPROV="Requesting Provider Unknown" 133 . F PSJLINE=0:0 S PSJLINE=$O(^TMP($J,"DUPDRG",TYPE,ON,PSJLINE)) Q:'PSJLINE D 134 .. I PSJFLN=1 S PSJOC=PSJOC+1,PSJOC(PSJOC)=TYPE_"^"_ON W PSJOC_".",^TMP($J,"DUPDRG",TYPE,ON,PSJLINE),! S PSJFLN=PSJFLN+1 Q 135 .. S X=^TMP($J,"DUPDRG",TYPE,ON,PSJLINE) S:PSJFLN=2 X=$$SETSTR^VALM1(REQPROV,X,(48+$L(PSJOC_".")),25) W ?($L(PSJOC_".")),X,! S PSJFLN=PSJFLN+1 Q 136 .. Q 137 . Q 138 Q 139 ; 140 PAUSE ; 141 K DIR W ! S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR W ! 142 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJMPEND.m
r613 r623 1 PSJMPEND ;BIR/CML3-MD MARS - GATHER ACK ORDERS INFO (MDWS) ; 6/18/07 12:11pm 2 ;;5.0; INPATIENT MEDICATIONS ;**191**;16 DEC 97;Build 9 3 ; 4 PEND ;*** Only select orders that were acknowledged by nurses and are 5 ;*** still having pending status. 6 NEW X S X=$O(^PS(59.6,"B",+PSJPWD,0)) Q:'+$P($G(^PS(59.6,+X,0)),U,6) 7 NEW ND,ON,TYPE,QST 8 F ON=0:0 S ON=$O(^PS(53.1,"AV",PSGP,ON)) Q:'ON D 9 . S ND=$G(^PS(53.1,ON,0)),TYPE=$P(ND,U,4) 10 . S ND2=$G(^PS(53.1,ON,2)),PSGLSD=$P(ND2,U,2),PSGLFD=$P(ND2,U,4) 11 . I $P(ND,U,7)="P"!($P($G(^PS(53.1,ON,2)),U)["PRN") S QST="PZ"_$S($P(ND,U,4)="F":"V",1:"A") 12 . E S QST="CZ"_$S($P(ND,U,4)="F":"V",1:"A") 13 . I PSGMTYPE[1 D:TYPE'="F" SETTMP D:TYPE="F" IV 14 . I PSGMTYPE'[1 D 15 .. I PSGMTYPE[2,(TYPE="U") D SETTMP Q 16 .. I PSGMTYPE'[2,(TYPE="I") D SETTMP Q 17 .. I PSGMTYPE[4,(TYPE="F") D IV 18 Q 19 ; 20 SETTMP ;*** Setup ^tmp for pending U/D and Inpatient med IVs. 21 ;*** PZ_(V/A) = PRN/One time orders (V=IV). 22 ;*** CZ_(V/A) = Continuous orders (A=U/D). 23 I 'PSJMPRN,(QST["PZ") Q 24 NEW MARX 25 D DRGDISP^PSJLMUT1(PSGP,+ON_"P",20,0,.MARX,1) S DRG=MARX(1)_U_ON 26 ;*** Set up ^TMP for sort by patients 27 S PSJDOS=$P(^PS(53.1,ON,.2),U,2),PSJMR=$E($S($P(ND,U,3)]"":$P(ND,U,3),1:$P(ND,U)),1,5),PSJSCHE=$P($G(^PS(53.1,ON,2)),U) 28 S PSJHOLD=$S($P(ND,U,9)["H":1,1:0),PSGLOD=$P(ND,U,14),PSJATME=9999,PSJADT=$S(QST["C":"8999999",1:"9999999") 29 D SI 30 I PSGSS="P" D Q 31 . S ^TMP($J,PSJADT,PPN_U_PSGP,PSJATME,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSJPWDN_U_PSJPRB 32 . S ^TMP($J,QST,PSGP,ON)=PSJDOS_U_PSJMR_U_PSJSCHE_U_PSJHOLD_U_PSGLOD 33 . S ^TMP($J,QST,PSGP,ON,1)=PSJSI 34 ;*** Set up ^TMP when listing by ward 35 S:PSGRBADM="A" ^TMP($J,PSJADT,TM,PSJATME,PSJPRB,PPN,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 36 S:PSGRBADM="R" ^TMP($J,PSJADT,TM,PSJPRB,PPN,PSJATME,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 37 S:PSGRBADM="P" ^TMP($J,PSJADT,TM,PPN_U_PSGP,PSJATME,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 38 S ^TMP($J,QST,PSGP,ON)=PSJDOS_U_PSJMR_U_PSJSCHE_U_PSJHOLD_U_PSGLOD_U_PSGLSD_U_PSGLFD 39 S ^TMP($J,QST,PSGP,ON,1)=PSJSI 40 Q 41 SI ;*** Find the Special instructions. 42 S X=0,PSJSI="" F S X=$O(^PS(53.1,ON,12,X)) Q:'X S Z=$G(^(X,0)),Y=$L(PSJSI) S:Y+$L(Z)'>179 PSJSI=PSJSI_Z_" " I Y+$L(Z)>179 S PSJSI="SEE PROVIDER COMMENTS" Q 43 Q 44 ; 45 IV ;*** Sort IV pending orders for 24 Hrs, 7/14 Day MAR. 46 K DRG,P NEW X,ON55,P,PSJLABEL 47 S DFN=PSGP,PSJLABEL=1 D GT531^PSIVORFA(DFN,ON) 48 S X=$P(P("MR"),U,2) 49 S QST=QST_4 50 S PSJADT=$S(QST["C":"8999999",1:"9999999") 51 I DRG S X=$S($G(DRG("AD",1)):DRG("AD",1),1:$G(DRG("SOL",1))),X=$E($P(X,U,2),1,20)_U_ON D 52 . I PSGSS="P" S ^TMP($J,PSJADT,PPN_U_PSGP,"9999",QST,X)=PSGP_U_ON_U_PSJPPID_U_PSJPWDN_U_PSJPRB Q 53 . S:PSGRBADM="A" ^TMP($J,PSJADT,TM,"9999",PSJPRB,PPN,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 54 . S:PSGRBADM="R" ^TMP($J,PSJADT,TM,PSJPRB,PPN,"9999",QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 55 . S:PSGRBADM="P" ^TMP($J,PSJADT,TM,PPN_U_PSGP,"9999",QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 56 Q 1 PSJMPEND ;BIR/CML3-MD MARS - GATHER ACK ORDERS INFO (MDWS) ;20 DEC 96 / 3:15 PM 2 ;;5.0; INPATIENT MEDICATIONS ;;16 DEC 97 3 ; 4 PEND ;*** Only select orders that were acknowledged by nurses and are 5 ;*** still having pending status. 6 NEW X S X=$O(^PS(59.6,"B",+PSJPWD,0)) Q:'+$P($G(^PS(59.6,+X,0)),U,6) 7 NEW ND,ON,TYPE,QST 8 F ON=0:0 S ON=$O(^PS(53.1,"AV",PSGP,ON)) Q:'ON D 9 . S ND=$G(^PS(53.1,ON,0)),TYPE=$P(ND,U,4) 10 . I $P(ND,U,7)="P"!($P($G(^PS(53.1,ON,2)),U)["PRN") S QST="PZ"_$S($P(ND,U,4)="F":"V",1:"A") 11 . E S QST="CZ"_$S($P(ND,U,4)="F":"V",1:"A") 12 . I PSGMTYPE[1 D:TYPE'="F" SETTMP D:TYPE="F" IV 13 . I PSGMTYPE'[1 D 14 .. I PSGMTYPE[2,(TYPE="U") D SETTMP Q 15 .. I PSGMTYPE'[2,(TYPE="I") D SETTMP Q 16 .. I PSGMTYPE[4,(TYPE="F") D IV 17 Q 18 ; 19 SETTMP ;*** Setup ^tmp for pending U/D and Inpatient med IVs. 20 ;*** PZ_(V/A) = PRN/One time orders (V=IV). 21 ;*** CZ_(V/A) = Continuous orders (A=U/D). 22 I 'PSJMPRN,(QST["PZ") Q 23 NEW MARX 24 D DRGDISP^PSJLMUT1(PSGP,+ON_"P",20,0,.MARX,1) S DRG=MARX(1)_U_ON 25 ;*** Set up ^TMP for sort by patients 26 S PSJDOS=$P(^PS(53.1,ON,.2),U,2),PSJMR=$E($S($P(ND,U,3)]"":$P(ND,U,3),1:$P(ND,U)),1,5),PSJSCH=$P($G(^PS(53.1,ON,2)),U) 27 S PSJHOLD=$S($P(ND,U,9)["H":1,1:0),PSGLOD=$P(ND,U,14),PSJATME=9999,PSJADT=$S(QST["C":"8999999",1:"9999999") 28 D SI 29 I PSGSS="P" D Q 30 . S ^TMP($J,PSJADT,PPN_U_PSGP,PSJATME,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSJPWDN_U_PSJPRB 31 . S ^TMP($J,QST,PSGP,ON)=PSJDOS_U_PSJMR_U_PSJSCHE_U_PSJHOLD_U_PSGLOD 32 . S ^TMP($J,QST,PSGP,ON,1)=PSJSI 33 ;*** Set up ^TMP when listing by ward 34 S:PSGRBADM="A" ^TMP($J,PSJADT,TM,PSJATME,PSJPRB,PPN,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 35 S:PSGRBADM="R" ^TMP($J,PSJADT,TM,PSJPRB,PPN,PSJATME,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 36 S:PSGRBADM="P" ^TMP($J,PSJADT,TM,PPN_U_PSGP,PSJATME,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 37 S ^TMP($J,QST,PSGP,ON)=PSJDOS_U_PSJMR_U_PSJSCHE_U_PSJHOLD_U_PSGLOD_U_PSGLSD_U_PSGLFD 38 S ^TMP($J,QST,PSGP,ON,1)=PSJSI 39 Q 40 SI ;*** Find the Special instructions. 41 S X=0,PSJSI="" F S X=$O(^PS(53.1,ON,12,X)) Q:'X S Z=$G(^(X,0)),Y=$L(PSJSI) S:Y+$L(Z)'>179 PSJSI=PSJSI_Z_" " I Y+$L(Z)>179 S PSJSI="SEE PROVIDER COMMENTS" Q 42 Q 43 ; 44 IV ;*** Sort IV pending orders for 24 Hrs, 7/14 Day MAR. 45 K DRG,P NEW X,ON55,P,PSJLABEL 46 S DFN=PSGP,PSJLABEL=1 D GT531^PSIVORFA(DFN,ON) 47 S X=$P(P("MR"),U,2) 48 S QST=QST_4 49 S PSJADT=$S(QST["C":"8999999",1:"9999999") 50 I DRG S X=$S($G(DRG("AD",1)):DRG("AD",1),1:$G(DRG("SOL",1))),X=$E($P(X,U,2),1,20)_U_ON D 51 . I PSGSS="P" S ^TMP($J,PSJADT,PPN_U_PSGP,"9999",QST,X)=PSGP_U_ON_U_PSJPPID_U_PSJPWDN_U_PSJPRB Q 52 . S:PSGRBADM="A" ^TMP($J,PSJADT,TM,"9999",PSJPRB,PPN,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 53 . S:PSGRBADM="R" ^TMP($J,PSJADT,TM,PSJPRB,PPN,"9999",QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 54 . S:PSGRBADM="P" ^TMP($J,PSJADT,TM,PPN_U_PSGP,"9999",QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB 55 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJOERI.m
r613 r623 1 PSJOERI ;BIR/LDT-CPRS ORDER UPDATE FOR INPATIENT MEDS ; 7/30/08 7:51am 2 ;;5.0; INPATIENT MEDICATIONS ;**86,108,204**;16 DEC 97;Build 3 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191 5 ; Reference to ^%DTC is supported by DBIA 10000 6 ; Reference to ^DIE is supported by DBIA 10018 7 ; 8 ENR(DFN,ON,PSJWARD) ; 9 I $G(DFN)=""!($G(ON)="")!(+$G(PSJWARD)'>0) Q 10 I PSJWARD'=+PSJWARD Q 11 D NOW^%DTC S PSJNOW=% 12 I ON["V" D Q 13 . I '$D(^PS(55,DFN,"IV",+ON)) Q 14 . I $P(^PS(55,DFN,"IV",+ON,0),"^",17)'="D" Q 15 . I $P(^PS(55,DFN,"IV",+ON,0),"^",12)="" Q 16 . N DA,DR,DIE,DIK,PSIVREA,PSIVALCK,PSIVOPT,PSIVAL,PSIVALT,X,Y 17 . S P(3)=$P($G(^PS(55,DFN,"IV",+ON,0)),"^",3) 18 . S X=$G(^PS(55,DFN,"IV",+ON,"ADC")) I X K ^PS(55,"ADC",X,DFN,+ON),^PS(55,DFN,"IV",+ON,"ADC") 19 . S PSIVACT=1,DR="100///A;.03////"_+$P($G(^PS(55,DFN,"IV",+ON,2)),U,7)_";9////^S X=PSJWARD;109///@;116///@;121///@",DIE="^PS(55,"_DFN_",""IV"",",DA=+ON,DA(1)=DFN 20 .;PSJ*5.0*204 21 . I $P($G(^PS(55,DFN,"IV",+ON,4)),"^",18)=1 S DR="100////H;.03////"_+$P($G(^PS(55,DFN,"IV",+ON,2)),U,7)_";9////^S X=PSJWARD;109///@;116///@;121///@" 22 . N CHKIT S CHKIT=$G(^PS(55,DFN,"IV",+ON,2)) I $P(CHKIT,U,6)["P",($P(CHKIT,U,9)="R") S DR=DR_";114///@;123///@" 23 . D ^DIE 24 . D IRA(1),EN1^PSJHL2(DFN,"SC",ON,"AUTO REINSTATED (CPRS)") 25 I ON["U" D Q 26 . I '$D(^PS(55,DFN,5,+ON)) Q 27 . I $P(^PS(55,DFN,5,+ON,0),"^",9)'="D" Q 28 . I $P(^PS(55,DFN,5,+ON,4),"^",11)="" Q 29 . N DA,DR,DIE,PSGFD,X,Z 30 . S PSGFD=$P($G(^PS(55,DFN,5,+ON,2)),"^",3) 31 . S DR="28////A;34////^S X=PSGFD;68////^S X=PSJWARD",Z=$G(^PS(55,DFN,5,+ON,4)),$P(Z,U,11)="",$P(Z,"^",15,17)="^^" S ^(4)=Z 32 .;PSJ*5.0*204 33 . I $P($G(^PS(55,DFN,5,+ON,4)),"^",18)=1 S DR="28////H;34////^S X=PSGFD;68////^S X=PSJWARD" 34 . N CHKIT S CHKIT=$G(^PS(55,DFN,5,+ON,0)) I $P(CHKIT,U,26)["P",($P(CHKIT,U,27)="R") S DR=DR_";105///@;107///@" 35 . S DIE="^PS(55,"_DFN_",5,",DA(1)=DFN,DA=+ON D ^DIE 36 . S X=$P(^PS(55,DFN,5,+ON,0),"^",20),$P(^(0),"^",20)="" K:X ^PS(55,"AUDDD",X,DFN,+ON) ;Removed cross reference after reinstate order. 37 . D URA(1),EN1^PSJHL2(DFN,"SC",ON,"AUTO REINSTATED (CPRS)") 38 Q 39 IRA(STAT) ; 40 S ON55=ON,P(17)="A",PSIVREA="AI",PSIVALCK="STOP",(PSIVOPT,PSIVALT)=1,PSJUNDC=1,PSIVAL="AUTO REINSTATED (CPRS)" 41 D LOG^PSIVORAL 42 Q 43 URA(STAT) ; 44 S PSGAL("C")=18560 D ^PSGAL5 45 Q 1 PSJOERI ;BIR/LDT-CPRS ORDER UPDATE FOR INPATIENT MEDS ;18 JUN 01 2 ;;5.0; INPATIENT MEDICATIONS ;**86,108**;16 DEC 97 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191 5 ; Reference to ^%DTC is supported by DBIA 10000 6 ; Reference to ^DIE is supported by DBIA 10018 7 ; 8 ENR(DFN,ON,PSJWARD) ; 9 I $G(DFN)=""!($G(ON)="")!(+$G(PSJWARD)'>0) Q 10 I PSJWARD'=+PSJWARD Q 11 D NOW^%DTC S PSJNOW=% 12 I ON["V" D Q 13 . I '$D(^PS(55,DFN,"IV",+ON)) Q 14 . I $P(^PS(55,DFN,"IV",+ON,0),"^",17)'="D" Q 15 . I $P(^PS(55,DFN,"IV",+ON,0),"^",12)="" Q 16 . N DA,DR,DIE,DIK,PSIVREA,PSIVALCK,PSIVOPT,PSIVAL,PSIVALT,X,Y 17 . S P(3)=$P($G(^PS(55,DFN,"IV",+ON,0)),"^",3) 18 . S X=$G(^PS(55,DFN,"IV",+ON,"ADC")) I X K ^PS(55,"ADC",X,DFN,+ON),^PS(55,DFN,"IV",+ON,"ADC") 19 . S PSIVACT=1,DR="100///A;.03////"_+$P($G(^PS(55,DFN,"IV",+ON,2)),U,7)_";9////^S X=PSJWARD;109///@;116///@;121///@",DIE="^PS(55,"_DFN_",""IV"",",DA=+ON,DA(1)=DFN 20 . N CHKIT S CHKIT=$G(^PS(55,DFN,"IV",+ON,2)) I $P(CHKIT,U,6)["P",($P(CHKIT,U,9)="R") S DR=DR_";114///@;123///@" 21 . D ^DIE 22 . D IRA(1),EN1^PSJHL2(DFN,"SC",ON,"AUTO REINSTATED (CPRS)") 23 I ON["U" D Q 24 . I '$D(^PS(55,DFN,5,+ON)) Q 25 . I $P(^PS(55,DFN,5,+ON,0),"^",9)'="D" Q 26 . I $P(^PS(55,DFN,5,+ON,4),"^",11)="" Q 27 . N DA,DR,DIE,PSGFD,X,Z 28 . S PSGFD=$P($G(^PS(55,DFN,5,+ON,2)),"^",3) 29 . S DR="28////A;34////^S X=PSGFD;68////^S X=PSJWARD",Z=$G(^PS(55,DFN,5,+ON,4)),$P(Z,U,11)="",$P(Z,"^",15,17)="^^" S ^(4)=Z 30 . N CHKIT S CHKIT=$G(^PS(55,DFN,5,+ON,0)) I $P(CHKIT,U,26)["P",($P(CHKIT,U,27)="R") S DR=DR_";105///@;107///@" 31 . S DIE="^PS(55,"_DFN_",5,",DA(1)=DFN,DA=+ON D ^DIE 32 . S X=$P(^PS(55,DFN,5,+ON,0),"^",20),$P(^(0),"^",20)="" K:X ^PS(55,"AUDDD",X,DFN,+ON) ;Removed cross reference after reinstate order. 33 . D URA(1),EN1^PSJHL2(DFN,"SC",ON,"AUTO REINSTATED (CPRS)") 34 Q 35 IRA(STAT) ; 36 S ON55=ON,P(17)="A",PSIVREA="AI",PSIVALCK="STOP",(PSIVOPT,PSIVALT)=1,PSJUNDC=1,PSIVAL="AUTO REINSTATED (CPRS)" 37 D LOG^PSIVORAL 38 Q 39 URA(STAT) ; 40 S PSGAL("C")=18560 D ^PSGAL5 41 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJOREN.m
r613 r623 1 PSJOREN ;BIR/CML3-INTERFACE FOR INPATIENT PHARMACY AND OE/RR ;07 AUG 97 / 3:21 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**109,127,134**;16 DEC 97;Build 124 3 ; 4 ;Reference to ^ORD(100.98 supported by DBIA 873 5 ;Reference to ^PS(51.2 supported by DBIA 2178 6 ;Reference to ^PS(55 supported by DBIA 2191 7 ; 8 ENTRY ; 9 K PSGOEE,PSGOES 10 I '$D(^DPT(+ORVP,.1)) W !!,"THIS PATIENT HAS NOT BEEN ADMITTED.",!,"(Any non-IV orders entered will be discontinued by the pharmacist...)" 11 ; 12 GO ; get orders 13 S PSGOEORF=1,PSGOEAV=0,PSJORTOU=$O(^ORD(100.98,"B","INPATIENT MEDICATIONS",0)),PSGOEDMR=$O(^PS(51.2,"B","ORAL",0)),PSGOEPR=PSJORPV 14 F S PSGOEOS="U" D ^PSGOE7 Q:Y<0 D:X?1"S."1.E ^PSGOES I X'?1."S."1.E D ^PSGOE6 K PSGOEE D:$D(Y) ^PSGOETO 15 ; 16 DONE ; 17 ; 18 OUT ; 19 Q ; 20 PS ; 21 W $C(7),!!,"The selected PROVIDER is NOT qualified to write MEDICATION orders. You must",!,"select a valid provider to be able to continue with Inpatient Medications." 22 K DIC S DIC="^VA(200,",DIC(0)="AEMQZ",DIC("A")="Select PHARMACY PROVIDER: ",DIC("S")="S PSG=$G(^(""PS"")) I PSG,$S('$P(PSG,""^"",4):1,1:DT<$P(PSG,""^"",4))" F W ! D ^DIC Q:$D(DUOUT)!$D(DTOUT)!(Y>0) W $C(7)," (Required.)" 23 K DIC S:Y'>0 PSJORPF=11 S:Y>0 PSJORPV=+Y,PSJORPVN=Y(0,0) Q 24 Q 25 ENBKOUT(DFN,ON) ; Undo Renew. 26 Q:'$G(ON) 27 N PSJOLD,PSJRES,PSJOC,PSJOC2,PSIVACT,PSIVALT,PSIVREA,ON55,PSGAL,DA,PSIVAL,PSJUNDC 28 S PSJOC=PSOC,PSJOC2=PSJHLMTN,PSIVAL=24000 29 S X=$G(^PS(53.1,+ON,0)) Q:'X 30 S PSJRES=$P(X,U,24),(X,PSJOLD)=$P(X,U,25) 31 I PSJOLD["V" D 32 .I $D(^PS(55,DFN,"IV",+PSJOLD,2)) D 33 ..N PSJOSTOP,PSJNOW,PSJSTAT S PSJNOW=$$DATE^PSJUTL2(),PSJOSTOP=$P($G(^PS(55,DFN,"IV",+PSJOLD,0)),"^",3),PSJSTAT=$P(^(0),"^",17) 34 ..S $P(^PS(55,DFN,"IV",+PSJOLD,2),U,6)="",$P(^(2),U,9)="",$P(^(0),U,17)=$S(PSJNOW>PSJOSTOP:"E",PSJSTAT="R":"A",1:PSJSTAT) 35 ..S PSIVACT=1,PSIVALT=$S(PSOC="CR":2,1:1),PSJUNDC=1,PSIVAL=$P($G(^PS(53.3,+PSIVAL,0)),U),PSIVREA="PNRD",ON55=PSJOLD 36 .D LOG^PSIVORAL 37 I PSJOLD["U" D 38 .I $D(^PS(55,DFN,5,+PSJOLD,0)) N PSJSTAT S PSJSTAT=$P(^(0),"^",9) D 39 ..N PSJOSTOP,PSJNOW S PSJNOW=$$DATE^PSJUTL2(),PSJOSTOP=$P($G(^PS(55,DFN,5,+PSJOLD,2)),"^",4) 40 ..S $P(^PS(55,DFN,5,+PSJOLD,0),U,26,27)=U,PSGAL("C")=24000,DA=+PSJOLD,DA(1)=DFN S $P(^(0),U,9)=$S(PSJNOW>PSJOSTOP:"E",PSJSTAT="R":"A",1:PSJSTAT) 41 .D ^PSGAL5 42 S PSOC="SC",PSJHLMTN="ORM" D EN1^PSJHL2(DFN,PSOC,PSJOLD) S PSOC=PSJOC,PSJHLMTN=PSJOC2 43 Q 44 ; 45 ENUDTX(DFN,ON,RES) ; Set up ORTX( Array for UD orders. 46 K ORTX N DO,MRN,ND0,NDP1,ND2,PD,ST,SCH 47 S Y=2 I ON["A"!(ON["O") S ND0=$G(^PS(55,DFN,5,+ON,0)),NDP1=$G(^(.1)),ND2=$G(^(2)),Y=2 F X=0:0 S X=$O(^PS(55,DFN,5,+ON,12,X)) Q:'X S Y=Y+1,ORTX(Y)=$G(^(X,0)) 48 E S ND0=$G(^PS(53.1,+ON,0)),NDP1=$G(^(.1)),ND2=$G(^(2)),Y=2 F X=0:0 S X=$O(^PS(53.1,+ON,12,X)) Q:'X S Y=Y+1,ORTX(Y)=$G(^(X,0)) 49 S ORTX(1)=$S($G(RES)="NR":"RENEWAL -",$G(RES)="OR":"RENEWED -",1:"")_$P($G(^PS(50.3,+NDP1,0)),U) 50 S ORTX(2)=" Give: "_$S($P(NDP1,U,2)]"":$P(NDP1,U,2)_" ",1:"")_$P($G(^PS(51.2,+$P(ND0,U,3),0)),U,3)_" "_$P(ND2,U)_$S($P(ND2,U)["PRN":"",$P(ND0,U,7)="P":" PRN",1:"") 51 I $G(DFN),$G(ON) S:ON["U" ^PS(55,"AUE",DFN,+ON)="" 52 Q 1 PSJOREN ;BIR/CML3-INTERFACE FOR INPATIENT PHARMACY AND OE/RR ;07 AUG 97 / 3:21 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**109,127**;16 DEC 97 3 ; 4 ;Reference to ^ORD(100.98 supported by DBIA 873 5 ;Reference to ^PS(51.2 supported by DBIA 2178 6 ;Reference to ^PS(55 supported by DBIA 2191 7 ; 8 ENTRY ; 9 K PSGOEE,PSGOES 10 ;S PSJORPF=0 S:ORNP PSJORPV=ORNP,PSJORPVN=$P(^VA(200,+ORNP,0),"^"),X=$G(^("PS")) I $S('ORNP:1,'X:1,'$P(X,"^",4):0,1:$P(X,"^",4)'>DT) D PS I PSJORPF G OUT 11 I '$D(^DPT(+ORVP,.1)) W !!,"THIS PATIENT HAS NOT BEEN ADMITTED.",!,"(Any non-IV orders entered will be discontinued by the pharmacist...)" 12 ; 13 GO ; get orders 14 ; S PSJORPCL=XQORNOD,PSJORNS=+XQORNOD,PSJORL=ORL,PSJORTS=ORTS,PSJORVP=ORVP 15 S PSGOEORF=1,PSGOEAV=0,PSJORTOU=$O(^ORD(100.98,"B","INPATIENT MEDICATIONS",0)),PSGOEDMR=$O(^PS(51.2,"B","ORAL",0)),PSGOEPR=PSJORPV 16 F S PSGOEOS="U" D ^PSGOE7 Q:Y<0 D:X?1"S."1.E ^PSGOES I X'?1."S."1.E D ^PSGOE6 K PSGOEE D:$D(Y) ^PSGOETO 17 ; 18 DONE ; 19 ; I $P(PSJSYSL,"^",2)]"" S PSGOP=PSGP D ENQL^PSGLW 20 ; 21 OUT ; 22 ; S PSJNKF=1 D ENIVKV^PSGSETU K PSJORPCL,PSJORTOI,PSJORTOU,PSJORPV,PSJORPVN,PSJORNS,PSJORVP,PSJORL,PSJORTS,PSGOEORF,PSGOEAV,PSJORPF,PSJORQF,PSJPV,PSGOEOS Q 23 Q ; 24 PS ; 25 W $C(7),!!,"The selected PROVIDER is NOT qualified to write MEDICATION orders. You must",!,"select a valid provider to be able to continue with Inpatient Medications." 26 K DIC S DIC="^VA(200,",DIC(0)="AEMQZ",DIC("A")="Select PHARMACY PROVIDER: ",DIC("S")="S PSG=$G(^(""PS"")) I PSG,$S('$P(PSG,""^"",4):1,1:DT<$P(PSG,""^"",4))" F W ! D ^DIC Q:$D(DUOUT)!$D(DTOUT)!(Y>0) W $C(7)," (Required.)" 27 K DIC S:Y'>0 PSJORPF=11 S:Y>0 PSJORPV=+Y,PSJORPVN=Y(0,0) Q 28 Q 29 ENBKOUT(DFN,ON) ; Undo Renew. 30 Q:'$G(ON) 31 N PSJOLD,PSJRES,PSJOC,PSJOC2,PSIVACT,PSIVALT,PSIVREA,ON55,PSGAL,DA,PSIVAL,PSJUNDC 32 S PSJOC=PSOC,PSJOC2=PSJHLMTN,PSIVAL=24000 33 S X=$G(^PS(53.1,+ON,0)) Q:'X 34 S PSJRES=$P(X,U,24),(X,PSJOLD)=$P(X,U,25) 35 I PSJOLD["V" S:$D(^PS(55,DFN,"IV",+PSJOLD,2)) $P(^(2),U,6)="",$P(^(2),U,9)="",$P(^(0),U,17)="A",PSIVACT=1,PSIVALT=$S(PSOC="CR":2,1:1),PSJUNDC=1,PSIVAL=$P($G(^PS(53.3,+PSIVAL,0)),U),PSIVREA="PNRD",ON55=PSJOLD D LOG^PSIVORAL 36 I PSJOLD["U" S:$D(^PS(55,DFN,5,+PSJOLD,0)) $P(^(0),U,26,27)=U,$P(^(0),U,9)="A",PSGAL("C")=24000,DA=+PSJOLD,DA(1)=DFN D ^PSGAL5 37 S PSOC="SC",PSJHLMTN="ORM" D EN1^PSJHL2(DFN,PSOC,PSJOLD) S PSOC=PSJOC,PSJHLMTN=PSJOC2 38 Q 39 ; 40 ENUDTX(DFN,ON,RES) ; Set up ORTX( Array for UD orders. 41 K ORTX N DO,MRN,ND0,NDP1,ND2,PD,ST,SCH 42 S Y=2 I ON["A"!(ON["O") S ND0=$G(^PS(55,DFN,5,+ON,0)),NDP1=$G(^(.1)),ND2=$G(^(2)),Y=2 F X=0:0 S X=$O(^PS(55,DFN,5,+ON,12,X)) Q:'X S Y=Y+1,ORTX(Y)=$G(^(X,0)) 43 E S ND0=$G(^PS(53.1,+ON,0)),NDP1=$G(^(.1)),ND2=$G(^(2)),Y=2 F X=0:0 S X=$O(^PS(53.1,+ON,12,X)) Q:'X S Y=Y+1,ORTX(Y)=$G(^(X,0)) 44 S ORTX(1)=$S($G(RES)="NR":"RENEWAL -",$G(RES)="OR":"RENEWED -",1:"")_$P($G(^PS(50.3,+NDP1,0)),U) 45 S ORTX(2)=" Give: "_$S($P(NDP1,U,2)]"":$P(NDP1,U,2)_" ",1:"")_$P($G(^PS(51.2,+$P(ND0,U,3),0)),U,3)_" "_$P(ND2,U)_$S($P(ND2,U)["PRN":"",$P(ND0,U,7)="P":" PRN",1:"") 46 I $G(DFN),$G(ON) S:ON["U" ^PS(55,"AUE",DFN,+ON)="" 47 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJORPOE.m
r613 r623 1 PSJORPOE ;BIR/MLM,LDT-MISC. PROCEDURE CALLS FOR OE/RR 3.0 ;24 Feb 99 / 10:43 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**50,56,92,80,110,127,133,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(50.7 is supported by DBIA# 2180. 5 ; Reference to ^PS(51.2 is supported by DBIA# 2178. 6 ; Reference to ^PS(55 is supported by DBIA# 2191. 7 ; Reference to ^PS(51.1 is supported by DBIA# 2177. 8 ; Reference to ^PS(52.6 is supported by DBIA# 1231. 9 ; Reference to ^PS(52.7 is supported by DBIA# 2173. 10 ; Reference to ^PSDRUG is supported by DBIA# 2192. 11 ; 12 STARTSTP(PSGP,SCH,OI,PSJPWD,PSGORD,PSJADM) ; 13 ; PSGP=Patient IEN 14 ; SCH=Schedule 15 ; OI=Orderable Item 16 ; PSJPWD=Ward Location (Optional) 17 ; PSGORD=Pharmacy Order Number if the order being placed is a Renewal (Optional) 18 ; 19 Q:+PSGP'>0 "" 20 Q:SCH']"" "" 21 Q:+OI'>0 "" 22 I SCH?.E1L.E S SCH=$$ENLU^PSGMI(SCH) 23 K DFN,PSGNEFDO,PSGNEFD,PSGST,PSGSCH,PSGNEDFD,PSGNESD,PSJSYSW,PSJSYSW0 N RESULT 24 S:'$D(PSGS0XT) PSGS0XT="" S:'$D(PSGS0Y) PSGSOY="" 25 I $G(PSJPWD)']"" S DFN=PSGP D IN5^VADPT S:VAIP(5)]"" PSJPWD=+VAIP(5) 26 S PSJSYSW0="",PSJSYSW=0 I $G(PSJPWD)]"" S PSJSYSW=+$O(^PS(59.6,"B",PSJPWD,0)) I PSJSYSW S PSJSYSW0=$G(^PS(59.6,PSJSYSW,0)) 27 S RESULT=$S($P(PSJSYSW0,"^",5)=0:"CLOSEST",$P(PSJSYSW0,"^",5)=1:"NEXT",1:"NOW") 28 I OI]"" S PSGST=$S($P($G(^PS(50.7,OI,0)),"^",7)]"":$P($G(^PS(50.7,OI,0)),"^",7),1:"C") 29 N %,PSGXSCH D NOW^%DTC S PSGDT=%,DFN=PSGP,(PSGSCH,PSGXSCH)=SCH 30 S X=PSGSCH,PSGS0Y="" D ADMIN 31 I $G(PSGORD)]"" D 32 .S PSGNESD=$$DSTART^PSJDCU(PSGP,PSGORD) I PSGNESD]"" S $P(RESULT,"^",2)=PSGNESD Q 33 .S ND=$S(PSGORD["U":$G(^PS(55,PSGP,5,+PSGORD,2)),1:$G(^PS(55,PSGP,"IV",+PSGORD,0))) 34 .N PSJADM,PSJSTRT S PSJADM=$S(PSGORD["U":$P(ND,"^",5),1:$P(ND,"^",11)),PSJSTRT=$P(ND,"^",2),PSJREN=1 35 S SCH=PSGXSCH 36 N PSJTMPW0 S PSJTMPW0=PSJSYSW0 S $P(PSJSYSW0,"^",5)=1 37 I $G(PSGNESD)="" S RESULT=RESULT_"^"_$$ENSD^PSGNE3(PSGSCH,$S($G(PSJADM)]"":$G(PSJADM),1:PSGS0Y),PSGDT,$S($G(PSJSTRT)]"":$G(PSJSTRT),1:PSGDT)) 38 S PSJSYSW0=PSJTMPW0 39 S PSGNESD=$P(RESULT,"^",2) 40 S PSGNEDFD=$$GTNEDFD^PSGOE7("U",OI) 41 K PSGODF,PSGOES,PSJREN 42 S SCH=PSGXSCH 43 D ENFD^PSGNE3(PSGDT) S RESULT=RESULT_"^"_$G(PSGNEFD) ;_"^"_$G(PSGNEFDO) 44 N DATE S DATE=$$FMDIFF^XLFDT($P(RESULT,"^",3),$P(RESULT,"^",2),3) 45 S $P(RESULT,"^",3)=$S($G(PSGST)="O":0,+DATE>0:+DATE_"D",$P($P(DATE," ",2),":")>0:$P($P(DATE," ",2),":")_"H",1:0) 46 N STRING S STRING=PSGNESD_U_PSGNEFD_U_$G(PSGSCH)_U_$G(PSGST)_U_$G(OI) I ($P($G(ZZND),U,2)]"")&($P($G(ZZND),"^")=$G(PSGSCH)) S STRING=STRING_U_$P(ZZND,U,2) 47 I $G(PSGSCH)]"" I $$DOW^PSIVUTL(PSGSCH) S:$G(PSGS0Y) $P(STRING,"^",6)=PSGS0Y 48 I $G(PSJADM) S $P(STRING,"^",6)=PSJADM 49 S RESULT=RESULT_"^"_$$ENQ^PSJORP2(PSGP,STRING) I ($G(PSGSCH)]"") I $$DOW^PSIVUTL(PSGSCH),(PSGSCH'["@"),'$G(PSGS0Y) S $P(RESULT,"^",4)=$P(RESULT,"^",2) 50 I ($G(PSGSCH)]"") I $$PRNOK^PSGS0(PSGSCH) S $P(RESULT,"^",4)=$P(RESULT,"^",2) 51 D KVAR^VADPT K LYN,ND,PSGDT,PSGNEDFD,PSGNEFD,PSGNEFDO,PSGNESD,PSGS0Y,PSGSCH,PSGST,PSJSYSW,PSJSYSW0,ZZ 52 ;RESULT=WARD PARAMETER^DEFAULT START DATE/TIME^#_D(NUMBER OF DAYS ORDER LASTS) OR #_H(NUMBER OF HOURS ORDER LASTS)^EXPECTED FIRST DOSE 53 Q RESULT 54 ; 55 RESOLVE(PSGP,SCH,OI,PCH,PSJPWD,PSJADM) ; 56 ; PSGP=Patient IEN 57 ; SCH=Schedule 58 ; OI=Orderable Item 59 ; PCH=Providers Choice 60 ; PSJPWD=Ward Location (Optional) 61 ; PSJADM=Admin Times (Optional) 62 ; 63 N PSJSYSW0,PSJSYSW,PSGSCH,PSGOES,PSGS0Y,DFN,RESULT1 64 I $G(PSJPWD)']"" S DFN=PSGP D IN5^VADPT S:VAIP(5)]"" PSJPWD=+VAIP(5) 65 S PSJSYSW0="",PSJSYSW=0 I $G(PSJPWD)]"" S PSJSYSW=+$O(^PS(59.6,"B",PSJPWD,0)) I PSJSYSW S PSJSYSW0=$G(^PS(59.6,PSJSYSW,0)) 66 S $P(PSJSYSW0,"^",5)=$S($$ONE(SCH):2,PCH="NEXT":1,1:0) 67 S RESULT1=$S($P(PSJSYSW0,"^",5)=0:"CLOSEST",$P(PSJSYSW0,"^",5)=1:"NEXT",1:"NOW") 68 I OI]"" S PSGST=$S($P($G(^PS(50.7,OI,0)),"^",7)]"":$P($G(^PS(50.7,OI,0)),"^",7),1:"C") 69 N % D NOW^%DTC S PSGDT=%,DFN=PSGP,PSGSCH=SCH 70 S X=PSGSCH,PSGS0Y="" I $D(^PS(51.1,"AC","PSJ",X)) D ADMIN 71 S:$G(PSJADM) PSGS0Y=PSJADM 72 S RESULT1=RESULT1_"^"_$$ENSD^PSGNE3(SCH,PSGS0Y,PSGDT,PSGDT) 73 I $G(PSGSCH)]"" I $$DOW^PSIVUTL(PSGSCH),(PSGSCH'["@"),'$G(PSGS0Y) S $P(RESULT,"^",4)=$P(RESULT,"^",2) 74 I $G(PSGSCH)]"" I $$PRNOK^PSGS0(PSGSCH) S $P(RESULT1,"^",4)=$P(RESULT,"^",2) 75 D KVAR^VADPT K LYN,PSGDT,PSGNEDFD,PSGNEFD,PSGNEFDO,PSGNESD,PSGS0Y,PSGSCH,PSGST,PSJSYSW,PSJSYSW0,ZZ,PSGS0XT,PSGS0Y 76 Q RESULT1 77 ; 78 SCHREQ(MR,OI,DD) ; 79 ; MR=Medication Route from 51.2 (Required) 80 ; OI=Orderable Item from 50.7 (Optional) 81 ; DD=Dispense Drug from 50 (Optional) 82 N ADDITIVE,SOLUTION,REQ S REQ=0,(SOLUTION,ADDITIVE)="" 83 I '+$G(MR) S REQ=1 Q REQ 84 I '+$G(OI),'+$G(DD) S REQ=1 Q REQ 85 I +$G(DD) S:$P($G(^PSDRUG(+DD,2)),U,3)["U" REQ=1 Q REQ 86 I '$D(PS(51.2,+MR,0)) S REQ=1 Q REQ 87 I $P($G(^PS(51.2,+MR,0)),"^",6)=1 D 88 .I +$G(OI) D 89 ..I '$D(^PS(50.7,+OI,0)) S REQ=1 Q 90 ..F S SOLUTION=$O(^PS(52.7,"AOI",+OI,SOLUTION)) Q:'SOLUTION Q:REQ=1 S:$P(^PSDRUG(+$P(^PS(52.7,SOLUTION,0),U,2),2),U,3)["U" REQ=1 91 ..F S ADDITIVE=$O(^PS(52.6,"AOI",+OI,ADDITIVE)) Q:'ADDITIVE Q:REQ=1 S:$P(^PSDRUG(+$P(^PS(52.6,ADDITIVE,0),U,2),2),U,3)["U" REQ=1 92 Q REQ 93 ; 94 ADMIN ; Get admin times associated with schedule 95 S PSGS0Y="",ZZ=0 96 I $$DOW^PSIVUTL($P(X,"@")),'$D(^PS(51.1,"AC","PSJ",X)) S PSGST="D" D Q:$G(PSGS0Y) 97 .I $P(X,"@",2) N PSJADBAD D Q 98 ..S PSGS0Y=$S($G(PSJADBAD):"",1:$P(X,"@",2)) 99 ..N ADMIN,TIME,II S ADMIN=$P(X,"@",2) F II=1:1:$L(ADMIN,"-") S TIME=$P(ADMIN,"-",II) I TIME'?2N&(TIME'?4N) S PSJADBAD=1 100 .I $P(X,"@",2)]"",$D(^PS(51.1,"APPSJ",$P(X,"@",2))) S X=$P(X,"@",2) 101 D FIND^DIC(51.1,,,,X,,"APPSJ",,,"LYN") 102 S ZZ=$O(LYN("DILIST",2,ZZ)) I ZZ S ZZ=+LYN("DILIST",2,ZZ) I ZZ S ZZND=$G(^PS(51.1,ZZ,0)) S PSGST=$P(ZZND,U,5),PSGS0XT=$P(ZZND,U,3) S:$G(PSGSFLG) PSGSCIEN=$G(LYN("DILIST",2,ZZ)) I $G(PSJPWD) D 103 . N ZZNDW S ZZNDW=$G(^PS(51.1,ZZ,1,PSJPWD,0)) I $P(ZZNDW,"^",2)]"" S PSGS0Y=$P(ZZNDW,"^",2),$P(ZZND,"^",2)=PSGS0Y I $G(PSGSFLG) S PSGSCIEN=$G(LYN("DILIST",2,ZZ)) 104 S ZZ=0 F S ZZ=$O(LYN("DILIST",1,ZZ)) Q:'ZZ I $G(LYN("DILIST",1,ZZ))'=X K LYN("DILIST",1,ZZ),LYN("DILIST",2,ZZ),LYN("DILIST","ID",ZZ,1) 105 I $D(PSJPWD) S ZZ=0 F S ZZ=$O(LYN("DILIST",2,ZZ)) Q:'ZZ!$G(PSGS0Y) I $P($G(^PS(51.1,+LYN("DILIST",2,ZZ),1,+PSJPWD,0)),U,2)]"" S PSGS0Y=$P($G(^(0)),U,2) I $G(PSGSFLG) S PSGSCIEN=$G(LYN("DILIST",2,ZZ)) 106 Q:PSGS0Y]"" S ZZ=0 F S ZZ=$O(LYN("DILIST",2,ZZ)) Q:'ZZ!$G(PSGS0Y) I $G(LYN("DILIST","ID",ZZ,1))]"" S PSGS0Y=$G(LYN("DILIST","ID",ZZ,1)) 107 Q 108 ; 109 ONE(SCH) ; 110 ; SCH=Admin Schedule 111 ; Returns 0 = (zero) Not a one time schedule. 112 ; 1 = One time schedule. 113 Q:$G(SCH)="" 0 114 N X,SCHLST 115 S SCHLST=",TODAY,ONCE,NOW,ONE TIME,ONETIME,ONE-TIME,1TIME,1 TIME,1-TIME,STAT," 116 I SCHLST[(","_SCH_",") Q 1 117 I $D(^PS(51.1,"AC","PSJ",SCH)) S X=$O(^(SCH,"")) S X=$P(^PS(51.1,X,0),"^",5) Q $S(X="O":1,1:0) 118 Q 0 1 PSJORPOE ;BIR/MLM,LDT-MISC. PROCEDURE CALLS FOR OE/RR 3.0 ;24 Feb 99 / 10:43 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**50,56,92,80,110,127,133**;16 DEC 97 3 ; 4 ; Reference to ^PS(50.7 is supported by DBIA# 2180. 5 ; Reference to ^PS(51.2 is supported by DBIA# 2178. 6 ; Reference to ^PS(55 is supported by DBIA# 2191. 7 ; Reference to ^PS(51.1 is supported by DBIA# 2177. 8 ; Reference to ^PS(52.6 is supported by DBIA# 1231. 9 ; Reference to ^PS(52.7 is supported by DBIA# 2173. 10 ; Reference to ^PSDRUG is supported by DBIA# 2192. 11 ; 12 STARTSTP(PSGP,SCH,OI,PSJPWD,PSGORD) ; 13 ; PSGP=Patient IEN 14 ; SCH=Schedule 15 ; OI=Orderable Item 16 ; PSJPWD=Ward Location (Optional) 17 ; PSGORD=Pharmacy Order Number if the order being placed is a Renewal (Optional) 18 ; 19 Q:+PSGP'>0 "" 20 Q:SCH']"" "" 21 Q:+OI'>0 "" 22 I SCH?.E1L.E S SCH=$$ENLU^PSGMI(SCH) 23 K DFN,PSGNEFDO,PSGNEFD,PSGST,PSGSCH,PSGNEDFD,PSGNESD,PSJSYSW,PSJSYSW0 N RESULT 24 S:'$D(PSGS0XT) PSGS0XT="" S:'$D(PSGS0Y) PSGSOY="" 25 I $G(PSJPWD)']"" S DFN=PSGP D IN5^VADPT S:VAIP(5)]"" PSJPWD=+VAIP(5) 26 S PSJSYSW0="",PSJSYSW=0 I $G(PSJPWD)]"" S PSJSYSW=+$O(^PS(59.6,"B",PSJPWD,0)) I PSJSYSW S PSJSYSW0=$G(^PS(59.6,PSJSYSW,0)) 27 S RESULT=$S($P(PSJSYSW0,"^",5)=0:"CLOSEST",$P(PSJSYSW0,"^",5)=1:"NEXT",1:"NOW") 28 I OI]"" S PSGST=$S($P($G(^PS(50.7,OI,0)),"^",7)]"":$P($G(^PS(50.7,OI,0)),"^",7),1:"C") 29 N %,PSGXSCH D NOW^%DTC S PSGDT=%,DFN=PSGP,(PSGSCH,PSGXSCH)=SCH 30 S X=PSGSCH,PSGS0Y="" D ADMIN 31 I $G(PSGORD)]"" D 32 .S PSGNESD=$$DSTART^PSJDCU(PSGP,PSGORD) I PSGNESD]"" S RESULT=RESULT_"^"_PSGNESD Q 33 .S ND=$S(PSGORD["U":$G(^PS(55,PSGP,5,+PSGORD,2)),1:$G(^PS(55,PSGP,"IV",+PSGORD,0))) 34 .N PSJADM,PSJSTRT S PSJADM=$S(PSGORD["U":$P(ND,"^",5),1:$P(ND,"^",11)),PSJSTRT=$P(ND,"^",2),PSJREN=1 35 S SCH=PSGXSCH 36 I $G(PSGNESD)="" S RESULT=RESULT_"^"_$$ENSD^PSGNE3(PSGSCH,$S($G(PSJADM)]"":$G(PSJADM),1:PSGS0Y),PSGDT,$S($G(PSJSTRT)]"":$G(PSJSTRT),1:PSGDT)) 37 ;S Y=$P(RESULT,"^",2) X ^DD("DD") S RESULT=RESULT_"^"_Y 38 S PSGNESD=$P(RESULT,"^",2) 39 S PSGNEDFD=$$GTNEDFD^PSGOE7("U",OI) 40 K PSGODF,PSGOES,PSJREN 41 S SCH=PSGXSCH 42 D ENFD^PSGNE3(PSGDT) S RESULT=RESULT_"^"_$G(PSGNEFD) ;_"^"_$G(PSGNEFDO) 43 N DATE S DATE=$$FMDIFF^XLFDT($P(RESULT,"^",3),$P(RESULT,"^",2),3) 44 S $P(RESULT,"^",3)=$S($G(PSGST)="O":0,+DATE>0:+DATE_"D",$P($P(DATE," ",2),":")>0:$P($P(DATE," ",2),":")_"H",1:0) 45 ;S RESULT=RESULT_"^"_$P($$RESOLVE(PSGP,SCH,OI,"NEXT"),"^",2) 46 N STRING S STRING=PSGNESD_U_PSGNEFD_U_$G(PSGSCH)_U_$G(PSGST)_U_$G(OI) I ($P($G(ZZND),U,2)]"")&($P($G(ZZND),"^")=$G(PSGSCH)) S STRING=STRING_U_$P(ZZND,U,2) 47 I $G(PSGSCH)]"" I $$DOW^PSIVUTL(PSGSCH) S:$G(PSGS0Y) $P(STRING,"^",6)=PSGS0Y 48 S RESULT=RESULT_"^"_$$ENQ^PSJORP2(PSGP,STRING) I ($G(PSGSCH)]"") I $$DOW^PSIVUTL(PSGSCH),(PSGSCH'["@"),'$G(PSGS0Y) S $P(RESULT,"^",4)=$P(RESULT,"^",2) 49 I ($G(PSGSCH)]"") I $$PRNOK^PSGS0(PSGSCH) S $P(RESULT,"^",4)=$P(RESULT,"^",2) 50 D KVAR^VADPT K LYN,ND,PSGDT,PSGNEDFD,PSGNEFD,PSGNEFDO,PSGNESD,PSGS0Y,PSGSCH,PSGST,PSJSYSW,PSJSYSW0,ZZ 51 ;RESULT=WARD PARAMETER^DEFAULT START DATE/TIME^#_D(NUMBER OF DAYS ORDER LASTS) OR #_H(NUMBER OF HOURS ORDER LASTS)^EXPECTED FIRST DOSE 52 Q RESULT 53 ; 54 RESOLVE(PSGP,SCH,OI,PCH,PSJPWD) ; 55 ; PSGP=Patient IEN 56 ; SCH=Schedule 57 ; OI=Orderable Item 58 ; PCH=Providers Choice 59 ; PSJPWD=Ward Location (Optional) 60 ; 61 N PSJSYSW0,PSJSYSW,PSGSCH,PSGOES,PSGS0Y,DFN,RESULT1 62 I $G(PSJPWD)']"" S DFN=PSGP D IN5^VADPT S:VAIP(5)]"" PSJPWD=+VAIP(5) 63 S PSJSYSW0="",PSJSYSW=0 I $G(PSJPWD)]"" S PSJSYSW=+$O(^PS(59.6,"B",PSJPWD,0)) I PSJSYSW S PSJSYSW0=$G(^PS(59.6,PSJSYSW,0)) 64 S $P(PSJSYSW0,"^",5)=$S($$ONE(SCH):2,PCH="NEXT":1,1:0) 65 S RESULT1=$S($P(PSJSYSW0,"^",5)=0:"CLOSEST",$P(PSJSYSW0,"^",5)=1:"NEXT",1:"NOW") 66 I OI]"" S PSGST=$S($P($G(^PS(50.7,OI,0)),"^",7)]"":$P($G(^PS(50.7,OI,0)),"^",7),1:"C") 67 N % D NOW^%DTC S PSGDT=%,DFN=PSGP,PSGSCH=SCH 68 S X=PSGSCH,PSGS0Y="" I $D(^PS(51.1,"AC","PSJ",X)) D ADMIN 69 S RESULT1=RESULT1_"^"_$$ENSD^PSGNE3(SCH,PSGS0Y,PSGDT,PSGDT) 70 I $G(PSGSCH)]"" I $$DOW^PSIVUTL(PSGSCH),(PSGSCH'["@"),'$G(PSGS0Y) S $P(RESULT,"^",4)=$P(RESULT,"^",2) 71 I $G(PSGSCH)]"" I $$PRNOK^PSGS0(PSGSCH) S $P(RESULT1,"^",4)=$P(RESULT,"^",2) 72 D KVAR^VADPT K LYN,PSGDT,PSGNEDFD,PSGNEFD,PSGNEFDO,PSGNESD,PSGS0Y,PSGSCH,PSGST,PSJSYSW,PSJSYSW0,ZZ,PSGS0XT,PSGS0Y 73 Q RESULT1 74 ; 75 SCHREQ(MR,OI,DD) ; 76 ; MR=Medication Route from 51.2 (Required) 77 ; OI=Orderable Item from 50.7 (Optional) 78 ; DD=Dispense Drug from 50 (Optional) 79 N ADDITIVE,SOLUTION,REQ S REQ=0,(SOLUTION,ADDITIVE)="" 80 I '+$G(MR) S REQ=1 Q REQ 81 I '+$G(OI),'+$G(DD) S REQ=1 Q REQ 82 I +$G(DD) S:$P($G(^PSDRUG(+DD,2)),U,3)["U" REQ=1 Q REQ 83 I '$D(PS(51.2,+MR,0)) S REQ=1 Q REQ 84 I $P($G(^PS(51.2,+MR,0)),"^",6)=1 D 85 .I +$G(OI) D 86 ..I '$D(^PS(50.7,+OI,0)) S REQ=1 Q 87 ..F S SOLUTION=$O(^PS(52.7,"AOI",+OI,SOLUTION)) Q:'SOLUTION Q:REQ=1 S:$P(^PSDRUG(+$P(^PS(52.7,SOLUTION,0),U,2),2),U,3)["U" REQ=1 88 ..F S ADDITIVE=$O(^PS(52.6,"AOI",+OI,ADDITIVE)) Q:'ADDITIVE Q:REQ=1 S:$P(^PSDRUG(+$P(^PS(52.6,ADDITIVE,0),U,2),2),U,3)["U" REQ=1 89 Q REQ 90 ; 91 ADMIN ; Get admin times associated with schedule 92 S PSGS0Y="",ZZ=0 93 I $$DOW^PSIVUTL(X),'$D(^PS(51.1,"AC","PSJ",X)) S PSGST="D" D Q 94 .I $P(X,"@",2) N PSJADBAD D I '$G(PSJADBAD) S PSGS0Y=$P(X,"@",2) 95 ..N ADMIN,TIME,II S ADMIN=$P(X,"@",2) F II=1:1:$L(ADMIN,"-") S TIME=$P(ADMIN,"-",II) I TIME'?2N&(TIME'?4N) S PSJADBAD=1 96 .I '$G(PSGS0Y) S PSGS0Y="" 97 D FIND^DIC(51.1,,,,X,,"APPSJ",,,"LYN") 98 S ZZ=$O(LYN("DILIST",2,ZZ)) I ZZ S ZZ=+LYN("DILIST",2,ZZ) I ZZ S ZZND=$G(^PS(51.1,ZZ,0)) S PSGST=$P(ZZND,U,5),PSGS0XT=$P(ZZND,U,3) I $G(PSJPWD) D 99 . N ZZNDW S ZZNDW=$G(^PS(51.1,ZZ,1,PSJPWD,0)) I $P(ZZNDW,"^",2)]"" S PSGS0Y=$P(ZZNDW,"^",2),$P(ZZND,"^",2)=PSGS0Y 100 S ZZ=0 F S ZZ=$O(LYN("DILIST",1,ZZ)) Q:'ZZ I $G(LYN("DILIST",1,ZZ))'=X K LYN("DILIST",1,ZZ),LYN("DILIST",2,ZZ),LYN("DILIST","ID",ZZ,1) 101 I $D(PSJPWD) S ZZ=0 F S ZZ=$O(LYN("DILIST",2,ZZ)) Q:'ZZ I $P($G(^PS(51.1,+LYN("DILIST",2,ZZ),1,+PSJPWD,0)),U,2)]"" S PSGS0Y=$P($G(^(0)),U,2) 102 Q:PSGS0Y]"" S ZZ=0 F S ZZ=$O(LYN("DILIST",2,ZZ)) Q:'ZZ Q:PSGS0Y]"" I $G(LYN("DILIST","ID",ZZ,1))]"" S PSGS0Y=$G(LYN("DILIST","ID",ZZ,1)) 103 Q 104 ; 105 ONE(SCH) ; 106 ; SCH=Admin Schedule 107 ; Returns 0 = (zero) Not a one time schedule. 108 ; 1 = One time schedule. 109 Q:$G(SCH)="" 0 110 N X,SCHLST 111 S SCHLST=",TODAY,ONCE,NOW,ONE TIME,ONETIME,ONE-TIME,1TIME,1 TIME,1-TIME,STAT," 112 I SCHLST[(","_SCH_",") Q 1 113 I $D(^PS(51.1,"AC","PSJ",SCH)) S X=$O(^(SCH,"")) S X=$P(^PS(51.1,X,0),"^",5) Q $S(X="O":1,1:0) 114 Q 0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJORRE.m
r613 r623 1 PSJORRE ;BIR/MV-RETURN INPATIENT ACTIVE MEDS (CONDENSED) ;28 Jan 99 / 12:56 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**22,51,50,58,81,110,111,112,134**;16 DEC 97;Build 124 3 ; 4 ;Reference to ^PS(52.6 is supported by DBIA 1231. 5 ;Reference to ^PS(52.7 is supported by DBIA 2173. 6 ;Reference to ^PS(55 is supported by DBIA 2191. 7 ;Reference to ^TMP("PS" is documented in DBIA #2383. 8 ; 9 OCL(DFN,BDT,EDT,TFN,MVIEW) ; return condensed list of inpat meds 10 ; MVIEW=0 - This returns the 'unsorted' list as it was returned prior to GUI 27 11 ; MVIEW=1 - This returns the old sort view of the list, pre-sorted for GUI 27 12 ; MVIEW=2 - This returns new sort view #1 of the order profile for GUI 27 13 ; MVIEW=3 - This returns new sort view #2 of the order profile for GUI 27 14 D @$S($G(MVIEW)=3:"OCL^PSJORRN1(DFN,BDT,EDT,.TFN)",$G(MVIEW)=2:"OCL^PSJORRN(DFN,BDT,EDT,.TFN)",$G(MVIEW)=1:"OCL^PSJORRO(DFN,BDT,EDT,.TFN)",1:"OCL1(DFN,BDT,EDT,TFN)") 15 Q 16 OCL1(DFN,BDT,EDT,TFN,MVIEW) ; Execute this section if MVIEW=0 17 N ADM,CNT,DN,DO,F,FON,INFUS,INST,MR,ND,ND0,ND2,ND6,ON,PON,PST,SCH,SIO,STAT,TYPE,UNITS,WBDT,X,Y,PSJCLIN,A 18 ; PON=placer order number (oerr), FON=filler order number 19 S:BDT="" BDT=DT S WBDT=BDT_".000001" 20 S:EDT="" EDT=9999999 21 S:EDT'["." EDT=EDT_".999999" 22 S F="^PS(55,DFN,5," F S WBDT=$O(^PS(55,DFN,5,"AUS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,5,"AUS",WBDT,ON)) Q:'ON D UDTMP 23 S F="^PS(53.1," F PST="P","N" F ON=0:0 S ON=$O(^PS(53.1,"AS",PST,DFN,ON)) Q:'ON S X=$P($G(^PS(53.1,+ON,0)),U,4) D @$S(X="U":"UDTMP",1:"IVTMP") 24 S F="^PS(55,"_DFN_",""IV"",",WBDT=BDT F S WBDT=$O(^PS(55,DFN,"IV","AIS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,"IV","AIS",WBDT,ON)) Q:'ON D IVTMP 25 Q 26 ; 27 UDTMP ;*** Set ^TMP for Unit dose orders. 28 N PROVIDER,RNWDT,EDTCMPLX,NDP2 S (MR,SCH,INST,PON)="",FON=+ON_$S(F["53.1":"P",1:"U") 29 D TYPE 30 S RNWDT=$$LASTREN^PSJLMPRI(DFN,FON) I RNWDT S RNWDT=+RNWDT 31 S NDP2=$G(@(F_ON_",.2)")) S EDTCMPLX=$P(NDP2,"^",8) 32 S ND2=$G(@(F_ON_",2)")) I 'EDTCMPLX I F'["53.1",($P(ND2,U,2)>EDT) Q 33 S ND0=$G(@(F_ON_",0)")) I 'EDTCMPLX I F["53.1",($P(ND0,U,16)>EDT) Q 34 S STAT=$$CODES^PSIVUTL($P(ND0,U,9),$S(FON["P":53.1,1:55.06),28) 35 S ND6=$P($G(@(F_ON_",6)")),"^"),INST=$G(@(F_+ON_",.3)")) 36 S FON=+ON_$S(F["53.1":"P",1:"U"),DO=$P($G(@(F_ON_",.2)")),"^",2) 37 D DRGDISP^PSJLMUT1(DFN,FON,40,0,.DN,1) 38 S UNITS="" I '$O(@(F_+ON_",1,1)")) S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2) S:(FON["U")&(UNITS="") UNITS=1 39 S:+$P(ND0,U,3) MR=$$MR^PSJORRE1(+$P(ND0,U,3)) 40 N NOTGIVEN S NOTGIVEN=$S(FON["U":$P($G(^PS(55,DFN,5,+ON,0)),"^",22),1:"") 41 S TFN=TFN+1 42 S ^TMP("PS",$J,TFN,0)=FON_";I"_U_DN(1)_"^^"_$P(ND2,U,4)_"^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_STAT_U_U_U_U_NOTGIVEN_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_$P(ND2,U,2)_U_$G(RNWDT) 43 K ^TMP("PS",$J,TFN,"CLINIC",0) I PSJCLIN]"" S ^TMP("PS",$J,TFN,"CLINIC",0)=PSJCLIN 44 S PROVIDER=$P($G(@(F_+ON_",0)")),"^",2) 45 I PROVIDER S ^TMP("PS",$J,TFN,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^") 46 S ^TMP("PS",$J,TFN,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,TFN,"MDR",1,0)=MR 47 S ^TMP("PS",$J,TFN,"SCH",0)=$P(ND2,U)]"" S:$P(ND2,U)]"" ^TMP("PS",$J,TFN,"SCH",1,0)=$P(ND2,U) 48 S ^TMP("PS",$J,TFN,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,TFN,"SIG",1,0)=INST 49 S ^TMP("PS",$J,TFN,"ADM",0)=$P(ND2,U,5)]"" S:$P(ND2,U,5)]"" ^TMP("PS",$J,TFN,"ADM",1,0)=$P(ND2,U,5) 50 S ^TMP("PS",$J,TFN,"SIO",0)=ND6]"" S:ND6]"" ^TMP("PS",$J,TFN,"SIO",1,0)=ND6 51 Q 52 ; 53 IVTMP ;*** Set ^TMP for IV orders. 54 N PROVIDER,START,STOP,EDTCMPLX,NDP2,IVLIM 55 S NDP2=$G(@(F_ON_",.2)")) S EDTCMPLX=$P(NDP2,"^",8) 56 S ND0=$G(@(F_ON_",0)")) I 'EDTCMPLX I F'["53.1",($P(ND0,U,2)>EDT) Q 57 D TYPE 58 S FON=+ON_$S(F["53.1":"P",1:"V"),TFN=TFN+1,CNT=0 59 S RNWDT=$$LASTREN^PSJLMPRI(DFN,FON) I RNWDT S RNWDT=+RNWDT 60 F X=0:0 S X=$O(@(F_ON_",""AD"","_X_")")) Q:'X S ND=$G(@(F_ON_",""AD"","_X_",0)")),DN=$P($G(^PS(52.6,+ND,0)),U),Y=DN_U_$P(ND,U,2) S:$P(ND,U,3) Y=Y_U_$P(ND,U,3) S CNT=CNT+1,^TMP("PS",$J,TFN,"A",CNT,0)=Y 61 S ^TMP("PS",$J,TFN,"A",0)=CNT,CNT=0 62 F X=0:0 S X=$O(@(F_ON_",""SOL"","_X_")")) Q:'X S ND=$G(@(F_ON_",""SOL"","_X_",0)")),DN=$G(^PS(52.7,+ND,0)),CNT=CNT+1,^TMP("PS",$J,TFN,"B",CNT,0)=$P(DN,U)_U_$P(ND,U,2)_U_$P(DN,U,4) 63 S ^TMP("PS",$J,TFN,"B",0)=CNT 64 S TYPE=$P(ND0,U,4),(MR,SCH,INST,INFUS)="" 65 I FON["P" S ND2=$G(^PS(53.1,+ON,2)),SCH=$P(ND2,U),START=$P(ND2,U,2),STOP=$P(ND2,U,4),MR=$P(ND0,U,3),INFUS=$P($G(^PS(53.1,+ON,8)),U,5),STAT=$$CODES^PSIVUTL($P(ND0,U,9),53.1,28),ADM=$P(ND2,U,5),SIO=$P($G(@(F_+ON_",6)")),"^") 66 I FON'["P" S START=$P(ND0,U,2),STOP=$P(ND0,U,3),SCH=$P(ND0,U,9),INFUS=$P(ND0,U,8),MR=$P($G(^PS(55,DFN,"IV",+ON,.2)),U,3),STAT=$$CODES^PSIVUTL($P(ND0,U,17),55.01,100),ADM=$P(ND0,U,11),SIO=$P($G(@(F_+ON_",3)")),"^") 67 S DN=$G(@(F_+ON_",.2)")),DO=$P(DN,U,2) 68 S DN=$S(+$P(DN,U):$$OIDF^PSJLMUT1($P(DN,U)),1:"") 69 S:MR MR=$$MR^PSJORRE1(+MR),INST=$G(@(F_+ON_",.3)")) 70 S ^TMP("PS",$J,TFN,0)=FON_";I"_U_DN_U_INFUS_U_STOP_"^^"_DO_"^^"_$P(ND0,"^",21)_U_STAT_U_U_U_U_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_START_U_$G(RNWDT) 71 K ^TMP("PS",$J,TFN,"CLINIC",0) I PSJCLIN]"" S ^TMP("PS",$J,TFN,"CLINIC",0)=PSJCLIN 72 S PROVIDER=$P($G(@(F_+ON_",0)")),"^",6) 73 I PROVIDER S ^TMP("PS",$J,TFN,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^") 74 S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) I $E(IVLIM)="a" S IVLIM="doses"_$P(IVLIM,"a",2) 75 I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM="" 76 S ^TMP("PS",$J,TFN,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,TFN,"MDR",1,0)=MR 77 S ^TMP("PS",$J,TFN,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,TFN,"SIG",1,0)=INST 78 S ^TMP("PS",$J,TFN,"SCH",0)=SCH]"" S:SCH]"" ^TMP("PS",$J,TFN,"SCH",1,0)=SCH 79 S ^TMP("PS",$J,TFN,"ADM",0)=ADM]"" S:ADM]"" ^TMP("PS",$J,TFN,"ADM",1,0)=ADM 80 S ^TMP("PS",$J,TFN,"SIO",0)=SIO]"" S:SIO]"" ^TMP("PS",$J,TFN,"SIO",1,0)=SIO 81 I $G(IVLIM)]"" S ^TMP("PS",$J,TFN,"IVLIM",0)=IVLIM 82 Q 83 STAT(Y,X) ;* Return the full status instead of just the code for U/D. 84 S X=$P($P(";"_$P(Y,U,3),";"_X_":",2),";") 85 Q X 86 TYPE ;determine if this is an IMO order or not 87 S (A,PSJCLIN)="" I F["PS(53.1" S A=$G(^PS(53.1,ON,"DSS")) 88 I F["PS(55" S A=$S(F["IV":$G(^PS(55,DFN,"IV",ON,"DSS")),1:$G(^PS(55,DFN,5,ON,8))) 89 I $P(A,"^",2)'="" S PSJCLIN=+A 90 Q 1 PSJORRE ;BIR/MV-RETURN INPATIENT ACTIVE MEDS (CONDENSED) ;28 Jan 99 / 12:56 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**22,51,50,58,81,110,111,112**;16 DEC 97 3 ; 4 ;Reference to ^PS(52.6 is supported by DBIA 1231. 5 ;Reference to ^PS(52.7 is supported by DBIA 2173. 6 ;Reference to ^PS(55 is supported by DBIA 2191. 7 ;Reference to OTF^OR3CONV is supported by DBIA 2412. 8 ;Reference to ^TMP("PS" is documented in DBIA #2383. 9 ; 10 OCL(DFN,BDT,EDT,TFN) ; return condensed list of inpat meds 11 N ADM,CNT,DN,DO,F,FON,INFUS,INST,MR,ND,ND0,ND2,ND6,ON,PON,PST,SCH,SIO,STAT,TYPE,UNITS,WBDT,X,Y,PSJCLIN,A 12 ;Check if 5.0 order conversion should be run for the selected patient. 13 F S X=$$OTF^OR3CONV(DFN,$S($E($G(IOST),1)="C":0,1:1)) Q:+X'<0 D 14 .I +X=-1 H 3 15 ; PON=placer order number (oerr), FON=filler order number 16 S:BDT="" BDT=DT S WBDT=BDT_".000001" 17 S:EDT="" EDT=9999999 18 S:EDT'["." EDT=EDT_".999999" 19 S F="^PS(55,DFN,5," F S WBDT=$O(^PS(55,DFN,5,"AUS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,5,"AUS",WBDT,ON)) Q:'ON D UDTMP 20 S F="^PS(53.1," F PST="P","N" F ON=0:0 S ON=$O(^PS(53.1,"AS",PST,DFN,ON)) Q:'ON S X=$P($G(^PS(53.1,+ON,0)),U,4) D @$S(X="U":"UDTMP",1:"IVTMP") 21 S F="^PS(55,"_DFN_",""IV"",",WBDT=BDT-1 F S WBDT=$O(^PS(55,DFN,"IV","AIS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,"IV","AIS",WBDT,ON)) Q:'ON D IVTMP 22 Q 23 ; 24 UDTMP ;*** Set ^TMP for Unit dose orders. 25 N PROVIDER,RNWDT,EDTCMPLX,NDP2 S (MR,SCH,INST,PON)="",FON=+ON_$S(F["53.1":"P",1:"U") 26 D TYPE 27 S RNWDT=$$LASTREN^PSJLMPRI(DFN,FON) I RNWDT S RNWDT=+RNWDT 28 S NDP2=$G(@(F_ON_",.2)")) S EDTCMPLX=$P(NDP2,"^",8) 29 S ND2=$G(@(F_ON_",2)")) I 'EDTCMPLX I F'["53.1",($P(ND2,U,2)>EDT) Q 30 S ND0=$G(@(F_ON_",0)")) I 'EDTCMPLX I F["53.1",($P(ND0,U,16)>EDT) Q 31 S STAT=$$CODES^PSIVUTL($P(ND0,U,9),$S(FON["P":53.1,1:55.06),28) 32 S ND6=$P($G(@(F_ON_",6)")),"^"),INST=$G(@(F_+ON_",.3)")) 33 S FON=+ON_$S(F["53.1":"P",1:"U"),DO=$P($G(@(F_ON_",.2)")),"^",2) 34 D DRGDISP^PSJLMUT1(DFN,FON,40,0,.DN,1) 35 ;S UNITS="" I '$O(@(F_+ON_",1,1)")),DO="" S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2) 36 S UNITS="" I '$O(@(F_+ON_",1,1)")) S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2) S:(FON["U")&(UNITS="") UNITS=1 37 S:+$P(ND0,U,3) MR=$$MR^PSJORRE1(+$P(ND0,U,3)) 38 N NOTGIVEN S NOTGIVEN=$S(FON["U":$P($G(^PS(55,DFN,5,+ON,0)),"^",22),1:"") 39 S TFN=TFN+1 40 S ^TMP("PS",$J,TFN,0)=FON_";I"_U_DN(1)_"^^"_$P(ND2,U,4)_"^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_STAT_U_U_U_U_NOTGIVEN_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_$P(ND2,U,2)_U_$G(RNWDT) 41 K ^TMP("PS",$J,TFN,"CLINIC",0) I PSJCLIN]"" S ^TMP("PS",$J,TFN,"CLINIC",0)=PSJCLIN 42 ;*S ^TMP("PS",$J,TFN,0)=FON_";I"_U_DN(1)_"^^"_$P(ND2,U,4)_"^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_STAT_U_U_U_U_$P($G(^PS(55,DFN,5,+ON,0)),"^",22)_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R")) 43 S PROVIDER=$P($G(@(F_+ON_",0)")),"^",2) 44 I PROVIDER S ^TMP("PS",$J,TFN,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^") 45 S ^TMP("PS",$J,TFN,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,TFN,"MDR",1,0)=MR 46 S ^TMP("PS",$J,TFN,"SCH",0)=$P(ND2,U)]"" S:$P(ND2,U)]"" ^TMP("PS",$J,TFN,"SCH",1,0)=$P(ND2,U) 47 ;S:$P(ND0,U,7)]"" ^TMP("PS",$J,TFN,"SCH",0)=1,$P(^TMP("PS",$J,TFN,"SCH",1,0),U,2)=$P(ND0,U,7) 48 S ^TMP("PS",$J,TFN,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,TFN,"SIG",1,0)=INST 49 S ^TMP("PS",$J,TFN,"ADM",0)=$P(ND2,U,5)]"" S:$P(ND2,U,5)]"" ^TMP("PS",$J,TFN,"ADM",1,0)=$P(ND2,U,5) 50 S ^TMP("PS",$J,TFN,"SIO",0)=ND6]"" S:ND6]"" ^TMP("PS",$J,TFN,"SIO",1,0)=ND6 51 Q 52 ; 53 IVTMP ;*** Set ^TMP for IV orders. 54 N PROVIDER,START,STOP,EDTCMPLX,NDP2,IVLIM 55 S NDP2=$G(@(F_ON_",.2)")) S EDTCMPLX=$P(NDP2,"^",8) 56 S ND0=$G(@(F_ON_",0)")) I 'EDTCMPLX I F'["53.1",($P(ND0,U,2)>EDT) Q 57 D TYPE 58 S FON=+ON_$S(F["53.1":"P",1:"V"),TFN=TFN+1,CNT=0 59 S RNWDT=$$LASTREN^PSJLMPRI(DFN,FON) I RNWDT S RNWDT=+RNWDT 60 F X=0:0 S X=$O(@(F_ON_",""AD"","_X_")")) Q:'X S ND=$G(@(F_ON_",""AD"","_X_",0)")),DN=$P($G(^PS(52.6,+ND,0)),U),Y=DN_U_$P(ND,U,2) S:$P(ND,U,3) Y=Y_U_$P(ND,U,3) S CNT=CNT+1,^TMP("PS",$J,TFN,"A",CNT,0)=Y 61 S ^TMP("PS",$J,TFN,"A",0)=CNT,CNT=0 62 F X=0:0 S X=$O(@(F_ON_",""SOL"","_X_")")) Q:'X S ND=$G(@(F_ON_",""SOL"","_X_",0)")),DN=$G(^PS(52.7,+ND,0)),CNT=CNT+1,^TMP("PS",$J,TFN,"B",CNT,0)=$P(DN,U)_U_$P(ND,U,2)_U_$P(DN,U,4) 63 S ^TMP("PS",$J,TFN,"B",0)=CNT 64 S TYPE=$P(ND0,U,4),(MR,SCH,INST,INFUS)="" 65 I FON["P" S ND2=$G(^PS(53.1,+ON,2)),SCH=$P(ND2,U),START=$P(ND2,U,2),STOP=$P(ND2,U,4),MR=$P(ND0,U,3),INFUS=$P($G(^PS(53.1,+ON,8)),U,5),STAT=$$CODES^PSIVUTL($P(ND0,U,9),53.1,28),ADM=$P(ND2,U,5),SIO=$P($G(@(F_+ON_",6)")),"^") 66 I FON'["P" S START=$P(ND0,U,2),STOP=$P(ND0,U,3),SCH=$P(ND0,U,9),INFUS=$P(ND0,U,8),MR=$P($G(^PS(55,DFN,"IV",+ON,.2)),U,3),STAT=$$CODES^PSIVUTL($P(ND0,U,17),55.01,100),ADM=$P(ND0,U,11),SIO=$P($G(@(F_+ON_",3)")),"^") 67 S DN=$G(@(F_+ON_",.2)")),DO=$P(DN,U,2) 68 S DN=$S(+$P(DN,U):$$OIDF^PSJLMUT1($P(DN,U)),1:"") 69 S:MR MR=$$MR^PSJORRE1(+MR),INST=$G(@(F_+ON_",.3)")) 70 ;S ^TMP("PS",$J,TFN,0)=FON_";I"_U_DN_U_INFUS_U_$P(ND0,U,3)_"^^"_DO_"^^"_$P(ND0,"^",21)_U_STAT 71 S ^TMP("PS",$J,TFN,0)=FON_";I"_U_DN_U_INFUS_U_STOP_"^^"_DO_"^^"_$P(ND0,"^",21)_U_STAT_U_U_U_U_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_START_U_$G(RNWDT) 72 K ^TMP("PS",$J,TFN,"CLINIC",0) I PSJCLIN]"" S ^TMP("PS",$J,TFN,"CLINIC",0)=PSJCLIN 73 S PROVIDER=$P($G(@(F_+ON_",0)")),"^",6) 74 I PROVIDER S ^TMP("PS",$J,TFN,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^") 75 S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) 76 I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM="" 77 S ^TMP("PS",$J,TFN,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,TFN,"MDR",1,0)=MR 78 S ^TMP("PS",$J,TFN,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,TFN,"SIG",1,0)=INST 79 S ^TMP("PS",$J,TFN,"SCH",0)=SCH]"" S:SCH]"" ^TMP("PS",$J,TFN,"SCH",1,0)=SCH 80 ;I FON["P" S:$P(ND0,U,7)]"" ^TMP("PS",$J,TFN,"SCH",0)=1,$P(^TMP("PS",$J,TFN,"SCH",1,0),U,2)=$P(ND0,U,7) 81 S ^TMP("PS",$J,TFN,"ADM",0)=ADM]"" S:ADM]"" ^TMP("PS",$J,TFN,"ADM",1,0)=ADM 82 S ^TMP("PS",$J,TFN,"SIO",0)=SIO]"" S:SIO]"" ^TMP("PS",$J,TFN,"SIO",1,0)=SIO 83 I $G(IVLIM)]"" S ^TMP("PS",$J,TFN,"IVLIM",0)=IVLIM 84 Q 85 STAT(Y,X) ;* Return the full status instead of just the code for U/D. 86 S X=$P($P(";"_$P(Y,U,3),";"_X_":",2),";") 87 Q X 88 TYPE ;determine if this is an IMO order or not 89 S (A,PSJCLIN)="" I F["PS(53.1" S A=$G(^PS(53.1,ON,"DSS")) 90 I F["PS(55" S A=$S(F["IV":$G(^PS(55,DFN,"IV",ON,"DSS")),1:$G(^PS(55,DFN,5,ON,8))) 91 I $P(A,"^",2)'="" S PSJCLIN=+A 92 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJORRE1.m
r613 r623 1 PSJORRE1 ;BIR/MV-RETURN INPATIENT ACTIVE MEDS (EXPANDED) ;29 Jan 99 / 8:49 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**22,51,50,58,81,91,110,111,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(51.2 is supported by DBIA 2178. 5 ; Reference to ^PS(52.6 is supported by DBIA 1231. 6 ; Reference to ^PS(52.7 is supported by DBIA 2173. 7 ; Reference to ^PS(55 is supported by DBIA 2191. 8 ; Reference to ^PSDRUG is supported by DBIA 2192. 9 ; Reference to ^TMP("PS" is documented in DBIA #2384. 10 ; 11 OEL(DFN,ON) ; return list of expanded inpat meds 12 K ^TMP("PS",$J) 13 N ADM,CNT,DN,DO,F,INFUS,INST,MR,ND,ND0,ND2,ND2P5,ND6,NDOI,SCH,SIO,START,STAT,STOP,TYP,UNITS,X,Y 14 S F=$S(ON["P":"^PS(53.1,",ON["U":"^PS(55,DFN,5,",1:"^PS(55,"_DFN_",""IV"",") 15 I ON'["P",'$D(@(F_+ON_")")) Q 16 I ON["P" S X=$G(^PS(53.1,+ON,0)) Q:$P(X,U,15)'=DFN S TYP=$P(X,U,4) D @$S(TYP="U":"UDTMP",1:"IVTMP") 17 D:ON'["P" @$S(ON["U":"UDTMP",1:"IVTMP") 18 S Y=$S(ON["V":5,1:12),CNT=0 19 I $O(@(F_+ON_","_Y_",0)")) D 20 . F X=0:0 S X=$O(@(F_+ON_","_Y_","_X_")")) Q:'X D 21 ..S CNT=CNT+1,ND=$G(@(F_+ON_","_Y_","_X_",0)")),^TMP("PS",$J,"PC",CNT,0)=ND 22 S ^TMP("PS",$J,"PC",0)=CNT 23 Q 24 ; 25 UDTMP ;*** Set ^TMP for Unit dose orders. 26 N DO,DN,INST,X,Y,PROVIDER,NOTGIVEN,RNWDT 27 S (MR,SCH,INST)="" 28 S ND2=$G(@(F_+ON_",2)")),ND0=$G(@(F_+ON_",0)")) 29 S ND6=$P($G(@(F_+ON_",6)")),"^") 30 S RNWDT=$$LASTREN^PSJLMPRI(DFN,ON) I RNWDT S RNWDT=+RNWDT 31 S STAT=$$CODES^PSIVUTL($P(ND0,U,9),$S(ON["P":53.1,1:55.06),28) 32 S NDOI=$G(@(F_+ON_",.2)")),DO=$P(NDOI,U,2) 33 S DN(1)=$$OIDF^PSJLMUT1(NDOI) I DN(1)="" K DN D DRGDISP^PSJLMUT1(DFN,ON,40,0,.DN,1) 34 S UNITS="" I '$O(@(F_+ON_",1,1)")) S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2) S:(ON["U")&(UNITS="") UNITS=1 35 S MR=$$MR(+$P(ND0,U,3)),INST=$G(@(F_+ON_",.3)")) 36 S NOTGIVEN=$S(ON["U":$P($G(^PS(55,DFN,5,+ON,0)),"^",22),1:"") 37 S ^TMP("PS",$J,0)=DN(1)_"^^"_$P(ND2,U,4)_"^^"_$P(ND2,U,2)_U_STAT_"^^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_U_NOTGIVEN_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_U_$G(RNWDT) 38 S PROVIDER=$P($G(@(F_+ON_",0)")),"^",2) 39 I PROVIDER S ^TMP("PS",$J,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^") 40 S ^TMP("PS",$J,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,"MDR",1,0)=MR 41 S ^TMP("PS",$J,"SCH",0)=$P(ND2,U)]"" S:$P(ND2,U)]"" ^TMP("PS",$J,"SCH",1,0)=$P(ND2,U) 42 S:$P(ND0,U,7)]"" ^TMP("PS",$J,"SCH",0)=1,$P(^TMP("PS",$J,"SCH",1,0),U,2)=$$GTSCHT($P(ND0,U,7))_"^"_$P(ND0,U,7) 43 S ^TMP("PS",$J,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,"SIG",1,0)=INST 44 S ^TMP("PS",$J,"ADM",0)=$P(ND2,U,5)]"" S:$P(ND2,U,5)]"" ^TMP("PS",$J,"ADM",1,0)=$P(ND2,U,5) 45 S ^TMP("PS",$J,"SIO",0)=ND6]"" S:ND6]"" ^TMP("PS",$J,"SIO",1,0)=ND6 46 NEW VERPHARM S:ON["U" VERPHARM=$P($G(@(F_+ON_",4)")),U,3) 47 S:+$G(VERPHARM) $P(^TMP("PS",$J,"RXN",0),U,5)=VERPHARM 48 NEW PSJDD,INACTDT,NDDD,OUTOI,PSJOUT S CNT=0 49 F PSJDD=0:0 S PSJDD=$O(@(F_+ON_",1,PSJDD)")) Q:'PSJDD D 50 . S NDDD=@(F_+ON_",1,PSJDD,0)") 51 . I $P(NDDD,U,3)]"",($P(NDDD,U,3)'>DT) Q 52 . S PSJOUT=$P($G(^PSDRUG(+NDDD,8)),U,5) 53 . I +PSJOUT D 54 .. S INACTDT=$G(^PSDRUG(+PSJOUT,"I")),OUTOI=+$G(^PSDRUG(+PSJOUT,2)) 55 .. I INACTDT]"",(INACTDT'>DT) S (PSJOUT,OUTOI)="" 56 . I '+PSJOUT,($P($G(^PSDRUG(+NDDD,2)),U,3)["O") D 57 .. S PSJOUT=+NDDD,OUTOI=+NDOI 58 .. S INACTDT=$G(^PSDRUG(+NDDD,"I")) 59 .. I INACTDT]"",(INACTDT'>DT) S (PSJOUT,OUTOI)="" 60 . S UNITS=$P(NDDD,U,2) S:(ON["U")&(UNITS="") UNITS=1 61 . S CNT=CNT+1,^TMP("PS",$J,"DD",CNT,0)=+NDDD_U_UNITS_U_PSJOUT_U_$G(OUTOI) 62 S ^TMP("PS",$J,"DD",0)=CNT 63 Q 64 ; 65 IVTMP ;*** Set ^TMP for IV orders. 66 N PROVIDER,RNWDT,IVLIM S ND0=$G(@(F_+ON_",0)")),CNT=0 67 F X=0:0 S X=$O(@(F_+ON_",""AD"","_X_")")) Q:'X S ND=$G(@(F_+ON_",""AD"","_X_",0)")),DN=$P($G(^PS(52.6,+ND,0)),U),Y=DN_U_$P(ND,U,2) S:$P(ND,U,3) Y=Y_U_$P(ND,U,3) S CNT=CNT+1,^TMP("PS",$J,"A",CNT,0)=Y 68 S RNWDT=$$LASTREN^PSJLMPRI(DFN,ON) I RNWDT S RNWDT=+RNWDT 69 S ^TMP("PS",$J,"A",0)=CNT,CNT=0 70 F X=0:0 S X=$O(@(F_+ON_",""SOL"","_X_")")) Q:'X S ND=$G(@(F_+ON_",""SOL"","_X_",0)")),DN=$G(^PS(52.7,+ND,0)),CNT=CNT+1,^TMP("PS",$J,"B",CNT,0)=$P(DN,U)_U_$P(ND,U,2)_U_$P(DN,U,4) 71 S ^TMP("PS",$J,"B",0)=CNT 72 S INST=$G(@(F_+ON_",.3)")) 73 I ON["P" D 74 . S SCH=$P($G(^PS(53.1,+ON,2)),U) 75 . S PROVIDER=$P(ND0,U,2) 76 . S MR=$$MR(+$P(ND0,U,3)),STAT=$$CODES^PSIVUTL($P(ND0,U,9),53.1,28) 77 . S INFUS=$P($G(^PS(53.1,+ON,8)),U,5) 78 . S ND2=$G(@(F_+ON_",2)")),START=$P(ND2,U,2),STOP=$P(ND2,U,4) 79 . S ADM=$P(ND2,U,5),SIO=$P($G(@(F_+ON_",6)")),"^") 80 . S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) I $E(IVLIM)="a" S IVLIM="doses"_$P(IVLIM,"a",2) 81 . I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM="" 82 I ON'["P" D 83 . S PROVIDER=$P(ND0,U,6) 84 . S SCH=$P(ND0,U,9),INFUS=$P(ND0,U,8),STAT=$$CODES^PSIVUTL($P(ND0,U,17),55.01,100) 85 . S MR=$$MR(+$P($G(^PS(55,DFN,"IV",+ON,.2)),U,3)) 86 . S START=$P(ND0,U,2),STOP=$P(ND0,U,3) 87 . S ADM=$P(ND0,U,11),SIO=$P($G(@(F_+ON_",3)")),"^") 88 . NEW VERPHARM S VERPHARM=$P($G(^PS(55,DFN,"IV",+ON,4)),U,4) 89 . S:+VERPHARM $P(^TMP("PS",$J,"RXN",0),U,5)=VERPHARM 90 . S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM="" 91 S DN=$G(@(F_+ON_",.2)")),DO=$P(DN,U,2) 92 S DN=$S(+$P(DN,U):$$OIDF^PSJLMUT1($P(DN,U)),1:"") 93 S ^TMP("PS",$J,0)=DN_U_INFUS_U_STOP_"^^"_START_U_STAT_"^^^"_DO_"^^"_$P(ND0,U,21)_U_U_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_U_$G(RNWDT) 94 I PROVIDER S ^TMP("PS",$J,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^") 95 S ^TMP("PS",$J,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,"MDR",1,0)=MR 96 S ^TMP("PS",$J,"SCH",0)=SCH]"" S:SCH]"" ^TMP("PS",$J,"SCH",1,0)=SCH 97 I ON["P" S:$P(ND0,U,7)]"" ^TMP("PS",$J,"SCH",0)=1,$P(^TMP("PS",$J,"SCH",1,0),U,2)=$$GTSCHT($P(ND0,U,7))_"^"_$P(ND0,U,7) 98 S ^TMP("PS",$J,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,"SIG",1,0)=INST 99 S ^TMP("PS",$J,"ADM",0)=ADM]"" S:ADM]"" ^TMP("PS",$J,"ADM",1,0)=ADM 100 S ^TMP("PS",$J,"SIO",0)=SIO]"" S:SIO]"" ^TMP("PS",$J,"SIO",1,0)=SIO 101 I $G(IVLIM)]"" S ^TMP("PS",$J,"IVLIM",0)=$G(IVLIM) 102 Q 103 ; 104 MR(X) ;RETURN MED ROUTE ABBR. IF THE ABBR="" RETURN MED ROUTE'S NAME. 105 S X=$G(^PS(51.2,X,0)) 106 Q $S($P(X,U,3)]"":$P(X,U,3),1:$P(X,U)) 107 ; 108 GTSTAT(X) ; 109 Q $S(X="A":"ACTIVE",X="D":"DISCONTINUED",X="I":"INCOMPLETE",X="N":"NON-VERFIED",X="U":"UNRELEASED",X="P":"PENDING",X="DE":"DISCONTINUED (EDIT)",X="O":"ON CALL",1:"NOT FOUND") 110 ; 111 VA200(X) ;Return the IEN for the user. 112 ; X = User name 113 NEW DIC,Y S DIC="^VA(200,",DIC(0)="NZ" D ^DIC 114 I +Y=-1 Q "" 115 Q $P(Y,U) 116 GTSCHT(X) ; 117 Q $S(X="C":"CONTINUOUS",X="O":"ONE TIME",X="P":"PRN",X="R":"FILL ON REQUEST",X="OC":"ON CALL",1:"NOT FOUND") 1 PSJORRE1 ;BIR/MV-RETURN INPATIENT ACTIVE MEDS (EXPANDED) ;29 Jan 99 / 8:49 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**22,51,50,58,81,91,110,111**;16 DEC 97 3 ; 4 ; Reference to ^PS(51.2 is supported by DBIA 2178. 5 ; Reference to ^PS(52.6 is supported by DBIA 1231. 6 ; Reference to ^PS(52.7 is supported by DBIA 2173. 7 ; Reference to ^PS(55 is supported by DBIA 2191. 8 ; Reference to ^PSDRUG is supported by DBIA 2192. 9 ; Reference to OTF^OR3CONV is supported by DBIA 2412. 10 ; Reference to ^TMP("PS" is documented in DBIA #2384. 11 ; 12 OEL(DFN,ON) ; return list of expanded inpat meds 13 K ^TMP("PS",$J) 14 N ADM,CNT,DN,DO,F,INFUS,INST,MR,ND,ND0,ND2,ND2P5,ND6,NDOI,SCH,SIO,START,STAT,STOP,TYP,UNITS,X,Y 15 ;Check if 5.0 order conversion should be run for the selected patient. 16 ;I '$P($G(^PS(55,DFN,5.1)),U,11) D CONVERT^PSJUTL1(DFN,0) 17 F S X=$$OTF^OR3CONV(DFN,$S($E(IOST,1)="C":0,1:1)) Q:+X'<0 D 18 .I +X=-1 H 3 19 S F=$S(ON["P":"^PS(53.1,",ON["U":"^PS(55,DFN,5,",1:"^PS(55,"_DFN_",""IV"",") 20 I ON'["P",'$D(@(F_+ON_")")) Q 21 I ON["P" S X=$G(^PS(53.1,+ON,0)) Q:$P(X,U,15)'=DFN S TYP=$P(X,U,4) D @$S(TYP="U":"UDTMP",1:"IVTMP") 22 D:ON'["P" @$S(ON["U":"UDTMP",1:"IVTMP") 23 S Y=$S(ON["V":5,1:12),CNT=0 24 I $O(@(F_+ON_","_Y_",0)")) D 25 . F X=0:0 S X=$O(@(F_+ON_","_Y_","_X_")")) Q:'X D 26 ..S CNT=CNT+1,ND=$G(@(F_+ON_","_Y_","_X_",0)")),^TMP("PS",$J,"PC",CNT,0)=ND 27 S ^TMP("PS",$J,"PC",0)=CNT 28 Q 29 ; 30 UDTMP ;*** Set ^TMP for Unit dose orders. 31 N DO,DN,INST,X,Y,PROVIDER,NOTGIVEN,RNWDT 32 S (MR,SCH,INST)="" 33 S ND2=$G(@(F_+ON_",2)")),ND0=$G(@(F_+ON_",0)")) 34 S ND6=$P($G(@(F_+ON_",6)")),"^") 35 S RNWDT=$$LASTREN^PSJLMPRI(DFN,ON) I RNWDT S RNWDT=+RNWDT 36 S STAT=$$CODES^PSIVUTL($P(ND0,U,9),$S(ON["P":53.1,1:55.06),28) 37 D DRGDISP^PSJLMUT1(DFN,ON,40,0,.DN,1) 38 S NDOI=$G(@(F_+ON_",.2)")),DO=$P(NDOI,U,2) 39 ;S UNITS="" I '$O(@(F_+ON_",1,1)")),DO="" S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2) 40 S UNITS="" I '$O(@(F_+ON_",1,1)")) S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2) S:(ON["U")&(UNITS="") UNITS=1 41 S MR=$$MR(+$P(ND0,U,3)),INST=$G(@(F_+ON_",.3)")) 42 S NOTGIVEN=$S(ON["U":$P($G(^PS(55,DFN,5,+ON,0)),"^",22),1:"") 43 S ^TMP("PS",$J,0)=DN(1)_"^^"_$P(ND2,U,4)_"^^"_$P(ND2,U,2)_U_STAT_"^^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_U_NOTGIVEN_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_U_$G(RNWDT) 44 ;S ^TMP("PS",$J,0)=DN(1)_"^^"_$P(ND2,U,4)_"^^"_$P(ND2,U,2)_U_STAT_"^^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_U_$P($G(^PS(55,DFN,5,+ON,0)),"^",22)_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R")) 45 S PROVIDER=$P($G(@(F_+ON_",0)")),"^",2) 46 I PROVIDER S ^TMP("PS",$J,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^") 47 S ^TMP("PS",$J,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,"MDR",1,0)=MR 48 S ^TMP("PS",$J,"SCH",0)=$P(ND2,U)]"" S:$P(ND2,U)]"" ^TMP("PS",$J,"SCH",1,0)=$P(ND2,U) 49 S:$P(ND0,U,7)]"" ^TMP("PS",$J,"SCH",0)=1,$P(^TMP("PS",$J,"SCH",1,0),U,2)=$$GTSCHT($P(ND0,U,7))_"^"_$P(ND0,U,7) 50 S ^TMP("PS",$J,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,"SIG",1,0)=INST 51 S ^TMP("PS",$J,"ADM",0)=$P(ND2,U,5)]"" S:$P(ND2,U,5)]"" ^TMP("PS",$J,"ADM",1,0)=$P(ND2,U,5) 52 S ^TMP("PS",$J,"SIO",0)=ND6]"" S:ND6]"" ^TMP("PS",$J,"SIO",1,0)=ND6 53 NEW VERPHARM S:ON["U" VERPHARM=$P($G(@(F_+ON_",4)")),U,3) 54 S:+$G(VERPHARM) $P(^TMP("PS",$J,"RXN",0),U,5)=VERPHARM 55 NEW PSJDD,INACTDT,NDDD,OUTOI,PSJOUT S CNT=0 56 F PSJDD=0:0 S PSJDD=$O(@(F_+ON_",1,PSJDD)")) Q:'PSJDD D 57 . S NDDD=@(F_+ON_",1,PSJDD,0)") 58 . I $P(NDDD,U,3)]"",($P(NDDD,U,3)'>DT) Q 59 . S PSJOUT=$P($G(^PSDRUG(+NDDD,8)),U,5) 60 . I +PSJOUT D 61 .. S INACTDT=$G(^PSDRUG(+PSJOUT,"I")),OUTOI=+$G(^PSDRUG(+PSJOUT,2)) 62 .. I INACTDT]"",(INACTDT'>DT) S (PSJOUT,OUTOI)="" 63 . I '+PSJOUT,($P($G(^PSDRUG(+NDDD,2)),U,3)["O") D 64 .. S PSJOUT=+NDDD,OUTOI=+NDOI 65 .. S INACTDT=$G(^PSDRUG(+NDDD,"I")) 66 .. I INACTDT]"",(INACTDT'>DT) S (PSJOUT,OUTOI)="" 67 . ;* S UNITS=$S('+$P(NDDD,U,2):1,1:$P(NDDD,U,2)) 68 . S UNITS=$P(NDDD,U,2) S:(ON["U")&(UNITS="") UNITS=1 69 . S CNT=CNT+1,^TMP("PS",$J,"DD",CNT,0)=+NDDD_U_UNITS_U_PSJOUT_U_$G(OUTOI) 70 S ^TMP("PS",$J,"DD",0)=CNT 71 Q 72 ; 73 IVTMP ;*** Set ^TMP for IV orders. 74 N PROVIDER,RNWDT,IVLIM S ND0=$G(@(F_+ON_",0)")),CNT=0 75 F X=0:0 S X=$O(@(F_+ON_",""AD"","_X_")")) Q:'X S ND=$G(@(F_+ON_",""AD"","_X_",0)")),DN=$P($G(^PS(52.6,+ND,0)),U),Y=DN_U_$P(ND,U,2) S:$P(ND,U,3) Y=Y_U_$P(ND,U,3) S CNT=CNT+1,^TMP("PS",$J,"A",CNT,0)=Y 76 S RNWDT=$$LASTREN^PSJLMPRI(DFN,ON) I RNWDT S RNWDT=+RNWDT 77 S ^TMP("PS",$J,"A",0)=CNT,CNT=0 78 F X=0:0 S X=$O(@(F_+ON_",""SOL"","_X_")")) Q:'X S ND=$G(@(F_+ON_",""SOL"","_X_",0)")),DN=$G(^PS(52.7,+ND,0)),CNT=CNT+1,^TMP("PS",$J,"B",CNT,0)=$P(DN,U)_U_$P(ND,U,2)_U_$P(DN,U,4) 79 S ^TMP("PS",$J,"B",0)=CNT 80 S INST=$G(@(F_+ON_",.3)")) 81 I ON["P" D 82 . S SCH=$P($G(^PS(53.1,+ON,2)),U) 83 . S PROVIDER=$P(ND0,U,2) 84 . S MR=$$MR(+$P(ND0,U,3)),STAT=$$CODES^PSIVUTL($P(ND0,U,9),53.1,28) 85 . S INFUS=$P($G(^PS(53.1,+ON,8)),U,5) 86 . S ND2=$G(@(F_+ON_",2)")),START=$P(ND2,U,2),STOP=$P(ND2,U,4) 87 . S ADM=$P(ND2,U,5),SIO=$P($G(@(F_+ON_",6)")),"^") 88 . S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM="" 89 I ON'["P" D 90 . S PROVIDER=$P(ND0,U,6) 91 . S SCH=$P(ND0,U,9),INFUS=$P(ND0,U,8),STAT=$$CODES^PSIVUTL($P(ND0,U,17),55.01,100) 92 . S MR=$$MR(+$P($G(^PS(55,DFN,"IV",+ON,.2)),U,3)) 93 . S START=$P(ND0,U,2),STOP=$P(ND0,U,3) 94 . S ADM=$P(ND0,U,11),SIO=$P($G(@(F_+ON_",3)")),"^") 95 . NEW VERPHARM S VERPHARM=$P($G(^PS(55,DFN,"IV",+ON,4)),U,4) 96 . S:+VERPHARM $P(^TMP("PS",$J,"RXN",0),U,5)=VERPHARM 97 . S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM="" 98 S DN=$G(@(F_+ON_",.2)")),DO=$P(DN,U,2) 99 S DN=$S(+$P(DN,U):$$OIDF^PSJLMUT1($P(DN,U)),1:"") 100 S ^TMP("PS",$J,0)=DN_U_INFUS_U_STOP_"^^"_START_U_STAT_"^^^"_DO_"^^"_$P(ND0,U,21)_U_U_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_U_$G(RNWDT) 101 ;*S PROVIDER=$P($G(@(F_+ON_",0)")),"^",6) 102 I PROVIDER S ^TMP("PS",$J,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^") 103 S ^TMP("PS",$J,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,"MDR",1,0)=MR 104 S ^TMP("PS",$J,"SCH",0)=SCH]"" S:SCH]"" ^TMP("PS",$J,"SCH",1,0)=SCH 105 I ON["P" S:$P(ND0,U,7)]"" ^TMP("PS",$J,"SCH",0)=1,$P(^TMP("PS",$J,"SCH",1,0),U,2)=$$GTSCHT($P(ND0,U,7))_"^"_$P(ND0,U,7) 106 S ^TMP("PS",$J,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,"SIG",1,0)=INST 107 S ^TMP("PS",$J,"ADM",0)=ADM]"" S:ADM]"" ^TMP("PS",$J,"ADM",1,0)=ADM 108 S ^TMP("PS",$J,"SIO",0)=SIO]"" S:SIO]"" ^TMP("PS",$J,"SIO",1,0)=SIO 109 I $G(IVLIM)]"" S ^TMP("PS",$J,"IVLIM",0)=$G(IVLIM) 110 Q 111 ; 112 MR(X) ;RETURN MED ROUTE ABBR. IF THE ABBR="" RETURN MED ROUTE'S NAME. 113 S X=$G(^PS(51.2,X,0)) 114 Q $S($P(X,U,3)]"":$P(X,U,3),1:$P(X,U)) 115 ; 116 GTSTAT(X) ; 117 Q $S(X="A":"ACTIVE",X="D":"DISCONTINUED",X="I":"INCOMPLETE",X="N":"NON-VERFIED",X="U":"UNRELEASED",X="P":"PENDING",X="DE":"DISCONTINUED (EDIT)",X="O":"ON CALL",1:"NOT FOUND") 118 ; 119 VA200(X) ;Return the IEN for the user. 120 ; X = User name 121 NEW DIC,Y S DIC="^VA(200,",DIC(0)="NZ" D ^DIC 122 I +Y=-1 Q "" 123 Q $P(Y,U) 124 GTSCHT(X) ; 125 Q $S(X="C":"CONTINUOUS",X="O":"ONE TIME",X="P":"PRN",X="R":"FILL ON REQUEST",X="OC":"ON CALL",1:"NOT FOUND") -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJORREN.m
r613 r623 1 PSJORREN 2 ;;5.0; INPATIENT MEDICATIONS ;**50,70,58,89,91,110,127,134**;16 DEC 97;Build 124 3 4 5 6 7 8 9 10 ACTIVE(DFN,ON) 11 12 13 14 15 16 17 18 I '$D(^PS(53.1,+ON))&'$D(^PS(55,+DFN,5,+ON,0))&'$D(^PS(55,+DFN,"IV",+ON,0)) S PSJRT="0^Invalid Package Reference" Q $G(PSJRT) 19 D:ON["U" UD 20 D:ON["V" IV 21 I (+$G(PSJRT)=1) S PSJEXP=$$EXPIRED^PSGOER(DFN,ON) I PSJEXP S PSJRT="0^Expired Time Limit Exceeded" 22 Q $G(PSJRT) 23 UD ; 24 ;If both PSJRT(2) & (3) existed it meant order has multiple DDs and one 25 ;is tied to a different OI. It's best to not allow renewal of the order. 26 ; 27 NEW PSJDD,PSJDDOI,PSJDDX,PSJACT,PSJOI,PSJOIACT,PSJUSE,PSJPRI,X,ND2 28 K PSJRT 29 S PSJOI=+^PS(55,DFN,5,+ON,.2)30 S PSJPRI=$P(^PS(55,DFN,5,+ON,.2),"^",4) 31 I PSJPRI="D" S PSJRT="0^Orders with a Done prioritymay not be renewed" Q32 S ND0=$G(^PS(55,DFN,5,+ON,0)) I $P(ND0,"^",7)="O" S PSJRT="0^One Time orders may not be renewed" Q 33 N PSJCANT,PSJDAD,NDP2,PSJORKID,PSJKID S NDP2=$G(^PS(55,DFN,5,+ON,.2)),PSJDAD=$P(NDP2,"^",8) I PSJDADD34 .S PSJORKID="" F S PSJORKID=$O(^PS(55,"ACX",PSJDAD,PSJORKID)) Q:'PSJORKID!$G(PSJCANT) S PSJKID="" F S PSJKID=$O(^PS(55,"ACX",PSJDAD,PSJORKID,PSJKID)) Q:'PSJKID!$G(PSJCANT) D 35 ..S ND0=$G(^PS(55,DFN,5,+PSJKID,2)) I $P(ND0,"^",7)="O" S PSJRT="0^Complex Orders with One-Time doses may not be renewed",PSJCANT=1 36 Q:$G(PSJCANT) 37 F PSJDD=0:0 S PSJDD=$O(^PS(55,DFN,5,+ON,1,PSJDD)) Q:('PSJDD!$D(PSJRT(1))) D 38 . S (PSJACT,PSJOIACT)=0 S PSJDDX=^PS(55,DFN,5,+ON,1,PSJDD,0) 39 . S X=$P(PSJDDX,U,3) I X]"",(X'>DT) S PSJACT=140 . S X=$G(^PSDRUG(+PSJDDX,"I")) I X]"",(X'>DT) S PSJACT=1 41 . S X=$G(^PSDRUG(+PSJDDX,2)),PSJUSE=$P(X,U,3)["U",PSJDDOI=+X I '+PSJDDOI S PSJRT(3)="0^Dispense drug is not matched to an Orderable Item" Q 42 . S X=$P($G(^PS(50.7,+PSJDDOI,0)),U,4) I X]"",(X'>DT) S PSJOIACT=1 43 . I 'PSJACT,PSJUSED Q44 .. I PSJOI=PSJDDOI DQ45 ... I 'PSJOIACT S PSJRT(1)=1 Q 46 ... S:PSJOIACT PSJRT(3)="0^Inactive Orderable Item" 47 .. I +PSJDDOI,(PSJOI'=PSJDDOI) D 48 ... S:'PSJOIACT PSJRT(2)="2"_U_PSJDDOI 49 ... S:PSJOIACT PSJRT(3)="0^Dispense drug ties to an inactive Orderable Item"50 . I PSJACT S PSJRT(3)="0^This drug has been Inactivated"51 . I 'PSJUSE S PSJRT(3)="0^Drug is No longer used in Inpatient Meds" 52 I $D(PSJRT(1)) S PSJRT=1Q53 I $D(PSJRT(2)),$D(PSJRT(3)) S PSJRT=PSJRT(3)Q54 I '$D(PSJRT) S PSJRT="0^Order has no Dispense drug" Q 55 S X=$O(PSJRT(0)),PSJRT=$G(PSJRT(X)) 56 Q 57 IV ; 58 NEW FIL,PSJACT,PSJAS,PSJASNO,PSJASOI,PSJCNT,PSJIEN,PSJOI,PSJOIACT,PSJPRI,X 59 K PSJRT 60 S PSJCNT=0 61 S PSJOI=+$G(^PS(55,DFN,"IV",+ON,.2))62 S PSJPRI=$P(^PS(55,DFN,"IV",+ON,.2),"^",4) 63 I PSJPRI="D" S PSJRT="0^Orders with a Done priority may not be renewed" Q 64 N ND2,PSBACT,IVSCHED 65 S ND0=$G(^PS(55,DFN,"IV",+ON,0)) I ($P(ND0,"^",4)="P")!($P(ND0,"^",23)="P")!$P(ND0,"^",5) D Q:$G(PSJRT)]"" 66 .N X,PSGOES,ZZND S PSGOES=2,X=$P(ND0,"^",9) D ENOS^PSGS0 Q:($G(X)="")!($P($G(ZZND),"^",5)'="O") 67 .S PSJRT="0^This One-Time order may not be renewed" 68 F FIL="AD","SOL" F PSJAS=0:0 S PSJAS=$O(^PS(55,DFN,"IV",+ON,FIL,PSJAS)) Q:'PSJAS D 69 . S (PSJACT,PSJOIACT)=0 70 . S PSJASNO=$S(FIL="AD":52.6,1:52.7)71 . S PSJIEN=+^PS(55,DFN,"IV",+ON,FIL,PSJAS,0) 72 . S X=$G(^PS(PSJASNO,+PSJIEN,"I")) I X]"",(X'>DT) S PSJACT=1 73 . S PSJASOI=$P(^PS(PSJASNO,PSJIEN,0),U,11) 74 . S X=$P($G(^PS(50.7,+PSJASOI,0)),U,4) I X]"",(X'>DT) S PSJOIACT=1 75 . I PSJACT S PSJCNT=PSJCNT+1,PSJRT(3)="0^Inactive "_$S(FIL="AD":"Additive",1:"Solution")Q76 . I PSJOI=PSJASOI DQ77 .. I 'PSJOIACT S PSJRT(1)="" Q 78 .. I PSJOIACT S PSJRT(3)="0^Inactive Orderable Item" 79 . I PSJOI'=PSJASOI D 80 .. I 'PSJOIACT S PSJCNT=PSJCNT+1,PSJRT(2)=2_U_PSJASOI 81 .. I PSJOIACT S PSJRT(3)="0^Inactive Orderable Item" 82 I $D(PSJRT(1)) S PSJRT=1Q83 I $D(PSJRT(3)) S PSJRT=PSJRT(3) Q84 85 86 1 PSJORREN ;BIR/MV-RENEWAL FLAG ;6 DEC 00 / 3:11 PM 2 ;;5.0; INPATIENT MEDICATIONS ;**50,70,58,89,91,110,127**;16 DEC 97 3 ; 4 ; Reference to ^PS(50.7 supported by DBIA #2180 5 ; References to ^PS(52.6 supported by DBIA #1231 6 ; References to ^PS(52.7 supported by DBIA #2173 7 ; References to ^PS(55 supported by DBIA #2191 8 ; Reference to ^PSDRUG( is supported by DBIA 2192 9 ; 10 ACTIVE(DFN,ON) ; 11 ;DFN: Patient IEN 12 ;ON : Order number_"U/V/P" 13 ;Output: 0^reason not renewable (Can't renew) 14 ; 2^New OI (Need to create a new order as in edit) 15 ; note: with PSJ*5*70 - instead of 2, IV order will return 0 16 ; 1 (OK to renew) 17 NEW PSJRT,PSJEXP 18 D:ON["U" UD 19 D:ON["V" IV 20 I (+$G(PSJRT)=1) S PSJEXP=$$EXPIRED^PSGOER(DFN,ON) I PSJEXP S PSJRT="0^Expired Time Limit Exceeded" 21 Q $G(PSJRT) 22 UD ; 23 ;If both PSJRT(2) & (3) existed it meant order has multiple DDs and one 24 ;is tied to a different OI. It's best to not allow renewal of the order. 25 ; 26 NEW PSJDD,PSJDDOI,PSJDDX,PSJACT,PSJOI,PSJOIACT,PSJUSE,PSJPRI,X,ND2 27 K PSJRT 28 S PSJOI=+^PS(55,DFN,5,+ON,.2) 29 S PSJPRI=$P(^PS(55,DFN,5,+ON,.2),"^",4) 30 I PSJPRI="D" S PSJRT="0^Orders with a Done priority may not be renewed" Q 31 S ND0=$G(^PS(55,DFN,5,+ON,0)) I $P(ND0,"^",7)="O" S PSJRT="0^One Time orders may not be renewed" Q 32 N PSJCANT,PSJDAD,NDP2,PSJORKID,PSJKID S NDP2=$G(^PS(55,DFN,5,+ON,.2)),PSJDAD=$P(NDP2,"^",8) I PSJDAD D 33 .S PSJORKID="" F S PSJORKID=$O(^PS(55,"ACX",PSJDAD,PSJORKID)) Q:'PSJORKID!$G(PSJCANT) S PSJKID="" F S PSJKID=$O(^PS(55,"ACX",PSJDAD,PSJORKID,PSJKID)) Q:'PSJKID!$G(PSJCANT) D 34 ..S ND0=$G(^PS(55,DFN,5,+PSJKID,2)) I $P(ND0,"^",7)="O" S PSJRT="0^Complex Orders with One-Time doses may not be renewed",PSJCANT=1 35 Q:$G(PSJCANT) 36 F PSJDD=0:0 S PSJDD=$O(^PS(55,DFN,5,+ON,1,PSJDD)) Q:('PSJDD!$D(PSJRT(1))) D 37 . S (PSJACT,PSJOIACT)=0 S PSJDDX=^PS(55,DFN,5,+ON,1,PSJDD,0) 38 . S X=$P(PSJDDX,U,3) I X]"",(X'>DT) S PSJACT=1 39 . S X=$G(^PSDRUG(+PSJDDX,"I")) I X]"",(X'>DT) S PSJACT=1 40 . S X=$G(^PSDRUG(+PSJDDX,2)),PSJUSE=$P(X,U,3)["U",PSJDDOI=+X I '+PSJDDOI S PSJRT(3)="0^Dispense drug is not matched to an Orderable Item" Q 41 . S X=$P($G(^PS(50.7,+PSJDDOI,0)),U,4) I X]"",(X'>DT) S PSJOIACT=1 42 . I 'PSJACT,PSJUSE D Q 43 .. I PSJOI=PSJDDOI D Q 44 ... I 'PSJOIACT S PSJRT(1)=1 Q 45 ... S:PSJOIACT PSJRT(3)="0^Inactive Orderable Item" 46 .. I +PSJDDOI,(PSJOI'=PSJDDOI) D 47 ... S:'PSJOIACT PSJRT(2)="2"_U_PSJDDOI 48 ... S:PSJOIACT PSJRT(3)="0^Dispense drug ties to an inactive Orderable Item" 49 . I PSJACT S PSJRT(3)="0^This drug has been Inactivated" 50 . I 'PSJUSE S PSJRT(3)="0^Drug is No longer used in Inpatient Meds" 51 I $D(PSJRT(1)) S PSJRT=1 Q 52 I $D(PSJRT(2)),$D(PSJRT(3)) S PSJRT=PSJRT(3) Q 53 I '$D(PSJRT) S PSJRT="0^Order has no Dispense drug" Q 54 S X=$O(PSJRT(0)),PSJRT=$G(PSJRT(X)) 55 Q 56 IV ; 57 NEW FIL,PSJACT,PSJAS,PSJASNO,PSJASOI,PSJCNT,PSJIEN,PSJOI,PSJOIACT,PSJPRI,X 58 K PSJRT 59 S PSJCNT=0 60 S PSJOI=+$G(^PS(55,DFN,"IV",+ON,.2)) 61 S PSJPRI=$P(^PS(55,DFN,"IV",+ON,.2),"^",4) 62 I PSJPRI="D" S PSJRT="0^Orders with a Done priority may not be renewed" Q 63 N ND2,PSBACT,IVSCHED 64 S ND0=$G(^PS(55,DFN,"IV",+ON,0)) I ($P(ND0,"^",4)="P")!($P(ND0,"^",23)="P")!$P(ND0,"^",5) D Q:$G(PSJRT)]"" 65 .N X,PSGOES,ZZND S PSGOES=2,X=$P(ND0,"^",9) D ENOS^PSGS0 Q:($G(X)="")!($P($G(ZZND),"^",5)'="O") 66 .S PSJRT="0^This One-Time order may not be renewed" 67 F FIL="AD","SOL" F PSJAS=0:0 S PSJAS=$O(^PS(55,DFN,"IV",+ON,FIL,PSJAS)) Q:'PSJAS D 68 . S (PSJACT,PSJOIACT)=0 69 . S PSJASNO=$S(FIL="AD":52.6,1:52.7) 70 . S PSJIEN=+^PS(55,DFN,"IV",+ON,FIL,PSJAS,0) 71 . S X=$G(^PS(PSJASNO,+PSJIEN,"I")) I X]"",(X'>DT) S PSJACT=1 72 . S PSJASOI=$P(^PS(PSJASNO,PSJIEN,0),U,11) 73 . S X=$P($G(^PS(50.7,+PSJASOI,0)),U,4) I X]"",(X'>DT) S PSJOIACT=1 74 . I PSJACT S PSJCNT=PSJCNT+1,PSJRT(3)="0^Inactive "_$S(FIL="AD":"Additive",1:"Solution") Q 75 . I PSJOI=PSJASOI D Q 76 .. I 'PSJOIACT S PSJRT(1)="" Q 77 .. I PSJOIACT S PSJRT(3)="0^Inactive Orderable Item" 78 . I PSJOI'=PSJASOI D 79 .. I 'PSJOIACT S PSJCNT=PSJCNT+1,PSJRT(2)=2_U_PSJASOI 80 .. I PSJOIACT S PSJRT(3)="0^Inactive Orderable Item" 81 I $D(PSJRT(1)) S PSJRT=1 Q 82 I $D(PSJRT(3)) S PSJRT=PSJRT(3) Q 83 ;I $D(PSJRT(2)),PSJCNT=1 S PSJRT=PSJRT(2) Q 84 I $D(PSJRT(2)),PSJCNT=1 S PSJRT="0^New Orderable Item" Q 85 S PSJRT="0^Inactive drug" 86 Q -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJORUT2.m
r613 r623 1 PSJORUT2 ;BIR/MLM-MISC. PROCEDURE CALLS FOR OE/RR 3.0 (CONT.) ;03 Aug 98 / 8:42 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**14,29,50,56,58,107,152,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191 5 ; Reference to ^PS(50.605 is supported by DBIA 2138,696. 6 ; References to ^PS(52.6 supported by DBIA 1231 7 ; Reference to ^PS(52.7 supported by DBIA 2173. 8 ; Reference to ^PSDRUG( is supported by DBIA 2192 9 ; Reference to ^PSNDF( is supported by DBIA 2195 10 ; Reference to ^PSRX( is supported by DBIA 824 11 ; Reference to ^PSNAPIS is supported by DBIA 2531 12 ; 13 ENVAC(PN) ; Find VA CLASS of VA Product Name 14 ;Input: PN - See above 15 ;Output: VA Drug Class^Classification 16 ; 17 ; NEW NDF CALL 18 N X S X="PSNAPIS" X ^%ZOSF("TEST") I N PSJC,X1,X2 S X1=+$P(PN,"."),X2=+$P(PN,".",2),PSJC=$$DCLASS^PSNAPIS(X1,X2) Q PSJC 19 ; 20 N GDP,PNP S GDP=$P(PN,"."),PNP=$P(PN,".",2) 21 S X=+$P($G(^PSNDF(+GDP,5,+PNP,0)),U,2),X=+$P($G(^PSNDF(GDP,2,X,0)),U,3),PSJC=$P($G(^PS(50.605,X,0)),U,2) 22 Q $S('X:0,PSJC="":0,1:X_U_PSJC) 23 ; 24 ENVAGN(PN) ; Return VA Generic Name for specified VA Product Name. 25 ;Input: PN - VA Product Name IEN 26 ;Output: VA Generic Name IEN^VA Generic Name 27 ; 28 ; NEW NDF CALL 29 N X S X="PSNAPIS" X ^%ZOSF("TEST") I N GDP,X1,X2 S X1=+$P(PN,"."),X2=+$P(PN,".",2),GDP=$$VAGN^PSNAPIS(X1) Q $S(GDP=0:0,1:X1_U_GDP) 30 ; 31 N GDP,PNP S GDP=+$P(PN,"."),PNP=+$P(PN,".",2) 32 S X=$P($G(^PSNDF(GDP,0)),U) 33 Q $S('GDP:0,X="":0,1:GDP_U_X) 34 ENVOL(PN,ARRAY) ; 35 I (PN'["A")&(PN'["B") S ARRAY="0" Q 36 N X,XX,F,INACT,IVFL 37 S X(1)="ML",X(2)="LITER",X(3)="MCG",X(4)="MG",X(5)="GM",X(6)="UNITS",X(7)="IU",X(8)="MEQ",X(9)="MM",X(10)="MU",X(11)="THOUU",X(12)="MG-PE",X(13)="NANOGRAM",X(14)="MMOL" 38 I PN["A" N ADD S (ADD,X,XX)=0 F S ADD=$O(^PS(52.6,"AOI",+PN,ADD)) Q:ADD="" D 39 .S INACT=$G(^PS(52.6,ADD,"I")) I INACT']""!(INACT>DT) S IVFL=$P($G(^(0)),"^",13) Q:'IVFL S XX=XX+1,ARRAY(ADD)="^"_X($P($G(^PS(52.6,ADD,0)),U,3)) Q 40 I PN["B" N SOL S SOL=0,XX=0 F S SOL=$O(^PS(52.7,"AOI",+PN,SOL)) Q:SOL="" D 41 .S INACT=$G(^PS(52.7,SOL,"I")) I INACT']""!(INACT>DT) S IVFL=$P($G(^(0)),"^",13) Q:'IVFL S XX=XX+1,ARRAY(SOL)=$P($G(^PS(52.7,SOL,0)),"^",3) 42 S ARRAY=XX>0 43 Q 44 ; 45 ENVOL2(PN,ARRAY) ;Only for Med Button IV orders. 46 I (PN'["A")&(PN'["B") S ARRAY="0" Q 47 N X,XX,F,INACT 48 S X(1)="ML",X(2)="LITER",X(3)="MCG",X(4)="MG",X(5)="GM",X(6)="UNITS",X(7)="IU",X(8)="MEQ",X(9)="MM",X(10)="MU",X(11)="THOUU",X(12)="MG-PE",X(13)="NANOGRAM",X(14)="MMOL" 49 I PN["A" N ADD S (ADD,X,XX)=0 F S ADD=$O(^PS(52.6,"AOI",+PN,ADD)) Q:ADD="" D 50 .S INACT=$G(^PS(52.6,ADD,"I")) I INACT']""!(INACT>DT) S XX=XX+1,ARRAY(ADD)="^"_X($P($G(^PS(52.6,ADD,0)),U,3)) Q 51 I PN["B" N SOL S SOL=0,XX=0 F S SOL=$O(^PS(52.7,"AOI",+PN,SOL)) Q:SOL="" D 52 .S INACT=$G(^PS(52.7,SOL,"I")) I INACT']""!(INACT>DT) S XX=XX+1,ARRAY(SOL)=$P($G(^PS(52.7,SOL,0)),"^",3) 53 S ARRAY=XX>0 54 Q 55 ; 56 ; 57 SENVOL(PN,PSJ) ;Return array listing volume (base only) and volume units for the specified additive or solution. 58 ;Input: PN - IEN_B (Base) or A (Additive) 59 ;Output: ARRAY(IEN,A:additive or B:Base)=volume^volume units 60 ; If no volume or units found PSJ=0; If found PSJ=1. 61 ; 62 N X S PSJ=1 63 S X(1)="ML",X(2)="LITER",X(3)="MCG",X(4)="MG",X(5)="GM",X(6)="UNITS",X(7)="IU",X(8)="MEQ",X(9)="MM",X(10)="MU",X(11)="THOUU",X(12)="MG-PE",X(13)="NANOGRAM",X(14)="MMOL" 64 I PN'["A",PN'["B" S PSJ=0 Q 65 S PSJ=PSJ+1 66 I PN["A" S PSJ(+PN,"A")=U_X(+$P($G(^PS(52.6,+PN,0)),U,3)) Q 67 I PN["B" S PSJ(+PN,"B")=+$P($G(^PS(52.7,+PN,0)),U,3)_U_X(1) Q 68 Q 69 ; 70 ENREF(PRX) ; Return number of refills remaining. 71 ;Input: PRX - Internal prescription number from File #52. 72 ;Output: Number of refills remaining. 73 ; 74 N X,COUNT,CNT S PRX=$P(PRX,"^"),COUNT=0,X=$P(^PSRX(PRX,0),"^",9) 75 D:$O(^PSRX(PRX,1,0)) 76 .F CNT=0:0 S CNT=$O(^PSRX(PRX,1,CNT)) Q:'CNT S COUNT=COUNT+1 77 S:$G(COUNT) X=X-COUNT 78 Q X 79 ; 80 ENCHK(DFN,PSJINX) ; Return dispense drug check array. 81 ;Input: DFN - Patient internal entry number 82 ; PSJINX - Index number so duplicate drugs will be returned. 83 ; PSGOCHK - Check should include dispense drugs in 53.45 84 ; PSIVOCHK - Check should include entries in DRG array 85 ;Output: ^TMP($J,"ORDERS",PSJINX)=DRUG CLASS^NATIONAL DRUG FILE ENTRY 86 ; _"A"_PSNDFA PRODUCT NAME ENTRY_DISPENSE DRUG NAME^OE/RR # 87 ; _ORDER NUMBER(P/I/V)_";I" 88 ; 89 NEW BDT,DDRUG,DDRUG0,DDRUGND,EDT,F,ON,ON1,PST,WBDT,X,PSJORIEN 90 D NOW^%DTC S (BDT,WBDT)=%,EDT=9999999 91 S F="^PS(55,DFN,5," F S WBDT=$O(^PS(55,DFN,5,"AUS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,5,"AUS",WBDT,ON)) Q:'ON D UD 92 S F="^PS(53.1," F PST="P","N" F ON=0:0 S ON=$O(^PS(53.1,"AS",PST,DFN,ON)) Q:'ON D 93 . I $O(^PS(53.1,+ON,"AD",0))!$O(^PS(53.1,+ON,"SOL",0)) D PIV Q 94 . D UD 95 S WBDT=BDT F S WBDT=$O(^PS(55,DFN,"IV","AIS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,"IV","AIS",WBDT,ON)) Q:'ON D IV 96 I '$G(PSIVOCON) D NEWIV ; Don't do this when Finishing orders (FN) 97 Q 98 UD ;*** Get the dispense drugs for the Unit Dose orders. 99 S PSJORIEN=$P(@(F_ON_",0)"),U,21),DDRUG=0 100 I F="^PS(53.1,",($P(@(F_ON_",0)"),U,4)="I") D Q 101 . NEW PSJPD S COD=ON_"P" 102 . S PSJPD=+$G(^PS(53.1,ON,.2)) D:$D(^PS(52.6,"AOI",PSJPD)) ENDDIV^PSJORUTL(PSJPD,"A","",.DDRUG) S DDRUG=+DDRUG D:DDRUG DDRUG 103 S ON1=0 F S ON1=$O(@(F_ON_",1,"_ON1_")")) Q:'ON1 S DDRUG=@(F_ON_",1,"_ON1_",0)") I $P(DDRUG,U,3)=""!($P(DDRUG,U,3)>BDT) S COD=ON_$S(F["^PS(53.1":"P",1:"U") D DDRUG 104 I $D(PSGOCHK) F ON1=0:0 S ON1=$O(^PS(53.45,+PSJSYSP,1,ON1)) Q:'ON1 S DDRUG=$G(^PS(53.45,+PSJSYSP,1,ON1,0)) I $P(DDRUG,U,3)=""!@($P(DDRUG,U,3)>BDT) S (COD,PSJORIEN)="" D DDRUG 105 I '$O(@(F_ON_",1,"_0_")")) N OI S OI=+$G(@(F_ON_",.2)")) I OI D 106 .S DDRUG="" F S DDRUG=$O(^PSDRUG("ASP",OI,DDRUG)) Q:'DDRUG D 107 ..I ($P(DDRUG,U,3)=""!($P(DDRUG,U,3)>BDT)) S COD=ON_$S(F["^PS(53.1":"P",1:"U") D DDRUG 108 Q 109 PIV ;*** Get the dispense drugs for the Pending IV orders. 110 S X=^PS(53.1,+ON,0),PSJORIEN=$P(X,U,21) Q:$P(X,U,27)="R" 111 S ON1=0 F S ON1=$O(^PS(53.1,+ON,"AD",ON1)) Q:'ON1 S X=+^PS(53.1,+ON,"AD",ON1,0),DDRUG=$P($G(^PS(52.6,X,0)),U,2) S COD=+ON_"P" D DDRUG 112 S ON1=0 F S ON1=$O(^PS(53.1,+ON,"SOL",ON1)) Q:'ON1 S X=+^PS(53.1,+ON,"SOL",ON1,0),DDRUG=$P($G(^PS(52.7,X,0)),U,2) S COD=+ON_"P" D DDRUG 113 Q 114 IV ;*** Get the dispense drugs for the IV orders. 115 NEW X S X=^PS(55,DFN,"IV",ON,0),PSJORIEN=$P(X,U,21) Q:$P(X,U,17)="R" 116 S ON1=0 F S ON1=$O(^PS(55,DFN,"IV",ON,"AD",ON1)) Q:'ON1 S X=+^PS(55,DFN,"IV",ON,"AD",ON1,0),DDRUG=$P($G(^PS(52.6,X,0)),U,2) S COD=ON_"V" D DDRUG 117 S ON1=0 F S ON1=$O(^PS(55,DFN,"IV",ON,"SOL",ON1)) Q:'ON1 S X=+^PS(55,DFN,"IV",ON,"SOL",ON1,0),DDRUG=$P($G(^PS(52.7,X,0)),U,2) S COD=ON_"V" D DDRUG 118 Q 119 NEWIV ;*** Get the dispense drugs for the newly entered IV order. 120 NEW PSIVX,ON 121 S ON=$O(DRGOC(0)),PSJORIEN="" Q:'+ON 122 F PSIVX=0:0 S PSIVX=$O(DRGOC(ON,"AD",PSIVX)) Q:'PSIVX S DDRUG=$P(^PS(52.6,+DRGOC(ON,"AD",PSIVX),0),U,2),COD=ON55 D DDRUG 123 F PSIVX=0:0 S PSIVX=$O(DRGOC(ON,"SOL",PSIVX)) Q:'PSIVX S DDRUG=$P(^PS(52.7,+DRGOC(ON,"SOL",PSIVX),0),U,2),COD=ON D DDRUG 124 Q 125 DDRUG ;*** Set PSJ(DDRUG NAME) arrays. 126 Q:'DDRUG S DDRUG0=$G(^PSDRUG(+DDRUG,0)),DDRUGND=$G(^PSDRUG(+DDRUG,"ND")) 127 S PSJINX=+$G(PSJINX)+1 ;* ^PSOORDRG calls this entry point. 128 I $D(DDRUG)=11,DDRUG[";" D Q ; if called from ^PSOORDRG 129 .N IPOROP S IPOROP=$P(DDRUG,";",2) 130 .S IPOROP=$S(IPOROP="PSO":";O",IPOROP="PSH":"N;O",1:";I") 131 .S ^TMP($J,"ORDERS",PSJINX)=$P(DDRUG0,U,2)_U_$P(DDRUGND,U)_"A"_$P(DDRUGND,U,3)_U_$P(DDRUG0,U)_U_$S($G(DDRUG(DDRUG)):DDRUG(DDRUG),1:$G(PSJORIEN))_U_$G(COD)_IPOROP 132 S ^TMP($J,"ORDERS",PSJINX)=$P(DDRUG0,U,2)_U_$P(DDRUGND,U)_"A"_$P(DDRUGND,U,3)_U_$P(DDRUG0,U)_U_$G(PSJORIEN)_U_$G(COD)_";I" 133 Q 134 ; 135 PRCHK(PSJ) ; Check if authorized to write med orders. 136 N %,X 137 D NOW^%DTC S X=$G(^VA(200,PSJ,"PS")) I $S('X:1,'$P(%,"^",4):0,1:$P(X,"^",4)'>%) Q 0 138 Q PSJ 139 ; 140 ENNG(PSJDPT,PSJNUM) ; returns 1 if order marked "Not To Be Given" 141 ; 0 if not marked 142 I '$D(^PS(55,PSJDPT,5,+PSJNUM,0)) Q 0 143 I $P($G(^PS(55,PSJDPT,5,+PSJNUM,0)),"^",22)=1 Q 1 144 Q 0 1 PSJORUT2 ;BIR/MLM-MISC. PROCEDURE CALLS FOR OE/RR 3.0 (CONT.) ;03 Aug 98 / 8:42 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**14,29,50,56,58,107,152**;16 DEC 97 3 ; 4 ; Reference to ^PS(55 is supported by DBIA 2191 5 ; Reference to ^PS(50.605 is supported by DBIA 2138 6 ; References to ^PS(52.6 supported by DBIA 1231 7 ; Reference to ^PS(52.7 supported by DBIA 2173. 8 ; Reference to ^PSDRUG( is supported by DBIA 2192 9 ; Reference to ^PSNDF( is supported by DBIA 2195 10 ; Reference to ^PSRX( is supported by DBIA 824 11 ; Reference to ^PSNAPIS is supported by DBIA 2531 12 ; 13 ENVAC(PN) ; Find VA CLASS of VA Product Name 14 ;Input: PN - See above 15 ;Output: VA Drug Class^Classification 16 ; 17 ; NEW NDF CALL 18 N X S X="PSNAPIS" X ^%ZOSF("TEST") I N PSJC,X1,X2 S X1=+$P(PN,"."),X2=+$P(PN,".",2),PSJC=$$DCLASS^PSNAPIS(X1,X2) Q PSJC 19 ; 20 N GDP,PNP S GDP=$P(PN,"."),PNP=$P(PN,".",2) 21 S X=+$P($G(^PSNDF(+GDP,5,+PNP,0)),U,2),X=+$P($G(^PSNDF(GDP,2,X,0)),U,3),PSJC=$P($G(^PS(50.605,X,0)),U,2) 22 Q $S('X:0,PSJC="":0,1:X_U_PSJC) 23 ; 24 ENVAGN(PN) ; Return VA Generic Name for specified VA Product Name. 25 ;Input: PN - VA Product Name IEN 26 ;Output: VA Generic Name IEN^VA Generic Name 27 ; 28 ; NEW NDF CALL 29 N X S X="PSNAPIS" X ^%ZOSF("TEST") I N GDP,X1,X2 S X1=+$P(PN,"."),X2=+$P(PN,".",2),GDP=$$VAGN^PSNAPIS(X1) Q $S(GDP=0:0,1:X1_U_GDP) 30 ; 31 N GDP,PNP S GDP=+$P(PN,"."),PNP=+$P(PN,".",2) 32 S X=$P($G(^PSNDF(GDP,0)),U) 33 Q $S('GDP:0,X="":0,1:GDP_U_X) 34 ENVOL(PN,ARRAY) ; 35 I (PN'["A")&(PN'["B") S ARRAY="0" Q 36 N X,XX,F,INACT,IVFL S X(1)="ML",X(2)="LITER",X(3)="MCG",X(4)="MG",X(5)="GM",X(6)="UNITS",X(7)="IU",X(8)="MEQ",X(9)="MM",X(10)="MU",X(11)="THOUU",X(12)="MG-PE",X(13)="NANOGRAM" 37 I PN["A" N ADD S (ADD,X,XX)=0 F S ADD=$O(^PS(52.6,"AOI",+PN,ADD)) Q:ADD="" D 38 .S INACT=$G(^PS(52.6,ADD,"I")) I INACT']""!(INACT>DT) S IVFL=$P($G(^(0)),"^",13) Q:'IVFL S XX=XX+1,ARRAY(ADD)="^"_X($P($G(^PS(52.6,ADD,0)),U,3)) Q 39 I PN["B" N SOL S SOL=0,XX=0 F S SOL=$O(^PS(52.7,"AOI",+PN,SOL)) Q:SOL="" D 40 .S INACT=$G(^PS(52.7,SOL,"I")) I INACT']""!(INACT>DT) S IVFL=$P($G(^(0)),"^",13) Q:'IVFL S XX=XX+1,ARRAY(SOL)=$P($G(^PS(52.7,SOL,0)),"^",3) 41 S ARRAY=XX>0 42 Q 43 ; 44 ENVOL2(PN,ARRAY) ;Only for Med Button IV orders. 45 I (PN'["A")&(PN'["B") S ARRAY="0" Q 46 N X,XX,F,INACT S X(1)="ML",X(2)="LITER",X(3)="MCG",X(4)="MG",X(5)="GM",X(6)="UNITS",X(7)="IU",X(8)="MEQ",X(9)="MM",X(10)="MU",X(11)="THOUU",X(12)="MG-PE",X(13)="NANOGRAM" 47 I PN["A" N ADD S (ADD,X,XX)=0 F S ADD=$O(^PS(52.6,"AOI",+PN,ADD)) Q:ADD="" D 48 .S INACT=$G(^PS(52.6,ADD,"I")) I INACT']""!(INACT>DT) S XX=XX+1,ARRAY(ADD)="^"_X($P($G(^PS(52.6,ADD,0)),U,3)) Q 49 I PN["B" N SOL S SOL=0,XX=0 F S SOL=$O(^PS(52.7,"AOI",+PN,SOL)) Q:SOL="" D 50 .S INACT=$G(^PS(52.7,SOL,"I")) I INACT']""!(INACT>DT) S XX=XX+1,ARRAY(SOL)=$P($G(^PS(52.7,SOL,0)),"^",3) 51 S ARRAY=XX>0 52 Q 53 ; 54 ; 55 SENVOL(PN,PSJ) ;Return array listing volume (base only) and volume units for the specified additive or solution. 56 ;Input: PN - IEN_B (Base) or A (Additive) 57 ;Output: ARRAY(IEN,A:additive or B:Base)=volume^volume units 58 ; If no volume or units found PSJ=0; If found PSJ=1. 59 ; 60 N X S PSJ=1,X(1)="ML",X(2)="LITER",X(3)="MCG",X(4)="MG",X(5)="GM",X(6)="UNITS",X(7)="IU",X(8)="MEQ",X(9)="MM",X(10)="MU",X(11)="THOUU",X(12)="MG-PE",X(13)="NANOGRAM" 61 I PN'["A",PN'["B" S PSJ=0 Q 62 S PSJ=PSJ+1 63 I PN["A" S PSJ(+PN,"A")=U_X(+$P($G(^PS(52.6,+PN,0)),U,3)) Q 64 I PN["B" S PSJ(+PN,"B")=+$P($G(^PS(52.7,+PN,0)),U,3)_U_X(1) Q 65 Q 66 ; 67 ENREF(PRX) ; Return number of refills remaining. 68 ;Input: PRX - Internal prescription number from File #52. 69 ;Output: Number of refills remaining. 70 ; 71 N X,COUNT,CNT S PRX=$P(PRX,"^"),COUNT=0,X=$P(^PSRX(PRX,0),"^",9) 72 D:$O(^PSRX(PRX,1,0)) 73 .F CNT=0:0 S CNT=$O(^PSRX(PRX,1,CNT)) Q:'CNT S COUNT=COUNT+1 74 S:$G(COUNT) X=X-COUNT 75 Q X 76 ; 77 ENCHK(DFN,PSJINX) ; Return dispense drug check array. 78 ;Input: DFN - Patient internal entry number 79 ; PSJINX - Index number so duplicate drugs will be returned. 80 ; PSGOCHK - Check should include dispense drugs in 53.45 81 ; PSIVOCHK - Check should include entries in DRG array 82 ;Output: ^TMP($J,"ORDERS",PSJINX)=DRUG CLASS^NATIONAL DRUG FILE ENTRY 83 ; _"A"_PSNDFA PRODUCT NAME ENTRY_DISPENSE DRUG NAME^OE/RR # 84 ; _ORDER NUMBER(P/I/V)_";I" 85 ; 86 NEW BDT,DDRUG,DDRUG0,DDRUGND,EDT,F,ON,ON1,PST,WBDT,X,PSJORIEN 87 ;* S BDT=DT,WBDT=BDT_".000001",EDT=9999999 88 D NOW^%DTC S (BDT,WBDT)=%,EDT=9999999 89 S F="^PS(55,DFN,5," F S WBDT=$O(^PS(55,DFN,5,"AUS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,5,"AUS",WBDT,ON)) Q:'ON D UD 90 S F="^PS(53.1," F PST="P","N" F ON=0:0 S ON=$O(^PS(53.1,"AS",PST,DFN,ON)) Q:'ON D 91 . I $O(^PS(53.1,+ON,"AD",0))!$O(^PS(53.1,+ON,"SOL",0)) D PIV Q 92 . D UD 93 S WBDT=BDT F S WBDT=$O(^PS(55,DFN,"IV","AIS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,"IV","AIS",WBDT,ON)) Q:'ON D IV 94 I '$G(PSIVOCON) D NEWIV ; Don't do this when Finishing orders (FN) 95 Q 96 UD ;*** Get the dispense drugs for the Unit Dose orders. 97 S PSJORIEN=$P(@(F_ON_",0)"),U,21),DDRUG=0 98 I F="^PS(53.1,",($P(@(F_ON_",0)"),U,4)="I") D Q 99 . NEW PSJPD S COD=ON_"P" 100 . S PSJPD=+$G(^PS(53.1,ON,.2)) D:$D(^PS(52.6,"AOI",PSJPD)) ENDDIV^PSJORUTL(PSJPD,"A","",.DDRUG) S DDRUG=+DDRUG D:DDRUG DDRUG 101 S ON1=0 F S ON1=$O(@(F_ON_",1,"_ON1_")")) Q:'ON1 S DDRUG=@(F_ON_",1,"_ON1_",0)") I $P(DDRUG,U,3)=""!($P(DDRUG,U,3)>BDT) S COD=ON_$S(F["^PS(53.1":"P",1:"U") D DDRUG 102 I $D(PSGOCHK) F ON1=0:0 S ON1=$O(^PS(53.45,+PSJSYSP,1,ON1)) Q:'ON1 S DDRUG=$G(^PS(53.45,+PSJSYSP,1,ON1,0)) I $P(DDRUG,U,3)=""!@($P(DDRUG,U,3)>BDT) S (COD,PSJORIEN)="" D DDRUG 103 I '$O(@(F_ON_",1,"_0_")")) N OI S OI=+$G(@(F_ON_",.2)")) I OI D 104 .S DDRUG="" F S DDRUG=$O(^PSDRUG("ASP",OI,DDRUG)) Q:'DDRUG D 105 ..I ($P(DDRUG,U,3)=""!($P(DDRUG,U,3)>BDT)) S COD=ON_$S(F["^PS(53.1":"P",1:"U") D DDRUG 106 Q 107 PIV ;*** Get the dispense drugs for the Pending IV orders. 108 S X=^PS(53.1,+ON,0),PSJORIEN=$P(X,U,21) Q:$P(X,U,27)="R" 109 S ON1=0 F S ON1=$O(^PS(53.1,+ON,"AD",ON1)) Q:'ON1 S X=+^PS(53.1,+ON,"AD",ON1,0),DDRUG=$P($G(^PS(52.6,X,0)),U,2) S COD=+ON_"P" D DDRUG 110 S ON1=0 F S ON1=$O(^PS(53.1,+ON,"SOL",ON1)) Q:'ON1 S X=+^PS(53.1,+ON,"SOL",ON1,0),DDRUG=$P($G(^PS(52.7,X,0)),U,2) S COD=+ON_"P" D DDRUG 111 Q 112 IV ;*** Get the dispense drugs for the IV orders. 113 NEW X S X=^PS(55,DFN,"IV",ON,0),PSJORIEN=$P(X,U,21) Q:$P(X,U,17)="R" 114 S ON1=0 F S ON1=$O(^PS(55,DFN,"IV",ON,"AD",ON1)) Q:'ON1 S X=+^PS(55,DFN,"IV",ON,"AD",ON1,0),DDRUG=$P($G(^PS(52.6,X,0)),U,2) S COD=ON_"V" D DDRUG 115 S ON1=0 F S ON1=$O(^PS(55,DFN,"IV",ON,"SOL",ON1)) Q:'ON1 S X=+^PS(55,DFN,"IV",ON,"SOL",ON1,0),DDRUG=$P($G(^PS(52.7,X,0)),U,2) S COD=ON_"V" D DDRUG 116 ;*D:$G(PSIVNEW) NEWIV 117 Q 118 NEWIV ;*** Get the dispense drugs for the newly entered IV order. 119 NEW PSIVX,ON 120 S ON=$O(DRGOC(0)),PSJORIEN="" Q:'+ON 121 F PSIVX=0:0 S PSIVX=$O(DRGOC(ON,"AD",PSIVX)) Q:'PSIVX S DDRUG=$P(^PS(52.6,+DRGOC(ON,"AD",PSIVX),0),U,2),COD=ON55 D DDRUG 122 F PSIVX=0:0 S PSIVX=$O(DRGOC(ON,"SOL",PSIVX)) Q:'PSIVX S DDRUG=$P(^PS(52.7,+DRGOC(ON,"SOL",PSIVX),0),U,2),COD=ON D DDRUG 123 Q 124 DDRUG ;*** Set PSJ(DDRUG NAME) arrays. 125 Q:'DDRUG S DDRUG0=$G(^PSDRUG(+DDRUG,0)),DDRUGND=$G(^PSDRUG(+DDRUG,"ND")) 126 S PSJINX=+$G(PSJINX)+1 ;* ^PSOORDRG calls this entry point. 127 I $D(DDRUG)=11,DDRUG[";" D Q ; if called from ^PSOORDRG 128 .N IPOROP S IPOROP=$P(DDRUG,";",2) 129 .S IPOROP=$S(IPOROP="PSO":";O",IPOROP="PSH":"N;O",1:";I") 130 .S ^TMP($J,"ORDERS",PSJINX)=$P(DDRUG0,U,2)_U_$P(DDRUGND,U)_"A"_$P(DDRUGND,U,3)_U_$P(DDRUG0,U)_U_$S($G(DDRUG(DDRUG)):DDRUG(DDRUG),1:$G(PSJORIEN))_U_$G(COD)_IPOROP 131 S ^TMP($J,"ORDERS",PSJINX)=$P(DDRUG0,U,2)_U_$P(DDRUGND,U)_"A"_$P(DDRUGND,U,3)_U_$P(DDRUG0,U)_U_$G(PSJORIEN)_U_$G(COD)_";I" 132 Q 133 ; 134 PRCHK(PSJ) ; Check if authorized to write med orders. 135 N %,X 136 D NOW^%DTC S X=$G(^VA(200,PSJ,"PS")) I $S('X:1,'$P(%,"^",4):0,1:$P(X,"^",4)'>%) Q 0 137 Q PSJ 138 ; 139 ENNG(PSJDPT,PSJNUM) ; returns 1 if order marked "Not To Be Given" 140 ; 0 if not marked 141 I '$D(^PS(55,PSJDPT,5,+PSJNUM,0)) Q 0 142 I $P($G(^PS(55,PSJDPT,5,+PSJNUM,0)),"^",22)=1 Q 1 143 Q 0 -
WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJUTL.m
r613 r623 1 PSJUTL ;BIR/MLM-MISC. INPATIENT UTILITIES ;17 Mar 98 / 11:05 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**9,47,58,80,110,136,157,177,134**;16 DEC 97;Build 124 3 ; 4 ; Reference to ^DIC(42 is supported by DBIA 10039. 5 ; Reference to ^PS(50.7 is supported by DBIA 2180. 6 ; Reference to ^PSDRUG( is supported by DBIA 2192. 7 ; Reference to ^DIC is supported by DBIA 10006. 8 ; Reference to ^DIC1 is supported by DBIA 10007. 9 ; Reference to ^DIR is supported by DBIA 10026. 10 ; Reference to ^VALM1 is supported by DBIA 10116. 11 ; 12 ENDL ; device look-up 13 N DA,DIC,DIE,DIX,DO,DR 14 S DIC="^%ZIS(1,",DIC(0)="EIMZ" D DO^DIC1,^DIC I Y'>0 K X Q 15 S X=Y(0,0) 16 Q 17 ; 18 ENDH(X) ; device help 19 N D,XQH,DA,DIC,DIE,DO,DR,DZ 20 S DIC="^%ZIS(1,",DIC(0)="EIM" D DO^DIC1,^DIC 21 Q 22 ; 23 READ ; hold screen 24 I $D(IOST) Q:$E(IOST)'="C" 25 W ! I $D(IOSL),$Y<(IOSL-4) G READ 26 W !?5,"Press return to continue " R X:$S($D(DTIME):DTIME,1:300) 27 Q 28 ; 29 ENOISC(PSJOI,USAGE) ;Set DIC("S") so that only Orderable Items with at 30 ;least 1 active dispense drug for the specified usage. 31 ;Input: PSJOI IEN of Orderable Item selected 32 ; USAGE - Type of drugs (UD,IV,etc) to be selected 33 ;Output: 1-At least one dispense drug found 34 ; 0-None found 35 N FOUND,PSJ 36 S PSJ=$P($G(^PS(50.7,+PSJOI,0)),U,4),FOUND=$S('PSJ:1,PSJ>DT:1,1:0) 37 I FOUND S FOUND=0 F PSJ=0:0 S PSJ=$O(^PSDRUG("ASP",PSJOI,PSJ)) Q:FOUND!'PSJ I $P($G(^PSDRUG(PSJ,2)),U,3)[USAGE,'$G(^("I"))!($G(^("I"))'<DT) S FOUND=1 38 Q FOUND 39 ; 40 AADR ; display allergies and adverse reactions 41 D ATS^PSJMUTL(60,50,1) N A,B 42 I (PSGALG=0)&(PSGADR=0) W !!,"No allergies or ADRs on file." 43 I PSGALG'=0 W !!,"Allergies: " S B="PSGALG" F S A=$Q(@B) Q:A="" W ?12,$G(@A),! S B=A 44 I PSGADR'=0 W !," ADR: " S B="PSGADR" F S A=$Q(@B) Q:A="" W ?12,$G(@A),! S B=A 45 D READ K PSGALG,PSGADR Q 46 ; 47 ENALU ; application look-up 48 N PSJ S PSJ=DA(1) N DA,DIC,DIE,DIX,DO,DR S DIC="^PS(50.35,",DIC(0)="EIMZ" D DO^DIC1,^DIC I Y'>0 K X Q 49 S X=$P(Y(0),"^",2) K:$S(X="":1,1:$D(^PS(50.3,PSJ,1,"B",X))) X 50 Q 51 ; 52 ENAQ ; application query 53 S X=DZ N D,DA,DIC,DIE,DO,DR,DZ,XQH S DIC="^PS(50.35,",DIC(0)="EIMQ" D DO^DIC1,^DIC 54 Q 55 ; 56 ENPC(PSJTYP,PSJSYSP,LEN,TEXT) ; Copy Provider Comments -> Special Instructions. 57 Q:'$D(^PS(53.1,+$G(PSJORD),12,1,0)) "" 58 N DIR,PSGSI,PSGOEE,X,Y 59 S Y="" F X=0:0 S X=$O(^PS(53.1,+$G(PSJORD),12,X)) Q:'X S Y=Y_^(X,0)_" " Q:$L(Y)>LEN 60 S:$G(PSJTYP)'="V" Y=$$ENSET^PSGSICHK(Y) S:$G(PSJTYP)="V" Y=$E(Y,1,$L(Y)-1) 61 I $L(Y)'<LEN S PSGOEE=0 D REDISP Q PSGSI 62 ;Display Provider Comments Prior to Asking the Copy Provider Comments Question;BHW;PSJ*5*136 63 N PSJTMP S PSJTMP=0 64 W !,"PROVIDER COMMENTS:" 65 F S PSJTMP=$O(^PS(53.1,+$G(PSJORD),12,PSJTMP)) Q:'PSJTMP W !,^PS(53.1,+$G(PSJORD),12,PSJTMP,0) 66 S PSGSI=Y W ! S DIR(0)="S^Y:Yes;N:No;!:Copy and flag for display in a BCMA Message Box",DIR("A")="Copy the Provider Comments into "_$$ENFIELD(PSJTYP)_" (Yes/No/!)",DIR("??")="^D ENPCHLP1^PSJUTL(PSJTYP)" D ^DIR 67 Q:Y="Y" PSGSI 68 Q:Y="!" PSGSI_"^1" 69 Q "" 70 ; 71 REDISP ; Redisplay Provider Comments and allow entry of Spec. Instructions. 72 D CLEAR^VALM1 F X=0:0 S X=$O(^PS(53.1,+$G(PSJORD),12,X)) Q:'X W ^(X,0),! 73 W !! S PSGSI="" 74 D:PSJTYP'="V" 8^PSGOE81 75 I PSJTYP="V" D 64^PSIVEDT1 S PSGSI=P("OPI") 76 Q 77 ; 78 ENPCHLP1(Y) ; Display help messages for Provider Comment copy. 79 W !,"Enter ""YES"" to copy Provider Comments into the ",$$ENFIELD(Y)," field",!,"or ""NO"" to bypass",!,"or ""!"" to copy the Provider Comments into the ",$$ENFIELD(PSJTYP)," field",!,"and flag them for display in a BCMA Message Box",!! 80 Q 81 ENPCHLP2(Y,X) ; 82 W !,"The Provider Comments entered for this order are longer than the space available",!,"in the ",$$ENFIELD(Y)," field.",!!,"Enter ""YES"" to copy the first ",X-3," characters into the ",$$ENFIELD(Y),!,"field, or ""NO"" to continue.",!! 83 Q 84 ENBCMA(PSJTYP) ; 85 N DIR,X,Y 86 W !!,"Would you like to flag the ",$$ENFIELD(PSJTYP)," field for display in a BCMA",!,"Message box?" 87 W ! S DIR(0)="S^Y:Yes;N:No",DIR("A")="Flag the "_$$ENFIELD(PSJTYP)_" (Yes/No)" D ^DIR 88 K PSJCOMSI I $G(PSJCOM),$G(PSJORD)'["P" N TEXT S TEXT=$S(PSJTYP="U":$G(PSGSI),1:$G(P("OPI"))) S PSJCOMSI=$$COMSI(PSJCOM,TEXT) 89 Q:Y="Y" $S($G(PSJTYP)="U":$P(PSGSI,"^")_"^1",1:$P(P("OPI"),"^")_"^1") 90 Q $S(PSJTYP="U":$P(PSGSI,"^"),1:$P($G(P("OPI")),"^")) 91 ENFIELD(Y) ; 92 Q $S(Y="V":"Other Print Info",1:"Special Instructions") 93 ; 94 COMSI(PARENT,INSTR) ; 95 N DIR,X,Y 96 W !!!!?15,"** WARNING **",!?5,"This order is part of a complex order." 97 W !!,"Would you like to copy the ",$$ENFIELD(PSJTYP) 98 W !,"to the other orders in the complex order?" 99 S DIR(0)="S^Y:Yes;N:No",DIR("A")=" Copy the "_$$ENFIELD(PSJTYP)_" (Yes/No)" D ^DIR 100 Q:Y="Y" 1 101 Q 0 102 ; 103 ENORL(X) ; Return patient's location as variable ptr. 104 Q $S(+$G(^DIC(42,+X,44)):+$G(^(44))_";SC(",$D(^DIC(42,+X,0)):+X_";DIC(42,",1:"") 105 ; 106 ENMARD() ; validate MAR SELECTION DEFAULT string in WARD PARMS file. 107 N PSJANS,PSJX1,PSJX2,RANGE,Q 108 S RANGE="1:6" F PSJX1=1:1:6 S RANGE(PSJX1)="" 109 S:$E(X)="-" X=+RANGE_X S:$E($L(X))="-" X=X_$P(RANGE,":",2) 110 S PSJANS="" F Q=1:1:$L(X,",") S PSJX1=$P(X,",",Q) D FS Q:'$D(PSJANS) 111 Q:'$G(PSJANS) 0 112 S PSJANS=$E(PSJANS,1,$L(PSJANS)-1) F Q=1:1:$L(PSJANS,",") D Q:'$D(PSJANS) 113 .I $P(PSJANS,",",Q)=1,$L(PSJANS,",")>1 W !!,"All Medications (1) may not be selected in combination with other types." K PSJANS Q 114 .W ?47,$P(PSJANS,",",Q)," - ",$P($T(@$P(PSJANS,",",Q)),";;",2),! 115 S:$G(PSJANS) X=PSJANS Q $G(PSJANS) 116 ; 117 FS ; 118 I $S(PSJX1?1.N1"-"1.N:0,PSJX1'?1.N:1,'$D(RANGE(PSJX1)):1,1:","_PSJANS[PSJX1) K PSJANS Q 119 I PSJX1'["-" S PSJANS=PSJANS_PSJX1_"," Q 120 S PSJX2=+PSJX1,PSJANS=PSJANS_PSJX2_"," 121 F S PSJX2=$O(RANGE(PSJX2)) K:$S(X="":1,","_PSJANS[PSJX2:1,1:PSJX2>$P(PSJX1,"-",2)) PSJANS Q:'$D(PSJANS) S PSJANS=PSJANS_PSJX2_"," Q:PSJX2=$P(PSJX1,"-",2) 122 Q 123 ; 124 ENMARDH ;Help text for MAR default answer. 125 W !!?2,"Enter the number corresponding to the type of orders to be included on MARs",!,"printed for this ward. Multiple types (except 1) may be selected using ""-""",!,"or "","" as delimiters.",!!,"Choose from: ",! 126 N X F X=1:1:6 W !?13,X," - ",$P($T(@X),";;",2) 127 W ! 128 Q 129 1 ;;All Medications 130 2 ;;Non-IV Medications only 131 3 ;;IV Piggybacks 132 4 ;;LVPs 133 5 ;;TPNs 134 6 ;;Chemotherapy Medications (IV) 135 ; 136 EFD ;The following EFD Tags are used to Calculate the Expected First Dose for backdoor 137 ;orders. The call to $$ENQ^PSJORP2 is used to actually perform the calculation. 138 ;The program $$ENQ^PSJORP2 requires the variable INFO to equal the following: 139 ;BHW;PSJ*5*136 140 ; INFO (piece 1) = START DATE/TIME ;PSGNESD (NEW ORDER) 141 ; INFO (piece 2) = STOP DATE/TIME ;PSGNEFD (NEW ORDER) 142 ; INFO (piece 3) = SCHEDULE ;PSGSCH (NEW ORDER) 143 ; INFO (piece 4) = SCHEDULE TYPE ;PSGST (NEW ORDER) 144 ; INFO (piece 5) = ORDERABLE ITEM ;PSGDRG (NEW ORDER) 145 ; INFO (piece 6) = ADMIN TIMES ;PSGS0Y (NEW ORDER) 146 ; 147 EFDNEW ;Call Here if NEW or RENEWED Order 148 N INFO 149 S INFO=($G(PSGNESD))_U_($G(PSGNEFD))_U_($G(PSGSCH))_U_($G(PSGST))_U_($G(PSGDRG))_U_($G(PSGS0Y)) 150 D EFDDISP 151 QUIT 152 EFDACT ;Call here if Editing Fields for an ACTIVE order 153 ; Field 10 = Start Date 154 ; Field 34 = Stop Date 155 ; Field 41 = Admin Times 156 N INFO,KEY,ORDER,LAST 157 ;Loop Fields to be edited, in order, and determine when to Display expected first dose message 158 F KEY=1:1 S ORDER=$P(PSGOEER,";",KEY) Q:'$L(ORDER) I "10^34^41"[$P(ORDER,U,1) S ORDER(KEY)=$P(ORDER,U,1) 159 ;If there are no entries in ORDER, then were Not Editing Start/Stop or Admin Times 160 S LAST=$O(ORDER(99),-1) Q:'LAST 161 ;Only display EFD once, so Quit if this call is not for the Last field in the Edit 162 S LAST=ORDER(LAST) 163 I LAST'=PSGF2 Q 164 S INFO=($G(PSGSD))_U_($G(PSGFD))_U_($G(PSGSCH))_U_($G(PSGST))_U_($G(PSGPDRG))_U_($G(PSGS0Y)) 165 D EFDDISP 166 QUIT 167 EFDNV ;Call here if Editing Fields for a NON-VERIFIED order 168 ; Field 10 = Start Date 169 ; Field 25 = Stop Date 170 ; Field 39 = Admin Times 171 N INFO,KEY,ORDER,LAST 172 ;Check if called during finish process 173 I '$D(PSGOEER) D D EFDDISP Q 174 . S INFO=($G(PSGNESD))_U_($G(PSGNEFD))_U_($G(PSGSCH))_U_($G(PSGST))_U_($G(PSGPDRG))_U_($G(PSGS0Y)) 175 . Q 176 ;Loop Fields to be edited, in order, and determine when to Display expected first dose message 177 F KEY=1:1 S ORDER=$P(PSGOEER,";",KEY) Q:'$L(ORDER) I "10^25^39"[$P(ORDER,U,1) S ORDER(KEY)=$P(ORDER,U,1) 178 ;If there are no entries in ORDER, then were Not Editing Start/Stop or Admin Times 179 S LAST=$O(ORDER(99),-1) Q:'LAST 180 ;Only display EFD once, so Quit if this call is not for the Last field in the Edit 181 S LAST=ORDER(LAST) 182 I LAST'=PSGF2 Q 183 S INFO=($G(PSGSD))_U_($G(PSGFD))_U_($G(PSGSCH))_U_($G(PSGST))_U_($G(PSGPDRG))_U_($G(PSGS0Y)) 184 D EFDDISP 185 QUIT 186 EFDIV(PSGZZND) ;Set variables for EFD on IV orders. 187 I $G(PSGZZND)="" D 188 .N X,ZZND,LYN,PSGS0XT,PSGS0Y,PSGOES S PSGOES=1 S X=P(9) D EN^PSGS0 S:$G(ZZND)'="" PSGZZND=ZZND 189 S PSGNESD=P(2),PSGNEFD=P(3),PSGSCH=P(9),PSGST=$P($G(PSGZZND),"^",5),PSGDRG=$P($G(P("PD")),"^"),PSGS0Y=P(11) 190 ;BHW - PSJ*5*177 Add call to check stop date. If it's in the past, Display Message 191 D CHKSTOP 192 D EFDNEW 193 W ! 194 Q 195 EFDDISP ;Display Expected First Dose 196 N Y,Z 197 Q:$G(PSGST)="OC"!($G(PSGST)="P")!($G(PSGST)="O") 198 Q:$G(PSGSCH)["ON CALL"!($G(PSGSCH)["ON-CALL")!($G(PSGSCH)["ONCALL") 199 Q:$G(PSGSCH)["PRN" 200 I '$L($G(PSGP)) N PSGP S PSGP="" 201 S Y=$$ENQ^PSJORP2(PSGP,INFO) 202 I 'Y S Y="Unable to Calculate" 203 X ^DD("DD") 204 W !,"Expected First Dose: ",Y H 2 205 Q 206 CHKSTOP ;BHW - PSJ*5*177 Warn user if the Stop Date is < now. 207 I '+$G(P(3)) Q 208 N PSNOW,%,%H,%I,X D NOW^%DTC S PSNOW=% 209 I +P(3)<PSNOW D Q 210 . W !,$C(7),"The Stop Date/Time is in the Past!!! This order will",!,"automatically EXPIRE upon Verification!!",! 211 . Q 212 Q 1 PSJUTL ;BIR/MLM-MISC. INPATIENT UTILITIES ;17 Mar 98 / 11:05 AM 2 ;;5.0; INPATIENT MEDICATIONS ;**9,47,58,80,110,136,157,177**;16 DEC 97 3 ; 4 ; Reference to ^DIC(42 is supported by DBIA 10039. 5 ; Reference to ^PS(50.7 is supported by DBIA 2180. 6 ; Reference to ^PSDRUG( is supported by DBIA 2192. 7 ; Reference to ^DIC is supported by DBIA 10006. 8 ; Reference to ^DIC1 is supported by DBIA 10007. 9 ; Reference to ^DIR is supported by DBIA 10026. 10 ; Reference to ^VALM1 is supported by DBIA 10116. 11 ; 12 ENDL ; device look-up 13 N DA,DIC,DIE,DIX,DO,DR 14 S DIC="^%ZIS(1,",DIC(0)="EIMZ" D DO^DIC1,^DIC I Y'>0 K X Q 15 S X=Y(0,0) 16 Q 17 ; 18 ENDH(X) ; device help 19 N D,XQH,DA,DIC,DIE,DO,DR,DZ 20 S DIC="^%ZIS(1,",DIC(0)="EIM" D DO^DIC1,^DIC 21 Q 22 ; 23 READ ; hold screen 24 I $D(IOST) Q:$E(IOST)'="C" 25 W ! I $D(IOSL),$Y<(IOSL-4) G READ 26 W !?5,"Press return to continue " R X:$S($D(DTIME):DTIME,1:300) 27 Q 28 ; 29 ENOISC(PSJOI,USAGE) ;Set DIC("S") so that only Orderable Items with at 30 ;least 1 active dispense drug for the specified usage. 31 ;Input: PSJOI IEN of Orderable Item selected 32 ; USAGE - Type of drugs (UD,IV,etc) to be selected 33 ;Output: 1-At least one dispense drug found 34 ; 0-None found 35 N FOUND,PSJ 36 S PSJ=$P($G(^PS(50.7,+PSJOI,0)),U,4),FOUND=$S('PSJ:1,PSJ>DT:1,1:0) 37 I FOUND S FOUND=0 F PSJ=0:0 S PSJ=$O(^PSDRUG("ASP",PSJOI,PSJ)) Q:FOUND!'PSJ I $P($G(^PSDRUG(PSJ,2)),U,3)[USAGE,'$G(^("I"))!($G(^("I"))'<DT) S FOUND=1 38 Q FOUND 39 ; 40 AADR ; display allergies and adverse reactions 41 D ATS^PSJMUTL(60,50,1) N A,B 42 I (PSGALG=0)&(PSGADR=0) W !!,"No allergies or ADRs on file." 43 I PSGALG'=0 W !!,"Allergies: " S B="PSGALG" F S A=$Q(@B) Q:A="" W ?12,$G(@A),! S B=A 44 I PSGADR'=0 W !," ADR: " S B="PSGADR" F S A=$Q(@B) Q:A="" W ?12,$G(@A),! S B=A 45 D READ K PSGALG,PSGADR Q 46 ; 47 ENALU ; application look-up 48 N PSJ S PSJ=DA(1) N DA,DIC,DIE,DIX,DO,DR S DIC="^PS(50.35,",DIC(0)="EIMZ" D DO^DIC1,^DIC I Y'>0 K X Q 49 S X=$P(Y(0),"^",2) K:$S(X="":1,1:$D(^PS(50.3,PSJ,1,"B",X))) X 50 Q 51 ; 52 ENAQ ; application query 53 S X=DZ N D,DA,DIC,DIE,DO,DR,DZ,XQH S DIC="^PS(50.35,",DIC(0)="EIMQ" D DO^DIC1,^DIC 54 Q 55 ; 56 ENPC(PSJTYP,PSJSYSP,LEN,TEXT) ; Copy Provider Comments -> Special Instructions. 57 Q:'$D(^PS(53.1,+$G(PSJORD),12,1,0)) "" 58 N DIR,PSGSI,PSGOEE,X,Y 59 S Y="" F X=0:0 S X=$O(^PS(53.1,+$G(PSJORD),12,X)) Q:'X S Y=Y_^(X,0)_" " Q:$L(Y)>LEN 60 S:$G(PSJTYP)'="V" Y=$$ENSET^PSGSICHK(Y) S:$G(PSJTYP)="V" Y=$E(Y,1,$L(Y)-1) 61 I $L(Y)'<LEN S PSGOEE=0 D REDISP Q PSGSI 62 ;Display Provider Comments Prior to Asking the Copy Provider Comments Question;BHW;PSJ*5*136 63 N PSJTMP S PSJTMP=0 64 W !,"PROVIDER COMMENTS:" 65 F S PSJTMP=$O(^PS(53.1,+$G(PSJORD),12,PSJTMP)) Q:'PSJTMP W !,^PS(53.1,+$G(PSJORD),12,PSJTMP,0) 66 S PSGSI=Y W ! S DIR(0)="S^Y:Yes;N:No;!:Copy and flag for display in a BCMA Message Box",DIR("A")="Copy the Provider Comments into "_$$ENFIELD(PSJTYP)_" (Yes/No/!)",DIR("??")="^D ENPCHLP1^PSJUTL(PSJTYP)" D ^DIR 67 Q:Y="Y" PSGSI 68 Q:Y="!" PSGSI_"^1" 69 Q "" 70 ; 71 REDISP ; Redisplay Provider Comments and allow entry of Spec. Instructions. 72 D CLEAR^VALM1 F X=0:0 S X=$O(^PS(53.1,+$G(PSJORD),12,X)) Q:'X W ^(X,0),! 73 W !! S PSGSI="" 74 D:PSJTYP'="V" 8^PSGOE81 75 I PSJTYP="V" D 64^PSIVEDT1 S PSGSI=P("OPI") 76 Q 77 ; 78 ENPCHLP1(Y) ; Display help messages for Provider Comment copy. 79 W !,"Enter ""YES"" to copy Provider Comments into the ",$$ENFIELD(Y)," field",!,"or ""NO"" to bypass",!,"or ""!"" to copy the Provider Comments into the ",$$ENFIELD(PSJTYP)," field",!,"and flag them for display in a BCMA Message Box",!! 80 Q 81 ENPCHLP2(Y,X) ; 82 W !,"The Provider Comments entered for this order are longer than the space available",!,"in the ",$$ENFIELD(Y)," field.",!!,"Enter ""YES"" to copy the first ",X-3," characters into the ",$$ENFIELD(Y),!,"field, or ""NO"" to continue.",!! 83 Q 84 ENBCMA(PSJTYP) ; 85 N DIR,X,Y 86 W !!,"Would you like to flag the ",$$ENFIELD(PSJTYP)," field for display in a BCMA",!,"Message box?" 87 W ! S DIR(0)="S^Y:Yes;N:No",DIR("A")="Flag the "_$$ENFIELD(PSJTYP)_" (Yes/No)" D ^DIR 88 K PSJCOMSI I $G(PSJCOM),$G(PSJORD)'["P" N TEXT S TEXT=$S(PSJTYP="U":$G(PSGSI),1:$G(P("OPI"))) S PSJCOMSI=$$COMSI(PSJCOM,TEXT) 89 Q:Y="Y" $S($G(PSJTYP)="U":$P(PSGSI,"^")_"^1",1:$P(P("OPI"),"^")_"^1") 90 Q $S(PSJTYP="U":$P(PSGSI,"^"),1:$P($G(P("OPI")),"^")) 91 ENFIELD(Y) ; 92 Q $S(Y="V":"Other Print Info",1:"Special Instructions") 93 ; 94 COMSI(PARENT,INSTR) ; 95 N DIR,X,Y 96 W !!!!?15,"** WARNING **",!?5,"This order is part of a complex order." 97 W !!,"Would you like to copy the ",$$ENFIELD(PSJTYP) 98 W !,"to the other orders in the complex order?" 99 S DIR(0)="S^Y:Yes;N:No",DIR("A")=" Copy the "_$$ENFIELD(PSJTYP)_" (Yes/No)" D ^DIR 100 Q:Y="Y" 1 101 Q 0 102 ; 103 ENORL(X) ; Return patient's location as variable ptr. 104 Q $S(+$G(^DIC(42,+X,44)):+$G(^(44))_";SC(",$D(^DIC(42,+X,0)):+X_";DIC(42,",1:"") 105 ; 106 ENMARD() ; validate MAR SELECTION DEFAULT string in WARD PARMS file. 107 N PSJANS,PSJX1,PSJX2,RANGE,Q 108 S RANGE="1:6" F PSJX1=1:1:6 S RANGE(PSJX1)="" 109 S:$E(X)="-" X=+RANGE_X S:$E($L(X))="-" X=X_$P(RANGE,":",2) 110 S PSJANS="" F Q=1:1:$L(X,",") S PSJX1=$P(X,",",Q) D FS Q:'$D(PSJANS) 111 Q:'$G(PSJANS) 0 112 S PSJANS=$E(PSJANS,1,$L(PSJANS)-1) F Q=1:1:$L(PSJANS,",") D Q:'$D(PSJANS) 113 .I $P(PSJANS,",",Q)=1,$L(PSJANS,",")>1 W !!,"All Medications (1) may not be selected in combination with other types." K PSJANS Q 114 .W ?47,$P(PSJANS,",",Q)," - ",$P($T(@$P(PSJANS,",",Q)),";;",2),! 115 S:$G(PSJANS) X=PSJANS Q $G(PSJANS) 116 ; 117 FS ; 118 I $S(PSJX1?1.N1"-"1.N:0,PSJX1'?1.N:1,'$D(RANGE(PSJX1)):1,1:","_PSJANS[PSJX1) K PSJANS Q 119 I PSJX1'["-" S PSJANS=PSJANS_PSJX1_"," Q 120 S PSJX2=+PSJX1,PSJANS=PSJANS_PSJX2_"," 121 F S PSJX2=$O(RANGE(PSJX2)) K:$S(X="":1,","_PSJANS[PSJX2:1,1:PSJX2>$P(PSJX1,"-",2)) PSJANS Q:'$D(PSJANS) S PSJANS=PSJANS_PSJX2_"," Q:PSJX2=$P(PSJX1,"-",2) 122 Q 123 ; 124 ENMARDH ;Help text for MAR default answer. 125 W !!?2,"Enter the number corresponding to the type of orders to be included on MARs",!,"printed for this ward. Multiple types (except 1) may be selected using ""-""",!,"or "","" as delimiters.",!!,"Choose from: ",! 126 N X F X=1:1:6 W !?13,X," - ",$P($T(@X),";;",2) 127 W ! 128 Q 129 1 ;;All Medications 130 2 ;;Non-IV Medications only 131 3 ;;IV Piggybacks 132 4 ;;LVPs 133 5 ;;TPNs 134 6 ;;Chemotherapy Medications (IV) 135 ; 136 EFD ;The following EFD Tags are used to Calculate the Expected First Dose for backdoor 137 ;orders. The call to $$ENQ^PSJORP2 is used to actually perform the calculation. 138 ;The program $$ENQ^PSJORP2 requires the variable INFO to equal the following: 139 ;BHW;PSJ*5*136 140 ; INFO (piece 1) = START DATE/TIME ;PSGNESD (NEW ORDER) 141 ; INFO (piece 2) = STOP DATE/TIME ;PSGNEFD (NEW ORDER) 142 ; INFO (piece 3) = SCHEDULE ;PSGSCH (NEW ORDER) 143 ; INFO (piece 4) = SCHEDULE TYPE ;PSGST (NEW ORDER) 144 ; INFO (piece 5) = ORDERABLE ITEM ;PSGDRG (NEW ORDER) 145 ; INFO (piece 6) = ADMIN TIMES ;PSGS0Y (NEW ORDER) 146 ; 147 EFDNEW ;Call Here if NEW or RENEWED Order 148 N INFO 149 S INFO=($G(PSGNESD))_U_($G(PSGNEFD))_U_($G(PSGSCH))_U_($G(PSGST))_U_($G(PSGDRG))_U_($G(PSGS0Y)) 150 D EFDDISP 151 QUIT 152 EFDACT ;Call here if Editing Fields for an ACTIVE order 153 ; Field 10 = Start Date 154 ; Field 34 = Stop Date 155 ; Field 41 = Admin Times 156 N INFO,KEY,ORDER,LAST 157 ;Loop Fields to be edited, in order, and determine when to Display expected first dose message 158 F KEY=1:1 S ORDER=$P(PSGOEER,";",KEY) Q:'$L(ORDER) I "10^34^41"[$P(ORDER,U,1) S ORDER(KEY)=$P(ORDER,U,1) 159 ;If there are no entries in ORDER, then were Not Editing Start/Stop or Admin Times 160 S LAST=$O(ORDER(99),-1) Q:'LAST 161 ;Only display EFD once, so Quit if this call is not for the Last field in the Edit 162 S LAST=ORDER(LAST) 163 I LAST'=PSGF2 Q 164 S INFO=($G(PSGSD))_U_($G(PSGFD))_U_($G(PSGSCH))_U_($G(PSGST))_U_($G(PSGPDRG))_U_($G(PSGS0Y)) 165 D EFDDISP 166 QUIT 167 EFDNV ;Call here if Editing Fields for a NON-VERIFIED order 168 ; Field 10 = Start Date 169 ; Field 25 = Stop Date 170 ; Field 39 = Admin Times 171 N INFO,KEY,ORDER,LAST 172 ;Check if called during finish process 173 I '$D(PSGOEER) D D EFDDISP Q 174 . S INFO=($G(PSGNESD))_U_($G(PSGNEFD))_U_($G(PSGSCH))_U_($G(PSGST))_U_($G(PSGPDRG))_U_($G(PSGS0Y)) 175 . Q 176 ;Loop Fields to be edited, in order, and determine when to Display expected first dose message 177 F KEY=1:1 S ORDER=$P(PSGOEER,";",KEY) Q:'$L(ORDER) I "10^25^39"[$P(ORDER,U,1) S ORDER(KEY)=$P(ORDER,U,1) 178 ;If there are no entries in ORDER, then were Not Editing Start/Stop or Admin Times 179 S LAST=$O(ORDER(99),-1) Q:'LAST 180 ;Only display EFD once, so Quit if this call is not for the Last field in the Edit 181 S LAST=ORDER(LAST) 182 I LAST'=PSGF2 Q 183 S INFO=($G(PSGSD))_U_($G(PSGFD))_U_($G(PSGSCH))_U_($G(PSGST))_U_($G(PSGPDRG))_U_($G(PSGS0Y)) 184 D EFDDISP 185 QUIT 186 EFDIV(PSGZZND) ;Set variables for EFD on IV orders. 187 S PSGNESD=P(2),PSGNEFD=P(3),PSGSCH=P(9),PSGST=$P($G(PSGZZND),"^",5),PSGDRG=$P($G(P("PD")),"^"),PSGS0Y=P(11) 188 ;BHW - PSJ*5*177 Add call to check stop date. If it's in the past, Display Message 189 D CHKSTOP 190 D EFDNEW 191 W ! 192 Q 193 EFDDISP ;Display Expected First Dose 194 N Y 195 Q:$G(PSGST)="OC"!($G(PSGST)="P") 196 Q:$G(PSGSCH)["ON CALL"!($G(PSGSCH)["ON-CALL")!($G(PSGSCH)["ONCALL") 197 Q:$G(PSGSCH)["PRN" 198 I '$L($G(PSGP)) N PSGP S PSGP="" 199 ; 200 S Y=$$ENQ^PSJORP2(PSGP,INFO) 201 I 'Y S Y="Unable to Calculate" 202 X ^DD("DD") 203 W !,"Expected First Dose: ",Y H 2 204 Q 205 CHKSTOP ;BHW - PSJ*5*177 Warn user if the Stop Date is < now. 206 I '+$G(P(3)) Q 207 N PSNOW,%,%H,%I,X D NOW^%DTC S PSNOW=% 208 I +P(3)<PSNOW D Q 209 . W !,$C(7),"The Stop Date/Time is in the Past!!! This order will",!,"automatically EXPIRE upon Verification!!",! 210 . Q 211 Q
Note:
See TracChangeset
for help on using the changeset viewer.