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

PSJLIACT.m

Go to the documentation of this file.
PSJLIACT ;BIR/MV - IV ACTION ;28 Jul 98  8:50 AM
 ;;5.0;INPATIENT MEDICATIONS;**15,47,62,58,82,97,80,110,111,134,181,247,260,275,257,299,281,346,256,347,344**;16 DEC 97;Build 7
 ;
 ; Reference to ^PS(55 is supported by DBIA 2191.
 ; Reference to MAIN^TIUEDIT is supported by DBIA 2410.
 ; Reference to ^TMP("PSODAOC",$J supported by DBIA 6071.
 ;
DC ; Discontinue order
 K PSGORQF
 D HOLDHDR^PSJOE
 S PSJCOM=+$S(PSJORD["V":$P($G(^PS(55,DFN,"IV",+PSJORD,.2)),"^",8),1:$P($G(^PS(53.1,+PSJORD,.2)),"^",8))
 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)
 I PSJCOM F  W !!,"Do you want to discontinue this order" S %=1 D YN^DICN Q:%  D ENCOM^PSGOEM
 I PSJCOM,%'=1 S VALMBK="" Q
 I $G(ON55)["P",$G(PSIVOORD) S PSJORD=ON55 ;*247 - Correct DCing newly copied orders
 I PSJORD["V" D DC^PSIVORA D:'$G(PSJOCFLG) EN^PSJLIORD(DFN,ON) Q
 I PSJORD["P" N ON S ON=PSJORD D DISCONT^PSIVORC
 S VALMBCK="Q"
 Q
ACEDIT ; Display LM screen and AC and EDit actions
 D EN^PSJLIVMD
 S VALMBCK=$S($G(PSIVACEP):"Q",1:"R")
 Q
AEEXIT ; Call for EXIT CODE in PSJ LM IV AC/EDIT
 I ON["V" K PSGORQF D GT55^PSIVORFB ;RTC 340818
 I ON["P" D GT531^PSIVORFA(DFN,ON) D:P("OT")'="I" GTDATA^PSJLIFN
 D EN^PSJLIVMD
 K PSIVENO
 Q
EDIT ; Edit order
 K PSIVFN1
 I $D(PSGACT),PSGACT'["E" W !,"This order may not be edited." D PAUSE^VALM1 Q
 D EDIT1
 Q:$D(PSIVNBD)!($G(PSIVCOPY)&'$G(PSIVENO))
 D EN^PSJLIVMD
 S VALMBCK=$S($G(PSIVFN1):"Q",1:"R")
 ;S PSJEDFLG=1 ;PSJ*346  Prevent double order display
 I $G(PSGORQF) S VALMBCK="Q" K PSIVENO,PSJOCCHK ;RTC 340818
 Q
EDIT1 ;
 K PSGORQF ;RTC 340818
 ;Ensure P() is defined
 I $D(P)<10 S XQORQUIT=1,P("PON")="",PSIVNBD=1 D  Q
 .W !,"WARNING: An error has occurred. Changes will not be saved"
 .D PAUSE^VALM1
 .S VALMBCK="Q"
 I "ANP"'[P(17) W !,"You cannot edit an inactive order" D PAUSE^VALM1 Q
 S:$G(ON55)="" ON55=$G(PSJORD)
 D HOLDHDR^PSJOE
 N PSIEDITO S PSIEDITO=1
 ;* Edit a new back door order
 I ($G(ON55)["V"&($G(P("21FLG"))="")) D  Q
 . D GSTRING^PSIVORE1,GTFLDS^PSIVORFE
 . I $G(ON55)["V",'$G(DONE) D OK^PSIVORE
 . S VALMBCK="Q",PSIVNBD=1
 ;* Edit an active order
 I $G(ON55)["V" NEW PSJEDIT1 D E^PSIVOPT1 D  Q
 . I $G(PSJIVBD) K PSJIVBD D EN^PSJLIORD(DFN,ON)
 . I $G(PSGORQF) K PSIVENO,PSJOCCHK ;RTC 340818
 I $G(ON55)["P" D EDIT^PSIVORC ;Edit incomplete order.
 K P("OVRIDE")
 Q
ACCEPT ; Accept order
 D HOLDHDR^PSJOE
 ;Accept IV from back door.
 I $G(PSJIVBD) K PSJIVBD D OK^PSIVORE S VALMBCK="Q" Q
 ;D:'$G(PSGORQF) IN^PSJOCDS($G(ON),"IV","") Q:$G(PSGORQF)
 I ON["V" D ACCEPT^PSIVOPT1 S:'$G(PSGORQF) PSJDSVFY=1 Q
 S PSIVFN1=1
 D COMPLTE^PSIVORC1
 K ^TMP("PSODAOC",$J)
 S VALMBCK="Q"
 Q
R ; Renewal
 K PSGORQF,PSJOCCHK,PSIVENO
 S PSJREN=1
 D HOLDHDR^PSJOE
 NEW PSIVAC,PSJOLDNM S PSIVAC="PR" K PSGFDX
 S PSJOLDNM("ORD_SCHD")=$P($G(^PS(55,DFN,"IV",+ON,0)),U,9)
 I PSJOLDNM("ORD_SCHD")]"",$$CHKSCHD^PSJMISC2(.PSJOLDNM,"R") K PSJOLDNM Q
 K PSJOLDNM
 D R^PSIVOPT
 D EN^PSJLIORD(DFN,ON)
 K PSJREN,^TMP("PSODAOC",$J)
 Q
H ; Hold
 K PSGORQF
 NEW TEX S TEX="Active order ***"
 D HOLDHDR^PSJOE
 D H^PSIVOPT(DFN,ON,P(17),P(3))
 D:P(17)="A" PAUSE^VALM1
 D EN^PSJLIORD(DFN,ON)
 Q
L ; Activity Log
 NEW PSIVLAB,PSIVLOG,PSJHIS S (PSIVLAB,PSIVLOG)=1
 D EN^PSIVVW1
 D EN^PSJLIVMD
 S VALMBCK="R"
 Q
O ; On Call
 K PSGORQF
 NEW TEX S TEX="Active order ***"
 D HOLDHDR^PSJOE
 D O^PSIVOPT(DFN,ON,P(17),P(3))
 D:P(17)="A" PAUSE^VALM1
 D EN^PSJLIORD(DFN,ON)
 Q
VF ; Make the order active **ENHANCEMENTS MADE IN PSJ*5.0*260
 NEW PSIVCHG,PSGORQF,PSJVFF,PSJOLDNM S PSIVCHG=0
 ;PSJ*5*256 - inform user of old schedule name and quit
 I $S((ON["P"):$P($G(^PS(53.1,+ON,0)),U,24)'="R",(ON["V"):$P($G(^PS(55,+PSGP,"IV",+ON,2)),U,8)'="R",1:0) D  Q:$G(PSGORQF)
 .D FULL^VALM1
 .S PSJOLDNM("ORD_SCHD")=$G(PSGSCH)
 .S PSGORQF=$$CHKSCHD^PSJMISC2(.PSJOLDNM,"V")
 ;IF VALM("TITLE")="ACTIVE IV " W !!,">>>  Verify may not be selected at this point." D PAUSE^VALM1 S VALMBCK="R" Q  ;PSJ*5*281 CCR 6995 Remedy ticket 861870
 ;ELSE  IF $G(PSGSTAT)="NON-VERIFIED",$G(PSJNEWOE)=0 S PSJVFF=1 D EN^PSJGMRA($G(DFN),$G(PSGPD)),IN^PSJOCDS($G(PSGORD),"IV",""),OC^PSIVOC K PSJVFF Q:$G(PSGORQF)
 ;PSGSTAT may not set for IV orders. Checking PSJOCFG so DI,DT is not displayed again for FN, CO, RN...
 IF (($G(PSGSTAT)="NON-VERIFIED")!($G(P(17))="N")&($G(PSJOCFG)="")),'+$G(PSJNEWOE) D
 .S PSJVFF=1 D:'$G(PSJENHOC)&'$G(PSGORQF) OC^PSIVOC D:('$G(PSGORQF)&'$G(PSJDSVFY)) IN^PSJOCDS($G(PSGORD),"IV","") K PSJVFF Q:$G(PSGORQF)
 Q:$G(PSGORQF)
 ELSE  IF '$G(PSGORQF),(ON["V") S ON55=ON D VF1("V","ORDER VERIFIED BY ",1) Q
 ELSE  IF $G(PSIVFN1),(ON["V") S ON55=ON D VF1("V","ORDER VERIFIED BY ",1) Q
 ELSE  IF $G(PSGDEF),(ON["V") S ON55=ON D VF1("V","ORDER VERIFIED BY ",1) Q
 ELSE  IF $G(PSIVCOPY),(ON["V") S ON55=ON D VF1("V","ORDER VERIFIED BY ",1) Q
 D ACTIVE^PSIVORC2
 Q
VF1(PSIVREA,PSIVAL,PSIVLOG) ;
 ;Update 4 node and set activity log.
 ;PSIVREA: the reason use by LOG^PSIVORAL
 ;PSIVAL : the description reason
 ;PSIVLOG: Log an activity if = 1
 K PSGORQF
 I '+$G(OD)!($L($G(OD))>16) K OD
 D:+PSJSYSU=3 ^PSIVORE1
 NEW DIE,DA,DR,PSJX,XX,PSIVACT,PSJRQND
 S PSIVACT=1
 S PSJX=$G(^PS(55,DFN,"IV",+ON55,4)),XX=""
 I $P(PSJX,U)="" S XX=";143////0"
 I $P(PSJX,U,4)="" S XX=XX_U_";142////0"
 D NOW^%DTC
 S DIE="^PS(55,"_DFN_",""IV"",",DA=+ON55,DA(1)=DFN
 I +PSJSYSU=3 S DR="140////"_DUZ_";141////"_$E(%,1,12)_";142////1"_$P(XX,U)
 I +PSJSYSU=1 S DR="16////"_DUZ_";17////"_$E(%,1,12)_";143////1"_$P(XX,U,2)
 I $G(P("PRY"))="D" S DR=DR_";.22////"_+P("IVRM")
 D ^DIE
 ; If pending IV renew is edited during finish, go back and DE the original active order left in RENEWED status
 S PREREN=$S(ON55["V":$G(@(DIE_"+ON55,2)")),1:""),PREREN=$P(PREREN,"^",5) I PREREN D  K PREREN
 . I PREREN["P" S PREREN=$G(@("^PS(53.1,+PREREN,0)")),PREREN=$P(PREREN,"^",25)
 . I PREREN["V" N PRERENOD S PRERENOD=$G(@("^PS(55,DFN,""IV"",+PREREN,0)")) I $P(PRERENOD,"^",17)="R",($G(P("RES"))="E") D
 ..  S DIE="^PS(55,"_DFN_",""IV"",",DA=+PREREN,DA(1)=DFN
 ..  S DR="100////D;.03////"_PSGDT S ORIGSTOP=$P($G(@("^PS(55,DFN,""IV"",+PREREN,2)")),"^",3) I ORIGSTOP S DR=DR_";116////"_ORIGSTOP
 ..  D ^DIE D EN1^PSJHL2(DFN,"SC",PREREN)
 K DR,DIE,DA
 I (+PSJSYSU=3)&($G(P("PRY"))="D") D
 .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
 .Q:Y="N"
 .D MAIN^TIUEDIT(3,.TIUDA,DFN,"","","","",1)
 Q:'$G(PSIVLOG)
 I $G(P("PACT"))]"",+$P(P("PACT"),U,2),+$P(P("PACT"),U,3) D
 . NEW DIC,DA,X,Y,XX,DO D NAME^PSJBCMA1($P(P("PACT"),U,2),.XX)
 . S DIC(0)="L",DA(1)=DFN,DA(2)=+ON55,X=1
 . S DIC="^PS(55,"_DA(1)_",""IV"","_DA(2)_",""A"","
 . 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)
 . D FILE^DICN
 NEW PSIVALCK
 S PSIVREA="V",PSIVALT=""
 S PSIVAL=PSIVAL_$S(+PSJSYSU=3:"PHARMACIST",1:"NURSE")
 D LOG^PSIVORAL K PSIVAL,PSIVREA,PSIVLN
 I $G(PSJORD)["P" S PSIVREA="V",PSIVALT="",PSGRDTX=$G(^PS(53.1,+PSJORD,2.5)) D
 . I $G(PSGRDTX) S PSIVAL="Requested Start Date: "_$$ENDTC^PSGMI($$DATE2^PSJUTL2($P(PSGRDTX,U))) D LOG^PSIVORAL
 . 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
 N DUR I $G(PSJORD) S DUR=$$GETDUR^PSJLIVMD(DFN,+PSJORD,$S(PSJORD["P":"P",1:"IV"),1) I DUR]""  D
 . K DR S DIE="^PS(55,"_DFN_",""IV"",",DA=+ON55,DA(1)=DFN
 . S DR=$S($G(IVLIMIT):"152////"_DUR,1:"151////"_DUR) K IVLIMIT
 . D ^DIE
 S ^TMP("PSODAOC",$J,"IP NEW IEN")=ON55
 D EN1^PSJHL2(DFN,"SC",ON55),SETOC^PSJNEWOC(ON55)
 D:+PSJSYSU=1 EN1^PSJHL2(DFN,"ZV",ON55)
 I '$D(^PS(55,DFN,"IV","CIMOI",+ON55)) D CIMOI^PSJIMO1(DFN,ON55,"",$G(PSJORD))
 E  I +$G(PSJORD) D KILL531^PSJIMO1(DFN,"",PSJORD)
 D GT55^PSIVORFB S OLDON=$P($G(^PS(55,DFN,"IV",+ON55,2)),"^",5),P("OLDON")=OLDON
 N PSJPRIO,PSJSCH,NODE0,NODEP2 S NODE0=$G(^PS(55,DFN,"IV",+ON55,0)),NODEP2=$G(^PS(55,DFN,"IV",+ON55,.2))
 S PSJPRIO=$P(NODEP2,"^",4),PSJSCH=$P(NODE0,"^",9)
 I (",S,A,")[(","_$G(PSJPRIO)_",")!($G(PSJSCH)="NOW")!($G(PSJSCH)["STAT") D NOTIFY^PSJHL4(ON55,DFN,$G(PSJPRIO),$G(PSJSCH))
 Q