- PSGOEF ;BIR/CML3-FINISH ORDERS ENTERED THROUGH OE/RR ;14 May 98 / 2:17 PM
- ;;5.0; INPATIENT MEDICATIONS ;**7,30,29,35,39,47,50,56,80,116,110,111,133,153,134,222**;16 DEC 97;Build 5
- ;
- ; Reference to ^PS(55 is supported by DBIA 2191
- ; Reference to ^PSDRUG( is supported by DBIA 2192
- ; Reference to DOSE^PSSORPH is supported by DBIA 3234.
- ;
- START ;
- I '$D(^PS(53.1,+PSGORD)) W $C(7),!?3,"Cannot find this pending order (#",+PSGORD,")." Q
- D NOW^%DTC S PSGDT=+$E(%,1,12) K PSGFDX,PSGEFN,PSGOEEF,PSGOES,PSGONF,PSGRDTX S PSGOES=1,(PSGOEF,PSGOEEF)=0,PSGOEEG=3
- I $D(PSJTUD) S PSGDO=$P($G(^PS(53.1,+PSGORD,.3)),U),(PSGPDRG,PSGPD)=PSJCOI,(PSGPDRGN,PSGPDN)=$$OINAME^PSJLMUTL(PSGPD)
- I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" S X=PSGSCH D EN^PSGORS0 D
- . S:($D(X)&($P($G(^PS(53.1,+PSGORD,2)),"^",5)="")&($P($G(^PS(53.1,+PSGORD,0)),"^",24)="N")) PSGAT=PSGS0Y
- . NEW PSJDOX,PSJDOSE,PSJPIECE,PSJUNIT,PSJX,X
- . S X=$G(^PS(53.1,+PSGORD,1,1,0)) Q:'+X
- . D DOSE^PSSORPH(.PSJDOX,+X,"U")
- . I $S('$D(PSJDOX):1,1:+PSJDOX(1)=-1) Q
- . S PSJPIECE=$S($P(PSJDOX(1),U)="":3,1:1)
- . S X=^PS(53.1,+PSGORD,.2)
- . S:PSJPIECE=3 PSJDOSE=$P(X,U,2)
- . S:PSJPIECE=1 PSJDOSE=$P(X,U,5),PSJUNIT=$P(X,U,6)
- . F X=0:0 S X=$O(PSJDOX(X)) Q:+$G(PSJX)!'X D
- .. I PSJPIECE=3,($P(PSJDOX(X),U,3)'=PSJDOSE) Q
- .. I PSJPIECE=1,($P(PSJDOX(X),U,1)_$P(PSJDOX(X),U,2)'=(PSJDOSE_PSJUNIT)) Q
- .. S:+$P(PSJDOX(X),U,12) $P(^PS(53.45,PSJSYSP,2,1,0),U,2)=+$P(PSJDOX(X),U,12),PSJX=1
- I PSGEB'=PSGOPR F X=7,11 S Y=$T(@(3_X)),@("PSGEFN("_X_")="_$P(Y,";",7)),PSGOEEF(+$P(Y,";",3))="",PSGOEEF=PSGOEEF+1
- D GTST^PSGOE6(+PSGORD)
- I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" S PSGSD="" D:PSGS0Y]""
- .N PSJX S PSJX=$P($G(^PS(53.1,+PSGORD,0)),U,25) I PSJX="" Q
- .I PSJX["U" S PSGSD=$P($G(^PS(55,DFN,5,+PSJX,2)),U,2) Q
- .I PSJX["V" S PSGSD=$P($G(^PS(55,DFN,"IV",+PSJX,0)),U,2) Q
- .I PSJX["P" S PSGSD=$P($G(^PS(53.1,+PSJX,2)),U,2)
- S:PSGSD="" PSGSD=PSGLI
- S PSGNEDFD=$$GTNEDFD^PSGOE7("U",+PSGPD)
- S:$P($G(PSGNEDFD),U,3)="" $P(PSGNEDFD,U,3)=PSGST ; N PSGOEA S PSGOEA="R"
- S (PSGNESD,PSGSD)=$$ENSD^PSGNE3(PSGSCH,PSGS0Y,PSGLI,PSGSD)
- ;if this is a renewal order, ignore any 'requested start date' received. Use the system calculated start date.
- I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" D
- . D REQDT^PSJLIVMD(PSGORD)
- E D
- . S X=$$DSTART^PSJDCU(DFN,$P(^PS(53.1,+PSGORD,0),U,25)) I X]"" S (PSGNESD,PSGSD)=X K PSGRSD
- D ; Extend the Default Stop Date if needed for the first renewed order.
- .N PSGOEAO,PSGWALLO
- .I $P($G(^PS(53.1,+PSGORD,0)),U,24)="R" S PSGOEAO=PSGOEA,PSGOEA="R",PSGWALLO=$P(^PS(55,DFN,5.1),U)
- .D ENFD^PSGNE3(PSGLI) S PSGFD=$S($G(PSGRDTX(+PSGORD,"PSGFD")):PSGRDTX(+PSGORD,"PSGFD"),1:PSGNEFD)
- .I $P($G(^PS(53.1,+PSGORD,0)),U,24)="R" S PSGOEA=PSGOEAO,$P(^PS(55,DFN,5.1),U)=PSGWALLO
- N DUR,PSGRNSD S PSGRNSD=+$$LASTREN^PSJLMPRI(DFN,PSGORD) I PSGRNSD S DUR=$$GETDUR^PSJLIVMD(DFN,PSGORD,"P",1) I DUR]"" D
- . N DURMIN S DURMIN=$$DURMIN^PSJLIVMD(DUR) I DURMIN S PSGFD=$$FMADD^XLFDT(PSGRNSD,,,DURMIN)
- S PSGOFD="",PSGSDN=$$ENDD^PSGMI(PSGSD)_U_$$ENDTC^PSGMI(PSGSD),PSGFDN=$$ENDD^PSGMI(PSGFD)_U_$$ENDTC^PSGMI(PSGFD)
- S PSGLIN=$$ENDD^PSGMI(PSGLI)_U_$$ENDTC^PSGMI(PSGLI)
- I '$O(^PS(53.45,PSJSYSP,2,0)) N DRG,DRGCNT S DRGCNT=0 D
- .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
- .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)=""
- Q
- FINISH ;
- ; force display of second screen if CPRS order checks exist
- N NSFF,PSGOEF39 S NSFF=1 K PSJNSS
- I $G(PSGORD),$D(PSGRDTX(+PSGORD)) D K PSGRDTX
- . S:$G(PSGRDTX(+PSGORD,"PSGRSD")) PSGSD=PSGRDTX(+PSGORD,"PSGRSD")
- . S:$G(PSGRDTX(+PSGORD,"PSGRFD")) PSGFD=$S($G(PSGRDTX(+PSGORD,"PSGRFD")):PSGRDTX(+PSGORD,"PSGRFD"),1:$G(PSGNEFD))
- N PSJCOM S PSJCOM=+$P($G(^PS(53.1,+PSGORD,.2)),"^",8)
- ;
- ; PSJ*5*222
- ; PSJCT1 is a counter variable. Every piece of a complex order calls PSGOEF.
- ; The only time this code is to look for overlapping admin times is when the
- ; first part of a complex order is being finished. This variable will keep track
- ; of how many "parts" of the complex order have been checked.
- ;
- ; Also, since the user can select multiple complex orders to finish, like selecting
- ; orders 1-2 or 1-3 from the profile, PSJCT1A will keep track of whether the parent
- ; order number is the same as the first parent order number selected for finishing.
- ; Since the PSJCT1 counter variable will still be set if multiple complex orders
- ; are selected, PSJCT1 will be re-set to 1 if the parent complex order number (PSJCT1A) is
- ; not equal to the original parent order number (PSJCOM).
- ;
- S PSJCT1=$G(PSJCT1)+1
- I PSJCT1=1 S PSJCT1A=PSJCOM
- I $G(PSJCT1A)'=PSJCOM S PSJCT1=1,PSJCT1A=PSJCOM
- ; End of flag setting for PSJ*5*222
- I $O(^PS(53.1,+PSGORD,12,0))!$O(^PS(53.1,+PSGORD,10,0)) D
- .Q:$G(PSJLMX)=1 ; there's no second screen to display
- .S VALMBG=16 D RE^VALM4,PAUSE^VALM1
- D FULL^VALM1
- I '$D(IOINORM)!('$D(IOINHI)) S X="IORVOFF;IORVON;IOINHI;IOINORM" D ENDR^%ZISS
- I $G(PSJCOM)'="",$G(PSJCT1)=1 D
- . D OVERLAP^PSGOEF2 I $G(PSJOVRLP)=1 D
- . . N X,X1,DIR
- . . W !!,"**WARNING**"
- . . W !,"The highlighted admin times for these portions of this complex order overlap.",!!
- . . S (X,X1)="" F S X=$O(^TMP("PSJATOVR",$J,X)) Q:X="" D
- . . . S X1=$G(^TMP("PSJATOVR",$J,X))
- . . . W $S($P(X1,"^",4)=1:IORVON,1:""),"Part "_X,IORVOFF," has a schedule of "_$P(X1,"^",2)_" and admin time(s) of "
- . . . W $S($P(X1,"^",4)=1:IORVON,1:""),$P(X1,"^",3),IORVOFF
- . . . W !
- . . . W $S($G(PSJOVR("CONJ",X))="A":"AND",$G(PSJOVR("CONJ",X))="T":"THEN",1:""),!
- . . W !,"Please ensure the schedules and administration times are appropriate.",!
- . . S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR W !
- K ^TMP("PSJATOVR",$J)
- I $G(PSJPROT)=3,'$D(PSJTUD),'$$ENIVUD^PSGOEF1(PSGORD) Q
- I $G(PSGOSCH)]"" D S:$G(PSGS0XT)'="" $P(^PS(53.1,+PSGORD,2),"^",6)=PSGS0XT
- .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:$G(PSGAT)="" PSGAT=PSGS0Y
- .I $G(PSJNSS) S PSGOSCH="" K PSJNSS
- .I $G(PSGORD)["P",$G(PSGAT),$G(PSGS0Y),($G(PSGOSCH)]"") I PSGAT'=PSGS0Y D
- ..S PSGNSTAT=1 W $C(7),!!,"PLEASE NOTE: This order's admin times (",PSGAT,")"
- ..W !?13," do not match the ward times (",PSGS0Y,")"
- ..W !?13," for this administration schedule (",PSGOSCH,")",!
- ..S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR K DIR W !
- I $G(PSGS0XT)="" S $P(^PS(53.1,+PSGORD,2),"^",6)=$S($P($G(ZZND),"^",3)'="":$P(ZZND,"^",3),1:"")
- S CHK=0 S:$P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" PSGSI=$$ENPC^PSJUTL("U",+PSJSYSP,180,PSGSI)
- I '$G(PSJTUD),$G(PSJNSS),($G(PSGOSCH)]"") D NSSCONT^PSGS0(PSGOSCH,PSGS0XT) K PSJNSS S PSGOSCH=""
- S PSGOEFF=PSGOSCH=""+('$O(^PS(53.45,PSJSYSP,2,0))*10)
- I PSGOEFF S X=$S(PSGOEFF#2:" a SCHEDULE",1:"")_$S(PSGOEFF=11:" and",1:"")_$S(PSGOEFF>9:" at least one DISPENSE DRUG",1:"")
- I 'PSGOEFF I (($G(PSGS0XT)="D")&($G(PSGAT)="")) S X=" Admin Times",PSGOEFF=1,PSGOEF39=1
- I PSGOEFF,X]"" S X=X_" before it can be finished."
- 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," "
- I $G(PSGOEF39) S PSGOEE=0,PSGOEFF=0 D I 'PSGOEE D REFRESH^VALM G DONE
- .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
- 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
- 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
- .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
- I PSGOEFF>9 S CHK=7 D ENDRG^PSGOEF1(+PSGPD,0) I CHK D ABORTACC Q
- I 'PSGOEFF D OC531^PSGOESF ; check every dispense drug from CPRS
- S VALMBG=1
- I 'PSGOEFF&($D(PSGORQF)) D RE^VALM4 Q
- I $G(MSG) K DIR S DIR(0)="E" W !! D ^DIR
- I PSGOEFF D:PSGST="" GTST^PSGOE6(+PSGORD)
- S PSJLMFIN=1
- K PSJACEPT I $O(^PS(53.1,+PSGORD,12,0)) S PSJLMP2=1
- S PSGOEENO=0,PSGSTAT=$S($P(PSJSYSP0,U,9):"ACTIVE",1:"NON-VERIFIED")
- NEW PSJDOSE,PSJDOX,PSJDSFLG
- D DOSECHK^PSJDOSE
- S:+$G(PSJDSFLG) VALMSG="Dosage Ordered & Dispense Drug are not compatible"
- I PSGODO=PSGDO S PSGOEEF(109)=""
- I PSGODO'=PSGDO S PSGOEENO=1,VALMSG="This change will cause a new order to be created "
- D EN^VALM("PSJU LM ACCEPT")
- I $G(PSJNSS) D S PSGOEEF(26)="" K PSJACEPT,PSJNSS
- .K DIR S DIR(0)="FOA",DIR("A")="Invalid Schedule" D ^DIR K DIR
- I $G(PSGS0XT)="D",'$G(PSGS0Y),'$G(PSGAT),((",P,R,")'[(","_$G(PSGST)_",")) D S PSGOEEF(39)="" K PSJACEPT
- .K DIR S DIR(0)="FOA",DIR("A")=" WARNING - Admin times are required for DAY OF WEEK schedules " D ^DIR K DIR
- I '$G(PSJACEPT) D ABORTACC Q
- I $G(PSJRNF),$G(^PS(53.1,+PSGORD,4)) D
- . W $C(7),!!,"ACCEPTING THIS ORDER WILL CHANGE THE STATUS TO ACTIVE."
- . 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,"
- . S DIR("?")="or ""Y"" to continue with the Activation process." D ^DIR S:'Y Y=-1 K DIR
- I $G(PSJRNF),$G(Y)=-1 S PSJACEPT=0 D ABORTACC Q
- I $G(PSJRNF),$G(Y)=1 S PSGOEAV=1
- I PSGOEENO S PSJNOO=$$ENNOO^PSJUTL5("E"),PSJACEPT=$S(PSJNOO<0:0,1:1)
- ACCEPT ;
- S VALMBCK=$S($G(PSJACEPT):"Q",1:"R")
- I '$G(PSJACEPT) D ABORTACC Q
- K PSGOES,PSGRSD,PSGRSDN D:PSGOEENO NEW3^PSGOEE D:'PSGOEENO UPD^PSGOEF1 I $D(PSGOEF)!PSGOEENO S PSGCANFL=-1
- D DONE1^PSGOEE
- D DONE
- Q
- BYPASS ;
- S PSGCANFL=1
- ;
- DONE ;
- K CHK,DA,DIE,DR,DRG,MSG,Q1,Q2,PSGNSTAT
- K PSJOVR
- Q
- ABORTACC ; Abort Accept process.
- K PSJCT1,PSJOVR,PSJOVRLP,PSJCT1A
- 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
- ;
- ;
- 31 ;;101^PSGOE8;PSGOPD;PSGPD;101;1
- 32 ;;109^PSGOE8;PSGODO;PSGDO;109;PSGODO]""
- 33 ;;10^PSGOE81;PSGOSD;PSGSD;10;0
- 34 ;;3^PSGOE8;PSGOMR;PSGMR;3;1
- 35 ;;25^PSGOE81;PSGOFD;PSGFD;25;0
- 36 ;;7^PSGOE8;PSGOST;PSGST;7;0
- 37 ;;5^PSGOE82;PSGOSM;PSGSM;5;0
- 38 ;;26^PSGOE8;PSGOSCH;PSGSCH;26;1
- 39 ;;39^PSGOE81;PSGOAT;PSGAT;39;0
- 310 ;;1^PSGOE82;PSGOPR;PSGPR;1;1
- 311 ;;8^PSGOE81;PSGOSI;PSGSI;8;0
- 312 ;;2^PSGOE82;;;2;0
- 313 ;;40^PSGOE82;;;40;0
- ;
- AH ;
- 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."
- Q
- PSGOEF ;BIR/CML3-FINISH ORDERS ENTERED THROUGH OE/RR ;14 May 98 / 2:17 PM
- +1 ;;5.0; INPATIENT MEDICATIONS ;**7,30,29,35,39,47,50,56,80,116,110,111,133,153,134,222**;16 DEC 97;Build 5
- +2 ;
- +3 ; Reference to ^PS(55 is supported by DBIA 2191
- +4 ; Reference to ^PSDRUG( is supported by DBIA 2192
- +5 ; Reference to DOSE^PSSORPH is supported by DBIA 3234.
- +6 ;
- START ;
- +1 IF '$DATA(^PS(53.1,+PSGORD))
- WRITE $CHAR(7),!?3,"Cannot find this pending order (#",+PSGORD,")."
- QUIT
- +2 DO NOW^%DTC
- SET PSGDT=+$EXTRACT(%,1,12)
- KILL PSGFDX,PSGEFN,PSGOEEF,PSGOES,PSGONF,PSGRDTX
- SET PSGOES=1
- SET (PSGOEF,PSGOEEF)=0
- SET PSGOEEG=3
- +3 IF $DATA(PSJTUD)
- SET PSGDO=$PIECE($GET(^PS(53.1,+PSGORD,.3)),U)
- SET (PSGPDRG,PSGPD)=PSJCOI
- SET (PSGPDRGN,PSGPDN)=$$OINAME^PSJLMUTL(PSGPD)
- +4 IF $PIECE($GET(^PS(53.1,+PSGORD,0)),U,24)'="R"
- SET X=PSGSCH
- DO EN^PSGORS0
- Begin DoDot:1
- +5 IF ($DATA(X)&($PIECE($GET(^PS(53.1,+PSGORD,2)),"^",5)="")&($PIECE($GET(^PS(53.1,+PSGORD,0)),"^",24)="N"))
- SET PSGAT=PSGS0Y
- +6 NEW PSJDOX,PSJDOSE,PSJPIECE,PSJUNIT,PSJX,X
- +7 SET X=$GET(^PS(53.1,+PSGORD,1,1,0))
- IF '+X
- QUIT
- +8 DO DOSE^PSSORPH(.PSJDOX,+X,"U")
- +9 IF $SELECT('$DATA(PSJDOX):1,1:+PSJDOX(1)=-1)
- QUIT
- +10 SET PSJPIECE=$SELECT($PIECE(PSJDOX(1),U)="":3,1:1)
- +11 SET X=^PS(53.1,+PSGORD,.2)
- +12 IF PSJPIECE=3
- SET PSJDOSE=$PIECE(X,U,2)
- +13 IF PSJPIECE=1
- SET PSJDOSE=$PIECE(X,U,5)
- SET PSJUNIT=$PIECE(X,U,6)
- +14 FOR X=0:0
- SET X=$ORDER(PSJDOX(X))
- IF +$GET(PSJX)!'X
- QUIT
- Begin DoDot:2
- +15 IF PSJPIECE=3
- IF ($PIECE(PSJDOX(X),U,3)'=PSJDOSE)
- QUIT
- +16 IF PSJPIECE=1
- IF ($PIECE(PSJDOX(X),U,1)_$PIECE(PSJDOX(X),U,2)'=(PSJDOSE_PSJUNIT))
- QUIT
- +17 IF +$PIECE(PSJDOX(X),U,12)
- SET $PIECE(^PS(53.45,PSJSYSP,2,1,0),U,2)=+$PIECE(PSJDOX(X),U,12)
- SET PSJX=1
- End DoDot:2
- End DoDot:1
- +18 IF PSGEB'=PSGOPR
- FOR X=7,11
- SET Y=$TEXT(@(3_X))
- SET @("PSGEFN("_X_")="_$PIECE(Y,";",7))
- SET PSGOEEF(+$PIECE(Y,";",3))=""
- SET PSGOEEF=PSGOEEF+1
- +19 DO GTST^PSGOE6(+PSGORD)
- +20 IF $PIECE($GET(^PS(53.1,+PSGORD,0)),U,24)'="R"
- SET PSGSD=""
- IF PSGS0Y]""
- Begin DoDot:1
- +21 NEW PSJX
- SET PSJX=$PIECE($GET(^PS(53.1,+PSGORD,0)),U,25)
- IF PSJX=""
- QUIT
- +22 IF PSJX["U"
- SET PSGSD=$PIECE($GET(^PS(55,DFN,5,+PSJX,2)),U,2)
- QUIT
- +23 IF PSJX["V"
- SET PSGSD=$PIECE($GET(^PS(55,DFN,"IV",+PSJX,0)),U,2)
- QUIT
- +24 IF PSJX["P"
- SET PSGSD=$PIECE($GET(^PS(53.1,+PSJX,2)),U,2)
- End DoDot:1
- +25 IF PSGSD=""
- SET PSGSD=PSGLI
- +26 SET PSGNEDFD=$$GTNEDFD^PSGOE7("U",+PSGPD)
- +27 ; N PSGOEA S PSGOEA="R"
- IF $PIECE($GET(PSGNEDFD),U,3)=""
- SET $PIECE(PSGNEDFD,U,3)=PSGST
- +28 SET (PSGNESD,PSGSD)=$$ENSD^PSGNE3(PSGSCH,PSGS0Y,PSGLI,PSGSD)
- +29 ;if this is a renewal order, ignore any 'requested start date' received. Use the system calculated start date.
- +30 IF $PIECE($GET(^PS(53.1,+PSGORD,0)),U,24)'="R"
- Begin DoDot:1
- +31 DO REQDT^PSJLIVMD(PSGORD)
- End DoDot:1
- +32 IF '$TEST
- Begin DoDot:1
- +33 SET X=$$DSTART^PSJDCU(DFN,$PIECE(^PS(53.1,+PSGORD,0),U,25))
- IF X]""
- SET (PSGNESD,PSGSD)=X
- KILL PSGRSD
- End DoDot:1
- +34 ; Extend the Default Stop Date if needed for the first renewed order.
- Begin DoDot:1
- +35 NEW PSGOEAO,PSGWALLO
- +36 IF $PIECE($GET(^PS(53.1,+PSGORD,0)),U,24)="R"
- SET PSGOEAO=PSGOEA
- SET PSGOEA="R"
- SET PSGWALLO=$PIECE(^PS(55,DFN,5.1),U)
- +37 DO ENFD^PSGNE3(PSGLI)
- SET PSGFD=$SELECT($GET(PSGRDTX(+PSGORD,"PSGFD")):PSGRDTX(+PSGORD,"PSGFD"),1:PSGNEFD)
- +38 IF $PIECE($GET(^PS(53.1,+PSGORD,0)),U,24)="R"
- SET PSGOEA=PSGOEAO
- SET $PIECE(^PS(55,DFN,5.1),U)=PSGWALLO
- End DoDot:1
- +39 NEW DUR,PSGRNSD
- SET PSGRNSD=+$$LASTREN^PSJLMPRI(DFN,PSGORD)
- IF PSGRNSD
- SET DUR=$$GETDUR^PSJLIVMD(DFN,PSGORD,"P",1)
- IF DUR]""
- Begin DoDot:1
- +40 NEW DURMIN
- SET DURMIN=$$DURMIN^PSJLIVMD(DUR)
- IF DURMIN
- SET PSGFD=$$FMADD^XLFDT(PSGRNSD,,,DURMIN)
- End DoDot:1
- +41 SET PSGOFD=""
- SET PSGSDN=$$ENDD^PSGMI(PSGSD)_U_$$ENDTC^PSGMI(PSGSD)
- SET PSGFDN=$$ENDD^PSGMI(PSGFD)_U_$$ENDTC^PSGMI(PSGFD)
- +42 SET PSGLIN=$$ENDD^PSGMI(PSGLI)_U_$$ENDTC^PSGMI(PSGLI)
- +43 IF '$ORDER(^PS(53.45,PSJSYSP,2,0))
- NEW DRG,DRGCNT
- SET DRGCNT=0
- Begin DoDot:1
- +44 FOR X=0:0
- SET X=$ORDER(^PSDRUG("ASP",+PSGPD,X))
- IF 'X!(DRGCNT>1)
- QUIT
- IF $PIECE($GET(^PSDRUG(+X,2)),U,3)["U"
- SET DRGCNT=DRGCNT+1
- SET DRG=+X
- +45 IF DRGCNT=1
- KILL ^PS(53.45,PSJSYSP,2)
- SET ^PS(53.45,PSJSYSP,2,1,0)=DRG_U_1
- SET ^PS(53.45,PSJSYSP,2,0)="^53.4502^1^1"
- SET PS(53.45,PSJSYSP,2,"B",+DRG,1)=""
- End DoDot:1
- +46 QUIT
- FINISH ;
- +1 ; force display of second screen if CPRS order checks exist
- +2 NEW NSFF,PSGOEF39
- SET NSFF=1
- KILL PSJNSS
- +3 IF $GET(PSGORD)
- IF $DATA(PSGRDTX(+PSGORD))
- Begin DoDot:1
- +4 IF $GET(PSGRDTX(+PSGORD,"PSGRSD"))
- SET PSGSD=PSGRDTX(+PSGORD,"PSGRSD")
- +5 IF $GET(PSGRDTX(+PSGORD,"PSGRFD"))
- SET PSGFD=$SELECT($GET(PSGRDTX(+PSGORD,"PSGRFD")):PSGRDTX(+PSGORD,"PSGRFD"),1:$GET(PSGNEFD))
- End DoDot:1
- KILL PSGRDTX
- +6 NEW PSJCOM
- SET PSJCOM=+$PIECE($GET(^PS(53.1,+PSGORD,.2)),"^",8)
- +7 ;
- +8 ; PSJ*5*222
- +9 ; PSJCT1 is a counter variable. Every piece of a complex order calls PSGOEF.
- +10 ; The only time this code is to look for overlapping admin times is when the
- +11 ; first part of a complex order is being finished. This variable will keep track
- +12 ; of how many "parts" of the complex order have been checked.
- +13 ;
- +14 ; Also, since the user can select multiple complex orders to finish, like selecting
- +15 ; orders 1-2 or 1-3 from the profile, PSJCT1A will keep track of whether the parent
- +16 ; order number is the same as the first parent order number selected for finishing.
- +17 ; Since the PSJCT1 counter variable will still be set if multiple complex orders
- +18 ; are selected, PSJCT1 will be re-set to 1 if the parent complex order number (PSJCT1A) is
- +19 ; not equal to the original parent order number (PSJCOM).
- +20 ;
- +21 SET PSJCT1=$GET(PSJCT1)+1
- +22 IF PSJCT1=1
- SET PSJCT1A=PSJCOM
- +23 IF $GET(PSJCT1A)'=PSJCOM
- SET PSJCT1=1
- SET PSJCT1A=PSJCOM
- +24 ; End of flag setting for PSJ*5*222
- +25 IF $ORDER(^PS(53.1,+PSGORD,12,0))!$ORDER(^PS(53.1,+PSGORD,10,0))
- Begin DoDot:1
- +26 ; there's no second screen to display
- IF $GET(PSJLMX)=1
- QUIT
- +27 SET VALMBG=16
- DO RE^VALM4
- DO PAUSE^VALM1
- End DoDot:1
- +28 DO FULL^VALM1
- +29 IF '$DATA(IOINORM)!('$DATA(IOINHI))
- SET X="IORVOFF;IORVON;IOINHI;IOINORM"
- DO ENDR^%ZISS
- +30 IF $GET(PSJCOM)'=""
- IF $GET(PSJCT1)=1
- Begin DoDot:1
- +31 DO OVERLAP^PSGOEF2
- IF $GET(PSJOVRLP)=1
- Begin DoDot:2
- +32 NEW X,X1,DIR
- +33 WRITE !!,"**WARNING**"
- +34 WRITE !,"The highlighted admin times for these portions of this complex order overlap.",!!
- +35 SET (X,X1)=""
- FOR
- SET X=$ORDER(^TMP("PSJATOVR",$JOB,X))
- IF X=""
- QUIT
- Begin DoDot:3
- +36 SET X1=$GET(^TMP("PSJATOVR",$JOB,X))
- +37 WRITE $SELECT($PIECE(X1,"^",4)=1:IORVON,1:""),"Part "_X,IORVOFF," has a schedule of "_$PIECE(X1,"^",2)_" and admin time(s) of "
- +38 WRITE $SELECT($PIECE(X1,"^",4)=1:IORVON,1:""),$PIECE(X1,"^",3),IORVOFF
- +39 WRITE !
- +40 WRITE $SELECT($GET(PSJOVR("CONJ",X))="A":"AND",$GET(PSJOVR("CONJ",X))="T":"THEN",1:""),!
- End DoDot:3
- +41 WRITE !,"Please ensure the schedules and administration times are appropriate.",!
- +42 SET DIR(0)="EA"
- SET DIR("A")="Press Return to continue..."
- DO ^DIR
- WRITE !
- End DoDot:2
- End DoDot:1
- +43 KILL ^TMP("PSJATOVR",$JOB)
- +44 IF $GET(PSJPROT)=3
- IF '$DATA(PSJTUD)
- IF '$$ENIVUD^PSGOEF1(PSGORD)
- QUIT
- +45 IF $GET(PSGOSCH)]""
- Begin DoDot:1
- +46 NEW PSGOES,PSGS0Y,PSGSCH
- SET X=PSGOSCH
- IF $GET(PSJTUD)
- KILL NSFF
- DO ENOS^PSGS0
- +47 IF '($GET(PSGORD)["P"&($PIECE($GET(^PS(53.1,+PSGORD,0)),"^",24)="R"))
- IF $GET(X)]""&$GET(PSGS0Y)
- IF $GET(PSGAT)=""
- SET PSGAT=PSGS0Y
- +48 IF $GET(PSJNSS)
- SET PSGOSCH=""
- KILL PSJNSS
- +49 IF $GET(PSGORD)["P"
- IF $GET(PSGAT)
- IF $GET(PSGS0Y)
- IF ($GET(PSGOSCH)]"")
- IF PSGAT'=PSGS0Y
- Begin DoDot:2
- +50 SET PSGNSTAT=1
- WRITE $CHAR(7),!!,"PLEASE NOTE: This order's admin times (",PSGAT,")"
- +51 WRITE !?13," do not match the ward times (",PSGS0Y,")"
- +52 WRITE !?13," for this administration schedule (",PSGOSCH,")",!
- +53 SET DIR(0)="EA"
- SET DIR("A")="Press Return to continue..."
- DO ^DIR
- KILL DIR
- WRITE !
- End DoDot:2
- End DoDot:1
- IF $GET(PSGS0XT)'=""
- SET $PIECE(^PS(53.1,+PSGORD,2),"^",6)=PSGS0XT
- +54 IF $GET(PSGS0XT)=""
- SET $PIECE(^PS(53.1,+PSGORD,2),"^",6)=$SELECT($PIECE($GET(ZZND),"^",3)'="":$PIECE(ZZND,"^",3),1:"")
- +55 SET CHK=0
- IF $PIECE($GET(^PS(53.1,+PSGORD,0)),U,24)'="R"
- SET PSGSI=$$ENPC^PSJUTL("U",+PSJSYSP,180,PSGSI)
- +56 IF '$GET(PSJTUD)
- IF $GET(PSJNSS)
- IF ($GET(PSGOSCH)]"")
- DO NSSCONT^PSGS0(PSGOSCH,PSGS0XT)
- KILL PSJNSS
- SET PSGOSCH=""
- +57 SET PSGOEFF=PSGOSCH=""+('$ORDER(^PS(53.45,PSJSYSP,2,0))*10)
- +58 IF PSGOEFF
- SET X=$SELECT(PSGOEFF#2:" a SCHEDULE",1:"")_$SELECT(PSGOEFF=11:" and",1:"")_$SELECT(PSGOEFF>9:" at least one DISPENSE DRUG",1:"")
- +59 IF 'PSGOEFF
- IF (($GET(PSGS0XT)="D")&($GET(PSGAT)=""))
- SET X=" Admin Times"
- SET PSGOEFF=1
- SET PSGOEF39=1
- +60 IF PSGOEFF
- IF X]""
- SET X=X_" before it can be finished."
- +61 IF PSGOEFF
- SET CHK=1
- WRITE $CHAR(7),!!,"PLEASE NOTE: This order must have"
- FOR Q=1:1:$LENGTH(X," ")
- SET Y=$PIECE(X," ",Q)
- IF $LENGTH(Y)+$X>78
- WRITE !
- WRITE Y," "
- +62 IF $GET(PSGOEF39)
- SET PSGOEE=0
- SET PSGOEFF=0
- Begin DoDot:1
- +63 SET F1=53.1
- SET MSG=0
- SET Y=$TEXT(39)
- SET @("PSGFN(39)="_$PIECE(Y,";",7))
- SET PSGOEEF(+$PIECE(Y,";",3))=1
- SET (PSGOEEF,PSGOEE)=1
- WRITE !
- DO @$PIECE($TEXT(39),";",3)
- SET CHK=0
- End DoDot:1
- IF 'PSGOEE
- DO REFRESH^VALM
- GOTO DONE
- +64 IF PSGOEFF=1
- SET F1=53.1
- SET MSG=0
- SET Y=$TEXT(38)
- SET @("PSGFN(38)="_$PIECE(Y,";",7))
- SET PSGOEEF(+$PIECE(Y,";",3))=1
- SET (PSGOEE,PSGOEEF)=1
- WRITE !
- DO @$PIECE($TEXT(38),";",3)
- SET CHK=0
- IF 'PSGOEE
- GOTO DONE
- +65 IF PSGOEFF=11
- SET F1=53.1
- SET MSG=0
- SET Y=$TEXT(32)
- SET @("PSGFN(32)="_$PIECE(Y,";",7))
- SET PSGOEEF(+$PIECE(Y,";",3))=1
- SET (PSGOEE,PSGOEEF)=1
- WRITE !
- DO @$PIECE($TEXT(32),";",3)
- Begin DoDot:1
- +66 SET F1=53.1
- SET MSG=0
- SET Y=$TEXT(38)
- SET @("PSGFN(38)="_$PIECE(Y,";",7))
- SET PSGOEEF(+$PIECE(Y,";",3))=1
- SET (PSGOEE,PSGOEEF)=1
- WRITE !
- DO @$PIECE($TEXT(38),";",3)
- SET CHK=0
- End DoDot:1
- IF 'PSGOEE
- GOTO DONE
- +67 IF PSGOEFF>9
- SET CHK=7
- DO ENDRG^PSGOEF1(+PSGPD,0)
- IF CHK
- DO ABORTACC
- QUIT
- +68 ; check every dispense drug from CPRS
- IF 'PSGOEFF
- DO OC531^PSGOESF
- +69 SET VALMBG=1
- +70 IF 'PSGOEFF&($DATA(PSGORQF))
- DO RE^VALM4
- QUIT
- +71 IF $GET(MSG)
- KILL DIR
- SET DIR(0)="E"
- WRITE !!
- DO ^DIR
- +72 IF PSGOEFF
- IF PSGST=""
- DO GTST^PSGOE6(+PSGORD)
- +73 SET PSJLMFIN=1
- +74 KILL PSJACEPT
- IF $ORDER(^PS(53.1,+PSGORD,12,0))
- SET PSJLMP2=1
- +75 SET PSGOEENO=0
- SET PSGSTAT=$SELECT($PIECE(PSJSYSP0,U,9):"ACTIVE",1:"NON-VERIFIED")
- +76 NEW PSJDOSE,PSJDOX,PSJDSFLG
- +77 DO DOSECHK^PSJDOSE
- +78 IF +$GET(PSJDSFLG)
- SET VALMSG="Dosage Ordered & Dispense Drug are not compatible"
- +79 IF PSGODO=PSGDO
- SET PSGOEEF(109)=""
- +80 IF PSGODO'=PSGDO
- SET PSGOEENO=1
- SET VALMSG="This change will cause a new order to be created "
- +81 DO EN^VALM("PSJU LM ACCEPT")
- +82 IF $GET(PSJNSS)
- Begin DoDot:1
- +83 KILL DIR
- SET DIR(0)="FOA"
- SET DIR("A")="Invalid Schedule"
- DO ^DIR
- KILL DIR
- End DoDot:1
- SET PSGOEEF(26)=""
- KILL PSJACEPT,PSJNSS
- +84 IF $GET(PSGS0XT)="D"
- IF '$GET(PSGS0Y)
- IF '$GET(PSGAT)
- IF ((",P,R,")'[(","_$GET(PSGST)_","))
- Begin DoDot:1
- +85 KILL DIR
- SET DIR(0)="FOA"
- SET DIR("A")=" WARNING - Admin times are required for DAY OF WEEK schedules "
- DO ^DIR
- KILL DIR
- End DoDot:1
- SET PSGOEEF(39)=""
- KILL PSJACEPT
- +86 IF '$GET(PSJACEPT)
- DO ABORTACC
- QUIT
- +87 IF $GET(PSJRNF)
- IF $GET(^PS(53.1,+PSGORD,4))
- Begin DoDot:1
- +88 WRITE $CHAR(7),!!,"ACCEPTING THIS ORDER WILL CHANGE THE STATUS TO ACTIVE."
- +89 SET DIR(0)="Y"
- SET DIR("A")="Do you wish to make this order Active"
- SET DIR("?",1)="Enter ""N"" if you wish to exit without Activating this order,"
- +90 SET DIR("?")="or ""Y"" to continue with the Activation process."
- DO ^DIR
- IF 'Y
- SET Y=-1
- KILL DIR
- End DoDot:1
- +91 IF $GET(PSJRNF)
- IF $GET(Y)=-1
- SET PSJACEPT=0
- DO ABORTACC
- QUIT
- +92 IF $GET(PSJRNF)
- IF $GET(Y)=1
- SET PSGOEAV=1
- +93 IF PSGOEENO
- SET PSJNOO=$$ENNOO^PSJUTL5("E")
- SET PSJACEPT=$SELECT(PSJNOO<0:0,1:1)
- ACCEPT ;
- +1 SET VALMBCK=$SELECT($GET(PSJACEPT):"Q",1:"R")
- +2 IF '$GET(PSJACEPT)
- DO ABORTACC
- QUIT
- +3 KILL PSGOES,PSGRSD,PSGRSDN
- IF PSGOEENO
- DO NEW3^PSGOEE
- IF 'PSGOEENO
- DO UPD^PSGOEF1
- IF $DATA(PSGOEF)!PSGOEENO
- SET PSGCANFL=-1
- +4 DO DONE1^PSGOEE
- +5 DO DONE
- +6 QUIT
- BYPASS ;
- +1 SET PSGCANFL=1
- +2 ;
- DONE ;
- +1 KILL CHK,DA,DIE,DR,DRG,MSG,Q1,Q2,PSGNSTAT
- +2 KILL PSJOVR
- +3 QUIT
- ABORTACC ; Abort Accept process.
- +1 KILL PSJCT1,PSJOVR,PSJOVRLP,PSJCT1A
- +2 DO ABORT^PSGOEE
- KILL PSGOEEF
- DO GETUD^PSJLMGUD(PSGP,PSGORD)
- DO ^PSGOEF
- DO ENSFE^PSGOEE0(PSGP,PSGORD)
- DO INIT^PSJLMUDE(PSGP,PSGORD)
- SET VALMBCK="R"
- SET PSGSD=PSGNESD
- SET PSGFD=PSGNEFD
- QUIT
- +3 ;
- +4 ;
- 31 ;;101^PSGOE8;PSGOPD;PSGPD;101;1
- 32 ;;109^PSGOE8;PSGODO;PSGDO;109;PSGODO]""
- 33 ;;10^PSGOE81;PSGOSD;PSGSD;10;0
- 34 ;;3^PSGOE8;PSGOMR;PSGMR;3;1
- 35 ;;25^PSGOE81;PSGOFD;PSGFD;25;0
- 36 ;;7^PSGOE8;PSGOST;PSGST;7;0
- 37 ;;5^PSGOE82;PSGOSM;PSGSM;5;0
- 38 ;;26^PSGOE8;PSGOSCH;PSGSCH;26;1
- 39 ;;39^PSGOE81;PSGOAT;PSGAT;39;0
- 310 ;;1^PSGOE82;PSGOPR;PSGPR;1;1
- 311 ;;8^PSGOE81;PSGOSI;PSGSI;8;0
- 312 ;;2^PSGOE82;;;2;0
- 313 ;;40^PSGOE82;;;40;0
- +1 ;
- AH ;
- +1 WRITE !!?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."
- +2 QUIT