source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGMTUB.m@ 1724

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

initial load of WorldVistAEHR

File size: 3.1 KB
Line 
1DGMTUB ;ALB/RMO/CAW,CPM,LBD - Means Test Billing Utilities ; 7/22/02 9:32am
2 ;;5.3;Registration;**33,456,481**;Aug 13, 1993
3 ;
4BIL(DFN,DGDT) ;Determine if patient is pending adjudication
5 ; or category C and has agreed to pay the deductible
6 ; Input -- DFN Patient IEN
7 ; DGDT Date/Time
8 ; Output -- 1=TRUE and 0=FALSE
9 N MT0,MTI,TDAT,EDAT,BILL,STOP
10 S (BILL,STOP)=0
11 I '$G(DFN) G BILQ
12 S:'$G(DGDT) DGDT=DT
13 ;
14 S TDAT=-(DGDT+.1)
15 F S TDAT=$O(^DGMT(408.31,"AID",1,DFN,TDAT)) Q:'TDAT!STOP D
16 .S MTI=0 F S MTI=$O(^DGMT(408.31,"AID",1,DFN,TDAT,MTI)) Q:'MTI!STOP D
17 ..S MT0=$G(^DGMT(408.31,MTI,0)) Q:'$G(^("PRIM")) ; not primary MT
18 ..;
19 ..; - evaluate the test if the category isn't 'REQUIRED'
20 ..I MT0,$P(MT0,"^",3)'=1 D
21 ...S EDAT=$S($P(MT0,"^",3)=3:+MT0,1:$P(MT0,"^",7))
22 ...;
23 ...; - if the patient is not billable on the evaluation date, quit
24 ...I EDAT\1=(DGDT\1),'$$CK(MT0) S STOP=1 Q
25 ...;
26 ...; - if the test effective date is prior to the evaluation date,
27 ...; obtain the billable status and quit
28 ...I EDAT'>DGDT S BILL=$$CK(MT0),STOP=1
29 ;
30BILQ Q BILL
31 ;
32BILST(DFN) ;Determine the last date patient was pending adjudication
33 ; or category C and agreed to pay the deductible
34 ; Input -- DFN Patient IEN
35 ; Output -- Last effective date
36 N DGDT,DGENDT,DGMT0,DGMTI,DGMTIDT,DGSTDT
37 S (DGDT,DGENDT,DGSTDT)=""
38 I '$G(DFN) G BILSTQ
39 I $$BIL(DFN,DT) S DGDT=DT G BILSTQ
40 ;
41 S DGMTIDT="" F S DGMTIDT=$O(^DGMT(408.31,"AID",1,DFN,DGMTIDT)) Q:DGMTIDT=""!(DGDT) D
42 .S DGMTI=0 F S DGMTI=$O(^DGMT(408.31,"AID",1,DFN,DGMTIDT,DGMTI)) Q:DGMTI=""!(DGDT) D
43 ..I $D(^DGMT(408.31,DGMTI,0)),$G(^("PRIM")) S DGMT0=^(0) D CKDT
44 ;
45BILSTQ Q +$P($G(DGDT),".")
46 ;
47CKDT ;Check the date of test
48 N DGMTS,X,X1,X2,Y
49 S Y=$$CK(DGMT0) S DGMTS=$P(DGMT0,"^",3) S:Y DGSTDT=$P(DGMT0,"^",7) S:'Y DGENDT=$S(DGMTS=1:DGENDT,DGMTS=3:$P(DGMT0,"^"),1:$P(DGMT0,"^",7))
50 I DGSTDT S:'DGENDT DGDT=DT I DGENDT S X1=DGENDT,X2=-1 D C^%DTC S DGDT=X
51 Q
52 ;
53CK(DGMT0) ;Check if patient is pending adjudication or category C
54 ; and has agreed to pay the deductible
55 ; Add check for GMT status (DG*5.3*456)
56 ; Input -- DGMT0 Annual Means Test 0th node
57 ; Output -- 1=TRUE and 0=FALSE
58 N DGMTATP,DGMTS,Y
59 S DGMTS=$P(DGMT0,"^",3),DGMTATP=$P(DGMT0,"^",11)
60 I ("^2^6^16^"[("^"_DGMTS_"^"))&(DGMTATP'=0) S Y=1
61 Q +$G(Y)
62 ;
63GMT(DFN,DGDT) ;Determine if patient is GMT Copay Required as of the date
64 ; specified
65 ; Input -- DFN Patient IEN
66 ; DGDT Date/Time
67 ; Output -- 1=Patient had GMT status or Pending Adjudication
68 ; for GMT as of date specified
69 ; 0=Patient did not have GMT status
70 ;
71 N DGMT,DGSTA,DGMT0,DGMTG
72 I '$G(DFN) Q 0
73 S:'$G(DGDT) DGDT=DT
74 ; Get last primary means test with status other than Required
75 S DGMT=$$LVMT^DGMTU(DFN,DGDT),DGSTA=$P(DGMT,U,4)
76 I DGSTA="G" Q 1 ; status = GMT copay required
77 S DGMT0=$G(^DGMT(408.31,+DGMT,0)),DGMTG=$P(DGMT0,U,27)
78 I DGMTG="" Q 0
79 ; If status = Pending Adjudication and GMT Threhold is greater than
80 ; MT Threshold, then patient is Pending Adjudication for GMT
81 I DGSTA="P",DGMTG>$P(DGMT0,U,12) Q 1
82 Q 0
Note: See TracBrowser for help on using the repository browser.