source: WorldVistAEHR/trunk/r/ENROLLMENT_APPLICATION_SYSTEM-EAS/EASPTRN5.m@ 1432

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

initial load of WorldVistAEHR

File size: 4.0 KB
RevLine 
[613]1EASPTRN5 ;ALB/CPM/GN - NIGHTLY BILLING TRANSMISSION PROCESSING ; 10/30/01 9:58am [12/17/03 1:09pm]
2 ;;1.0;ENROLLMENT APPLICATION SYSTEM;**23,33,47**; 21-OCT-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 ; For Edb Transmission Only - VAMC-to-Edb
6 ;
7 ;EAS*1*47 - break up Z09's by Income year, via new "ATR" xref
8 ;
9EN ; This routine performs the nightly compilation and transmission
10 ; of DHCP billing activity for IVM patients to the IVM Center.
11 ;
12TRNSMT ; Transmit required billing activity.
13 Q:'$D(^IVM(301.61,"ATR"))
14 ; =============
15 N HL,HLDT,HLDT1,HLEID,HLMID,MID,MTIEN,RESULT,ICYR
16 S HLEID="EAS EDB ORU-Z09 SERVER"
17 S HLEID=$O(^ORD(101,"B",HLEID,0))
18 D INIT^IVMUFNC(HLEID,.HL) S HLMTN="ORU"
19 S NUMS=""
20 F I=1:1:30 S NUMS=NUMS_$S(NUMS'="":",",1:"")_I
21 S ICYR=0 ;EAS*1*47
22 F S ICYR=$O(^IVM(301.61,"ATR",ICYR)) Q:'ICYR D
23 . D BLDZ09(ICYR)
24 D FILE^IVMPTRN3
25 K DFN,IVMPID,IVMTDA,IVMMTDT,IVMN,IVMSTOP,IVMEVENT,IVMHZIC,VAFPID,DGREL,DGINC,DGINR,DGDEP
26 D CLEAN^IVMUFNC
27 Q
28 ;
29BLDZ09(ICYR) ;create the Z09 per DFN
30 S DFN=0
31 F S DFN=$O(^IVM(301.61,"ATR",ICYR,DFN)) Q:'DFN D
32 .I '$$WHERETO^EASPTRN1(ICYR,DFN) Q ;Do not send legacy Z09's
33 .I IVMCT=0,$G(IVMGTOT) D FILE^HLTF
34 .S HLEVN=HLEVN+1
35 .; ==========
36 .; Find a slot for each batch
37 .I HLEVN#100=1 D
38 ..K HLDT,HLDT1,HLMID,MTIEN
39 ..D CREATE^HLTF(.HLMID,.MTIEN,.HLDT,.HLDT1)
40 .; ==========
41 .;
42 .; Setup MSH Segment
43 .S MID=HLMID_"-"_HLEVN
44 .D MSH^HLFNC2(.HL,MID,.RESULT)
45 .S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=RESULT
46 .;
47 .; - re-set msg control id into MSH segment
48 .D MSGID^IVMUFNC4(.IVMCT)
49 .;
50 .; - create PID segment
51 .K IVMPID,VAFPID
52 .S IVMPID=$$EN^VAFCPID(DFN,"1,2,3,4,5,7,8,19")
53 .I $D(VAFPID(1)) S IVMPID(1)=VAFPID(1)
54 .;I $P(IVMPID_$G(IVMPID(1)),HLFS,20)["P" D PSEUDO^IVMPTRN1
55 .S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=IVMPID
56 .I $D(IVMPID(1)) S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=IVMPID(1)
57 .;
58 .; - create PD1 segment - Patient CMOR segment <<<<<<<<<<<<<<<<<
59 .;S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=$$EN^VAFHLPD1(DFN,"1,2,3,4")
60 .S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=$$EN^VAFHLPD1(DFN,"1,3")
61 .;
62 .; - find the patient's Means Test date and create ZIC segment
63 .S IVMTDA=$O(^IVM(301.61,"ATR",ICYR,DFN,0))
64 .S IVMMTDT=$S(IVMTDA:$P($G(^IVM(301.61,IVMTDA,0)),"^",5),1:DT)
65 .D ALL^DGMTU21(DFN,"V",IVMMTDT,"IPR",+$$LST^DGMTU(DFN,IVMMTDT))
66 .S IVMHZIC=$$EN^VAFHLZIC(+$G(DGINC("V")),"1,2")
67 .;S IVMHZIC=$$EN^VAFHLZIC(+$G(DGINC("V")),$P(NUMS,",",1,23))
68 .I '$P(IVMHZIC,"^",3) S $P(IVMHZIC,"^",3)=$$HLDATE^HLFNC($O(^IVM(301.5,"APT",DFN,0)))
69 .;
70 .; - find all transactions for the patient and create FT1 segments
71 .S IVMTDA=0 F S IVMTDA=$O(^IVM(301.61,"ATR",ICYR,DFN,IVMTDA)) Q:'IVMTDA D
72 ..S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=$$FT1^EASUFNC3(IVMTDA)
73 ..S IVMN=$G(^IVM(301.61,IVMTDA,0))
74 ..;
75 ..; - if a payment has been made (or if the bill is closed),
76 ..; - but the bill has never been transmitted, re-transmit.
77 ..I ($P(IVMN,"^",9)!($P(IVMN,"^",10))),'$P(IVMN,"^",13) D
78 ...D NOW^%DTC S DA=IVMTDA,DIE="^IVM(301.61,",DR=".13////"_% D ^DIE
79 ...S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=$$FT1^EASUFNC3(IVMTDA)
80 ..;
81 ..; - update transmission record
82 ..;D:ISITESW'["H"
83 ..S IVMSTOP=0
84 ..I $P(IVMN,"^",10)!$P(IVMN,"^",11) S IVMSTOP=1
85 ..I $P(IVMN,"^",4)>1 S IVMSTOP=1
86 ..D NOW^%DTC S DR=".12////0;.13////"_%
87 ..I IVMSTOP S DR=DR_";.14////1"
88 ..S DR=DR_";1.03////"_%_";1.04////"_DUZ
89 ..S DA=IVMTDA,DIE="^IVM(301.61," D ^DIE K DA,DR,DIE
90 .;
91 .; - set ZIC segment
92 .S IVMCT=IVMCT+1,^TMP("HLS",$J,IVMCT)=IVMHZIC
93 .;
94 .S IVMEVENT="Z09"
95 .I HLEVN'<100 D FILE^IVMPTRN3
96 ;
97 Q
98 ;
99 ;
100INIT(DFN) ; Find the initial date for which to return patient charges.
101 ; Input: DFN -- Pointer to the patient in file #2
102 ; Output: Date patient became Cat C, or null (for ins. patients)
103 ;
104 N IVMDATE,X,Y S IVMDATE=0
105 I '$G(DFN) G INITQ
106 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
107 I IVMDATE S IVMDATE=$P($$LST^DGMTU(DFN,IVMDATE),"^",2)
108INITQ Q IVMDATE
Note: See TracBrowser for help on using the repository browser.