source: FOIAVistA/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBARXPFS.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 5.5 KB
Line 
1IBARXPFS ;OAK/ELZ - PFSS ROUTINE FOR INTER-FACILITY RX COPAY ;23-MAR-05
2 ;;2.0;INTEGRATED BILLING;**308**;21-MAR-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5NEW(DFN) ; this entry point will check patient cap knowledge status and queue to look up as necessary
6 N ZTSK,ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTSAVE,X,Y,POP
7 I $D(^IBAM(354.7,DFN,0)) Q
8 L +^IBAM(DFN):5 I '$T Q
9 S ZTRTN="DQNEW^IBARXPFS",ZTDESC="IB INTER-FACILITY CAP QUERY",ZTDTH=$$NOW^XLFDT,(ZTIO,ZTSAVE("DFN"),ZTSAVE("IBADT"))=""
10 D ^%ZTLOAD
11 L -^IBAM(DFN)
12 Q
13 ;
14DQNEW ; tasked entry point for cap information query
15 I $D(^IBAM(354.7,DFN,0)) Q
16 L +^IBAM(DFN):5 I '$T Q
17 D ADD^IBARXMU(DFN)
18BBE ; back billing entry assumes IBADT
19 N IBDT,IBT,IBX,IBS,IBD,IBB,DIE,DA,DR,X,IBA,IBP,IBZ,IBY,IBFD,IBTD
20 S IBDT=$E($S($G(IBADT):IBADT,1:DT),1,5)_"00"
21 S IBB=0,IBP=$$PRIORITY^IBARXMU(DFN)
22 S IBT=$$TFL^IBARXMU(DFN,.IBT) G:'IBT DQNEWQ
23 D CAP^IBARXMC(IBDT,IBP,.IBZ,.IBY,.IBFD,.IBTD) I 'IBY,'IBZ G DQNEWQ
24 I 'IBFD!('IBTD) G DQNEWQ
25 S IBX=0 F S IBX=$O(IBT(IBX)) Q:IBX<1 D
26 . ;
27 . ; need to query every month in the cap billing period
28 . S IBDT=IBFD D F S IBDT=$$NEXTMO^IBARXMC(IBDT) Q:IBDT>IBTD D
29 .. D UQUERY^IBARXMU(DFN,$E(IBDT,1,5)_"00",IBX,.IBD)
30 .. ;
31 .. ; error returned
32 .. I -1=+$G(IBD,"-1") Q
33 .. ;
34 .. ; loop through query and file data
35 .. S X=0 F S X=$O(IBD(X)) Q:X<1 S:$E(IBD(X),1,4)=(+IBT(IBX)_"-") IBA=$$ADD^IBARXMN(DFN,IBD(X)),IBB=IBB+$P(IBD(X),"^",11)
36 .. K IBD
37DQNEWQ ;
38 L -^IBAM(DFN)
39 ;
40 Q
41 ;
42MSG ; receives HL7 message from COTS product and files in 354.71 or others
43 N IBMSG,IBHEADER,IBICN,IBDFN,IBSSN,IBCLAIM,IBALIAS,IBSTAT,IBTYPE,IBINST
44 N IBRXDAT,IBRESLT,IB35471,IB351,IB35181,IB350,IBMTDT21,IBCODE,SEG,DFN,HLA
45 ;
46 ;parse message
47 S IBSTAT=$$STARTMSG^HLPRS(.IBMSG,HLMTIENS,.IBHEADER)
48 I 'IBSTAT S HLERR="Unable to start parse of message" G NEWTRANQ
49 ;
50 F Q:'$$NEXTSEG^HLPRS(.IBMSG,.SEG) D
51 . F IBT=3:1 S IBD=$P($T(HL7DATA+IBT),";",4) Q:IBD="" D
52 . . I $P(IBD,"^",2)=SEG("SEGMENT TYPE") D
53 . . . S @$P(IBD,"^")=$$GET^HLOPRS(.SEG,$P(IBD,"^",3),$P(IBD,"^",4),$P(IBD,"^",5),$P(IBD,"^",6))
54 . . . S IBCODE=$P(IBD,"^",7,99)
55 . . . I $L(IBCODE),$L(@$P(IBD,"^")) S X=@$P(IBD,"^") X IBCODE S @$P(IBD,"^")=X
56 ;
57 ;check out data received from message
58 S DFN=$$PATIENT($G(IBICN),$G(IBDFN),$G(IBSSN),$G(IBVACLM),$G(IBALIAS))
59 G:'DFN NEWTRANQ
60 S IBTYPE=$G(IBTYPE)
61 ;
62 D @($S(IBTYPE="IN":"35471",IBTYPE="MT":"351",IBTYPE="LB":"35181",IBTYPE="ML":"350",IBTYPE="ST":"QUERYVA",IBTYPE="BL":"BILLVA",1:"ERR")_"^IBARXMI")
63 ;
64 ;
65NEWTRANQ ;
66 S HLA("HLA",1)="MSA"_HL("FS")_$S('$D(HLERR):"AA",1:"AE")_HL("FS")_HL("MID")
67 D GENACK^HLMA1(HL("EID"),HLMTIENS,HL("EIDS"),"LM",1,.IBRESLT)
68 Q
69 ;
70PATIENT(IBICN,IBDFN,IBSSN,IBVACLM,IBALIAS) ; this function will receive
71 ; several patient data elements and validate them. Assuming the data
72 ; meets expected requirements, the function will return the patient's
73 ; DFN. The requirement is ICN is a must, the patient must also match
74 ; at least 2 other data elements.
75 ;
76 N DFN,IBMATCH,IBX
77 S (IBMATCH,IBX)=0,HLERR=""
78 S DFN=$$DFN^IBARXMU(IBICN) I 'DFN S HLERR="Invalid ICN: "_IBICN G PATQ
79 ;
80 I DFN=IBDFN S IBMATCH=1
81 E S HLERR=DFN_" Doesn't match ICN DFN "_IBDFN
82 ;
83 I IBSSN,$P($G(^DPT(DFN,0)),"^",9)=IBSSN S IBMATCH=IBMATCH+1
84 E S HLERR=HLERR_" SSN Mismatch:"_IBSSN
85 I IBMATCH>1 G PATQ
86 ;
87 I $L(IBVACLM),$P($G(^DPT(DFN,.31)),"^",3)=IBVACLM S IBMATCH=IBMATCH+1
88 E S:$L(IBVACLM) HLERR=HLERR_" VA Claim Mismatch:"_IBVACLM
89 I IBMATCH>1 G PATQ
90 ;
91 F S IBX=$O(^DPT(DFN,.01,IBX)) Q:'IBX!(IBMATCH>1) I $L(IBALIAS),$P($G(^DPT(DFN,.01,IBX,0)),"^",2)=IBALIAS S IBMATCH=IBMATCH+1 Q
92 I IBMATCH<2 S DFN=0,HLERR=HLERR_" ALIAS Mismatch"
93PATQ ;
94 I DFN K HLERR
95 Q DFN
96 ;
97HL7DATA ; hl7 data mapping
98 ; format: description ; IB Variable ^ segment ^ seq ^ comp ^ subcomp ^
99 ; extract code
100 ;;patient icn;IBICN^PID^3^1^1^1
101 ;;patient dfn;IBDFN^PID^3^1^1^2^S IBINST=$E(X,1,3),X=$E(X,4,99)
102 ;;patient ssn;IBSSN^PID^3^1^1^3
103 ;;patient va claim;IBVACLM^PID^3^1^1^4
104 ;;patient alias ssn;IBALIAS^PID^3^1^1^5
105 ;;receiver trans type;IBTYPE^FT1^6
106 ;;transaction number;IB35471(.01)^FT1^2
107 ;;trans eff date;IB35471(.03)^FT1^4^1^1^^S X=$$FMDATE^HLFNC(X)
108 ;;trans status;IB35471(.05)^FT1^8
109 ;;rx number;IB35471(.091)^RXE^15
110 ;;refill number;IB35471(.092)^RXE^12
111 ;;units;IB35471(.07)^FT1^12^5^1
112 ;;total charge;IB35471(.08)^FT1^12^1^1
113 ;;parent transaction;IB35471(.1)^FT1^9
114 ;;billed amount;IB35471(.11)^FT1^11^1^1
115 ;;unbilled amount;IB35471(.12)^FT1^15^1^1
116 ;;mt clock begin date;IB351(.03)^ZMT^35^^^^S X=$$FMDATE^HLFNC(X)
117 ;;mt clock status;IB351(.04)^ZMT^36
118 ;;1st 90 day amt;IB351(.05)^ZMT^37
119 ;;2nd 90 day amt;IB351(.06)^ZMT^38
120 ;;3rd 90 day amt;IB351(.07)^ZMT^39
121 ;;4th 90 day amt;IB351(.08)^ZMT^40
122 ;;number of inpt days;IB351(.09)^ZMT^41
123 ;;mt clock end date;IB351(.1)^ZMT^42^^^^S X=$$FMDATE^HLFNC(X)
124 ;;ltc clock begin date;IB35181(.03)^ZMT^43^^^^S X=$$FMDATE^HLFNC(X)
125 ;;ltc clock end date;IB35181(.04)^ZMT^44^^^^S X=$$FMDATE^HLFNC(X)
126 ;;ltc clock status;IB35181(.05)^ZMT^45
127 ;;ltc 21 exempt dates;IBMTD21^ZMT^46^^^^S IBMTDT21=$G(IBMTDT21)+1,IBMTDT21(IBMTDT21)=$$FMDATE^HLFNC(X)
128 ;;charege type;IB350("TYP")^ZMT^47
129 ;;patient type;IB350("IO")^PV1^2
130 ;;event date/time;IB350("EDT")^PV1^44^1^^^S X=$$FMDATE^HLFNC(X)
131 ;;bed section;IB350("BS")^ZMT^48
132 ;;units;IB350(.06)^ZMT^49
133 ;;total charge;IB350(.07)^ZMT^50
134 ;;event date;IB350(.17)^ZMT^51^^^^S X=$$FMDATE^HLFNC(X)
135 ;;from date;IB350(.14)^ZMT^52^^^^S X=$$FMDATE^HLFNC(X)
136 ;;to date;IB350(.15)^ZMT^53^^^^S X=$$FMDATE^HLFNC(X)
137 ;;stop code;IB350(.2)^ZMT^54
138 ;;trans status;IB350(.05)^ZMT^55
139 ;;idx visit number;IB350("IDX")^PV1^19^1
140 ;;
141 ;
Note: See TracBrowser for help on using the repository browser.