PSOBPSUT ;BIRM/MFR - BPS (ECME) Utilities ;29-May-2012 14:40;PLS
;;7.0;OUTPATIENT PHARMACY;**148,247,260,281,287,289,1015**;DEC 1997;Build 62
;Reference to $$ECMEON^BPSUTIL supported by IA 4410
;Reference to IBSEND^BPSECMP2 supported by IA 4411
;Reference to $$STATUS^BPSOSRX supported by IA 4412
;Reference to $$NDCFMT^PSSNDCUT supported by IA 4707
;Reference to $$CLAIM^BPSBUTL supported by IA 4719
;Reference to ^PS(55 supported by IA 2228
;Reference to ^PSDRUG( supported by IA 221
;Reference to ^PSDRUG("AQ" supported by IA 3165
;
;Modified - IHS/MSC/PLS - 05/20/2010 - Line SUBMIT+7
; ECME+1
; STATUS+3
; 05/26/2010 - Line MANREL+6
; 06/01/2010 - Line AUTOREL+10
ECME(RX) ; Returns "e" if Rx/Refill is Electronically Billable (3rd party)
Q "" ;IHS/MSC/PLS - 5/20/2010
Q $S($$STATUS^BPSOSRX(RX,$$LSTRFL^PSOBPSU1(RX))'="":"e",1:"")
;
STATUS(RX,RFL) ; Returns the Rx's ECME Status (calls STATUS^BPSOSRX)
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
Q "" ;IHS/MSC/PLS - 05/20/2010
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
Q $P($$STATUS^BPSOSRX(RX,RFL),"^")
;
SUBMIT(RX,RFL,IGRL,IGCMP) ; Returns whether the Rx should be submitted to ECME at the moment or not
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Def.: most recent)
; (o) IGRL - Ignore Release Date? (1-YES/0-NO) (Def.: 0 - NO)
; (o) IGCMP- Ignore CMOP/Suspense check? (1-YES/0-NO) (Def.: 0 - NO)
;
; - Get the REFILL # (multiple IEN)
Q 0 ;IHS/MSC/PLS - 05/20/2010
N STATUS
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
; - Not the latest fill for the prescription
I RFL'=$$LSTRFL^PSOBPSU1(RX) Q 0
; - Status not ACTIVE, DISCONTINUED, or EXPIRED
S STATUS=$$GET1^DIQ(52,RX,100,"I")
I ",0,11,12,14,15,"'[(","_STATUS_",") Q 0
; Will suspend for CMOP
I '$G(IGCMP),$$CMOP(RX,RFL) Q 0
; - ECME turned OFF for Rx's site
I '$$ECMEON^BPSUTIL($$RXSITE(RX,RFL)) Q 0
; - Rx is RELEASED - Do not submit
I '$G(IGRL),$$RXRLDT(RX,RFL) Q 0
; - Future Fill/AUTO SUSPENSE ON - will suspend
I '$G(IGCMP),$$RXFLDT(RX,RFL)>DT,$$GET1^DIQ(59,$$RXSITE(RX,RFL),.16,"I") Q 0
Q 1
;
CMOP(RX,RFL) ; Returns if the Rx will be a CMOP Rx or not
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
; Output: 1 - CMOP / 0 - NON-CMOP
;
N DFN,CMOP,MAIL,MAILEXP,DRUG,WARNS,STATUS,MW,A
; Get the REFILL # (multiple IEN)
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
; MAIL=MAIL Code, MAILEXP=Mail Code Expiration Date
S CMOP=0
S DFN=$$GET1^DIQ(52,RX,2,"I"),MAIL=$$GET1^DIQ(55,DFN,.03,"I"),MAILEXP=$$GET1^DIQ(55,DFN,.05,"I")
I MAIL>1,MAILEXP=""!(MAILEXP>DT) G QCMOP
; Get drug IEN and check DRUG if CMOP ,$S($G(MAILEXP)=""!($G(MAILEXP)>DT):1,1:0)
S DRUG=$$GET1^DIQ(52,RX,6,"I") G QCMOP:'DRUG,QCMOP:'$D(^PSDRUG("AQ",DRUG))
; Not marked for O.P.
I $$GET1^DIQ(50,DRUG,63)'["O" G QCMOP
; Drug Warning >11
S WARNS=$$GET1^DIQ(50,DRUG,8) I $L(WARNS)>11 G QCMOP
; If tradename
I $$GET1^DIQ(52,RX,6.5)'="" G QCMOP
; If Cancelled, Expired, Deleted, Hold
S STATUS=$$GET1^DIQ(52,RX,100,"I") I (STATUS>9&(",14,15,"'[(","_STATUS_",")))!(STATUS=4)!(STATUS=3) G QCMOP
; Rx RELEASED
I $$RXRLDT^PSOBPSUT(RX,RFL) G QCMOP
; MAIL/WINDOW
S MW=$S('RFL:$$GET1^DIQ(52,RX,11,"I"),1:$$GET1^DIQ(52.1,RFL_","_RX,2,"I"))
; IF WINDOW/ORIGINAL/FUTURE FILL SETS MW = MAIL
I MW="W",$$RXFLDT^PSOBPSUT(RX,RFL)>DT S MW="M"
; If not MAIL
I MW'="M" G QCMOP
S CMOP=1
;
QCMOP Q CMOP
;
RXRLDT(RX,RFL) ; Returns the Rx Release Date
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
;
; Output: RXRLDT - Rx Release Date
N RXRLDT
I '$G(RX) Q ""
S RXRLDT=$$GET1^DIQ(52,RX,31,"I")
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
I RFL S RXRLDT=$$GET1^DIQ(52.1,RFL_","_RX,17,"I")
Q RXRLDT
;
RXFLDT(RX,RFL) ; Returns the Rx Fill Date
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
; Output: RXFLDT - Rx Fill Date
N RXFLDT
I '$G(RX) Q ""
S RXFLDT=$$GET1^DIQ(52,RX,22,"I")
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
I RFL S RXFLDT=$$GET1^DIQ(52.1,RFL_","_RX,.01,"I")
Q RXFLDT
;
RXSUDT(RX,RFL) ; Returns the prescription/fill Suspense Date for the RX/Reject passed in
;Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill IEN (#52.1)
;Output: SUSPENSE DATE (External format) or <NULL>, if not suspended
;
I $G(^PSRX(RX,"STA"))'=5 Q ""
N SURX,SURFL
S SURX=$O(^PS(52.5,"B",RX,0)) I 'SURX Q ""
I $$GET1^DIQ(52.5,SURX,.05,"I") Q ""
S SURFL=+$$GET1^DIQ(52.5,SURX,9) I RFL'=SURFL Q ""
Q $$GET1^DIQ(52.5,SURX,.02,"I")
;
RXSITE(RX,RFL) ; Returns the Rx DIVISION
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill #
; Output: SITE - Rx Fill Date
;
N SITE
I '$G(RX) Q ""
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
I RFL S SITE=$$GET1^DIQ(52.1,RFL_","_RX,8,"I")
I 'RFL!'$G(SITE) S SITE=$$GET1^DIQ(52,RX,20,"I")
Q SITE
;
MANREL(RX,RFL,PID) ; ePharmacy Manual Rx Release
;Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
; (o) PID - Displays PID/Drug/Rx in the NDC prompts
;Output: "" (null - OK to Release) OR "^" (User entered "^", or no valid NDC on file for ePharmacy Rx)
;
Q "" ;IHS/MSC/PLS - 05/26/2010
N ACTION
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
; - Checking for REJECTS before proceeding to Rx Release
I $$FIND^PSOREJUT(RX,RFL) D I ACTION="Q"!(ACTION="^") W ! Q "^"
. S ACTION=$$HDLG^PSOREJU1(RX,RFL,"79,88","ED","OIQ","Q")
; - ePharmacy switch is OFF
I '$$ECMEON^BPSUTIL($$RXSITE^PSOBPSUT(RX,RFL)) Q ""
; - Not an ePharmacy Rx
I $$STATUS^PSOBPSUT(RX,RFL)="" Q ""
I '$D(PSOTRIC) N PSOTRIC S PSOTRIC="",PSOTRIC=$$TRIC^PSOREJP1(RX,RFL,PSOTRIC)
; - NDC editing before Rx release
S ACTION=$$CHGNDC^PSONDCUT(RX,RFL,$G(PID))
I ACTION="^"!(ACTION=2) D Q "^"
. W:ACTION="^" !!,$C(7),"A valid NDC must be entered before the Release function can be completed.",! H 1
. I $G(PSOTRIC) D:ACTION=2 TRIC
; - Checking for OPEN/UNRESOLVED 3rd. Party Payer Rejects (After possible NDC edit)
I $$FIND^PSOREJUT(RX,RFL) D I ACTION="Q"!(ACTION="^") W ! Q "^"
. S ACTION=$$HDLG^PSOREJU1(RX,RFL,"79,88","ED","OIQ","Q")
I $G(PSOTRIC),$$STATUS^PSOBPSUT(RX,RFL)["IN PROGRESS" D TRIC Q "^"
; - Notifying IB of a Rx RELEASE event
D RELEASE^PSOBPSU1(RX,RFL,DUZ)
Q ""
;
TRIC ;
W !!,$C(7),"TRICARE Rx remains in 'IN PROGRESS' status for ECME, and cannot be released.",! H 1
Q
;
AUTOREL(RX,RFL,RLDT,NDC,SRC,STS,HNG) ; Sends Rx Release information to ECME/IB and updates NDC
; in the DRUG/PRESCRIPTION files
;Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
; (r) RLDT- Release Date
; (r) NDC - NDC Number (Must be 11 digits)
; (o) SRC - SOURCE: "C" - CMOP / "A" - OPAI
; (o) STS - Status: (S)uccessful/(U)nsuccessful Release (Default: "S" - Successful)
; (o) HNG - HANG time after resubmission and before checking the status of the claim (Default: 0)
;
Q ;IHS/MSC/PLS - 06/01/2010
N RXNDC,SITE
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
S:'$D(STS) STS="S" S:'$D(SRC) SRC="" S HNG=+$G(HNG)
S RXNDC=$$GETNDC^PSONDCUT(RX,RFL)
; - Saves the NDC from CMOP/Automated Dispensing Machine in the Prescription file
I $$NDCFMT^PSSNDCUT(NDC)'="" D SAVNDC^PSONDCUT(RX,RFL,$$NDCFMT^PSSNDCUT(NDC),$S(SRC="C":1,1:0))
; - Not an ePharmacy Rx
I $$STATUS^PSOBPSUT(RX,RFL)="" Q ""
; - Unsuccessful Release
I STS="U" D Q
. D REVERSE^PSOBPSU1(RX,RFL,"CRLX",,"UNSUCCESSFUL "_$S(SRC="C":"CMOP",1:"EXT INTERFACE")_" RELEASE",1)
; - Notifying IB of a Rx RELEASE event
D RELEASE^PSOBPSU1(RX,RFL)
; - Invalid NDC from Automated Dispensing Machine
I SRC="A",$$NDCFMT^PSSNDCUT(NDC)="" D Q
. D REVERSE^PSOBPSU1(RX,RFL,"CRLR",,"INVALID EXT INTERFACE NDC",1,NDC)
; - Invalid NDC number for CMOP
I SRC="C",$$NDCFMT^PSSNDCUT(NDC)="" D Q
. D REVERSE^PSOBPSU1(RX,RFL,"CRLR",,"INVALID CMOP NDC",1,NDC)
; - If NDC not equal RXNDC, issue reversal and submit new claim
I SRC="A",$$NDCFMT^PSSNDCUT(NDC)'=RXNDC D Q
. D ECMESND^PSOBPSU1(RX,RFL,RLDT,"CRLB",$$NDCFMT^PSSNDCUT(NDC),,"AUTO RELEASE",,1,,1),UPDFL^PSOBPSU2(RX,RFL,RLDT)
. H HNG
. ; - If new claim returned PAYABLE, save new NDC in the DRUG/PRESCRIPTION files
. I $$STATUS^PSOBPSUT(RX,RFL)="E PAYABLE" D SAVNDC^PSONDCUT(RX,RFL,$$NDCFMT^PSSNDCUT(NDC),0,1)
; - If NDC not equal RXNDC, issue reversal and submit new claim
I SRC="C",$$NDCFMT^PSSNDCUT(NDC)'=RXNDC D Q
. ; - Reverse/Resubmit with correct NDC
. D ECMESND^PSOBPSU1(RX,RFL,RLDT,"CRLB",$$NDCFMT^PSSNDCUT(NDC),1,"CMOP RELEASE",,1,,1),UPDFL^PSOBPSU2(RX,RFL,RLDT)
. ; - Wait for a response from the Payer for the submission above
. H HNG
. ; - If new claim returned PAYABLE, save new NDC in the DRUG/PRESCRIPTION files
. I $$STATUS^PSOBPSUT(RX,RFL)="E PAYABLE" D SAVNDC^PSONDCUT(RX,RFL,$$NDCFMT^PSSNDCUT(NDC),1,1)
; - Calls ECME api responsible for notifying IB to create a BILL
D IBSEND(RX,RFL)
Q
;
IBSEND(RX,RFL) ; Rx Release: Calls ECME, which will call IB to create a bill
;Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
;
Q ;IHS/MSC/PLS - 05/26/2010
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
; - ECME turned OFF for Rx's site
I '$$ECMEON^BPSUTIL($$RXSITE^PSOBPSUT(RX,RFL)) Q
; - Not an ePharmacy Rx
I $$STATUS^PSOBPSUT(RX,RFL)="" Q ""
; - Calls ECME previously reversed, re-submit the claim to the payer
I $$STATUS^PSOBPSUT(RX,RFL)="E REVERSAL ACCEPTED"!($$STATUS^PSOBPSUT(RX,RFL)="IN PROGRESS") D Q
. D ECMESND^PSOBPSU1(RX,RFL,$$RXRLDT^PSOBPSUT(RX,RFL),"RRL")
; - Notifying ECME of a BILLING event
I $$STATUS^PSOBPSUT(RX,RFL)="E PAYABLE" D Q
. N PSOCLAIM S PSOCLAIM=$$CLAIM^BPSBUTL(RX,RFL)
. D IBSEND^BPSECMP2($P(PSOCLAIM,"^",2),$P(PSOCLAIM,"^",3),"BILL",DUZ)
Q
;
RETRX(RX,RFL) ; - Re-transmit a claim for the prescription/fill?
;Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
;Output: 1 - Re-transmit / 0 - Don't re-transmit
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
I RFL Q +$$GET1^DIQ(52.1,RFL_","_RX,82,"I")
Q +$$GET1^DIQ(52,RX,82,"I")
PSOBPSUT ;BIRM/MFR - BPS (ECME) Utilities ;29-May-2012 14:40;PLS
+1 ;;7.0;OUTPATIENT PHARMACY;**148,247,260,281,287,289,1015**;DEC 1997;Build 62
+2 ;Reference to $$ECMEON^BPSUTIL supported by IA 4410
+3 ;Reference to IBSEND^BPSECMP2 supported by IA 4411
+4 ;Reference to $$STATUS^BPSOSRX supported by IA 4412
+5 ;Reference to $$NDCFMT^PSSNDCUT supported by IA 4707
+6 ;Reference to $$CLAIM^BPSBUTL supported by IA 4719
+7 ;Reference to ^PS(55 supported by IA 2228
+8 ;Reference to ^PSDRUG( supported by IA 221
+9 ;Reference to ^PSDRUG("AQ" supported by IA 3165
+10 ;
+11 ;Modified - IHS/MSC/PLS - 05/20/2010 - Line SUBMIT+7
+12 ; ECME+1
+13 ; STATUS+3
+14 ; 05/26/2010 - Line MANREL+6
+15 ; 06/01/2010 - Line AUTOREL+10
ECME(RX) ; Returns "e" if Rx/Refill is Electronically Billable (3rd party)
+1 ;IHS/MSC/PLS - 5/20/2010
QUIT ""
+2 QUIT $SELECT($$STATUS^BPSOSRX(RX,$$LSTRFL^PSOBPSU1(RX))'="":"e",1:"")
+3 ;
STATUS(RX,RFL) ; Returns the Rx's ECME Status (calls STATUS^BPSOSRX)
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill # (Default: most recent)
+3 ;IHS/MSC/PLS - 05/20/2010
QUIT ""
+4 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+5 QUIT $PIECE($$STATUS^BPSOSRX(RX,RFL),"^")
+6 ;
SUBMIT(RX,RFL,IGRL,IGCMP) ; Returns whether the Rx should be submitted to ECME at the moment or not
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill # (Def.: most recent)
+3 ; (o) IGRL - Ignore Release Date? (1-YES/0-NO) (Def.: 0 - NO)
+4 ; (o) IGCMP- Ignore CMOP/Suspense check? (1-YES/0-NO) (Def.: 0 - NO)
+5 ;
+6 ; - Get the REFILL # (multiple IEN)
+7 ;IHS/MSC/PLS - 05/20/2010
QUIT 0
+8 NEW STATUS
+9 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+10 ; - Not the latest fill for the prescription
+11 IF RFL'=$$LSTRFL^PSOBPSU1(RX)
QUIT 0
+12 ; - Status not ACTIVE, DISCONTINUED, or EXPIRED
+13 SET STATUS=$$GET1^DIQ(52,RX,100,"I")
+14 IF ",0,11,12,14,15,"'[(","_STATUS_",")
QUIT 0
+15 ; Will suspend for CMOP
+16 IF '$GET(IGCMP)
IF $$CMOP(RX,RFL)
QUIT 0
+17 ; - ECME turned OFF for Rx's site
+18 IF '$$ECMEON^BPSUTIL($$RXSITE(RX,RFL))
QUIT 0
+19 ; - Rx is RELEASED - Do not submit
+20 IF '$GET(IGRL)
IF $$RXRLDT(RX,RFL)
QUIT 0
+21 ; - Future Fill/AUTO SUSPENSE ON - will suspend
+22 IF '$GET(IGCMP)
IF $$RXFLDT(RX,RFL)>DT
IF $$GET1^DIQ(59,$$RXSITE(RX,RFL),.16,"I")
QUIT 0
+23 QUIT 1
+24 ;
CMOP(RX,RFL) ; Returns if the Rx will be a CMOP Rx or not
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill # (Default: most recent)
+3 ; Output: 1 - CMOP / 0 - NON-CMOP
+4 ;
+5 NEW DFN,CMOP,MAIL,MAILEXP,DRUG,WARNS,STATUS,MW,A
+6 ; Get the REFILL # (multiple IEN)
+7 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+8 ; MAIL=MAIL Code, MAILEXP=Mail Code Expiration Date
+9 SET CMOP=0
+10 SET DFN=$$GET1^DIQ(52,RX,2,"I")
SET MAIL=$$GET1^DIQ(55,DFN,.03,"I")
SET MAILEXP=$$GET1^DIQ(55,DFN,.05,"I")
+11 IF MAIL>1
IF MAILEXP=""!(MAILEXP>DT)
GOTO QCMOP
+12 ; Get drug IEN and check DRUG if CMOP ,$S($G(MAILEXP)=""!($G(MAILEXP)>DT):1,1:0)
+13 SET DRUG=$$GET1^DIQ(52,RX,6,"I")
IF 'DRUG
GOTO QCMOP
IF '$DATA(^PSDRUG("AQ",DRUG))
GOTO QCMOP
+14 ; Not marked for O.P.
+15 IF $$GET1^DIQ(50,DRUG,63)'["O"
GOTO QCMOP
+16 ; Drug Warning >11
+17 SET WARNS=$$GET1^DIQ(50,DRUG,8)
IF $LENGTH(WARNS)>11
GOTO QCMOP
+18 ; If tradename
+19 IF $$GET1^DIQ(52,RX,6.5)'=""
GOTO QCMOP
+20 ; If Cancelled, Expired, Deleted, Hold
+21 SET STATUS=$$GET1^DIQ(52,RX,100,"I")
IF (STATUS>9&(",14,15,"'[(","_STATUS_",")))!(STATUS=4)!(STATUS=3)
GOTO QCMOP
+22 ; Rx RELEASED
+23 IF $$RXRLDT^PSOBPSUT(RX,RFL)
GOTO QCMOP
+24 ; MAIL/WINDOW
+25 SET MW=$SELECT('RFL:$$GET1^DIQ(52,RX,11,"I"),1:$$GET1^DIQ(52.1,RFL_","_RX,2,"I"))
+26 ; IF WINDOW/ORIGINAL/FUTURE FILL SETS MW = MAIL
+27 IF MW="W"
IF $$RXFLDT^PSOBPSUT(RX,RFL)>DT
SET MW="M"
+28 ; If not MAIL
+29 IF MW'="M"
GOTO QCMOP
+30 SET CMOP=1
+31 ;
QCMOP QUIT CMOP
+1 ;
RXRLDT(RX,RFL) ; Returns the Rx Release Date
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill # (Default: most recent)
+3 ;
+4 ; Output: RXRLDT - Rx Release Date
+5 NEW RXRLDT
+6 IF '$GET(RX)
QUIT ""
+7 SET RXRLDT=$$GET1^DIQ(52,RX,31,"I")
+8 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+9 IF RFL
SET RXRLDT=$$GET1^DIQ(52.1,RFL_","_RX,17,"I")
+10 QUIT RXRLDT
+11 ;
RXFLDT(RX,RFL) ; Returns the Rx Fill Date
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill # (Default: most recent)
+3 ; Output: RXFLDT - Rx Fill Date
+4 NEW RXFLDT
+5 IF '$GET(RX)
QUIT ""
+6 SET RXFLDT=$$GET1^DIQ(52,RX,22,"I")
+7 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+8 IF RFL
SET RXFLDT=$$GET1^DIQ(52.1,RFL_","_RX,.01,"I")
+9 QUIT RXFLDT
+10 ;
RXSUDT(RX,RFL) ; Returns the prescription/fill Suspense Date for the RX/Reject passed in
+1 ;Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill IEN (#52.1)
+3 ;Output: SUSPENSE DATE (External format) or <NULL>, if not suspended
+4 ;
+5 IF $GET(^PSRX(RX,"STA"))'=5
QUIT ""
+6 NEW SURX,SURFL
+7 SET SURX=$ORDER(^PS(52.5,"B",RX,0))
IF 'SURX
QUIT ""
+8 IF $$GET1^DIQ(52.5,SURX,.05,"I")
QUIT ""
+9 SET SURFL=+$$GET1^DIQ(52.5,SURX,9)
IF RFL'=SURFL
QUIT ""
+10 QUIT $$GET1^DIQ(52.5,SURX,.02,"I")
+11 ;
RXSITE(RX,RFL) ; Returns the Rx DIVISION
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill #
+3 ; Output: SITE - Rx Fill Date
+4 ;
+5 NEW SITE
+6 IF '$GET(RX)
QUIT ""
+7 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+8 IF RFL
SET SITE=$$GET1^DIQ(52.1,RFL_","_RX,8,"I")
+9 IF 'RFL!'$GET(SITE)
SET SITE=$$GET1^DIQ(52,RX,20,"I")
+10 QUIT SITE
+11 ;
MANREL(RX,RFL,PID) ; ePharmacy Manual Rx Release
+1 ;Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill # (Default: most recent)
+3 ; (o) PID - Displays PID/Drug/Rx in the NDC prompts
+4 ;Output: "" (null - OK to Release) OR "^" (User entered "^", or no valid NDC on file for ePharmacy Rx)
+5 ;
+6 ;IHS/MSC/PLS - 05/26/2010
QUIT ""
+7 NEW ACTION
+8 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+9 ; - Checking for REJECTS before proceeding to Rx Release
+10 IF $$FIND^PSOREJUT(RX,RFL)
Begin DoDot:1
+11 SET ACTION=$$HDLG^PSOREJU1(RX,RFL,"79,88","ED","OIQ","Q")
End DoDot:1
IF ACTION="Q"!(ACTION="^")
WRITE !
QUIT "^"
+12 ; - ePharmacy switch is OFF
+13 IF '$$ECMEON^BPSUTIL($$RXSITE^PSOBPSUT(RX,RFL))
QUIT ""
+14 ; - Not an ePharmacy Rx
+15 IF $$STATUS^PSOBPSUT(RX,RFL)=""
QUIT ""
+16 IF '$DATA(PSOTRIC)
NEW PSOTRIC
SET PSOTRIC=""
SET PSOTRIC=$$TRIC^PSOREJP1(RX,RFL,PSOTRIC)
+17 ; - NDC editing before Rx release
+18 SET ACTION=$$CHGNDC^PSONDCUT(RX,RFL,$GET(PID))
+19 IF ACTION="^"!(ACTION=2)
Begin DoDot:1
+20 IF ACTION="^"
WRITE !!,$CHAR(7),"A valid NDC must be entered before the Release function can be completed.",!
HANG 1
+21 IF $GET(PSOTRIC)
IF ACTION=2
DO TRIC
End DoDot:1
QUIT "^"
+22 ; - Checking for OPEN/UNRESOLVED 3rd. Party Payer Rejects (After possible NDC edit)
+23 IF $$FIND^PSOREJUT(RX,RFL)
Begin DoDot:1
+24 SET ACTION=$$HDLG^PSOREJU1(RX,RFL,"79,88","ED","OIQ","Q")
End DoDot:1
IF ACTION="Q"!(ACTION="^")
WRITE !
QUIT "^"
+25 IF $GET(PSOTRIC)
IF $$STATUS^PSOBPSUT(RX,RFL)["IN PROGRESS"
DO TRIC
QUIT "^"
+26 ; - Notifying IB of a Rx RELEASE event
+27 DO RELEASE^PSOBPSU1(RX,RFL,DUZ)
+28 QUIT ""
+29 ;
TRIC ;
+1 WRITE !!,$CHAR(7),"TRICARE Rx remains in 'IN PROGRESS' status for ECME, and cannot be released.",!
HANG 1
+2 QUIT
+3 ;
AUTOREL(RX,RFL,RLDT,NDC,SRC,STS,HNG) ; Sends Rx Release information to ECME/IB and updates NDC
+1 ; in the DRUG/PRESCRIPTION files
+2 ;Input: (r) RX - Rx IEN (#52)
+3 ; (o) RFL - Refill # (Default: most recent)
+4 ; (r) RLDT- Release Date
+5 ; (r) NDC - NDC Number (Must be 11 digits)
+6 ; (o) SRC - SOURCE: "C" - CMOP / "A" - OPAI
+7 ; (o) STS - Status: (S)uccessful/(U)nsuccessful Release (Default: "S" - Successful)
+8 ; (o) HNG - HANG time after resubmission and before checking the status of the claim (Default: 0)
+9 ;
+10 ;IHS/MSC/PLS - 06/01/2010
QUIT
+11 NEW RXNDC,SITE
+12 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+13 IF '$DATA(STS)
SET STS="S"
IF '$DATA(SRC)
SET SRC=""
SET HNG=+$GET(HNG)
+14 SET RXNDC=$$GETNDC^PSONDCUT(RX,RFL)
+15 ; - Saves the NDC from CMOP/Automated Dispensing Machine in the Prescription file
+16 IF $$NDCFMT^PSSNDCUT(NDC)'=""
DO SAVNDC^PSONDCUT(RX,RFL,$$NDCFMT^PSSNDCUT(NDC),$SELECT(SRC="C":1,1:0))
+17 ; - Not an ePharmacy Rx
+18 IF $$STATUS^PSOBPSUT(RX,RFL)=""
QUIT ""
+19 ; - Unsuccessful Release
+20 IF STS="U"
Begin DoDot:1
+21 DO REVERSE^PSOBPSU1(RX,RFL,"CRLX",,"UNSUCCESSFUL "_$SELECT(SRC="C":"CMOP",1:"EXT INTERFACE")_" RELEASE",1)
End DoDot:1
QUIT
+22 ; - Notifying IB of a Rx RELEASE event
+23 DO RELEASE^PSOBPSU1(RX,RFL)
+24 ; - Invalid NDC from Automated Dispensing Machine
+25 IF SRC="A"
IF $$NDCFMT^PSSNDCUT(NDC)=""
Begin DoDot:1
+26 DO REVERSE^PSOBPSU1(RX,RFL,"CRLR",,"INVALID EXT INTERFACE NDC",1,NDC)
End DoDot:1
QUIT
+27 ; - Invalid NDC number for CMOP
+28 IF SRC="C"
IF $$NDCFMT^PSSNDCUT(NDC)=""
Begin DoDot:1
+29 DO REVERSE^PSOBPSU1(RX,RFL,"CRLR",,"INVALID CMOP NDC",1,NDC)
End DoDot:1
QUIT
+30 ; - If NDC not equal RXNDC, issue reversal and submit new claim
+31 IF SRC="A"
IF $$NDCFMT^PSSNDCUT(NDC)'=RXNDC
Begin DoDot:1
+32 DO ECMESND^PSOBPSU1(RX,RFL,RLDT,"CRLB",$$NDCFMT^PSSNDCUT(NDC),,"AUTO RELEASE",,1,,1)
DO UPDFL^PSOBPSU2(RX,RFL,RLDT)
+33 HANG HNG
+34 ; - If new claim returned PAYABLE, save new NDC in the DRUG/PRESCRIPTION files
+35 IF $$STATUS^PSOBPSUT(RX,RFL)="E PAYABLE"
DO SAVNDC^PSONDCUT(RX,RFL,$$NDCFMT^PSSNDCUT(NDC),0,1)
End DoDot:1
QUIT
+36 ; - If NDC not equal RXNDC, issue reversal and submit new claim
+37 IF SRC="C"
IF $$NDCFMT^PSSNDCUT(NDC)'=RXNDC
Begin DoDot:1
+38 ; - Reverse/Resubmit with correct NDC
+39 DO ECMESND^PSOBPSU1(RX,RFL,RLDT,"CRLB",$$NDCFMT^PSSNDCUT(NDC),1,"CMOP RELEASE",,1,,1)
DO UPDFL^PSOBPSU2(RX,RFL,RLDT)
+40 ; - Wait for a response from the Payer for the submission above
+41 HANG HNG
+42 ; - If new claim returned PAYABLE, save new NDC in the DRUG/PRESCRIPTION files
+43 IF $$STATUS^PSOBPSUT(RX,RFL)="E PAYABLE"
DO SAVNDC^PSONDCUT(RX,RFL,$$NDCFMT^PSSNDCUT(NDC),1,1)
End DoDot:1
QUIT
+44 ; - Calls ECME api responsible for notifying IB to create a BILL
+45 DO IBSEND(RX,RFL)
+46 QUIT
+47 ;
IBSEND(RX,RFL) ; Rx Release: Calls ECME, which will call IB to create a bill
+1 ;Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill # (Default: most recent)
+3 ;
+4 ;IHS/MSC/PLS - 05/26/2010
QUIT
+5 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+6 ; - ECME turned OFF for Rx's site
+7 IF '$$ECMEON^BPSUTIL($$RXSITE^PSOBPSUT(RX,RFL))
QUIT
+8 ; - Not an ePharmacy Rx
+9 IF $$STATUS^PSOBPSUT(RX,RFL)=""
QUIT ""
+10 ; - Calls ECME previously reversed, re-submit the claim to the payer
+11 IF $$STATUS^PSOBPSUT(RX,RFL)="E REVERSAL ACCEPTED"!($$STATUS^PSOBPSUT(RX,RFL)="IN PROGRESS")
Begin DoDot:1
+12 DO ECMESND^PSOBPSU1(RX,RFL,$$RXRLDT^PSOBPSUT(RX,RFL),"RRL")
End DoDot:1
QUIT
+13 ; - Notifying ECME of a BILLING event
+14 IF $$STATUS^PSOBPSUT(RX,RFL)="E PAYABLE"
Begin DoDot:1
+15 NEW PSOCLAIM
SET PSOCLAIM=$$CLAIM^BPSBUTL(RX,RFL)
+16 DO IBSEND^BPSECMP2($PIECE(PSOCLAIM,"^",2),$PIECE(PSOCLAIM,"^",3),"BILL",DUZ)
End DoDot:1
QUIT
+17 QUIT
+18 ;
RETRX(RX,RFL) ; - Re-transmit a claim for the prescription/fill?
+1 ;Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill # (Default: most recent)
+3 ;Output: 1 - Re-transmit / 0 - Don't re-transmit
+4 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+5 IF RFL
QUIT +$$GET1^DIQ(52.1,RFL_","_RX,82,"I")
+6 QUIT +$$GET1^DIQ(52,RX,82,"I")