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

PSJCLOR4.m

Go to the documentation of this file.
PSJCLOR4 ;BIR/JCH - INPATIENT MEDICATIONS PROFILE FOR CLINIC ORDERS ;25 SEP 97 / 7:43 AM
 ;;5.0;INPATIENT MEDICATIONS;**275**;16 DEC 97;Build 157
 ;
 ; Reference to ^PS(55 is supported by DBIA# 2191
 ;
 N PFLG,PSJNEW,PSGPTMP,PPAGE,QFLG S PSJNEW=1
 N PSGLI,PSGWD,PSJAT,PSJPNRB,PSJPWDO,PSJSTOP,PSJTEAM
 ;
EN ;
 G:$D(XQUIT) DONE
 D @$S('$D(PSJEXTP):"^PSIVXU",1:"ENCV^PSGSETU")
 G:$D(XQUIT) DONE S PSGPTMP=0,PPAGE=1 K PSJSEL D @$S($D(PSJEXTP):"P^PSJPDIR",1:"GWP^PSJPDIR") G:$G(PSJSTOP)=1 DONE S:$D(PSJEXTP) PSJSEL("SELECT")="P"
 I $G(PSJSEL("WG"))="^OTHER",PSJSEL("SELECT")="G",PSJSTOP=2 S PSJSEL("SELECT")="C",PSJSEL("RBP")="P"
 D ENL^PSJO3 G:"^N"[PSJOL EN D GO
 ;
DONE ;
 K ^TMP("PSJON",$J),^TMP("PSJ",$J)
 D ENIVKV^PSGSETU K AND,AT,C,CA,DDH,DFN,DN,DOB,DRGI,DRGN,DRGT,FIL,FQC,HDR,I1,J,JJ,MF,NF,O,OD,ON,ON55,P,P1,PDRG,PG,PPN,PRI,PRIV,PSGLMT,PSGOE,PSGONC,PSGONR,PSGONV,PSGORD,PSGSS,PSGSSH,PSGON,PSGPR,PSGPRP
 K PSIVAC,PSIVCT,PSIVREA,PSIVSCR,PSIVUP,PSIVX,CLINIC,JDFN,POP,PSGTIR,PSJEXTP,PSJNKF,DTOUT,DUOUT,Q,STDTE,X,Y,ZTDESC
 K PSJACNWP,PSJACOK,PSJDEV,PSJDBL,PSJION,PSJON,PSJOS,PSJP,PSJSEL,PSJSS,PSJSSH,PSJPRW,PSJPRWN,PSJPRWG,PSJPRWGN
 K PSJOPC,PSJORD,PSJQ,PSJIVOF,PSJOCNT,PSJPR,PSJPRA,PSJPRF,PSJPRP,PSJON,PSJS1,PSJS2,PSJS3,PSJS4,PSJPR,PX,HDT,PSGODT,RF,SD,SLS,SSN,TF,UD,WD,WDP,WT,PSJORIFN,RB,RCT,SUB,XQUIT,ZTOUT
 Q
 ;
GO ;
 S PSJPRP="P",PSJPRA="" G:PSJSEL("SELECT")'="P" DEV
 N DIR S DIR(0)="SAO^P:PROFILE;E:EXPANDED VIEWS;B:BOTH",DIR("A")="Show PROFILE only, EXPANDED VIEWS only, or BOTH: ",DIR("B")="PROFILE",DIR("?")="^D PH^PSJPR" W ! D ^DIR G:"^"[Y EN S PSJPRP=Y
 I "EB"[PSJPRP F  R !!,"Show SHORT, LONG, or NO activity log?  NO// ",AT:DTIME D ALC^PSGVW0 I Q S PSJPRA=AT Q
 G:PSJPRA="^" EN
DEV ;
 S PSJOS=$P(PSJSYSP0,"^",11)
 K ZTSAVE S PSGTIR="ENQ^PSJCLOR4",ZTDESC="INPATIENT PATIENT PROFILE" F X="DFN","PSJSEL(","PSJOL","PSJOS","PSJPRA","PSJPRP","PSGPTMP","PPAGE","PSJEXTP","PSJHDATE" S ZTSAVE(X)=""
 D ENQ
 K DIR S DIR(0)="YO",DIR("A")="Print this profile to a printer",DIR("B")="N" D ^DIR I $G(Y) D ENDEV^PSGTI Q:POP  D:'$D(IO("Q")) ENQ
 Q
 ;
ENQ ;
 S Y="PSJPR" F X="W","WG" S:$D(PSJSEL(X)) @(Y_X)=+PSJSEL(X),@(Y_X_"N")=$P(PSJSEL(X),U,2)
 S PSJACNWP=1 K ^TMP("PSJAT",$J) S PSJPR=IO'=IO(0)!($E(IOST)'="C"),PSGPRP=PSJPRP
 I PSJSEL("SELECT")="P" S PPN="" F  S PPN=$O(PSJSEL("P",PPN)) Q:PPN=""  D  Q:$G(X)?1"^"."^"
 .F DFN=0:0 S (PSGP,DFN)=$O(PSJSEL("P",PPN,DFN)) Q:'DFN  D ENBOTH^PSJAC,PP Q:$G(X)?1"^"."^"
 D:PSJSEL("SELECT")'="P" @("P"_PSJSEL("SELECT")) I PSJPR W:$Y @IOF D ^%ZISC,DONE
 Q
PC ;
 K ^TMP("PSJPR",$J,"OUTPAT")
 S (STDTE,CLINIC,JDFN)=0
 F  S STDTE=$O(^PS(55,"AIVC",STDTE)) Q:STDTE=""  F  S CLINIC=$O(^PS(55,"AIVC",STDTE,CLINIC)) Q:CLINIC=""  D
 . F  S JDFN=$O(^PS(55,"AIVC",STDTE,CLINIC,JDFN)) Q:JDFN=""  I '$D(^TMP("PSJPR",$J,"OUTPAT",JDFN)) S DFN=JDFN K ^TMP("PSJAT",$J) D PAT,PAT1,PJ
 S (STDTE,CLINIC,JDFN)=0
 F  S STDTE=$O(^PS(55,"AUDC",STDTE)) Q:STDTE=""  F  S CLINIC=$O(^PS(55,"AIVC",STDTE,CLINIC)) Q:CLINIC=""  D
 . F  S JDFN=$O(^PS(55,"AUDC",STDTE,CLINIC,JDFN)) Q:JDFN=""  I '$D(^TMP("PSJPR",$J,"OUTPAT",JDFN)) S DFN=JDFN K ^TMP("PSJAT",$J) D PAT,PAT1,PJ
 Q
PJ ;
 S ^TMP("PSJPR",$J,"OUTPAT",JDFN)=""
PG ;
 F PSJPRW=0:0 S PSJPRW=$O(^PS(57.5,"AC",PSJPRWG,PSJPRW)) Q:'PSJPRW  S PSJPRWN=$P($G(^DIC(42,+PSJPRW,0)),"^") I PSJPRWN]"" D PW Q:$G(X)="^"
 Q
PW ;
 K ^TMP("PSJAT",$J) F DFN=0:0 S (DFN,PSGP)=$O(^DPT("CN",PSJPRWN,DFN)) Q:'DFN  D PAT
 D PAT1
 Q
PAT ;
 S RB=$P($G(^DPT(DFN,.101)),U),PPN=$P($G(^(0)),U),X=$S(PSJSEL("RBP")="R":RB,1:PPN),AT=""
 I $D(PSJSEL("TM")) S:RB]"" AT=$O(^PS(57.7,"AWRT",PSJPRW,RB,0)) Q:$S($D(PSJSEL("TM","ALL")):0,AT="":1,1:'$D(PSJSEL("TM",AT)))
 F Y="AT","RB","X" S:@Y="" @Y="ZZ"
 S ^TMP("PSJAT",$J,AT,X,DFN)=""
 Q
PAT1 ;
 K PSJDBL S PSJAT="" F  S PSJAT=$O(^TMP("PSJAT",$J,PSJAT)) Q:PSJAT=""!$G(PSJDBL)  D
 .S PSJPNRB="" F  S PSJPNRB=$O(^TMP("PSJAT",$J,PSJAT,PSJPNRB)) Q:PSJPNRB=""  S (DFN,PSGP)=+$O(^TMP("PSJAT",$J,PSJAT,PSJPNRB,0)) D ENBOTH^PSJAC,PP I $G(X)["^" S:X="^^" PSJDBL=1 Q
 Q
PP ;
 I PSJPRP'="E" D ^PSJO I PSJPRP="P",'PSJPR D:'PSJON READ^PSJUTL Q:$G(X)?1"^"."^"  I PSJON S PSJPRF=1 D ENVW^PSJOE0 K PSGPRF Q
 Q:PSJPRP="P"  I PSJPRP="E" U IO S PSJON=0,PSJDEV=PSJPR D @$S($D(PSJEXTP):"EN^PSJH1,ENGET^PSJO3",1:"EN^PSJO1(3),ENGET^PSJO3")
 I 'PSJPR,PSJSEL("SELECT")'="P",'$D(^TMP("PSG",$J)) D READ^PSJUTL Q
 I PSJPRP'="E",'PSJPR D PP3 Q:$D(DUOUT)!$D(DTOUT)
 S (PSJS1,PSJS2,PSJS3,PSJS4,X)=""
 F PSJQ=0:0 S PSJS1=$O(^TMP("PSJ",$J,PSJS1)) Q:PSJS1=""  F PSJQ=0:0 S PSJS2=$O(^TMP("PSJ",$J,PSJS1,PSJS2)) Q:PSJS2=""  F PSJQ=0:0 S PSJS3=$O(^TMP("PSJ",$J,PSJS1,PSJS2,PSJS3)) Q:PSJS3=""  D PP1
 D:X'["^"&PSJPR BOT^PSJO3 K ^TMP("PSJ",$J) Q
PP1 ;
 F PSJQ=0:0 S PSJS4=$O(^TMP("PSJ",$J,PSJS1,PSJS2,PSJS3,PSJS4)) Q:PSJS4=""  D PP2
 Q
 ;
PP2 ; Display selected order.
 N PSJPRF,PSJLM S PSJORD=PSJS4 I $S(PSJORD["V":1,PSJORD["P":$P($G(^PS(53.1,+PSJORD,0)),U,4)="F",1:0) D  Q
 .S PSJPRF=1 D ENINP^PSIVOPT(PSGP,PSJORD),PP3 Q:$D(DUOUT)!$D(DTOUT)  I PSJPRA'="N" I PSJORD'["P" D ENLOG^PSIVVW1,PP3 Q
 S PSGORD=PSJORD D EN2^PSGVW,PP3 Q:$D(DUOUT)!$D(DTOUT)  I PSJPRA'="N",((PSJS1["A")!(PSJS1["O")) S AT=PSJPRA D ENA^PSGVW0 D PP3
 Q
PP3 S X="" I 'PSJPR K DIR S DIR(0)="E" D ^DIR S:$D(DUOUT)!$D(DTOUT) X="^" I X["^" S (PSJS1,PSJS2,PSJS3,PSJS4)="~"
 Q
 ;
PH ;
 W !!?2,"Enter a 'P' to print ONLY the PROFILE of orders for this patient.  Enter an",!,"'E' to print ONLY the EXPANDED VIEW of the orders for this patient.  Enter a",!,"'B' to have BOTH the profile (first) and the expanded views print."
 W "  Enter an '^'to exit." Q
 ;
ENOR(PSGP) ;S (PSGP,DFN)=+ORVP,PSGP(0)=^DPT(PSGP,0)
 S DFN=+PSGP,PSGP(0)=^DPT(PSGP,0)
ENLM N PSJNEW,PSGPTMP,PPAGE S PSJNEW=1
 S PSGPTMP=0,PPAGE=1
 D ENCV^PSGSETU
 D ENBOTH^PSJAC D:$D(PSJEXTP) CNV^PSJP D ENL^PSJO3 I "^N"'[PSJOL S PSJSEL("SELECT")="P",PSJSEL("P",PSGP(0),PSGP)="",(PSJPRW,PSJPRWG)=0,(PSJPRWN,PSJPRWGN)="",XQUIT="YES" D GO
 ;* S PSJNKF=1 D READ^PSJUTL G DONE
 S PSJNKF=1 G DONE
 Q
 ;
A34 ; Stop date Active Unit Dose
 S MSG=0,PSGF2=34
 K PSGFDX
 I $G(PSJORD),$G(PSGP) I $$COMPLEX^PSJOE(PSGP,PSJORD) S PSGOEE=0 D  Q
 . W !!?5,"Stop Date/Time may not be edited for active complex orders." D PAUSE^VALM1
 . D A34DONE
 W !,"STOP DATE/TIME: "_$S($P(PSGFDN,"^")]"":$P(PSGFDN,"^")_"// ",1:"") R X:DTIME I X="^"!'$T W:'$T $C(7) S PSGOEE=0 D A34DONE Q
 I X="",PSGFD W "   "_$P(PSGFDN,"^") G W34
 I $E(X)="^" D ENFF^PSGOE92 G:Y>0 @Y G A34
 I X="@"!(X?1."?") W:X="@" $C(7),"  (Required)" S:X="@" X="?" D ENHLP^PSGOEM(55.06,34)
 I X=+X,(X>0),(X'>2000000) G A34:'$$ENDL^PSGDL(PSGSCH,X) K PSGDLS S PSGDL=X W " ...dose limit..." D ENE^PSGDL
 K %DT S %DT="ERTX",%DT(0)=PSGSD D ^%DT K %DT G:Y'>0 A34 S (PSGFDX,PSGFD)=+Y,PSGFDN=$$ENDD^PSGMI(PSGFD)_"^"_$$ENDTC^PSGMI(PSGFD)
W34 ;Compare to Start Date
 N Z,MSG
 D DOSE^PSGOE91 I $G(Z)]"",Z>$S($G(PSGFD):PSGFD,1:$G(PSGNEFD)) D  G A34
 . S MSG(1)="There is no administration time that falls between the Start Date/Time"
 . S MSG(2)="and the Stop Date/Time."
 . D EN^DDIOL(.MSG)
 I PSGFD<PSGDT W $C(7),!!?13,"*** WARNING! THE STOP DATE ENTERED IS IN THE PAST! ***",! S MSG=1
 Q
A34DONE ; clean up Active UD Stop Date vars
 K MSG
 Q
A25NV ; Stop Date Non-Verified
 K PSGFDX
 W !,"STOP DATE/TIME: "_$S($P(PSGFDN,"^")]"":$P(PSGFDN,"^")_"// ",1:"") R X:DTIME I X="^"!'$T W:'$T $C(7) S PSGOEE=0 G A25DONE
 I X="",PSGFD S X=$P(PSGFDN,"^") ;W "   "_$P(PSGFDN,"^")
 I $E(X)="^" D ENFF^PSGOE82 G:Y>0 @Y G A25NV
 I X="@"!(X?1."?") W:X="@" $C(7),"  (Required)" S:X="@" X="?" D ENHLP^PSGOEM(53.1,25)
 I X=+X,(X>0),(X'>2000000) G A25NV:'$$ENDL^PSGDL(PSGSCH,X) K PSGDLS S PSGDL=X W " ...dose limit..." D ENE^PSGDL
 K %DT S %DT="ERTX",%DT(0)=PSGSD D ^%DT K %DT G:Y'>0 A25NV S (PSGFDX,PSGFD,PSGNEFD)=+Y,PSGFDN=$$ENDD^PSGMI(PSGFD)_"^"_$$ENDTC^PSGMI(PSGFD)
W25 ; Loop Stop Date NV
 N Z,MSG
 D DOSE^PSGOE81 I $G(Z)]"",Z>PSGNEFD D  G A25NV
 . S MSG(1)="There is no administration time that falls between the Start Date/Time"
 . S MSG(2)="and the Stop Date/Time."
 . D EN^DDIOL(.MSG)
 I PSGFD<PSGDT W $C(7),!!?13,"*** WARNING! THE STOP DATE ENTERED IS IN THE PAST! ***",! G A25NV
 Q
A25DONE ; NV Stop Date Done
 D EFDNV^PSJUTL
 K MSG
 Q
A25V(DFN,ON) ; Stop Date Active IV
 N X,TMPY,DIR
A25V2 ; IV Stop Date Continued
 I P("IVRM")]"",$S(P(3)<P(2):1,$G(PSIVAC)["E":0,1:1) S PSIVSITE=$G(^PS(59.5,+P("IVRM"),1)),$P(PSIVSITE,"^",20,21)=$G(^PS(59.5,+P("IVRM"),5)) D ENSTOP^PSIVCAL
 I $G(ON)["V"!($G(ON)["U") I $$COMPLEX^PSJOE(DFN,ON) D  Q
 .Q:$G(PSJBKDR)  W !!?5,"This is a Complex Order. Stop Date may not be edited at this point." D PAUSE^VALM1
 S Y=P(3) X ^DD("DD") W !,"STOP DATE/TIME: "_$S(Y]"":Y_"// ",1:"") R X:DTIME S:'$T X=U S:X=U DONE=1 Q:X=""&P(2)  I $E(X)=U!(X=""&P(2)) Q
 I X="@"!(X["?") W $C(7),"  (Required)" S F1=53.1,F2=25,X="?" D ENHLP^PSIVORC1 G A25V2
 K %DT S:X="" X=$G(Y) S:X="" X=P(3) S %DT="TE" D:X'=+X ^%DT
 I X=+X,X>0,X'>2000000 G A25V2:'$$ENDL^PSGDL(P(9),X) D ENDL^PSIVSP
 S TMPY=Y I TMPY["^" S PSJQMSG=0 Q
 I $E(TMPY)="?" K DIR,X,Y D ENHLP^PSGOEM(55.06,10) S PSJQMSG=1 G A25V2
 I TMPY'["." W $C(7),!?5," Time is REQUIRED. Re-enter Start Date. " S PSJQMSG=1 G A25V2
 D DOSE^PSIVEDT1
 I $G(X)="" S X=Y
 I $G(X)="" S X=P(3)
 I $G(Z)]"",Z>X D  G A25V2
 . W !,"There is no administration time that falls between the Start Date/Time"
 . W !,"and Stop Date/Time.",!
 S X=Y S:Y<1!Y'["." X="" G:Y'>0 A25V2 S P(3)=+Y,PSGFDX=1
 Q