IVMUFNC2 ;ALB/SEK - INPATIENT/OUTPATIENT CALCULATIONS (CON'T) ; 24-NOV-93
;;2.0;INCOME VERIFICATION MATCH ;**3,11**; 21-OCT-94
;;Per VHA Directive 10-93-142, this routine should not be modified.
;
EN(IVMQUERY) ; Calculate number of outpatient days
; Input: IVMQUERY("OVIS") - the # of the QUERY this job has open for
; searching for patient's outpatient visits. If null, this QUERY has
; yet been opened. (pass by reference)
;
; - find visits on or after IVMMTDT
N IVMQ
K ^TMP("DIERR",$J)
S IVMQ=$G(IVMQUERY("OVIS"))
I $G(IVMQ) D ACTIVE^SDQ(.IVMQ,"FALSE","SET") ;Reset from previous query
;
I '$G(IVMQ) D
. D OPEN^SDQ(.IVMQ) Q:'$G(IVMQ)
. D INDEX^SDQ(.IVMQ,"PATIENT/DATE","SET")
. D SCANCB^SDQ(.IVMQ,"I '$D(^TMP($J,""IVMUFNC1"",DFN,SDOE0\1)) D VALENC^IVMUFNC2(SDOE,SDOE0)","SET")
. S IVMQUERY("OVIS")=IVMQ
;
D PAT^SDQ(.IVMQ,DFN,"SET")
D DATE^SDQ(.IVMQ,IVMMTDT\1,IVMENDT,"SET")
D ACTIVE^SDQ(.IVMQ,"TRUE","SET")
D SCAN^SDQ(.IVMQ,"FORWARD")
K ^TMP("DIERR",$J)
Q
;
VALENC(IVME,IVME0) ; Check for valid outpatient encounter
; Input: IVME = encounter ien
; IVME0 = 0-node of encounter (optional)
N IVMZ,IVMD
;
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
;
S IVMD=IVME0\1
;
Q:$$IGN^IBEFUNC(+$P(IVME0,U,10),IVMD) ; Not billable appt type
Q:$P($G(^SC(+($P(IVME0,U,4)),0)),U,17)="Y" ; non-count clinic
Q:$$ENCL(IVME)[1 ; claim exposure
S VAINDT=IVMD+.2359 D ADM^VADPT2 Q:VADMVT ; was an inpatient
;
S IVMOUT=IVMOUT+1,^TMP($J,"IVMUFNC1",DFN,IVMD)=""
Q
;
ENCL(IVMIBOE) ; Return classification results for an encounter.
; Input: IVMIBOE -- Pointer to outpatient encounter in file #409.68
; Output: ao^ir^sc^ec, where, for each piece,
; 1 - care was related to condition, and
; 0 (or null) - care not related to condition
N CL,CLD,X,Y S Y=""
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)
Q Y
;
;
END(DFN,IVMPMTD) ; return end date for calculating inpatient/
; outpatient days. this date will be earliest of day before next means
; test and day before current date.
; Input: DFN -- pointer to patient in file #2
; IVMPMTD -- previous means test date
;
N X,IVMICY
S IVMICY=$$LYR^DGMTSCU1(IVMPMTD)
S X=$P($$LST^DGMTCOU1(DFN,($E(IVMICY,1,3)+2)_"1231.9999",3),"^",2)
Q $$FMADD^XLFDT($S(X'>IVMPMTD:DT,X>DT:DT,1:X),-1)_.999999
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIVMUFNC2 2574 printed Oct 16, 2024@18:03:33 Page 2
IVMUFNC2 ;ALB/SEK - INPATIENT/OUTPATIENT CALCULATIONS (CON'T) ; 24-NOV-93
+1 ;;2.0;INCOME VERIFICATION MATCH ;**3,11**; 21-OCT-94
+2 ;;Per VHA Directive 10-93-142, this routine should not be modified.
+3 ;
EN(IVMQUERY) ; Calculate number of outpatient days
+1 ; Input: IVMQUERY("OVIS") - the # of the QUERY this job has open for
+2 ; searching for patient's outpatient visits. If null, this QUERY has
+3 ; yet been opened. (pass by reference)
+4 ;
+5 ; - find visits on or after IVMMTDT
+6 NEW IVMQ
+7 KILL ^TMP("DIERR",$JOB)
+8 SET IVMQ=$GET(IVMQUERY("OVIS"))
+9 ;Reset from previous query
IF $GET(IVMQ)
DO ACTIVE^SDQ(.IVMQ,"FALSE","SET")
+10 ;
+11 IF '$GET(IVMQ)
Begin DoDot:1
+12 DO OPEN^SDQ(.IVMQ)
if '$GET(IVMQ)
QUIT
+13 DO INDEX^SDQ(.IVMQ,"PATIENT/DATE","SET")
+14 DO SCANCB^SDQ(.IVMQ,"I '$D(^TMP($J,""IVMUFNC1"",DFN,SDOE0\1)) D VALENC^IVMUFNC2(SDOE,SDOE0)","SET")
+15 SET IVMQUERY("OVIS")=IVMQ
End DoDot:1
+16 ;
+17 DO PAT^SDQ(.IVMQ,DFN,"SET")
+18 DO DATE^SDQ(.IVMQ,IVMMTDT\1,IVMENDT,"SET")
+19 DO ACTIVE^SDQ(.IVMQ,"TRUE","SET")
+20 DO SCAN^SDQ(.IVMQ,"FORWARD")
+21 KILL ^TMP("DIERR",$JOB)
+22 QUIT
+23 ;
VALENC(IVME,IVME0) ; Check for valid outpatient encounter
+1 ; Input: IVME = encounter ien
+2 ; IVME0 = 0-node of encounter (optional)
+3 NEW IVMZ,IVMD
+4 ;
+5 IF $GET(IVME0)=""
KILL ^TMP("DIERR",$JOB)
DO GETGEN^SDOE(IVME,"IVMZ")
SET IVME0=$GET(IVMZ(0))
IF $DATA(^TMP("DIERR",$JOB))
KILL ^TMP("DIERR",$JOB)
QUIT
+6 ;
+7 SET IVMD=IVME0\1
+8 ;
+9 ; Not billable appt type
if $$IGN^IBEFUNC(+$PIECE(IVME0,U,10),IVMD)
QUIT
+10 ; non-count clinic
if $PIECE($GET(^SC(+($PIECE(IVME0,U,4)),0)),U,17)="Y"
QUIT
+11 ; claim exposure
if $$ENCL(IVME)[1
QUIT
+12 ; was an inpatient
SET VAINDT=IVMD+.2359
DO ADM^VADPT2
if VADMVT
QUIT
+13 ;
+14 SET IVMOUT=IVMOUT+1
SET ^TMP($JOB,"IVMUFNC1",DFN,IVMD)=""
+15 QUIT
+16 ;
ENCL(IVMIBOE) ; Return classification results for an encounter.
+1 ; Input: IVMIBOE -- Pointer to outpatient encounter in file #409.68
+2 ; Output: ao^ir^sc^ec, where, for each piece,
+3 ; 1 - care was related to condition, and
+4 ; 0 (or null) - care not related to condition
+5 NEW CL,CLD,X,Y
SET Y=""
+6 SET CL=0
FOR
SET CL=$ORDER(^SDD(409.42,"OE",+$GET(IVMIBOE),CL))
if 'CL
QUIT
SET CLD=$GET(^SDD(409.42,CL,0))
IF CLD
SET $PIECE(Y,"^",+CLD)=+$PIECE(CLD,"^",3)
+7 QUIT Y
+8 ;
+9 ;
END(DFN,IVMPMTD) ; return end date for calculating inpatient/
+1 ; outpatient days. this date will be earliest of day before next means
+2 ; test and day before current date.
+3 ; Input: DFN -- pointer to patient in file #2
+4 ; IVMPMTD -- previous means test date
+5 ;
+6 NEW X,IVMICY
+7 SET IVMICY=$$LYR^DGMTSCU1(IVMPMTD)
+8 SET X=$PIECE($$LST^DGMTCOU1(DFN,($EXTRACT(IVMICY,1,3)+2)_"1231.9999",3),"^",2)
+9 QUIT $$FMADD^XLFDT($SELECT(X'>IVMPMTD:DT,X>DT:DT,1:X),-1)_.999999