Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSGOEF

PSGOEF.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. ; Reference to ^PS(55 is supported by DBIA 2191
  1. ; Reference to ^PSDRUG( is supported by DBIA 2192
  1. ; Reference to DOSE^PSSORPH is supported by DBIA 3234.
  1. ;
  1. START ;
  1. I '$D(^PS(53.1,+PSGORD)) W $C(7),!?3,"Cannot find this pending order (#",+PSGORD,")." Q
  1. D NOW^%DTC S PSGDT=+$E(%,1,12) K PSGFDX,PSGEFN,PSGOEEF,PSGOES,PSGONF,PSGRDTX S PSGOES=1,(PSGOEF,PSGOEEF)=0,PSGOEEG=3
  1. I $D(PSJTUD) S PSGDO=$P($G(^PS(53.1,+PSGORD,.3)),U),(PSGPDRG,PSGPD)=PSJCOI,(PSGPDRGN,PSGPDN)=$$OINAME^PSJLMUTL(PSGPD)
  1. I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" S X=PSGSCH D EN^PSGORS0 D
  1. . S:($D(X)&($P($G(^PS(53.1,+PSGORD,2)),"^",5)="")&($P($G(^PS(53.1,+PSGORD,0)),"^",24)="N")) PSGAT=PSGS0Y
  1. . NEW PSJDOX,PSJDOSE,PSJPIECE,PSJUNIT,PSJX,X
  1. . S X=$G(^PS(53.1,+PSGORD,1,1,0)) Q:'+X
  1. . D DOSE^PSSORPH(.PSJDOX,+X,"U")
  1. . I $S('$D(PSJDOX):1,1:+PSJDOX(1)=-1) Q
  1. . S PSJPIECE=$S($P(PSJDOX(1),U)="":3,1:1)
  1. . S X=^PS(53.1,+PSGORD,.2)
  1. . S:PSJPIECE=3 PSJDOSE=$P(X,U,2)
  1. . S:PSJPIECE=1 PSJDOSE=$P(X,U,5),PSJUNIT=$P(X,U,6)
  1. . F X=0:0 S X=$O(PSJDOX(X)) Q:+$G(PSJX)!'X D
  1. .. I PSJPIECE=3,($P(PSJDOX(X),U,3)'=PSJDOSE) Q
  1. .. I PSJPIECE=1,($P(PSJDOX(X),U,1)_$P(PSJDOX(X),U,2)'=(PSJDOSE_PSJUNIT)) Q
  1. .. S:+$P(PSJDOX(X),U,12) $P(^PS(53.45,PSJSYSP,2,1,0),U,2)=+$P(PSJDOX(X),U,12),PSJX=1
  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
  1. D GTST^PSGOE6(+PSGORD)
  1. I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" S PSGSD="" D:PSGS0Y]""
  1. .N PSJX S PSJX=$P($G(^PS(53.1,+PSGORD,0)),U,25) I PSJX="" Q
  1. .I PSJX["U" S PSGSD=$P($G(^PS(55,DFN,5,+PSJX,2)),U,2) Q
  1. .I PSJX["V" S PSGSD=$P($G(^PS(55,DFN,"IV",+PSJX,0)),U,2) Q
  1. .I PSJX["P" S PSGSD=$P($G(^PS(53.1,+PSJX,2)),U,2)
  1. S:PSGSD="" PSGSD=PSGLI
  1. S PSGNEDFD=$$GTNEDFD^PSGOE7("U",+PSGPD)
  1. S:$P($G(PSGNEDFD),U,3)="" $P(PSGNEDFD,U,3)=PSGST ; N PSGOEA S PSGOEA="R"
  1. S (PSGNESD,PSGSD)=$$ENSD^PSGNE3(PSGSCH,PSGS0Y,PSGLI,PSGSD)
  1. ;if this is a renewal order, ignore any 'requested start date' received. Use the system calculated start date.
  1. I $P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" D
  1. . D REQDT^PSJLIVMD(PSGORD)
  1. E D
  1. . S X=$$DSTART^PSJDCU(DFN,$P(^PS(53.1,+PSGORD,0),U,25)) I X]"" S (PSGNESD,PSGSD)=X K PSGRSD
  1. D ; Extend the Default Stop Date if needed for the first renewed order.
  1. .N PSGOEAO,PSGWALLO
  1. .I $P($G(^PS(53.1,+PSGORD,0)),U,24)="R" S PSGOEAO=PSGOEA,PSGOEA="R",PSGWALLO=$P(^PS(55,DFN,5.1),U)
  1. .D ENFD^PSGNE3(PSGLI) S PSGFD=$S($G(PSGRDTX(+PSGORD,"PSGFD")):PSGRDTX(+PSGORD,"PSGFD"),1:PSGNEFD)
  1. .I $P($G(^PS(53.1,+PSGORD,0)),U,24)="R" S PSGOEA=PSGOEAO,$P(^PS(55,DFN,5.1),U)=PSGWALLO
  1. N DUR,PSGRNSD S PSGRNSD=+$$LASTREN^PSJLMPRI(DFN,PSGORD) I PSGRNSD S DUR=$$GETDUR^PSJLIVMD(DFN,PSGORD,"P",1) I DUR]"" D
  1. . N DURMIN S DURMIN=$$DURMIN^PSJLIVMD(DUR) I DURMIN S PSGFD=$$FMADD^XLFDT(PSGRNSD,,,DURMIN)
  1. S PSGOFD="",PSGSDN=$$ENDD^PSGMI(PSGSD)_U_$$ENDTC^PSGMI(PSGSD),PSGFDN=$$ENDD^PSGMI(PSGFD)_U_$$ENDTC^PSGMI(PSGFD)
  1. S PSGLIN=$$ENDD^PSGMI(PSGLI)_U_$$ENDTC^PSGMI(PSGLI)
  1. I '$O(^PS(53.45,PSJSYSP,2,0)) N DRG,DRGCNT S DRGCNT=0 D
  1. .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
  1. .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)=""
  1. Q
  1. FINISH ;
  1. ; force display of second screen if CPRS order checks exist
  1. N NSFF,PSGOEF39 S NSFF=1 K PSJNSS
  1. I $G(PSGORD),$D(PSGRDTX(+PSGORD)) D K PSGRDTX
  1. . S:$G(PSGRDTX(+PSGORD,"PSGRSD")) PSGSD=PSGRDTX(+PSGORD,"PSGRSD")
  1. . S:$G(PSGRDTX(+PSGORD,"PSGRFD")) PSGFD=$S($G(PSGRDTX(+PSGORD,"PSGRFD")):PSGRDTX(+PSGORD,"PSGRFD"),1:$G(PSGNEFD))
  1. N PSJCOM S PSJCOM=+$P($G(^PS(53.1,+PSGORD,.2)),"^",8)
  1. ;
  1. ; PSJ*5*222
  1. ; PSJCT1 is a counter variable. Every piece of a complex order calls PSGOEF.
  1. ; The only time this code is to look for overlapping admin times is when the
  1. ; first part of a complex order is being finished. This variable will keep track
  1. ; of how many "parts" of the complex order have been checked.
  1. ;
  1. ; Also, since the user can select multiple complex orders to finish, like selecting
  1. ; orders 1-2 or 1-3 from the profile, PSJCT1A will keep track of whether the parent
  1. ; order number is the same as the first parent order number selected for finishing.
  1. ; Since the PSJCT1 counter variable will still be set if multiple complex orders
  1. ; are selected, PSJCT1 will be re-set to 1 if the parent complex order number (PSJCT1A) is
  1. ; not equal to the original parent order number (PSJCOM).
  1. ;
  1. S PSJCT1=$G(PSJCT1)+1
  1. I PSJCT1=1 S PSJCT1A=PSJCOM
  1. I $G(PSJCT1A)'=PSJCOM S PSJCT1=1,PSJCT1A=PSJCOM
  1. ; End of flag setting for PSJ*5*222
  1. I $O(^PS(53.1,+PSGORD,12,0))!$O(^PS(53.1,+PSGORD,10,0)) D
  1. .Q:$G(PSJLMX)=1 ; there's no second screen to display
  1. .S VALMBG=16 D RE^VALM4,PAUSE^VALM1
  1. D FULL^VALM1
  1. I '$D(IOINORM)!('$D(IOINHI)) S X="IORVOFF;IORVON;IOINHI;IOINORM" D ENDR^%ZISS
  1. I $G(PSJCOM)'="",$G(PSJCT1)=1 D
  1. . D OVERLAP^PSGOEF2 I $G(PSJOVRLP)=1 D
  1. . . N X,X1,DIR
  1. . . W !!,"**WARNING**"
  1. . . W !,"The highlighted admin times for these portions of this complex order overlap.",!!
  1. . . S (X,X1)="" F S X=$O(^TMP("PSJATOVR",$J,X)) Q:X="" D
  1. . . . S X1=$G(^TMP("PSJATOVR",$J,X))
  1. . . . W $S($P(X1,"^",4)=1:IORVON,1:""),"Part "_X,IORVOFF," has a schedule of "_$P(X1,"^",2)_" and admin time(s) of "
  1. . . . W $S($P(X1,"^",4)=1:IORVON,1:""),$P(X1,"^",3),IORVOFF
  1. . . . W !
  1. . . . W $S($G(PSJOVR("CONJ",X))="A":"AND",$G(PSJOVR("CONJ",X))="T":"THEN",1:""),!
  1. . . W !,"Please ensure the schedules and administration times are appropriate.",!
  1. . . S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR W !
  1. K ^TMP("PSJATOVR",$J)
  1. I $G(PSJPROT)=3,'$D(PSJTUD),'$$ENIVUD^PSGOEF1(PSGORD) Q
  1. I $G(PSGOSCH)]"" D S:$G(PSGS0XT)'="" $P(^PS(53.1,+PSGORD,2),"^",6)=PSGS0XT
  1. .N PSGOES,PSGS0Y,PSGSCH S X=PSGOSCH K:$G(PSJTUD) NSFF D ENOS^PSGS0
  1. .I '($G(PSGORD)["P"&($P($G(^PS(53.1,+PSGORD,0)),"^",24)="R")) I $G(X)]""&$G(PSGS0Y) S:$G(PSGAT)="" PSGAT=PSGS0Y
  1. .I $G(PSJNSS) S PSGOSCH="" K PSJNSS
  1. .I $G(PSGORD)["P",$G(PSGAT),$G(PSGS0Y),($G(PSGOSCH)]"") I PSGAT'=PSGS0Y D
  1. ..S PSGNSTAT=1 W $C(7),!!,"PLEASE NOTE: This order's admin times (",PSGAT,")"
  1. ..W !?13," do not match the ward times (",PSGS0Y,")"
  1. ..W !?13," for this administration schedule (",PSGOSCH,")",!
  1. ..S DIR(0)="EA",DIR("A")="Press Return to continue..." D ^DIR K DIR W !
  1. I $G(PSGS0XT)="" S $P(^PS(53.1,+PSGORD,2),"^",6)=$S($P($G(ZZND),"^",3)'="":$P(ZZND,"^",3),1:"")
  1. S CHK=0 S:$P($G(^PS(53.1,+PSGORD,0)),U,24)'="R" PSGSI=$$ENPC^PSJUTL("U",+PSJSYSP,180,PSGSI)
  1. I '$G(PSJTUD),$G(PSJNSS),($G(PSGOSCH)]"") D NSSCONT^PSGS0(PSGOSCH,PSGS0XT) K PSJNSS S PSGOSCH=""
  1. S PSGOEFF=PSGOSCH=""+('$O(^PS(53.45,PSJSYSP,2,0))*10)
  1. I PSGOEFF S X=$S(PSGOEFF#2:" a SCHEDULE",1:"")_$S(PSGOEFF=11:" and",1:"")_$S(PSGOEFF>9:" at least one DISPENSE DRUG",1:"")
  1. I 'PSGOEFF I (($G(PSGS0XT)="D")&($G(PSGAT)="")) S X=" Admin Times",PSGOEFF=1,PSGOEF39=1
  1. I PSGOEFF,X]"" S X=X_" before it can be finished."
  1. 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," "
  1. I $G(PSGOEF39) S PSGOEE=0,PSGOEFF=0 D I 'PSGOEE D REFRESH^VALM G DONE
  1. .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
  1. 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
  1. 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
  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
  1. I PSGOEFF>9 S CHK=7 D ENDRG^PSGOEF1(+PSGPD,0) I CHK D ABORTACC Q
  1. I 'PSGOEFF D OC531^PSGOESF ; check every dispense drug from CPRS
  1. S VALMBG=1
  1. I 'PSGOEFF&($D(PSGORQF)) D RE^VALM4 Q
  1. I $G(MSG) K DIR S DIR(0)="E" W !! D ^DIR
  1. I PSGOEFF D:PSGST="" GTST^PSGOE6(+PSGORD)
  1. S PSJLMFIN=1
  1. K PSJACEPT I $O(^PS(53.1,+PSGORD,12,0)) S PSJLMP2=1
  1. S PSGOEENO=0,PSGSTAT=$S($P(PSJSYSP0,U,9):"ACTIVE",1:"NON-VERIFIED")
  1. NEW PSJDOSE,PSJDOX,PSJDSFLG
  1. D DOSECHK^PSJDOSE
  1. S:+$G(PSJDSFLG) VALMSG="Dosage Ordered & Dispense Drug are not compatible"
  1. I PSGODO=PSGDO S PSGOEEF(109)=""
  1. I PSGODO'=PSGDO S PSGOEENO=1,VALMSG="This change will cause a new order to be created "
  1. D EN^VALM("PSJU LM ACCEPT")
  1. I $G(PSJNSS) D S PSGOEEF(26)="" K PSJACEPT,PSJNSS
  1. .K DIR S DIR(0)="FOA",DIR("A")="Invalid Schedule" D ^DIR K DIR
  1. I $G(PSGS0XT)="D",'$G(PSGS0Y),'$G(PSGAT),((",P,R,")'[(","_$G(PSGST)_",")) D S PSGOEEF(39)="" K PSJACEPT
  1. .K DIR S DIR(0)="FOA",DIR("A")=" WARNING - Admin times are required for DAY OF WEEK schedules " D ^DIR K DIR
  1. I '$G(PSJACEPT) D ABORTACC Q
  1. I $G(PSJRNF),$G(^PS(53.1,+PSGORD,4)) D
  1. . W $C(7),!!,"ACCEPTING THIS ORDER WILL CHANGE THE STATUS TO ACTIVE."
  1. . 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,"
  1. . S DIR("?")="or ""Y"" to continue with the Activation process." D ^DIR S:'Y Y=-1 K DIR
  1. I $G(PSJRNF),$G(Y)=-1 S PSJACEPT=0 D ABORTACC Q
  1. I $G(PSJRNF),$G(Y)=1 S PSGOEAV=1
  1. I PSGOEENO S PSJNOO=$$ENNOO^PSJUTL5("E"),PSJACEPT=$S(PSJNOO<0:0,1:1)
  1. ACCEPT ;
  1. S VALMBCK=$S($G(PSJACEPT):"Q",1:"R")
  1. I '$G(PSJACEPT) D ABORTACC Q
  1. K PSGOES,PSGRSD,PSGRSDN D:PSGOEENO NEW3^PSGOEE D:'PSGOEENO UPD^PSGOEF1 I $D(PSGOEF)!PSGOEENO S PSGCANFL=-1
  1. D DONE1^PSGOEE
  1. D DONE
  1. Q
  1. BYPASS ;
  1. S PSGCANFL=1
  1. ;
  1. DONE ;
  1. K CHK,DA,DIE,DR,DRG,MSG,Q1,Q2,PSGNSTAT
  1. K PSJOVR
  1. Q
  1. ABORTACC ; Abort Accept process.
  1. K PSJCT1,PSJOVR,PSJOVRLP,PSJCT1A
  1. 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
  1. ;
  1. ;
  1. 31 ;;101^PSGOE8;PSGOPD;PSGPD;101;1
  1. 32 ;;109^PSGOE8;PSGODO;PSGDO;109;PSGODO]""
  1. 33 ;;10^PSGOE81;PSGOSD;PSGSD;10;0
  1. 34 ;;3^PSGOE8;PSGOMR;PSGMR;3;1
  1. 35 ;;25^PSGOE81;PSGOFD;PSGFD;25;0
  1. 36 ;;7^PSGOE8;PSGOST;PSGST;7;0
  1. 37 ;;5^PSGOE82;PSGOSM;PSGSM;5;0
  1. 38 ;;26^PSGOE8;PSGOSCH;PSGSCH;26;1
  1. 39 ;;39^PSGOE81;PSGOAT;PSGAT;39;0
  1. 310 ;;1^PSGOE82;PSGOPR;PSGPR;1;1
  1. 311 ;;8^PSGOE81;PSGOSI;PSGSI;8;0
  1. 312 ;;2^PSGOE82;;;2;0
  1. 313 ;;40^PSGOE82;;;40;0
  1. ;
  1. AH ;
  1. 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."
  1. Q