VistA-WorldVistAEHR/r/INPATIENT_MEDICATIONS-PSJ-P.../PSJHL6.m

102 lines
5.5 KiB
Mathematica
Raw Normal View History

2009-11-29 13:37:14 -05:00
PSJHL6 ;BIR/LDT-ACTIONS ON HL7 MESSAGES FROM OE/RR (CONT) ;02 Mar 99 / 9:26 AM
;;5.0; INPATIENT MEDICATIONS ;**1,11,27,34,40,42,51,59,88,98**;16 DEC 97
;
; Reference to EN^ORERR is supported by DBIA# 2187.
; Reference to ^PS(55 is supported by DBIA# 2191.
;
CANCEL ;Cancel or Discontinue orders thru OE/RR
N DA,DR,DIE,STATUS,STPDT,NODE,NODE2,PSREASON,PSIVACT,PSIVALT,ON55,PSIVREA,PSIVALCK,P
S NODE=$G(@(RXORDER_"0)")),NODE2=$G(@(RXORDER_"2)"))
I 'NODE S PSREASON="Invalid Pharmacy order number" D Q
.S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(PSREASON_"/DC Msg",.PSJMSG)
.D EN1^PSJHLERR(PSJHLDFN,$S(PSOC="CA":"UC",1:"UD"),$P(ORDER,U),PSREASON)
I RXON["P",PSJHLDFN'=$P(NODE,U,15) S ORDCON="Patient does not match/Discontinue Msg" D Q
.S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(ORDCON,.PSJMSG)
.D EN1^PSJHLERR(PSJHLDFN,$S(PSOC="CA":"UC",1:"UD"),$P(ORDER,U),ORDCON)
S $P(@(RXORDER_"0)"),"^",21)=$P(ORDER,"^",1)
S STATUS=$S(RXON["V":$P(NODE,"^",17),1:$P(NODE,"^",9))
S STPDT=$S(RXON["V":$P(NODE,"^",3),1:$P(NODE2,"^",4))
I "AHNOPR"'[STATUS D @STATUS S PSREASON=PSREASON_" orders may not be "_$S(PSOC="CA":"cancelled",1:"discontinued") D EN1^PSJHL2(PSJHLDFN,$S(PSOC="CA":"UC",1:"UD"),RXON,PSREASON) Q
S:(RXON["A")!(RXON["U")!(RXON["V") DA(1)=PSJHLDFN,DA=+RXON
D NOW^%DTC
S DIE=$S(RXON["V":"^PS(55,"_PSJHLDFN_",""IV"",",(RXON["N")!(RXON["P"):"^PS(53.1,",1:"^PS(55,"_PSJHLDFN_",5,"),DA=+RXON
S DR=$S(RXON["V":"100////D;116////^S X=STPDT;.03////",(RXON["N")!(RXON["P"):"28////D;25////",1:"25////^S X=STPDT;28////D;34////")_$S($G(ORDCON)="A"&($G(PSJASTP)'=""):$G(PSJASTP),1:%)
I RXON["A"!(RXON["U") S PSGAL("C")=$S($G(ORDCON)="A":1040,1:4000) D ^PSGAL5
I RXON["V" S PSIVACT=1,PSIVALT=$S($G(ORDCON)="A":"",1:2),PSIVAL=$S($G(ORDCON)="A":"AUTO DISCONTINUED (TREATING SPECIALTY TRANSFER)",1:""),ON55=RXON,PSIVREA="D",P(3)=STPDT
S:$G(ORDCON)="A" DR=$S(RXON["V":DR_";121////1",RXON["N"!(RXON["P"):DR_";42////1",1:DR_";49////1")
D ^DIE
S:$G(ORDCON)="A" $P(^PS(55,PSJHLDFN,5.1),"^")=""
I RXON["V" N DFN S DFN=PSJHLDFN D LOG^PSIVORAL
D EN1^PSJHL2(PSJHLDFN,$S(PSOC="CA":"CR",1:"DR"),RXON)
D NOW^%DTC I "ANR"[STATUS I STPDT<% D EXPIR Q
D AUE(PSJHLDFN,RXON)
Q
;
HOLD ;Place orders on hold thru OE/RR and check for expired orders
N DA,DR,DIE,STATUS,STPDT,NODE,NODE2,PSREASON,PSIVACT,PSIVALT,PSIVREA,ON55
S NODE=$G(@(RXORDER_"0)")),NODE2=$G(@(RXORDER_"2)"))
I 'NODE S PSREASON="Invalid Pharmacy order number" D Q
.S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(PSREASON_"/Hold Msg",.PSJMSG)
.D EN1^PSJHLERR(PSJHLDFN,"UH",$P(ORDER,U),PSREASON)
S $P(@(RXORDER_"0)"),"^",21)=$P(ORDER,"^",1)
S STATUS=$S(RXON["V":$P(NODE,"^",17),1:$P(NODE,"^",9))
S STPDT=$S(RXON["V":$P(NODE,"^",3),1:$P(NODE2,"^",4))
D NOW^%DTC I "ANR"[STATUS I STPDT<% D EXPIR
I STATUS'="A" D @STATUS S PSREASON=PSREASON_" orders may not be placed on hold" D EN1^PSJHL2(PSJHLDFN,"UH",RXON,PSREASON) Q
I STATUS="A" S DA(1)=PSJHLDFN,DA=+RXON,DIE=$S(RXON["V":"^PS(55,"_PSJHLDFN_",""IV"",",1:"^PS(55,"_PSJHLDFN_",5,"),DR=$S(RXON["V":"100////H;120////1;149////1",1:"28////H;56////1;59////A;59.1////1;60////@;61////@;62////@;58////"_%)
I RXON["A"!(RXON["U") S PSGAL("C")=8500 D ^PSGAL5
S:RXON["V" PSIVACT=1,PSIVALT=2,PSIVREA="H",ON55=RXON
D ^DIE
I RXON["V" N DFN S DFN=PSJHLDFN D LOG^PSIVORAL
D EN1^PSJHL2(PSJHLDFN,"HR",RXON)
D NOW^%DTC I "ANR"[STATUS I STPDT<% D EXPIR Q
D AUE(PSJHLDFN,RXON)
Q
;
UNHOLD ;Change status of orders palced on hold thru OE/RR & check for expired orders
N DA,DR,DIE,STATUS,STPDT,NODE,NODE2,NODE4,HFLAG,PSREASON,PSIVACT,PSIVALT,PSIVREA,ON55
S NODE=$G(@(RXORDER_"0)")),NODE2=$G(@(RXORDER_"2)")),NODE4=$G(@(RXORDER_"4)"))
I 'NODE S PSREASON="Invalid Pharmacy order number" D Q
.S X="ORERR" X ^%ZOSF("TEST") I D EN^ORERR(PSREASON_"/Unhold Msg",.PSJMSG)
.D EN1^PSJHLERR(PSJHLDFN,"UR",$P(ORDER,U),PSREASON)
S $P(@(RXORDER_"0)"),"^",21)=$P(ORDER,"^",1)
S STATUS=$S(RXON["V":$P(NODE,"^",17),1:$P(NODE,"^",9))
S STPDT=$S(RXON["V":$P(NODE,"^",3),1:$P(NODE2,"^",4))
S HFLAG=$S(RXON["V":$P(NODE,"^",10),1:$P(NODE4,"^",26))
I 'HFLAG S PSREASON="Orders placed on hold by Pharmacy may not be removed from hold through CPRS." D EN1^PSJHL2(PSJHLDFN,"UR",RXON,PSREASON) Q
I "H"'[STATUS D @STATUS S PSREASON=PSREASON_" orders may not be taken off hold" D EN1^PSJHL2(PSJHLDFN,"UR",RXON,PSREASON) Q
I STATUS="H" S DA(1)=PSJHLDFN,DA=+RXON,DIE=$S(RXON["V":"^PS(55,"_PSJHLDFN_",""IV"",",1:"^PS(55,"_PSJHLDFN_",5,")
D NOW^%DTC
S DR=$S(RXON["V":"100////A;120////@;149////@",1:"28////A;56////@;57////@;58////@;59////@;59.1////@;60////1;62////"_%)
I RXON["A"!(RXON["U") S PSGAL("C")=8000 D ^PSGAL5
S:RXON["V" PSIVACT=1,PSIVALT=2,PSIVREA="U",ON55=RXON
D ^DIE
I RXON["V" N DFN S DFN=PSJHLDFN D LOG^PSIVORAL
D EN1^PSJHL2(PSJHLDFN,"OR",RXON)
D NOW^%DTC I "A"[STATUS I STPDT<% D EXPIR Q
D AUE(PSJHLDFN,RXON)
Q
EXPIR ;Change status of order to expired and send notice to OE/RR
N DA,DIE,DR,PSGPO,PSIVACT
S STATUS="E",(PSGPO,PSIVACT)=1,DA=+RXON,DA(1)=PSJHLDFN,DIE=$S(RXON["V":"^PS(55,"_PSJHLDFN_",""IV"",",1:"^PS(55,"_PSJHLDFN_",5,"),DR=$S(RXON["V":"100////E",1:"28////E") D ^DIE
S PSJHLMTN="ORM" D EN1^PSJHL2(PSJHLDFN,"SC",RXON) S PSJHLMTN="ORR"
;D AUE(PSJHLDFN,RXON)
Q
AUE(PSJHLDFN,ON) ; Set "AUE" xref for 55.06 if hold/unhold
I ON["A"!(ON["U") S ^PS(55,"AUE",PSJHLDFN,+ON)=""
Q
;
A S PSREASON="Active" Q
D S PSREASON="Discontinued" Q
I S PSREASON="Incomplete" Q
N S PSREASON="Non-verified" Q
U S PSREASON="Unreleased" Q
P S PSREASON="Pending" Q
DE S PSREASON="Discontinued (edit)" Q
E S PSREASON="Expired" Q
H S PSREASON="Hold" Q
R S PSREASON="Renewed" Q
RE S PSREASON="Reinstated" Q
DR S PSREASON="Discontinued (renewal)" Q
O S PSREASON="On call" Q