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

PSGOEC.m

Go to the documentation of this file.
  1. PSGOEC ;BIR/CML3-CANCEL ORDERS ;02 Mar 99 / 9:29 AM
  1. ;;5.0;INPATIENT MEDICATIONS ;**23,58,110,175,201,134,181,260,288,257,299,327**;16 DEC 97;Build 114
  1. ;
  1. ; Reference to ^PS(55 is supported by DBIA# 2191.
  1. ; Reference to ^PSSLOCK is supported by DBIA 2789.
  1. ;
  1. ENA ; all orders
  1. 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)"
  1. 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
  1. 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
  1. E F PSGDA=0:0 S PSGDA=$O(^PS(53.1,"AC",PSGP,PSGDA)) Q:'PSGDA I @ND1 Q
  1. E G DONE
  1. W !!,"SOME OR ALL OF THESE ORDERS HAVE" D ENUMK^PSGOEM Q:%'=1
  1. W !!,"...a few moments, please..." S PSGAL("C")=PSJSYSU*10+21400
  1. 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
  1. F PSGDA=0:0 S PSGDA=$O(^PS(53.1,"AC",PSGP,PSGDA)) Q:'PSGDA I @ND1 W "." D RS
  1. W " . . . DONE!" G DONE
  1. ENCA ;
  1. 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
  1. 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
  1. I S PSJNOO=$$ENNOO^PSJUTL5("D") I PSJNOO<0!('$$REQPROV) D G DONE
  1. .W !!,$C(7),"No changes made to this order." D PAUSE^VALM1
  1. 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
  1. 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
  1. 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
  1. W " . . . DONE!" K PSGORD G DONE
  1. ENO(PSGP,PSGORD) ; single order
  1. I PSGSTAT="D" W !,"This order has already been DISCONTINUED." D PAUSE^VALM1 Q
  1. 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)))
  1. S PSJCOM=+$S(PSGORD["U":$P($G(^PS(55,PSGP,5,+PSGORD,.2)),"^",8),1:$P($G(^PS(53.1,+PSGORD,.2)),"^",8))
  1. I 'CF,PSJCOM W !!,"This order is part of a complex order and CANNOT be marked for discontinuation." Q
  1. I $$PNDRNOK(PSGORD) N PSJDCTYP S PSJDCTYP=$$PNDRNA(PSGORD) D:(PSJDCTYP=1!(PSJDCTYP=2)) PNDRN($G(PSJDCTYP),PSGORD) G DONE
  1. ;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)
  1. ;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 %=$S($G(PSJOCFLG):2,1:1) D YN^DICN Q:% D ENCOM^PSGOEM
  1. ;I %<0 S VALMBCK="" Q
  1. 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)
  1. I PSJCOM F W !!,"Do you want to discontinue this series of complex orders" S %=$S($G(PSJOCFLG):2,1:1) D YN^DICN Q:% D ENCOM^PSGOEM
  1. I 'PSJCOM,CF,'$D(PSJDCDTF) F W !!,"Do you want to discontinue this order" S %=$S($G(PSJOCFLG):2,1:1) D YN^DICN Q:% D ENCOM^PSGOEM I %<0 S VALMBCK="" Q
  1. I 'PSJCOM,CF,$D(PSJDCDTF) F W !!,"Enter DC to discontinue the above order or press <RETURN> to continue:" S %=$S($G(PSJOCFLG):2,1:1) D TST4DC W:%=2 !,"No action taken!" Q:% D ENDC^PSGOEM I %<0 S VALMBCK="" Q
  1. I 'PSJCOM,'CF,'$D(PSJDCDTF) F W !!,"Do you want mark this order for discontinuation" S %=$S($G(PSJOCFLG):2,1:1) D YN^DICN Q:% D ENCOM^PSGOEM I %<0 S VALMBCK="" Q
  1. 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"
  1. 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!"
  1. G DONE
  1. SOC ;
  1. 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..."
  1. E I CF,'($G(PSJDCTYP)=2) S PSJNOO=$$ENNOO^PSJUTL5("D") I PSJNOO<0 D ABORT^PSGOEE G DONE
  1. ; prompt for requesting provider
  1. I '($G(PSJDCTYP)=2) I CF,'$$REQPROV D ABORT^PSGOEE G DONE
  1. K DA D NOW^%DTC S PSGDT=%,T=$E("T",'PSJSYSU),PSGALR=20,DA=+PSGORD,DA(1)=PSGP
  1. I 'PSJCOM D
  1. .I PSGORD["U" D ASET:CF,AC
  1. .I PSGORD'["U" D NSET:CF,NC
  1. I PSJCOM N COMFLG S COMFLG=0 D
  1. . I PSGORD["P" Q:('$$LOCK^PSJOEA(PSGP,PSJCOM)) D
  1. .. N O S O="" F S O=$O(^PS(53.1,"ACX",PSJCOM,O)) Q:O="" S (PSGORD,PSJORD)=O_"P" D NSET,NC
  1. .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
  1. .. Q:OO=PSGORD I '$$LS^PSSLOCK(DFN,OO) S COMFLG=1 Q
  1. 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
  1. . 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
  1. .. 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
  1. . I OO["U" N PSGORD,PSJORD S (PSGORD,PSJORD)=OO D ASET^PSGOEC,AC^PSGOEC
  1. K:+$$ISCLOZ^PSJCLOZ(,,,,$G(PSGDN)) ^XTMP("PSJ4D-"_DFN) ;p357 clear clozapine 4-day supply
  1. Q
  1. D1 N %,DA,DIE,DIU,STP,NSTOP
  1. 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"
  1. 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
  1. 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))
  1. D:'$D(PSJIVORF) ORPARM^PSIVOREN Q:'PSJIVORF ;* S ORIFN=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,21) Q:'ORIFN
  1. Q
  1. OUT ;
  1. W $S(PSJCOM:"...ORDER ",1:"...ORDERS "),$S(CF:"DISCONTINUED!",1:"MARKED!") S PSGCANFL=1
  1. DONE ;
  1. K CF,DA,DIE,DP,DR,ORIFN,ORETURN,PSGAL,PSGALR,PSGDA,SD,ST,T,UCF,Y,PSJDCTYP Q
  1. ASET ;
  1. S DIE="^PS(55,"_PSGP_",5,",DR="136////@;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:"")
  1. Q
  1. NSET ;
  1. 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
  1. AC ;
  1. 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
  1. I 'CF,$D(PSJSYSO) S PSGORD=+PSGORD_"A",PSGPOSA="C",PSGPOSD=PSGDT D ENPOS^PSGVDS
  1. 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)=""
  1. I '$D(PSJSYSL) S PSJSYSL=""
  1. 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
  1. S ORIFN=$P($G(^PS(55,PSGP,5,+PSGORD,0)),U,21) D:ORIFN DCOR^PSGOECS
  1. Q
  1. NC ;
  1. D KILL531^PSJIMO1(PSGP,"",+PSGORD)
  1. I 'CF S $P(^PS(53.1,+PSGORD,4),"^",11,14)="^1^"_DUZ_U_PSGDT
  1. I 'CF,$D(PSJSYSO) S PSGORD=+PSGORD_"N",PSGPOSA="C",PSGPOSD=PSGDT D ENPOS^PSGVDS
  1. Q:'CF S PSGSTAT=$P($G(^PS(53.1,+PSGORD,0)),U,9),PSGORIFN=$P($G(^(0)),U,21)
  1. 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
  1. I PSGSTAT="U" K DA S DA=+PSGORD,DIK="^PS(53.1," D ^DIK
  1. I PSGORIFN S ORIFN=PSGORIFN D DCOR^PSGOECS
  1. Q
  1. T ;
  1. F W !!,"Is this due to the patient being transferred" S %=2 D YN^DICN Q:% D ENCTM^PSGOEM1
  1. S T=$S(%<0:"^",1:$E("T",%=1)) Q
  1. RS ;
  1. ; naked ref below is from variable ND1, ^PS(53.1,PSGDA,4)
  1. S $P(^(4),U,11,14)="^^^" Q
  1. ;
  1. REQPROV() ;
  1. I $G(PSJDCTYP)=2 Q 1
  1. K PSJDCPRV,DIC,DUOUT,DTOUT,Y
  1. N PROVIDER,PROVNAME,RESULT,RSB S RESULT=0
  1. S PROVIDER=+$P($G(^PS(55,DFN,5.1)),"^",2),PROVNAME=""
  1. I PROVIDER>0 D
  1. .S DIC=200,DR="53.1;53.4",DIQ="RSB",DIQ(0)="I",DA=PROVIDER D EN^DIQ1
  1. .K DIC,DR,DA,DIQ
  1. .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
  1. ..S DIC=200,DA=PROVIDER,DR=".01",DIQ="RSB",DIQ(0)="E" D EN^DIQ1
  1. ..S PROVNAME=$G(RSB(200,PROVIDER,.01,"E")) K DA,DIQ,DR
  1. K DIC S DIC=200,DIC(0)="AEMQZ"
  1. S:PROVNAME]"" DIC("B")=PROVNAME
  1. S DIC("A")="Requesting PROVIDER: "
  1. S DIC("S")="I $D(^(""PS"")),^(""PS""),$S('$P(^(""PS""),""^"",4):1,1:$P(^(""PS""),""^"",4)>DT)" D ^DIC K DIC
  1. I +Y>0,'$D(DUOUT),'$D(DTOUT) S RESULT=1,PSJDCPRV=+Y
  1. Q RESULT
  1. ;
  1. PNDRNA(ORDER) ; Ask Discontinue Pending Renewal only, or both Pending Renew and Renewed Order
  1. ; Perform this action only for pending renewals
  1. I '$G(ORDER)!'($G(ORDER)["P") Q 3
  1. ; Quit if original order is no longer active
  1. N ORIGORD,ORIGSTOP S ORIGORD=$P($G(^PS(53.1,+ORDER,0)),"^",25) Q:'ORIGORD D I ORIGSTOP<$G(PSGDT) Q 1
  1. .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:"")
  1. N NDP2
  1. S NDP2=^PS(53.1,+ORDER,.2) S DRG=NDP2,DO=$P(DRG,"^",2) S DRG=$$ENPDN^PSGMI($P(DRG,"^"))
  1. S ND2=^PS(53.1,+ORDER,2) S SCH=$P(ND2,"^"),START=$P(ND2,"^",2),START=$$FMTE^XLFDT(START,2)
  1. W !!?5,DRG_" "_DO
  1. W !?5,"This order has a pending status. If this pending order"
  1. W !?5,"is discontinued, the original order may still be active."
  1. S DIR("A")="Select order(s) to discontinue"
  1. S DIR(0)="S^1:DC BOTH Orders;2:DC Pending Order;3:Cancel - No Action Taken"
  1. S DIR("L",1)="1 - DC BOTH Orders"
  1. S DIR("L",2)="2 - DC Pending Order"
  1. S DIR("L",3)="3 - Cancel - No Action Taken" D ^DIR
  1. ; Reverse order - Y=1 - Pending only Y=2:BOTH
  1. S Y=$S(Y=1:2,Y=2:1,1:3)
  1. Q Y
  1. ;
  1. PNDRN(PSJDCTYP,ORDER) ; Perform Discontinue action for Pending order only or both Pending and Renewed
  1. ; Perform this action only for pending renewals
  1. N PSGORD S PSGORD=ORDER
  1. Q:'$G(PSGORD)!'($G(PSGORD)["P")
  1. I PSJDCTYP=1 G SOC
  1. I PSJDCTYP=2 S PSJDCTYP=1 D SOC Q:'$G(PSJDCTYP) D
  1. .I ($G(PSJNOO)<0) Q
  1. .N ND5310 S ND5310=$G(^PS(53.1,+PSGORD,0))
  1. .N PSGORD S PSGORD=$P(ND5310,"^",25) I PSGORD S PSJDCTYP=2 D SOC K PSJDCTYP
  1. Q
  1. ;
  1. PNDRNOK(ORDER) ; Execute DC Pending Renew enhancement only if
  1. ; 1) Renewal order is pending/non-verified, and
  1. ; 2) Original order is not DC'd or Expired
  1. Q:'$G(PSGORD)!'($G(PSGORD)["P") 0
  1. N ORIGORD,ORIGSTOP S ORIGORD=$P($G(^PS(53.1,+ORDER,0)),"^",25) Q:'ORIGORD 0 D I ORIGSTOP<$G(PSGDT) Q 0
  1. .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:"")
  1. Q:'($P($G(^PS(53.1,+PSGORD,0)),U,24)="R") 0
  1. Q 1
  1. ;
  1. TST4DC ; Test for DC at prompt
  1. R X:$S($D(DTIME):DTIME,1:300) I '$T S %=2 Q
  1. S %=$S(X="DC":1,X="Dc":1,X="dc":1,X="dC":1,X="D":1,X="d":1,X="":2,X="^":2,X]"":"",1:2)
  1. Q