BQIDCHSA ;PRXM/HC/BWF-Visits with Service Category of 'Hospitalization' ; 09 Dec 2005 3:15 PM
;;2.4;ICARE MANAGEMENT SYSTEM;**2**;Apr 01, 2015;Build 10
;
Q
;
VIS(DATA,PARMS,MPARMS) ;EP
;
;Description
; Retrieves inpatient hospitalizations for the specified parameters
;Input
; PARMS = Array of parameters and their values
; MPARMS = Multiple array of a parameter
;Output
; ^TMP(UID,"BQIDCHSA",DFN,VISIT IEN)=""
;
NEW UID,ADMDT,DSCDT
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP(UID,"BQIDCHSA"))
K @DATA
;
FND ; Find if the patients have admission flag of "H" - Hospitalization
;
NEW FDT,TDT,STRT,VSTIEN,DFN,NM,TMFRAME,X,Y,DIEN
S NM=""
F S NM=$O(PARMS(NM)) Q:NM="" S @NM=PARMS(NM)
;
S TMFRAME=$G(PARMS("TMFRAME"))
I $G(DT)="" D DT^DICRW
I TMFRAME["T-" D
. S FDT=$$DATE^BQIUL1(TMFRAME)
S TDT=DT
;
; Order through B x-ref in Visit file. This xref is by visit date, and visit ien.
S STRT=FDT-.01
F S STRT=$O(^AUPNVSIT("B",STRT)) Q:'STRT!(STRT>TDT) D
. S VSTIEN=""
. F S VSTIEN=$O(^AUPNVSIT("B",STRT,VSTIEN)) Q:VSTIEN="" D
.. I $P($G(^AUPNVSIT(VSTIEN,0)),"^",7)'="H" Q
.. ; If visit has been deleted, quit
.. ;I $$GET1^DIQ(9000010,VSTIEN,.11,"I")=1 Q
.. I $P($G(^AUPNVSIT(VSTIEN,0)),"^",11)=1 Q
.. I $P($G(^AUPNVSIT(VSTIEN,0)),"^",9)=1 Q
.. ;S ADMDT=$$GET1^DIQ(9000010,VSTIEN,.01,"I")
.. S ADMDT=$P($G(^AUPNVSIT(VSTIEN,0)),"^",1)
.. S DIEN=0,DSCDT=""
.. F S DIEN=$O(^AUPNVINP("AD",VSTIEN,DIEN)) Q:DIEN="" D
... S DSCDT=$P($G(^AUPNVINP(DIEN,0)),"^",1)
.. I (ADMDT\1)=(DSCDT\1) Q
.. ;S DFN=$$GET1^DIQ(9000010,VSTIEN,.05,"I") Q:DFN=""
.. S DFN=$P($G(^AUPNVSIT(VSTIEN,0)),"^",5) I DFN="" Q
.. ; Exclude deceased patients
.. I $P($G(^DPT(DFN,.35)),U,1)'="" Q
.. ; If patient has no active HRNs, quit
.. I '$$HRN^BQIUL1(DFN) Q
.. ; If patient has no visit in last 3 years, quit
.. I '$$VTHR^BQIUL1(DFN) Q
.. ;S @DATA@(DFN,VSTIEN)=VSTIEN_U_$$GET1^DIQ(9000010,VSTIEN,.01,"I")
.. S @DATA@(DFN,VSTIEN)=VSTIEN_U_$P($G(^AUPNVSIT(VSTIEN,0)),"^",1)
Q
BQIDCHSA ;PRXM/HC/BWF-Visits with Service Category of 'Hospitalization' ; 09 Dec 2005 3:15 PM
+1 ;;2.4;ICARE MANAGEMENT SYSTEM;**2**;Apr 01, 2015;Build 10
+2 ;
+3 QUIT
+4 ;
VIS(DATA,PARMS,MPARMS) ;EP
+1 ;
+2 ;Description
+3 ; Retrieves inpatient hospitalizations for the specified parameters
+4 ;Input
+5 ; PARMS = Array of parameters and their values
+6 ; MPARMS = Multiple array of a parameter
+7 ;Output
+8 ; ^TMP(UID,"BQIDCHSA",DFN,VISIT IEN)=""
+9 ;
+10 NEW UID,ADMDT,DSCDT
+11 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+12 SET DATA=$NAME(^TMP(UID,"BQIDCHSA"))
+13 KILL @DATA
+14 ;
FND ; Find if the patients have admission flag of "H" - Hospitalization
+1 ;
+2 NEW FDT,TDT,STRT,VSTIEN,DFN,NM,TMFRAME,X,Y,DIEN
+3 SET NM=""
+4 FOR
SET NM=$ORDER(PARMS(NM))
IF NM=""
QUIT
SET @NM=PARMS(NM)
+5 ;
+6 SET TMFRAME=$GET(PARMS("TMFRAME"))
+7 IF $GET(DT)=""
DO DT^DICRW
+8 IF TMFRAME["T-"
Begin DoDot:1
+9 SET FDT=$$DATE^BQIUL1(TMFRAME)
End DoDot:1
+10 SET TDT=DT
+11 ;
+12 ; Order through B x-ref in Visit file. This xref is by visit date, and visit ien.
+13 SET STRT=FDT-.01
+14 FOR
SET STRT=$ORDER(^AUPNVSIT("B",STRT))
IF 'STRT!(STRT>TDT)
QUIT
Begin DoDot:1
+15 SET VSTIEN=""
+16 FOR
SET VSTIEN=$ORDER(^AUPNVSIT("B",STRT,VSTIEN))
IF VSTIEN=""
QUIT
Begin DoDot:2
+17 IF $PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",7)'="H"
QUIT
+18 ; If visit has been deleted, quit
+19 ;I $$GET1^DIQ(9000010,VSTIEN,.11,"I")=1 Q
+20 IF $PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",11)=1
QUIT
+21 IF $PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",9)=1
QUIT
+22 ;S ADMDT=$$GET1^DIQ(9000010,VSTIEN,.01,"I")
+23 SET ADMDT=$PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",1)
+24 SET DIEN=0
SET DSCDT=""
+25 FOR
SET DIEN=$ORDER(^AUPNVINP("AD",VSTIEN,DIEN))
IF DIEN=""
QUIT
Begin DoDot:3
+26 SET DSCDT=$PIECE($GET(^AUPNVINP(DIEN,0)),"^",1)
End DoDot:3
+27 IF (ADMDT\1)=(DSCDT\1)
QUIT
+28 ;S DFN=$$GET1^DIQ(9000010,VSTIEN,.05,"I") Q:DFN=""
+29 SET DFN=$PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",5)
IF DFN=""
QUIT
+30 ; Exclude deceased patients
+31 IF $PIECE($GET(^DPT(DFN,.35)),U,1)'=""
QUIT
+32 ; If patient has no active HRNs, quit
+33 IF '$$HRN^BQIUL1(DFN)
QUIT
+34 ; If patient has no visit in last 3 years, quit
+35 IF '$$VTHR^BQIUL1(DFN)
QUIT
+36 ;S @DATA@(DFN,VSTIEN)=VSTIEN_U_$$GET1^DIQ(9000010,VSTIEN,.01,"I")
+37 SET @DATA@(DFN,VSTIEN)=VSTIEN_U_$PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",1)
End DoDot:2
End DoDot:1
+38 QUIT