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

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

initial load of FOIAVistA 6/30/08 version

File size: 2.9 KB
Line 
1IBCU8 ;ALB/ARH - THIRD PARTY BILLING UTILITIES (AUTOMATED BILLER) ;02 JUL 93
2 ;;2.0;INTEGRATED BILLING;**137**;21-MAR-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5BCDT(DATE,TYPE) ;returns end date of bill cycle for beginning DATE and TYPE
6 ;result is the billing date range, inclusive
7 N X,Y,IBBC S X="" S DATE=$E($G(DATE),1,7) I DATE'?7N G BCDTE
8 S IBBC=$G(^IBE(356.6,+$G(TYPE),0))
9 ; I '$P(IBBC,U,4) G BCDTE
10 S IBBC=$P(IBBC,U,5),X=DATE,Y=IBBC-1
11 I IBBC="" S Y=$E(DATE,4,5),X=$E(DATE,1,3)+(Y\12)_$S(Y>11:"01",Y>8:Y+1,1:"0"_(Y+1))_"01",Y=-1
12 S X=$$FMADD^XLFDT(X,Y) ;S Y=$$FYCY(DATE) F I=2,4 I X>$P(Y,U,I) S X=$P(Y,U,I)
13BCDTE Q X
14 ;
15MBC(DATE,TYPE) ;returns maximum date range possible for bill cycle of DATE and TYPE
16 ;result is the billing date range, inclusive
17 N X,Y,I,IBBC S X="" S DATE=$E($G(DATE),1,7) I DATE'?7N G MBCE
18 S IBBC=$G(^IBE(356.6,+$G(TYPE),0))
19 ; I '$P(IBBC,U,4) G MBCE
20 S IBBC=$P(IBBC,U,5)
21 I IBBC'="" S Y=IBBC-1,X=$$FMADD^XLFDT(DATE,-Y)_"^"_$$FMADD^XLFDT(DATE,Y) G MBCE
22 S Y=$E(DATE,4,5),X=$E(DATE,1,3)+(Y\12)_$S(Y>11:"01",Y>8:Y+1,1:"0"_(Y+1))_"01",Y=-1
23 S X=$E(DATE,1,5)_"01^"_$$FMADD^XLFDT(X,Y)
24MBCE ;check dates against bill range rules
25 I +X S Y=$$STRGCHK(+X,$P(X,U,2)) I 'Y D ;reset dates for CY and FY
26 . I '$P(Y,U,3) S X="" Q
27 . ;S Y=$$FYCY(DATE)
28 . ;F I=1,3 I $P(Y,U,I)>$P(X,U,1) S $P(X,U,1)=$P(Y,U,I)
29 . ;F I=2,4 I $P(Y,U,I)<$P(X,U,2) S $P(X,U,2)=$P(Y,U,I)
30 Q X
31 ;
32FYCY(DATE) ;returns calandar and fiscal years for particular date
33 N X,Y,Y2 S X="" S DATE=$G(DATE)\1 I DATE'?7N G FYCYE
34 S (Y,Y2)=$E(DATE,1,3) I $E(DATE,4,5)>9 S Y2=Y+1
35 S X=Y_"0101^"_Y_"1231^"_(Y2-1)_"1001^"_Y2_"0930"
36FYCYE Q X
37 ;
38STRGCHK(DT1,DT2) ;genaric edit checks for STATEMENT FROM and TO dates, returns true if dates passes
39 N X S X=1 S DT1=$G(DT1)\1,DT2=$G(DT2)\1 I DT1'?7N!(DT2'?7N) G STRGCHKE
40 I DT1>(DT+.2359) S X="0^Can not bill for future treatment" G STRGCHKE
41 I DT1>DT2 S X="0^End date can not preceed start date" G STRGCHKE
42 ;I $E(DT1,2,3)'=$E(DT2,2,3) S X="0^Must be in the same calandar year^"_$E(DT1,1,3)_"1231" G STRGCHKE
43 ;I $E(DT1,4,5)<10,$E(DT2,4,5)>9 S X="0^Must be in the same fiscal year^"_$E(DT1,1,3)_"0930"
44STRGCHKE Q X
45 ;
46CMPLT(IBTRN) ;returns true if event is ready to be billed NOT FINISHED
47 N X
48 N X,IBTRND S X=1 I '$G(IBTRN) G CMPLTE
49 S IBTRND=$G(^IBT(356,+IBTRN,0))
50 I +$P(IBTRND,U,31)>2 S X="0^Release of information not obtained" G CMPLTE
51CMPLTE Q X
52 ;
53BILLED(IBTRN) ;returns bill IFN if Claims Tracking event is already associated with an uncancelled bill
54 ;for inpatients interim with no final bill, returns last bill^last bill date, 0 otherwise
55 ;based on most recent STATEMENT TO date
56 N X,Y,IBIFN S X=0 I +$G(IBTRN) S IBIFN="" F S IBIFN=$O(^IBT(356.399,"ACB",IBTRN,IBIFN)) Q:'IBIFN D I +X,$P(X,U,2)="" Q
57 . S Y=$G(^DGCR(399,+IBIFN,0)) I $P(Y,U,13)'=7 S X=IBIFN I $P(Y,U,4)<3,($P(Y,U,6)=2!($P(Y,U,6)=3)) S X=IBIFN_U_$P($G(^DGCR(399,+IBIFN,"U")),U,2)
58 Q X
Note: See TracBrowser for help on using the repository browser.