source: FOIAVistA/trunk/r/INCOME_VERIFICATION_MATCH-IVM/IVMPTRN5.m@ 1582

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

initial load of FOIAVistA 6/30/08 version

File size: 4.6 KB
Line 
1IVMPTRN5 ;ALB/CPM/GN - NIGHTLY BILLING TRANSMISSION PROCESSING ; 1/15/01 11:21am [12/17/03 3:45pm]
2 ;;2.0;INCOME VERIFICATION MATCH;**1,9,24,34,69,78,96**; 21-OCT-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 ;
6 ;IVM*2*96 - break up Z09's by Income year, via new "ATR" xref
7 ;
8EN ; This routine performs the nightly compilation and transmission
9 ; of DHCP billing activity for IVM patients to the IVM Center.
10 ;
11 K ^TMP("IVMPTRN5",$J)
12 D IVMPT ; get data for IVM patients
13 D INS^IBAMTV4("^TMP(""IVMPTRN5"",$J)") ; get data for Insurance patients
14 D UPDATE^IVMPTRN6 ; update file #301.61
15 D TRNSMT ; post transmissions
16 D TRNSMT^EASPTRN5 ;If any EDB Z09's to transmit - then send
17 Q
18 ;
19 ;
20IVMPT ; Get claims and patient charges for IVM patients
21 N DFN,IVMSTART,IVMEND
22 S DFN=0 F S DFN=$O(^IVM(301.61,"C",DFN)) Q:'DFN D
23 .S IVMSTART=$$INIT(DFN) S:'IVMSTART IVMEND=0
24 .I IVMSTART S IVMEND=$$FMADD^XLFDT(IVMSTART,364) S:IVMEND>DT IVMEND=DT
25 .D ALL^IBAMTV4(DFN,"^TMP(""IVMPTRN5"",$J)",IVMSTART,IVMEND)
26 Q
27 ;
28 ;
29TRNSMT ; Transmit required billing activity.
30 Q:'$D(^IVM(301.61,"ATR"))
31 ;
32 N HL,HLDT,HLDT1,HLEID,HLMID,MID,MTIEN,RESULT
33 S HLEID="VAMC "_$P($$SITE^VASITE,"^",3)_" ORU-Z09 SERVER"
34 S HLEID=$O(^ORD(101,"B",HLEID,0))
35 D INIT^IVMUFNC(HLEID,.HL) S HLMTN="ORU"
36 ;
37 S ICYR=0 ;IVM*2*96
38 F S ICYR=$O(^IVM(301.61,"ATR",ICYR)) Q:'ICYR D
39 . D BLDZ09(ICYR)
40 D FILE^IVMPTRN3
41 K DFN,IVMPID,IVMTDA,IVMMTDT,IVMN,IVMSTOP,IVMEVENT,IVMHZIC,VAFPID,DGREL,DGINC,DGINR,DGDEP
42 D CLEAN^IVMUFNC
43 Q
44 ;
45BLDZ09(ICYR) ;create the Z09 per DFN
46 S DFN=0
47 F S DFN=$O(^IVM(301.61,"ATR",ICYR,DFN)) Q:'DFN D
48 .I $$WHERETO^EASPTRN1(ICYR,DFN) Q ;Do not send EDB Z09's
49 .I IVMCT=0,$G(IVMGTOT) D FILE^HLTF
50 .S HLEVN=HLEVN+1
51 .;
52 .; FIND A SLOT FOR EACH BATCH
53 .I HLEVN#100=1 D
54 ..K HLDT,HLDT1,HLMID,MTIEN
55 ..D CREATE^HLTF(.HLMID,.MTIEN,.HLDT,.HLDT1)
56 .;
57 .; SET UP MSH SEGMENT
58 .S MID=HLMID_"-"_HLEVN
59 .D MSH^HLFNC2(.HL,MID,.RESULT)
60 .S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=RESULT
61 .;
62 .; - re-set msg control id into MSH segment
63 .D MSGID^IVMUFNC4(.IVMCT)
64 .;
65 .; - create PID segment
66 .K IVMPID,VAFPID
67 .S IVMPID=$$EN^VAFHLPID(DFN,"1,3,5,7,8,19") I $D(VAFPID(1)) S IVMPID(1)=VAFPID(1)
68 .;I $P(IVMPID_$G(IVMPID(1)),HLFS,20)["P" D PSEUDO^IVMPTRN1
69 .S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=IVMPID
70 .I $D(IVMPID(1)) S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=IVMPID(1)
71 .;
72 .; - find the patient's Means Test date and create ZIC segment
73 .S IVMTDA=$O(^IVM(301.61,"ATR",ICYR,DFN,0))
74 .S IVMMTDT=$S(IVMTDA:$P($G(^IVM(301.61,IVMTDA,0)),"^",5),1:DT)
75 .D ALL^DGMTU21(DFN,"V",IVMMTDT,"IPR",+$$LST^DGMTU(DFN,IVMMTDT))
76 .S IVMHZIC=$$EN^VAFHLZIC(+$G(DGINC("V")),"1,2")
77 .I '$P(IVMHZIC,"^",3) S $P(IVMHZIC,"^",3)=$$HLDATE^HLFNC($O(^IVM(301.5,"APT",DFN,0)))
78 .;
79 .; - find all transactions for the patient and create FT1 segments
80 .S IVMTDA=0 F S IVMTDA=$O(^IVM(301.61,"ATR",ICYR,DFN,IVMTDA)) Q:'IVMTDA D
81 ..S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=$$FT1^IVMUFNC3(IVMTDA)
82 ..S IVMN=$G(^IVM(301.61,IVMTDA,0))
83 ..;
84 ..; - if a payment has been made (or if the bill is closed),
85 ..; - but the bill has never been transmitted, re-transmit.
86 ..I ($P(IVMN,"^",9)!($P(IVMN,"^",10))),'$P(IVMN,"^",13) D
87 ...D NOW^%DTC S DA=IVMTDA,DIE="^IVM(301.61,",DR=".13////"_% D ^DIE
88 ...S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=$$FT1^IVMUFNC3(IVMTDA)
89 ..;
90 ..; - update transmission record
91 ..S IVMSTOP=0
92 ..I $P(IVMN,"^",10)!$P(IVMN,"^",11) S IVMSTOP=1
93 ..I $P(IVMN,"^",4)>1 S IVMSTOP=1
94 ..D NOW^%DTC S DR=".12////0;.13////"_%
95 ..I IVMSTOP S DR=DR_";.14////1"
96 ..S DR=DR_";1.03////"_%_";1.04////"_DUZ
97 ..S DA=IVMTDA,DIE="^IVM(301.61," D ^DIE K DA,DR,DIE
98 .;
99 .; - set ZIC segment
100 .S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=IVMHZIC
101 .;
102 .S IVMEVENT="Z09"
103 .I HLEVN'<100 D FILE^IVMPTRN3
104 ;
105 Q
106 ;
107 ;
108INIT(DFN) ; Find the initial date for which to return patient charges.
109 ; Input: DFN -- Pointer to the patient in file #2
110 ; Output: Date patient became Cat C, or null (for ins. patients)
111 ;
112 N IVMDATE,X,Y S IVMDATE=0
113 I '$G(DFN) G INITQ
114 S X=0 F S X=$O(^IVM(301.61,"C",DFN,X)) Q:'X S Y=$G(^IVM(301.61,X,0)) I $P(Y,"^",4)>1,$P(Y,"^",5) S IVMDATE=$P(Y,"^",5) Q
115 I IVMDATE S IVMDATE=$P($$LST^DGMTU(DFN,IVMDATE),"^",2)
116INITQ Q IVMDATE
117 ;
118 ;Check DISABLE text in #101 to determine if communications with
119 ; Edb are active or not. Text in this field indicates link is not
120 ; active
121 ;
122EDB(HLEID) S HLEID=$O(^ORD(101,"B",HLEID,0))
123 I 'HLEID Q 0 ;Protocol not defined
124 I $P(^ORD(101,HLEID,0),"^",3)="" Q 1 ;Edb protocol active
125 Q 0
Note: See TracBrowser for help on using the repository browser.