PSOBPSUT ;BIRM/MFR - BPS (ECME) Utilities ;07 Jun 2005 8:39 PM
;;7.0;OUTPATIENT PHARMACY;**148,247,260,281,287,289,358,385,403,408,512,630,562,680,753**;DEC 1997;Build 53
; Reference to $$ECMEON^BPSUTIL in ICR #4410
; Reference to IBSEND^BPSECMP2 in ICR #4411
; Reference to $$STATUS^BPSOSRX in ICR #4412
; Reference to $$NDCFMT^PSSNDCUT in ICR #4707
; Reference to $$CLAIM^BPSBUTL in ICR #4719
; Reference to ^PS(55 in ICR #2228
; Reference to ^PSDRUG( in ICR #221
; Reference to ^PSDRUG("AQ" in ICR #3165
;
ECME(RX) ; Returns "e" if Rx/Refill is Electronically Billable (3rd party)
Q $S($$STATUS^BPSOSRX(RX,$$LSTRFL^PSOBPSU1(RX))'="":"e",1:"")
;
STATUS(RX,RFL,COB) ; Returns the Rx's ECME Status (calls STATUS^BPSOSRX)
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
; (o) COB - Coordination of Benefits (1=primary, etc.)
;
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
I '$G(COB) S COB=1
Q $P($$STATUS^BPSOSRX(RX,RFL,,,COB),"^")
;
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)
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 $$GET1^DIQ(52,RX,100.2,"I")]"" S MAIL=$$GET1^DIQ(52,RX,100.2,"I"),MAILEXP="" ;p753
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")
I RFL["P" S RXRLDT=$$GET1^DIQ(52.2,+$E(RFL,2,9)_","_RX,8,"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 (FM format)
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")
I RFL["P" S RXFLDT=$$GET1^DIQ(52.2,+$E(RFL,2,9)_","_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["P" S SITE=$$GET1^DIQ(52.2,+$E(RFL,2,9)_","_RX,.09,"I")
I (RFL=0)!'$G(SITE) S SITE=$$GET1^DIQ(52,RX,20,"I")
Q SITE
;
RXSTATE(RX,RFL) ; Returns the Rx Division STATE
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill #
; Output: SITE - Rx Fill Date
N SITE
S SITE=$$RXSITE(RX,RFL) I 'SITE Q ""
Q +$$GET1^DIQ(59,SITE,.08,"I")
;
RXSTATEP(RX,RFL,STATE) ; Returns the Rx Export States
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill #
; STATE - Selected State
; Output: RSLT - Export States
N SITE,MBMST,RSLT,DFN
S MBMST=$$GET1^DIQ(58.41,STATE,21,"I")
S RSLT="^"
I (+MBMST=0)!(+MBMST=1) D
.S SITE=$$RXSITE(RX,RFL) I 'SITE Q
.S RSLT=RSLT_+$$GET1^DIQ(59,SITE,.08,"I")_"^"
I (+MBMST=1)!(+MBMST=2) D
.S DFN=$$GET1^DIQ(52,RX,2,"I") D ADD^VADPT I +VAPA(5)]"" S RSLT=RSLT_+VAPA(5)_"^"
Q RSLT
;
RXSTATEZ(RX,RFL,STATE) ; Returns the Rx Export States
; Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill #
; STATE - Selected State
; Output: RSLT - Export to State
N SITE,MBMST,RSLT,DFN
S MBMST=$$GET1^DIQ(58.41,STATE,21,"I")
I (+MBMST=0)!(+MBMST=1) S SITE=$$RXSITE(RX,RFL) Q:'SITE 0 Q +$$GET1^DIQ(59,SITE,.08,"I")
I +MBMST=2 S DFN=$$GET1^DIQ(52,RX,2,"I") D ADD^VADPT I +VAPA(5)]"" Q +VAPA(5)
Q 0
;
RXQTY(RXIEN,FILL) ; Returns the Quantity Dispense for the Fill
; Input: (r) RXIEN - Rx IEN (#52)
; (o) FILL - Refill # (Default: most recent)
; Output: RXQTY - Quantity Dispensed
N RXQTY
I '$G(RXIEN) Q ""
S RXQTY=$$GET1^DIQ(52,RXIEN,7,"I")
I '$D(FILL) S FILL=$$LSTRFL^PSOBPSU1(RXIEN)
I FILL S RXQTY=$$GET1^DIQ(52.1,FILL_","_RXIEN,1,"I")
I FILL["P" S RXQTY=$$GET1^DIQ(52.2,+$E(FILL,2,9)_","_RXIEN,.04,"I")
Q RXQTY
;
RXDAYSUP(RXIEN,FILL) ; Returns the Days Supply for the Fill
; Input: (r) RXIEN - Rx IEN (#52)
; (o) FILL - Refill # (Default: most recent)
; Output: RXDAYSUP - Days Supply
N RXDAYSUP
I '$G(RXIEN) Q ""
S RXDAYSUP=$$GET1^DIQ(52,RXIEN,8,"I")
I '$D(FILL) S FILL=$$LSTRFL^PSOBPSU1(RXIEN)
I FILL S RXDAYSUP=$$GET1^DIQ(52.1,FILL_","_RXIEN,1.1,"I")
I FILL["P" S RXDAYSUP=$$GET1^DIQ(52.2,+$E(FILL,2,9)_","_RXIEN,.041,"I")
Q RXDAYSUP
;
RXPRV(RXIEN,FILL) ; Returns the Rx Fill Provider IEN
; Input: (r) RXIEN - Rx IEN (#52)
; (o) FILL - Refill # (Default: most recent - except Partial)
; Note: "P1", "P2"... represent partial fills
; Output: RXPRV - Rx Fill Provider IEN
N RXPRV
I '$G(RXIEN) Q ""
I '$D(FILL) S RFL=$$LSTRFL^PSOBPSU1(RXIEN)
I FILL S RXPRV=$$GET1^DIQ(52.1,FILL_","_RXIEN,15,"I")
I FILL["P" S RXPRV=$$GET1^DIQ(52.2,+$E(FILL,2,9)_","_RXIEN,6,"I")
I '$G(RXPRV) S RXPRV=$$GET1^DIQ(52,RXIEN,4,"I")
Q RXPRV
;
RXRPH(RXIEN,FILL) ; Returns the Pharmacist IEN for the Fill
; Input: (r) RXIEN - Rx IEN (#52)
; (o) FILL - Refill # (Default: most recent)
; Output: RXRPH - Pharmacist IEN (Pointer to File #200)
N RXRPH
I '$G(RXIEN) Q ""
I '$D(FILL) S FILL=$$LSTRFL^PSOBPSU1(RXIEN)
I FILL S RXRPH=$$GET1^DIQ(52.1,FILL_","_RXIEN,4,"I")
I FILL["P" S RXRPH=$$GET1^DIQ(52.2,+$E(FILL,2,9)_","_RXIEN,.05,"I")
I '$G(RXRPH) S RXRPH=$$GET1^DIQ(52,RXIEN,23,"I")
Q RXRPH
;
VALUE(RX,FILL,ORFLD,RFFLD,PRFLD,OROK) ; Retrieve corresponding Internal value for the specific prescription fill
; Input: (r) RX - Rx IEN (#52)
; (r) FILL - Refill #
; (r) ORFLD - Original Fill Field #
; (r) RFFLD - Refill Field #
; (r) PRFLD - Partial Field #
; (o) OROK - OK to retrieve from Original Fill (1: YES/0:NO)
; Output: VALUE - Fill Field Value
;
N VALUE
I '$G(RX)!($G(FILL)="") Q ""
I RFFLD,FILL S VALUE=$$GET1^DIQ(52.1,FILL_","_RX,RFFLD,"I")
I PRFLD,FILL["P" S VALUE=$$GET1^DIQ(52.2,+$E(FILL,2,9)_","_RX,PRFLD,"I")
I ORFLD,(FILL=0!(($G(VALUE)="")&$G(OROK))) S VALUE=$$GET1^DIQ(52,RX,ORFLD,"I")
Q $G(VALUE)
;
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)
;
N ACTION
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
; Check for unresolved TRICARE/CHAMPVA non-billable reject code, PSO*7*358
I $$PSOET^PSOREJP3(RX,RFL) W ! Q "^"
; 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,943","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,943","ED","OIQ","Q")
I $G(PSOTRIC),$$STATUS^PSOBPSUT(RX,RFL)["IN PROGRESS" D TRIC Q "^"
Q ""
;
TRIC ;
W !!,$C(7),$S(PSOTRIC=1:"TRICARE",1:"CHAMPVA")_" 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)
;
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,$S(SRC="C":2,1:1),NDC)
Q
;
IBSEND(RX,RFL,AUTO,PSONDC) ; Rx Release
; Create Release Event
; Calls ECME, if needed
; If Payable or Duplicate, calls IB to create a bill
;
;Input: (r) RX - Rx IEN (#52)
; (o) RFL - Refill # (Default: most recent)
; (o) AUTO - Set if called by Auto Release Process (1=OPAI, 2=CMOP)
; (o) PSONDC - NDC to be on outgoing claim
;
N PSORELDT
I '$D(RFL) S RFL=$$LSTRFL^PSOBPSU1(RX)
; - ECME turned OFF for Rx's site
I '$$ECMEON^BPSUTIL($$RXSITE^PSOBPSUT(RX,RFL)) Q
N STATUS
S STATUS=$$STATUS(RX,RFL)
; - Not an ePharmacy Rx
I STATUS="" Q ""
; - Notifying IB of a Rx RELEASE event
; - Do not call for auto release process as it has already been done
S AUTO=+$G(AUTO)
I 'AUTO D RELEASE^PSOBPSU1(RX,RFL,DUZ)
; - If the previous ECME claim was reversed or incomplete, re-submit the claim to the payer
I (STATUS="E REVERSAL ACCEPTED")!(STATUS="IN PROGRESS") D Q
. S PSORELDT=$$RXRLDT^PSOBPSUT(RX,RFL)
. S PSONDC=$$NDCFMT^PSSNDCUT($G(PSONDC))
. D ECMESND^PSOBPSU1(RX,RFL,PSORELDT,$S(AUTO:"C",1:"")_"RRL",PSONDC,$S(AUTO=2:1,1:""))
; - Notifying ECME of a BILLING event
I STATUS="E PAYABLE"!(STATUS="E DUPLICATE") 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")
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSOBPSUT 14786 printed Oct 16, 2024@18:25:45 Page 2
PSOBPSUT ;BIRM/MFR - BPS (ECME) Utilities ;07 Jun 2005 8:39 PM
+1 ;;7.0;OUTPATIENT PHARMACY;**148,247,260,281,287,289,358,385,403,408,512,630,562,680,753**;DEC 1997;Build 53
+2 ; Reference to $$ECMEON^BPSUTIL in ICR #4410
+3 ; Reference to IBSEND^BPSECMP2 in ICR #4411
+4 ; Reference to $$STATUS^BPSOSRX in ICR #4412
+5 ; Reference to $$NDCFMT^PSSNDCUT in ICR #4707
+6 ; Reference to $$CLAIM^BPSBUTL in ICR #4719
+7 ; Reference to ^PS(55 in ICR #2228
+8 ; Reference to ^PSDRUG( in ICR #221
+9 ; Reference to ^PSDRUG("AQ" in ICR #3165
+10 ;
ECME(RX) ; Returns "e" if Rx/Refill is Electronically Billable (3rd party)
+1 QUIT $SELECT($$STATUS^BPSOSRX(RX,$$LSTRFL^PSOBPSU1(RX))'="":"e",1:"")
+2 ;
STATUS(RX,RFL,COB) ; Returns the Rx's ECME Status (calls STATUS^BPSOSRX)
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill # (Default: most recent)
+3 ; (o) COB - Coordination of Benefits (1=primary, etc.)
+4 ;
+5 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+6 IF '$GET(COB)
SET COB=1
+7 QUIT $PIECE($$STATUS^BPSOSRX(RX,RFL,,,COB),"^")
+8 ;
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 NEW STATUS
+8 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+9 ; - Not the latest fill for the prescription
+10 IF RFL'=$$LSTRFL^PSOBPSU1(RX)
QUIT 0
+11 ; - Status not ACTIVE, DISCONTINUED, or EXPIRED
+12 SET STATUS=$$GET1^DIQ(52,RX,100,"I")
+13 IF ",0,11,12,14,15,"'[(","_STATUS_",")
QUIT 0
+14 ; Will suspend for CMOP
+15 IF '$GET(IGCMP)
IF $$CMOP(RX,RFL)
QUIT 0
+16 ; - ECME turned OFF for Rx's site
+17 IF '$$ECMEON^BPSUTIL($$RXSITE(RX,RFL))
QUIT 0
+18 ; - Rx is RELEASED - Do not submit
+19 IF '$GET(IGRL)
IF $$RXRLDT(RX,RFL)
QUIT 0
+20 ; - Future Fill/AUTO SUSPENSE ON - will suspend
+21 IF '$GET(IGCMP)
IF $$RXFLDT(RX,RFL)>DT
IF $$GET1^DIQ(59,$$RXSITE(RX,RFL),.16,"I")
QUIT 0
+22 QUIT 1
+23 ;
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 ;p753
IF $$GET1^DIQ(52,RX,100.2,"I")]""
SET MAIL=$$GET1^DIQ(52,RX,100.2,"I")
SET MAILEXP=""
+12 IF MAIL>1
IF MAILEXP=""!(MAILEXP>DT)
GOTO QCMOP
+13 ; Get drug IEN and check DRUG if CMOP ,$S($G(MAILEXP)=""!($G(MAILEXP)>DT):1,1:0)
+14 SET DRUG=$$GET1^DIQ(52,RX,6,"I")
if 'DRUG
GOTO QCMOP
if '$DATA(^PSDRUG("AQ",DRUG))
GOTO QCMOP
+15 ; Not marked for O.P.
+16 IF $$GET1^DIQ(50,DRUG,63)'["O"
GOTO QCMOP
+17 ; Drug Warning >11
+18 SET WARNS=$$GET1^DIQ(50,DRUG,8)
IF $LENGTH(WARNS)>11
GOTO QCMOP
+19 ; If tradename
+20 IF $$GET1^DIQ(52,RX,6.5)'=""
GOTO QCMOP
+21 ; If Cancelled, Expired, Deleted, Hold
+22 SET STATUS=$$GET1^DIQ(52,RX,100,"I")
IF (STATUS>9&(",14,15,"'[(","_STATUS_",")))!(STATUS=4)!(STATUS=3)
GOTO QCMOP
+23 ; Rx RELEASED
+24 IF $$RXRLDT^PSOBPSUT(RX,RFL)
GOTO QCMOP
+25 ; MAIL/WINDOW
+26 SET MW=$SELECT('RFL:$$GET1^DIQ(52,RX,11,"I"),1:$$GET1^DIQ(52.1,RFL_","_RX,2,"I"))
+27 ; IF WINDOW/ORIGINAL/FUTURE FILL SETS MW = MAIL
+28 IF MW="W"
IF $$RXFLDT^PSOBPSUT(RX,RFL)>DT
SET MW="M"
+29 ; If not MAIL
+30 IF MW'="M"
GOTO QCMOP
+31 SET CMOP=1
+32 ;
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 IF RFL["P"
SET RXRLDT=$$GET1^DIQ(52.2,+$EXTRACT(RFL,2,9)_","_RX,8,"I")
+11 QUIT RXRLDT
+12 ;
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 (FM format)
+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 IF RFL["P"
SET RXFLDT=$$GET1^DIQ(52.2,+$EXTRACT(RFL,2,9)_","_RX,.01,"I")
+10 QUIT RXFLDT
+11 ;
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["P"
SET SITE=$$GET1^DIQ(52.2,+$EXTRACT(RFL,2,9)_","_RX,.09,"I")
+10 IF (RFL=0)!'$GET(SITE)
SET SITE=$$GET1^DIQ(52,RX,20,"I")
+11 QUIT SITE
+12 ;
RXSTATE(RX,RFL) ; Returns the Rx Division STATE
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill #
+3 ; Output: SITE - Rx Fill Date
+4 NEW SITE
+5 SET SITE=$$RXSITE(RX,RFL)
IF 'SITE
QUIT ""
+6 QUIT +$$GET1^DIQ(59,SITE,.08,"I")
+7 ;
RXSTATEP(RX,RFL,STATE) ; Returns the Rx Export States
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill #
+3 ; STATE - Selected State
+4 ; Output: RSLT - Export States
+5 NEW SITE,MBMST,RSLT,DFN
+6 SET MBMST=$$GET1^DIQ(58.41,STATE,21,"I")
+7 SET RSLT="^"
+8 IF (+MBMST=0)!(+MBMST=1)
Begin DoDot:1
+9 SET SITE=$$RXSITE(RX,RFL)
IF 'SITE
QUIT
+10 SET RSLT=RSLT_+$$GET1^DIQ(59,SITE,.08,"I")_"^"
End DoDot:1
+11 IF (+MBMST=1)!(+MBMST=2)
Begin DoDot:1
+12 SET DFN=$$GET1^DIQ(52,RX,2,"I")
DO ADD^VADPT
IF +VAPA(5)]""
SET RSLT=RSLT_+VAPA(5)_"^"
End DoDot:1
+13 QUIT RSLT
+14 ;
RXSTATEZ(RX,RFL,STATE) ; Returns the Rx Export States
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (o) RFL - Refill #
+3 ; STATE - Selected State
+4 ; Output: RSLT - Export to State
+5 NEW SITE,MBMST,RSLT,DFN
+6 SET MBMST=$$GET1^DIQ(58.41,STATE,21,"I")
+7 IF (+MBMST=0)!(+MBMST=1)
SET SITE=$$RXSITE(RX,RFL)
if 'SITE
QUIT 0
QUIT +$$GET1^DIQ(59,SITE,.08,"I")
+8 IF +MBMST=2
SET DFN=$$GET1^DIQ(52,RX,2,"I")
DO ADD^VADPT
IF +VAPA(5)]""
QUIT +VAPA(5)
+9 QUIT 0
+10 ;
RXQTY(RXIEN,FILL) ; Returns the Quantity Dispense for the Fill
+1 ; Input: (r) RXIEN - Rx IEN (#52)
+2 ; (o) FILL - Refill # (Default: most recent)
+3 ; Output: RXQTY - Quantity Dispensed
+4 NEW RXQTY
+5 IF '$GET(RXIEN)
QUIT ""
+6 SET RXQTY=$$GET1^DIQ(52,RXIEN,7,"I")
+7 IF '$DATA(FILL)
SET FILL=$$LSTRFL^PSOBPSU1(RXIEN)
+8 IF FILL
SET RXQTY=$$GET1^DIQ(52.1,FILL_","_RXIEN,1,"I")
+9 IF FILL["P"
SET RXQTY=$$GET1^DIQ(52.2,+$EXTRACT(FILL,2,9)_","_RXIEN,.04,"I")
+10 QUIT RXQTY
+11 ;
RXDAYSUP(RXIEN,FILL) ; Returns the Days Supply for the Fill
+1 ; Input: (r) RXIEN - Rx IEN (#52)
+2 ; (o) FILL - Refill # (Default: most recent)
+3 ; Output: RXDAYSUP - Days Supply
+4 NEW RXDAYSUP
+5 IF '$GET(RXIEN)
QUIT ""
+6 SET RXDAYSUP=$$GET1^DIQ(52,RXIEN,8,"I")
+7 IF '$DATA(FILL)
SET FILL=$$LSTRFL^PSOBPSU1(RXIEN)
+8 IF FILL
SET RXDAYSUP=$$GET1^DIQ(52.1,FILL_","_RXIEN,1.1,"I")
+9 IF FILL["P"
SET RXDAYSUP=$$GET1^DIQ(52.2,+$EXTRACT(FILL,2,9)_","_RXIEN,.041,"I")
+10 QUIT RXDAYSUP
+11 ;
RXPRV(RXIEN,FILL) ; Returns the Rx Fill Provider IEN
+1 ; Input: (r) RXIEN - Rx IEN (#52)
+2 ; (o) FILL - Refill # (Default: most recent - except Partial)
+3 ; Note: "P1", "P2"... represent partial fills
+4 ; Output: RXPRV - Rx Fill Provider IEN
+5 NEW RXPRV
+6 IF '$GET(RXIEN)
QUIT ""
+7 IF '$DATA(FILL)
SET RFL=$$LSTRFL^PSOBPSU1(RXIEN)
+8 IF FILL
SET RXPRV=$$GET1^DIQ(52.1,FILL_","_RXIEN,15,"I")
+9 IF FILL["P"
SET RXPRV=$$GET1^DIQ(52.2,+$EXTRACT(FILL,2,9)_","_RXIEN,6,"I")
+10 IF '$GET(RXPRV)
SET RXPRV=$$GET1^DIQ(52,RXIEN,4,"I")
+11 QUIT RXPRV
+12 ;
RXRPH(RXIEN,FILL) ; Returns the Pharmacist IEN for the Fill
+1 ; Input: (r) RXIEN - Rx IEN (#52)
+2 ; (o) FILL - Refill # (Default: most recent)
+3 ; Output: RXRPH - Pharmacist IEN (Pointer to File #200)
+4 NEW RXRPH
+5 IF '$GET(RXIEN)
QUIT ""
+6 IF '$DATA(FILL)
SET FILL=$$LSTRFL^PSOBPSU1(RXIEN)
+7 IF FILL
SET RXRPH=$$GET1^DIQ(52.1,FILL_","_RXIEN,4,"I")
+8 IF FILL["P"
SET RXRPH=$$GET1^DIQ(52.2,+$EXTRACT(FILL,2,9)_","_RXIEN,.05,"I")
+9 IF '$GET(RXRPH)
SET RXRPH=$$GET1^DIQ(52,RXIEN,23,"I")
+10 QUIT RXRPH
+11 ;
VALUE(RX,FILL,ORFLD,RFFLD,PRFLD,OROK) ; Retrieve corresponding Internal value for the specific prescription fill
+1 ; Input: (r) RX - Rx IEN (#52)
+2 ; (r) FILL - Refill #
+3 ; (r) ORFLD - Original Fill Field #
+4 ; (r) RFFLD - Refill Field #
+5 ; (r) PRFLD - Partial Field #
+6 ; (o) OROK - OK to retrieve from Original Fill (1: YES/0:NO)
+7 ; Output: VALUE - Fill Field Value
+8 ;
+9 NEW VALUE
+10 IF '$GET(RX)!($GET(FILL)="")
QUIT ""
+11 IF RFFLD
IF FILL
SET VALUE=$$GET1^DIQ(52.1,FILL_","_RX,RFFLD,"I")
+12 IF PRFLD
IF FILL["P"
SET VALUE=$$GET1^DIQ(52.2,+$EXTRACT(FILL,2,9)_","_RX,PRFLD,"I")
+13 IF ORFLD
IF (FILL=0!(($GET(VALUE)="")&$GET(OROK)))
SET VALUE=$$GET1^DIQ(52,RX,ORFLD,"I")
+14 QUIT $GET(VALUE)
+15 ;
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 NEW ACTION
+7 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+8 ; Check for unresolved TRICARE/CHAMPVA non-billable reject code, PSO*7*358
+9 IF $$PSOET^PSOREJP3(RX,RFL)
WRITE !
QUIT "^"
+10 ; Checking for REJECTS before proceeding to Rx Release
+11 IF $$FIND^PSOREJUT(RX,RFL)
Begin DoDot:1
+12 SET ACTION=$$HDLG^PSOREJU1(RX,RFL,"79,88,943","ED","OIQ","Q")
End DoDot:1
IF ACTION="Q"!(ACTION="^")
WRITE !
QUIT "^"
+13 ; - ePharmacy switch is OFF
+14 IF '$$ECMEON^BPSUTIL($$RXSITE^PSOBPSUT(RX,RFL))
QUIT ""
+15 ; - Not an ePharmacy Rx
+16 IF $$STATUS^PSOBPSUT(RX,RFL)=""
QUIT ""
+17 IF '$DATA(PSOTRIC)
NEW PSOTRIC
SET PSOTRIC=""
SET PSOTRIC=$$TRIC^PSOREJP1(RX,RFL,PSOTRIC)
+18 ; - NDC editing before Rx release
+19 SET ACTION=$$CHGNDC^PSONDCUT(RX,RFL,$GET(PID))
+20 IF ACTION="^"!(ACTION=2)
Begin DoDot:1
+21 if ACTION="^"
WRITE !!,$CHAR(7),"A valid NDC must be entered before the Release function can be completed.",!
HANG 1
+22 IF $GET(PSOTRIC)
if ACTION=2
DO TRIC
End DoDot:1
QUIT "^"
+23 ; - Checking for OPEN/UNRESOLVED 3rd. Party Payer Rejects (After possible NDC edit)
+24 IF $$FIND^PSOREJUT(RX,RFL)
Begin DoDot:1
+25 SET ACTION=$$HDLG^PSOREJU1(RX,RFL,"79,88,943","ED","OIQ","Q")
End DoDot:1
IF ACTION="Q"!(ACTION="^")
WRITE !
QUIT "^"
+26 IF $GET(PSOTRIC)
IF $$STATUS^PSOBPSUT(RX,RFL)["IN PROGRESS"
DO TRIC
QUIT "^"
+27 QUIT ""
+28 ;
TRIC ;
+1 WRITE !!,$CHAR(7),$SELECT(PSOTRIC=1:"TRICARE",1:"CHAMPVA")_" 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 NEW RXNDC,SITE
+11 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+12 if '$DATA(STS)
SET STS="S"
if '$DATA(SRC)
SET SRC=""
SET HNG=+$GET(HNG)
+13 SET RXNDC=$$GETNDC^PSONDCUT(RX,RFL)
+14 ; - Saves the NDC from CMOP/Automated Dispensing Machine in the Prescription file
+15 IF $$NDCFMT^PSSNDCUT(NDC)'=""
DO SAVNDC^PSONDCUT(RX,RFL,$$NDCFMT^PSSNDCUT(NDC),$SELECT(SRC="C":1,1:0))
+16 ; - Not an ePharmacy Rx
+17 IF $$STATUS^PSOBPSUT(RX,RFL)=""
QUIT ""
+18 ; - Unsuccessful Release
+19 IF STS="U"
Begin DoDot:1
+20 DO REVERSE^PSOBPSU1(RX,RFL,"CRLX",,"UNSUCCESSFUL "_$SELECT(SRC="C":"CMOP",1:"EXT INTERFACE")_" RELEASE",1)
End DoDot:1
QUIT
+21 ; - Notifying IB of a Rx RELEASE event
+22 DO RELEASE^PSOBPSU1(RX,RFL)
+23 ; - Invalid NDC from Automated Dispensing Machine
+24 IF SRC="A"
IF $$NDCFMT^PSSNDCUT(NDC)=""
Begin DoDot:1
+25 DO REVERSE^PSOBPSU1(RX,RFL,"CRLR",,"INVALID EXT INTERFACE NDC",1,NDC)
End DoDot:1
QUIT
+26 ; - Invalid NDC number for CMOP
+27 IF SRC="C"
IF $$NDCFMT^PSSNDCUT(NDC)=""
Begin DoDot:1
+28 DO REVERSE^PSOBPSU1(RX,RFL,"CRLR",,"INVALID CMOP NDC",1,NDC)
End DoDot:1
QUIT
+29 ; - If NDC not equal RXNDC, issue reversal and submit new claim
+30 IF SRC="A"
IF $$NDCFMT^PSSNDCUT(NDC)'=RXNDC
Begin DoDot:1
+31 DO ECMESND^PSOBPSU1(RX,RFL,RLDT,"CRLB",$$NDCFMT^PSSNDCUT(NDC),,"AUTO RELEASE",,1,,1)
DO UPDFL^PSOBPSU2(RX,RFL,RLDT)
+32 HANG HNG
+33 ; - If new claim returned PAYABLE, save new NDC in the DRUG/PRESCRIPTION files
+34 IF $$STATUS^PSOBPSUT(RX,RFL)="E PAYABLE"
DO SAVNDC^PSONDCUT(RX,RFL,$$NDCFMT^PSSNDCUT(NDC),0,1)
End DoDot:1
QUIT
+35 ; - If NDC not equal RXNDC, issue reversal and submit new claim
+36 IF SRC="C"
IF $$NDCFMT^PSSNDCUT(NDC)'=RXNDC
Begin DoDot:1
+37 ; - Reverse/Resubmit with correct NDC
+38 DO ECMESND^PSOBPSU1(RX,RFL,RLDT,"CRLB",$$NDCFMT^PSSNDCUT(NDC),1,"CMOP RELEASE",,1,,1)
DO UPDFL^PSOBPSU2(RX,RFL,RLDT)
+39 ; - Wait for a response from the Payer for the submission above
+40 HANG HNG
+41 ; - If new claim returned PAYABLE, save new NDC in the DRUG/PRESCRIPTION files
+42 IF $$STATUS^PSOBPSUT(RX,RFL)="E PAYABLE"
DO SAVNDC^PSONDCUT(RX,RFL,$$NDCFMT^PSSNDCUT(NDC),1,1)
End DoDot:1
QUIT
+43 ; - Calls ECME api responsible for notifying IB to create a BILL
+44 DO IBSEND(RX,RFL,$SELECT(SRC="C":2,1:1),NDC)
+45 QUIT
+46 ;
IBSEND(RX,RFL,AUTO,PSONDC) ; Rx Release
+1 ; Create Release Event
+2 ; Calls ECME, if needed
+3 ; If Payable or Duplicate, calls IB to create a bill
+4 ;
+5 ;Input: (r) RX - Rx IEN (#52)
+6 ; (o) RFL - Refill # (Default: most recent)
+7 ; (o) AUTO - Set if called by Auto Release Process (1=OPAI, 2=CMOP)
+8 ; (o) PSONDC - NDC to be on outgoing claim
+9 ;
+10 NEW PSORELDT
+11 IF '$DATA(RFL)
SET RFL=$$LSTRFL^PSOBPSU1(RX)
+12 ; - ECME turned OFF for Rx's site
+13 IF '$$ECMEON^BPSUTIL($$RXSITE^PSOBPSUT(RX,RFL))
QUIT
+14 NEW STATUS
+15 SET STATUS=$$STATUS(RX,RFL)
+16 ; - Not an ePharmacy Rx
+17 IF STATUS=""
QUIT ""
+18 ; - Notifying IB of a Rx RELEASE event
+19 ; - Do not call for auto release process as it has already been done
+20 SET AUTO=+$GET(AUTO)
+21 IF 'AUTO
DO RELEASE^PSOBPSU1(RX,RFL,DUZ)
+22 ; - If the previous ECME claim was reversed or incomplete, re-submit the claim to the payer
+23 IF (STATUS="E REVERSAL ACCEPTED")!(STATUS="IN PROGRESS")
Begin DoDot:1
+24 SET PSORELDT=$$RXRLDT^PSOBPSUT(RX,RFL)
+25 SET PSONDC=$$NDCFMT^PSSNDCUT($GET(PSONDC))
+26 DO ECMESND^PSOBPSU1(RX,RFL,PSORELDT,$SELECT(AUTO:"C",1:"")_"RRL",PSONDC,$SELECT(AUTO=2:1,1:""))
End DoDot:1
QUIT
+27 ; - Notifying ECME of a BILLING event
+28 IF STATUS="E PAYABLE"!(STATUS="E DUPLICATE")
Begin DoDot:1
+29 NEW PSOCLAIM
SET PSOCLAIM=$$CLAIM^BPSBUTL(RX,RFL)
+30 DO IBSEND^BPSECMP2($PIECE(PSOCLAIM,"^",2),$PIECE(PSOCLAIM,"^",3),"BILL",DUZ)
End DoDot:1
QUIT
+31 QUIT
+32 ;
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")