source: WorldVistAEHR/trunk/r/INCOME_VERIFICATION_MATCH-IVM/IVMUFNC2.m@ 1361

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

initial load of WorldVistAEHR

File size: 2.5 KB
RevLine 
[613]1IVMUFNC2 ;ALB/SEK - INPATIENT/OUTPATIENT CALCULATIONS (CON'T) ; 24-NOV-93
2 ;;2.0;INCOME VERIFICATION MATCH ;**3,11**; 21-OCT-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5EN(IVMQUERY) ; Calculate number of outpatient days
6 ; Input: IVMQUERY("OVIS") - the # of the QUERY this job has open for
7 ; searching for patient's outpatient visits. If null, this QUERY has
8 ; yet been opened. (pass by reference)
9 ;
10 ; - find visits on or after IVMMTDT
11 N IVMQ
12 K ^TMP("DIERR",$J)
13 S IVMQ=$G(IVMQUERY("OVIS"))
14 I $G(IVMQ) D ACTIVE^SDQ(.IVMQ,"FALSE","SET") ;Reset from previous query
15 ;
16 I '$G(IVMQ) D
17 . D OPEN^SDQ(.IVMQ) Q:'$G(IVMQ)
18 . D INDEX^SDQ(.IVMQ,"PATIENT/DATE","SET")
19 . D SCANCB^SDQ(.IVMQ,"I '$D(^TMP($J,""IVMUFNC1"",DFN,SDOE0\1)) D VALENC^IVMUFNC2(SDOE,SDOE0)","SET")
20 . S IVMQUERY("OVIS")=IVMQ
21 ;
22 D PAT^SDQ(.IVMQ,DFN,"SET")
23 D DATE^SDQ(.IVMQ,IVMMTDT\1,IVMENDT,"SET")
24 D ACTIVE^SDQ(.IVMQ,"TRUE","SET")
25 D SCAN^SDQ(.IVMQ,"FORWARD")
26 K ^TMP("DIERR",$J)
27 Q
28 ;
29VALENC(IVME,IVME0) ; Check for valid outpatient encounter
30 ; Input: IVME = encounter ien
31 ; IVME0 = 0-node of encounter (optional)
32 N IVMZ,IVMD
33 ;
34 I $G(IVME0)="" K ^TMP("DIERR",$J) D GETGEN^SDOE(IVME,"IVMZ") S IVME0=$G(IVMZ(0)) I $D(^TMP("DIERR",$J)) K ^TMP("DIERR",$J) Q
35 ;
36 S IVMD=IVME0\1
37 ;
38 Q:$$IGN^IBEFUNC(+$P(IVME0,U,10),IVMD) ; Not billable appt type
39 Q:$P($G(^SC(+($P(IVME0,U,4)),0)),U,17)="Y" ; non-count clinic
40 Q:$$ENCL(IVME)[1 ; claim exposure
41 S VAINDT=IVMD+.2359 D ADM^VADPT2 Q:VADMVT ; was an inpatient
42 ;
43 S IVMOUT=IVMOUT+1,^TMP($J,"IVMUFNC1",DFN,IVMD)=""
44 Q
45 ;
46ENCL(IVMIBOE) ; Return classification results for an encounter.
47 ; Input: IVMIBOE -- Pointer to outpatient encounter in file #409.68
48 ; Output: ao^ir^sc^ec, where, for each piece,
49 ; 1 - care was related to condition, and
50 ; 0 (or null) - care not related to condition
51 N CL,CLD,X,Y S Y=""
52 S CL=0 F S CL=$O(^SDD(409.42,"OE",+$G(IVMIBOE),CL)) Q:'CL S CLD=$G(^SDD(409.42,CL,0)) I CLD S $P(Y,"^",+CLD)=+$P(CLD,"^",3)
53 Q Y
54 ;
55 ;
56END(DFN,IVMPMTD) ; return end date for calculating inpatient/
57 ; outpatient days. this date will be earliest of day before next means
58 ; test and day before current date.
59 ; Input: DFN -- pointer to patient in file #2
60 ; IVMPMTD -- previous means test date
61 ;
62 N X,IVMICY
63 S IVMICY=$$LYR^DGMTSCU1(IVMPMTD)
64 S X=$P($$LST^DGMTCOU1(DFN,($E(IVMICY,1,3)+2)_"1231.9999",3),"^",2)
65 Q $$FMADD^XLFDT($S(X'>IVMPMTD:DT,X>DT:DT,1:X),-1)_.999999
Note: See TracBrowser for help on using the repository browser.