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

PSOERXUX.m

Go to the documentation of this file.
  1. PSOERXUX ;BIRM/MFR - eRx Un Process action ;07/19/23
  1. ;;7.0;OUTPATIENT PHARMACY;**700,746**;DEC 1997;Build 106
  1. ;
  1. UNPROC ; Un-Process
  1. I '$D(PSOIEN) D MSG("No eRx IEN found") Q
  1. D FULL^VALM1
  1. N DIR,ERXSTAT,UKEY,PSRXNUM,STAT,MTYPE,RVALUE,RVFLAG,SEQ,CMFLAG,PSODFN,PSOPLCK,DIE,DA,DR,HCOMM,INCOM
  1. N Y,REA,PSONOOR,RCODE,RESP,FDA,PSCAN,PSOCANRC,PSOCANRD,PSOCANRN
  1. ;
  1. ; #1 - Check if status is "Processed"
  1. S ERXSTAT=$$GET1^DIQ(52.49,PSOIEN,1,"E")
  1. I ",PR,RXP,CXP,"'[(","_ERXSTAT_",") D MSG("eRx status must be 'PR','RXP', or 'CXP' to Un-Process") Q
  1. ;
  1. ; #2 - Check if user hold the KEY "PSDRPH"
  1. S UKEY=$O(^DIC(19.1,"B","PSDRPH",0))
  1. I '$D(^VA(200,DUZ,51,"B",UKEY)) D MSG("Cannot Un-Process if you don't hold the KEY 'PSDRPH'") Q
  1. ;
  1. ; #3 - Check if 52.49/.13 exists
  1. S PSRXNUM=$P(^PS(52.49,PSOIEN,0),"^",12)
  1. I 'PSRXNUM D MSG("No prescription number found in eRx") Q
  1. ;
  1. ; #4 - Check 52/zero node
  1. I '$D(^PSRX(PSRXNUM,0)) D MSG("Prescription number not valid") Q
  1. ;
  1. ; #5 - Check Message Type, only "N","RE", and "CX" can be Un-Processed
  1. S MTYPE=$$GET1^DIQ(52.49,PSOIEN,.08,"I")
  1. I ",N,RE,CX,"'[(","_MTYPE_",") D MSG("Cannot Un-Process Message Types other than 'N','RE', or 'CX'") Q
  1. ;
  1. ; #6 - Check Message Type RXRENEWALRESPONSE, it must have a Response Value of "REPLACE"
  1. I MTYPE="RE" D
  1. . S RVALUE=$$GET1^DIQ(52.49,PSOIEN,52.1,"I")
  1. . I RVALUE'="R" S RVFLAG=1
  1. I $G(RVFLAG) D MSG("RXRENEWALRESPONSE does not have a Response Value of 'REPLACE'") Q
  1. ;
  1. ; #7 - Check if original fill, check if partial entered, check if transmitted to CMOP
  1. I $D(^PSRX(PSRXNUM,1)) D MSG("Refill(s) already entered, cannot Un-Process") Q ;Refill request
  1. I $D(^PSRX(PSRXNUM,"P")) D MSG("Partial(s) already entered, cannot Un-Process") Q ;At least 1 partial has been entered
  1. ;
  1. ; #8 - CMOP logic - check if original fill and if not dispensed
  1. I $D(^PSRX(PSRXNUM,4)) D
  1. . S SEQ=0
  1. . F S SEQ=$O(^PSRX(PSRXNUM,4,SEQ)) Q:'SEQ D
  1. . . I ($P($G(^PSRX(PSRXNUM,4,SEQ,0)),"^",3)'=0),($P($G(^PSRX(PSRXNUM,4,SEQ,0)),"^",4)'=3) S CMFLAG=1
  1. I $G(CMFLAG) D MSG("Already transmitted to CMOP, cannot Un-Process") Q
  1. ;
  1. ; #9 - Check 52/100 if value is 5 (Suspended) or 3 (Hold)
  1. S STAT=+$G(^PSRX(PSRXNUM,"STA"))
  1. I STAT'=5,STAT'=3 D MSG("Prescription status is not SUSPENDED or HOLD") Q
  1. ;
  1. ; User comments, to both 52 and 52.49
  1. S DIR("A")="Comments",DIR("B")="Un-Process for correction",DIR(0)="F^5:100" D ^DIR K DIR
  1. S (HCOMM,INCOM)=Y
  1. ;
  1. ; Final confirmation to Un-Process
  1. S DIR(0)="YO",DIR("A")="Would you like to 'Un-Process' eRx #"_$$GET1^DIQ(52.49,PSOIEN,.01,"E")_" and Rx #"_$$GET1^DIQ(52,PSRXNUM,.01,"E")
  1. S DIR("B")="Y" D ^DIR K DIR
  1. Q:'Y
  1. ;
  1. ; Once the user confirms the Un-Process, then put a lock/unlock on the patient
  1. S PSODFN=+$P(^PSRX(PSRXNUM,0),"^",2)
  1. S PSOPLCK=$$L^PSSLOCK(PSODFN,0) I '$G(PSOPLCK) Q
  1. ;
  1. CANCEL ; Requirement - DC - discontinue prescription (PSO CANCEL)
  1. N DA
  1. S PSONOOR="S",DA=PSRXNUM,REA="C"
  1. S PSOCANRC=DUZ,PSOCANRN=$P(^VA(200,DUZ,0),"^"),PSOCANRD=$P(^PSRX(DA,0),"^",4)
  1. S PSCAN(+^PSRX(DA,0))=DA_"^C"
  1. D CAN1^PSOCAN3
  1. ;
  1. ; Replace status code from 12 (Discontinued) to 15 (Discontinued - Edit)
  1. S DIE=52,DA=PSRXNUM,DR="100///15" D ^DIE K DIE
  1. ;
  1. ; Replace Reason code in RX activity log from "C" (Discontinued) to "E" (Edit)
  1. S RCODE=+$P($G(^PSRX(PSRXNUM,"A",0)),"^",3)
  1. I $G(RCODE) S $P(^PSRX(PSRXNUM,"A",RCODE,0),"^",2)="E"
  1. ;
  1. D UL^PSSLOCK(PSODFN)
  1. ;
  1. ERX ; Change eRx status to "Wait"
  1. N DA
  1. S RESP=$O(^PS(52.45,"C","ERX","W",0))
  1. S DIE="52.49",DR="1///"_RESP_";.13///@;25.2///@",DA=PSOIEN D ^DIE K DIE
  1. ; Add eRx history
  1. S FDA(52.4919,"+1,"_PSOIEN_",",.01)=$$NOW^XLFDT()
  1. S FDA(52.4919,"+1,"_PSOIEN_",",.02)=RESP
  1. S FDA(52.4919,"+1,"_PSOIEN_",",.03)=$G(DUZ)
  1. S FDA(52.4919,"+1,"_PSOIEN_",",1)=HCOMM
  1. D UPDATE^DIE(,"FDA","NEWSTAT","ERR") K FDA
  1. S VALMBCK="R"
  1. Q
  1. ;
  1. MSG(TXT) ;
  1. S DIR("A",1)="",DIR("A")="Press Enter to continue"
  1. S DIR("A",2)=TXT
  1. S DIR(0)="FO"
  1. D ^DIR K DIR
  1. S VALMBCK="R"
  1. Q