source: WorldVistAEHR/trunk/r/FEE_BASIS-FB/FBFHLL.m@ 1524

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

initial load of WorldVistAEHR

File size: 4.1 KB
Line 
1FBFHLL ;AISC/LEG-FPPS QUEUED INVOICE FILE ;9/10/2003
2 ;;3.5;FEE BASIS;**61**;JULY 18, 2003
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 Q
6 ;
7LOG(FBN,FBTYPE) ; processes batch and logs 0.00 invoices to FILE #163.5
8 ; input
9 ; FBN - pointer to FEE BASIS BATCH file
10 ; FBTYPE - batch type (B3,B5,B9,BT)
11 N FBX,FBERR
12 S FBERR=""
13 F FBX="FBN","FBTYPE" S:'$L(@FBX) FBERR=FBX_":0 LENGTH"
14 I $L(FBERR) W FBERR Q
15 I "B3,B5,B9"[FBTYPE D @FBTYPE ;either B3, B5, B9
16 Q
17 ;
18B3 ; process outpatient/ancillary batch
19 Q:FBTYPE'="B3"
20 N DA,FBAAIN,FBAMTPD,FBINV,FBY0
21 ;
22 ; loop thru items in batch and build list of EDI invoices and their $
23 S DA(3)=0 F S DA(3)=$O(^FBAAC("AC",FBN,DA(3))) Q:'DA(3) D
24 . S DA(2)=0 F S DA(2)=$O(^FBAAC("AC",FBN,DA(3),DA(2))) Q:'DA(2) D
25 . . S DA(1)=0
26 . . F S DA(1)=$O(^FBAAC("AC",FBN,DA(3),DA(2),DA(1))) Q:'DA(1) D
27 . . . S DA=0
28 . . . F S DA=$O(^FBAAC("AC",FBN,DA(3),DA(2),DA(1),DA)) Q:'DA D
29 . . . . Q:$P($G(^FBAAC(DA(3),1,DA(2),1,DA(1),1,DA,3)),U)="" ; not EDI
30 . . . . S FBY0=$G(^FBAAC(DA(3),1,DA(2),1,DA(1),1,DA,0))
31 . . . . S FBAAIN=$P(FBY0,U,16)
32 . . . . S FBAMTPD=$P(FBY0,U,3)
33 . . . . I FBAAIN]"" S FBINV(FBAAIN)=$G(FBINV(FBAAIN))+FBAMTPD
34 ;
35 ; loop thru EDI invoices and queue invoices with 0.00 payment
36 S FBAAIN="" F S FBAAIN=$O(FBINV(FBAAIN)) Q:FBAAIN="" D
37 . Q:$G(FBINV(FBAAIN))>0 ; not zero dollar invoice
38 . D FILEQUE(FBAAIN,3)
39 Q
40 ;
41B5 ; processes pharmacy batch
42 Q:FBTYPE'="B5"
43 N DA,FBAAIN,FBAMTPD,FBINV,FBRXY0,FBY0
44 ;
45 ; loop thru items in batch and build list of EDI invoices and their $
46 S DA(1)=0 F S DA(1)=$O(^FBAA(162.1,"AE",FBN,DA(1))) Q:'DA(1) D
47 . S DA=0 F S DA=$O(^FBAA(162.1,"AE",FBN,DA(1),DA)) Q:'DA D
48 . . S FBY0=$G(^FBAA(162.1,DA(1),0))
49 . . S FBRXY0=$G(^FBAA(162.1,DA(1),"RX",DA,0))
50 . . Q:$P(FBY0,U,13)="" ; not EDI
51 . . S FBAAIN=$P(FBY0,U)
52 . . S FBAMTPD=$P(FBRXY0,U,16)
53 . . I FBAAIN]"" S FBINV(FBAAIN)=$G(FBINV(FBAAIN))+FBAMTPD
54 ;
55 ; loop thru EDI invoices and queue invoices with 0.00 payment
56 S FBAAIN="" F S FBAAIN=$O(FBINV(FBAAIN)) Q:FBAAIN="" D
57 . Q:$G(FBINV(FBAAIN))>0 ; not zero dollar invoice
58 . D FILEQUE(FBAAIN,5)
59 Q
60 ;
61B9 ; processes inpatient batch
62 Q:FBTYPE'="B9"
63 N DA,FBAAIN,FBAMTPD,FBY0
64 ;
65 ; loop thru items in batch and log 0.00 EDI invoices
66 S DA=0 F S DA=$O(^FBAAI("AC",FBN,DA)) Q:'DA D
67 . Q:$P($G(^FBAAI(DA,3)),U)="" ; not EDI
68 . S FBY0=$G(^FBAAI(DA,0))
69 . S FBAAIN=$P(FBY0,U)
70 . S FBAMTPD=$P(FBY0,U,9)
71 . Q:FBAMTPD>0 ; not 0.00 invoice
72 . D FILEQUE(FBAAIN,9)
73 Q
74 ;
75PAIDLOG(FBINV) ; process EDI invoices from payment conf/canc message
76 ; input FBINV array, passed by reference
77 ; format FBINV(fbtype,fbaain)=""
78 ; where fbtype = 3, 5, or 9
79 ; fbaain = invoice number
80 ;
81 N FBAAIN,FBTYPE
82 ; loop thru type
83 F FBTYPE=3,5,9 D
84 . ; loop thru invoices
85 . S FBAAIN="" F S FBAAIN=$O(FBINV(FBTYPE,FBAAIN)) Q:FBAAIN="" D
86 . . ; queue invoice
87 . . D FILEQUE(FBAAIN,FBTYPE)
88 Q
89 ;
90FILEQUE(FBAAIN,FBTYPE) ; file invoice into FPPS Queue
91 ; input
92 ; FBAAIN - invoice number
93 ; FBTYPE - type (3, 5, or 9)
94 ; where 3 = outpatient/ancillary - file 162
95 ; 5 = pharmacy - file 162.1
96 ; 9 = inpatient - file 162.5
97 ;
98 N FBDA,FBFDA
99 ;
100 ;
101 S FBDA=$O(^FBHL(163.5,"B",FBAAIN,""),-1) ; last entry for invoice
102 I FBDA,$D(^FBHL(163.5,"AC",0,FBDA)) Q ; already queued to be sent
103 ;
104 S FBFDA(163.5,"+1,",.01)=FBAAIN
105 S FBFDA(163.5,"+1,",1)=FBTYPE
106 S FBFDA(163.5,"+1,",2)=0
107 D UPDATE^DIE("","FBFDA")
108 Q
109 ;
110CKFPPS(FBAAIN) ; checks if invoice was previously sent to FPPS
111 ; input
112 ; FBAAIN - invoice number
113 ; result
114 ; status (0,1,X) of 1st entry for invoice in file 163.5
115 ; where 0 = waiting to be transmitted
116 ; 1 = transmitted
117 ; X = not logged
118 N FBDA,FBRET,FBSTAT
119 S FBRET=""
120 ;
121 ; loop thru entries for invoice (look until end or return value is true)
122 S FBDA=0 F S FBDA=$O(^FBHL(163.5,"B",FBAAIN,FBDA)) Q:'FBDA D Q:FBRET
123 . S FBSTAT=$P($G(^FBHL(163.5,FBDA,0)),U,3)
124 . I "^1^2^"[(U_FBSTAT_U) S FBRET=1 ; status=transmitted or acknowledged
125 . I "^0^"[(U_FBSTAT_U) S FBRET=0 ; status=pending
126 ;
127 ; if no status found for invoice then return X for not logged
128 I FBRET="" S FBRET="X"
129 Q FBRET
130 ;
131 ;FBFHLL
Note: See TracBrowser for help on using the repository browser.