source: WorldVistAEHR/trunk/r/E_CLAIMS_MGMT_ENGINE-BPS/BPSUTIL.m@ 1270

Last change on this file since 1270 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 5.1 KB
Line 
1BPSUTIL ;BHAM ISC/FLS/SS - General Utility functions ;06/01/2004
2 ;;1.0;E CLAIMS MGMT ENGINE;**1,3,2,5**;JUN 2004;Build 45
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 Q
6 ;
7 ; ECMEON
8 ; Input:
9 ; SITE - Pointer to Outpatient Site file (#59)
10 ; Output
11 ; 1 - ECME is turned ON for the Outpatient Site
12 ; 0 - ECME is not turned ON for the Outpatient Site.
13 ; Note that ON means that the Outpatient site is linked to an active
14 ; BPS Pharmacy that has a Pharmacy ID.
15ECMEON(SITE) ;
16 I '$G(SITE) Q 0
17 N BPSPHARM,FACID
18 S FACID=0
19 S BPSPHARM=$$GETPHARM(SITE)
20 I BPSPHARM="" Q 0
21 S FACID=$$GET1^DIQ(9002313.56,BPSPHARM_",",41.01)
22 I FACID="",'$$NPIREQ^BPSNPI(DT) S FACID=$$GET1^DIQ(9002313.56,BPSPHARM_",",.02)
23 Q $S(FACID:1,1:0)
24 ;
25CMOPON(SITE) ; - Returns 1 if CMOP is turned ON for ECME or 0 if not
26 ; SITE - Pointer to #59 (OUTPATIENT SITE)
27 Q:'$G(SITE) 0
28 N PHRM S PHRM=$O(^BPS(9002313.56,"C",SITE,0)) I 'PHRM Q 0
29 Q $$GET1^DIQ(9002313.56,PHRM,1,"I")
30 ;
31 ;Function returns STATUS flag from BPS PHARMACIES (file #56)
32 ; Returns '1' for active or '0' for inactive BPS Pharmacy
33BPSACTV(BPSPHARM) ;
34 Q:'$G(BPSPHARM) 0
35 Q +$P($G(^BPS(9002313.56,BPSPHARM,0)),U,10)
36 ;
37BPSPLN(RXI,RXR) ; - Returns the insurance PLAN NAME (902.24) field from BPS TRANSACTION
38 ;
39 ; Input variables -> RXI - Internal Prescription File IEN
40 ; RXR - Refill Number
41 ;
42 I '$G(RXI) Q ""
43 I '$G(RXR) S RXR=0
44 N IEN59 S IEN59=$$IEN59^BPSOSRX(RXI,RXR) Q:IEN59="" ""
45 N CINS S CINS=$$GET1^DIQ(9002313.59,IEN59,901) Q:'CINS ""
46 Q $$GET1^DIQ(9002313.59902,CINS_","_IEN59,902.24)
47 ;
48 ;API for IB (IA #4146) to select BPS PHARMACY
49 ;returns results as a local array BPPHARM
50 ; Select the ECME Pharmacy or Pharmacies
51 ;
52 ; Input Variable -> BPSPHAR is passed by reference to get the result of user's selection
53 ; BPPHARM = 1 One or More Pharmacies Selected
54 ; = 0 User Entered 'ALL'
55 ; If BPSPHAR = 1 then the BPSPHAR array will be defined where:
56 ; BPSPHAR(ptr) = ptr ^ BPS PHARMACY NAME and
57 ; ptr = Internal Pointer to BPS PHARMACIES file (#9002313.56)
58 ;
59 ; Return Value -> "" = Valid Entry or Entries Selected
60 ; ^ = Exit
61SELPHARM(BPSPHAR) ;
62 N BPRET,BPPHARM
63 S BPRET=$$SELPHARM^BPSRPT3()
64 M BPSPHAR=BPPHARM
65 Q BPRET
66 ;
67 ;
68 ;API for IB (IA #4146) to determine whether is one or more BPS PHARMACIES in the system
69 ;Function returns
70 ;1 - if the site has more than one record in the file #9002313.56
71 ;0 - if there are no any divisions
72 ;0^NAME OF THE EPHARM - if only one division return 0 and its name
73 ; to use in the header of the report
74MULTPHRM() ;
75 N IBX
76 S IBX=+$O(^BPS(9002313.56,0))
77 I IBX=0 Q 0
78 I $O(^BPS(9002313.56,IBX))>0 Q 1
79 Q "0^"_$$GET1^DIQ(9002313.56,IBX,.01,"E")
80 ;
81 ; Function for IB (IA #4146) to return site linked to pharmacy
82 ; Input
83 ; BPSDIV - Outpatient Site
84 ; Returns
85 ; BPSPHARM - BPS Pharmacy IEN
86GETPHARM(BPSDIV) ;
87 N BPSPHARM
88 I $G(BPSDIV)="" Q ""
89 S BPSPHARM=$O(^BPS(9002313.56,"C",BPSDIV,0)) I 'BPSPHARM Q ""
90 Q:'$$BPSACTV^BPSUTIL(BPSPHARM) ""
91 Q BPSPHARM
92 ;
93 ;API for the IB package (IA#4146)
94 ;Input parameters:
95 ; BPSRX - Rx ien (file #52)
96 ; BPSREFNO - refill number
97 ;Returned value:
98 ; 1st piece:
99 ; 0 - status "non-payable" OR there is no response from the payer for whatever reason OR wasn't submitted OR invalid parameters
100 ; 1- status "payable"
101 ; 2nd piece:
102 ; amount the payer agreed to pay
103 ; 3rd piece:
104 ; Date of Service
105 ;
106PAIDAMNT(BPSRX,BPSREFNO) ;
107 I ($G(BPSRX)="")!($G(BPSREFNO)="") Q "0^"
108 N BPSTAT,BPSRET,IEN59,BPSRESP,BPDOS
109 S BPSTAT=$$STATUS^BPSOSRX(BPSRX,BPSREFNO)
110 ;The status of the claim should be "payable" in order to get amount of the 3rd party payment
111 ;If it was an attempt to reverse the payable claim AND reversal was rejected
112 ;then the claim still is considered as "payable" and we still can get the amount paid by the 3rd party.
113 ;In this case we return 1 (payable) in first piece and the amount paid in the 2nd piece of the returned value.
114 ;All other statuses mean that we cannot get amount paid so we return 0 = "non payable"
115 I $P(BPSTAT,U)'="E PAYABLE",$P(BPSTAT,U)'="E REVERSAL REJECTED",$P(BPSTAT,U)'="E DUPLICATE" Q "0^"
116 ;get ien for BPS TRANSACTION file
117 S IEN59=+$$IEN59^BPSOSRX(BPSRX,BPSREFNO)
118 I IEN59="" Q "0^" ;BPS Transaction IEN could not be calculated
119 S BPSRESP=+$P($G(^BPST(IEN59,0)),U,5)
120 ;response from the payer was not found - either claim was never submitted OR there
121 ;is no response for some reason - either way - we cannot provide the amount paid, so return "0"
122 I BPSRESP=0 Q "0^"
123 S BPDOS=+$P($G(^BPST(IEN59,12)),U,2)
124 S BPSRET=+$$INSPAID^BPSOS03(BPSRESP)
125 Q "1^"_BPSRET_U_BPDOS
126 ;
127 ; NPIEXTR
128 ; This API was written for the NPI extract (XUSNPIX2) and returns
129 ; the NCPDP and STATUS of the associated BPS Pharmacy
130 ; Input:
131 ; SITE - Pointer to Outpatient Site file (#59)
132 ; Output
133 ; NCPDP^STATUS (0 - inactive, 1 - active)
134 ; "" if no SITE passed in or no linkage
135NPIEXTR(SITE) ;
136 I '$G(SITE) Q ""
137 N BPSPHARM,NCPDP,STATUS
138 S BPSPHARM=$O(^BPS(9002313.56,"C",SITE,0))
139 I 'BPSPHARM Q ""
140 S STATUS=$$BPSACTV^BPSUTIL(BPSPHARM)
141 S NCPDP=$$GET1^DIQ(9002313.56,BPSPHARM_",",.02)
142 Q NCPDP_"^"_STATUS
Note: See TracBrowser for help on using the repository browser.