BQIDCERA ;PRXM/HC/ALA-Emergency Room Visits ; 09 Dec 2005 3:15 PM
;;2.4;ICARE MANAGEMENT SYSTEM;**2**;Apr 01, 2015;Build 10
;
Q
;
VIS(DATA,PARMS,MPARMS) ;EP
;
;Description
; Executable to retrieve ER visits for the specified parameters
;Input
; PARMS = Array of parameters and their values
; MPARMS = Multiple array of a parameter
;Output
; ^TMP(UID,"BQIDCERA",DFN,VISIT IEN)=""
;
NEW UID
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP(UID,"BQIDCERA"))
K @DATA
;
FND ; Find if the patients have emergency room visits
;
NEW FDT,TDT,STRT,VSTIEN,DFN,NM,TMFRAME,X,Y,%DT,ER
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 %DT="",X=TMFRAME D ^%DT S FDT=Y
S TDT=DT
;
;S ER=$$FIND1^DIC(40.7,"","Q","EMERGENCY","B","","ERROR")
S ER=$O(^DIC(40.7,"B","EMERGENCY MEDICINE",""))
I ER="" Q
;I 'ER Q
;
; Order through visit date/time x-ref in Visit file.
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
.. ; If the clinic code is not 30 (Emergency), quit
.. ;I $$GET1^DIQ(9000010,VSTIEN,.08,"I")'=ER Q
.. I $P($G(^AUPNVSIT(VSTIEN,0)),"^",8)'=ER Q
.. ; If the 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 DFN=$$GET1^DIQ(9000010,VSTIEN,.05,"I") I DFN="" Q
.. 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
.. ; If the visit is already flagged, quit
.. I $D(^BQIPAT(DFN,10,"AC",VSTIEN))>0 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
BQIDCERA ;PRXM/HC/ALA-Emergency Room Visits ; 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 ; Executable to retrieve ER visits 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,"BQIDCERA",DFN,VISIT IEN)=""
+9 ;
+10 NEW UID
+11 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+12 SET DATA=$NAME(^TMP(UID,"BQIDCERA"))
+13 KILL @DATA
+14 ;
FND ; Find if the patients have emergency room visits
+1 ;
+2 NEW FDT,TDT,STRT,VSTIEN,DFN,NM,TMFRAME,X,Y,%DT,ER
+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 %DT=""
SET X=TMFRAME
DO ^%DT
SET FDT=Y
End DoDot:1
+10 SET TDT=DT
+11 ;
+12 ;S ER=$$FIND1^DIC(40.7,"","Q","EMERGENCY","B","","ERROR")
+13 SET ER=$ORDER(^DIC(40.7,"B","EMERGENCY MEDICINE",""))
+14 IF ER=""
QUIT
+15 ;I 'ER Q
+16 ;
+17 ; Order through visit date/time x-ref in Visit file.
+18 SET STRT=FDT-.01
+19 FOR
SET STRT=$ORDER(^AUPNVSIT("B",STRT))
IF 'STRT!(STRT>TDT)
QUIT
Begin DoDot:1
+20 SET VSTIEN=""
+21 FOR
SET VSTIEN=$ORDER(^AUPNVSIT("B",STRT,VSTIEN))
IF VSTIEN=""
QUIT
Begin DoDot:2
+22 ; If the clinic code is not 30 (Emergency), quit
+23 ;I $$GET1^DIQ(9000010,VSTIEN,.08,"I")'=ER Q
+24 IF $PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",8)'=ER
QUIT
+25 ; If the visit has been "deleted", quit
+26 ;I $$GET1^DIQ(9000010,VSTIEN,.11,"I")=1 Q
+27 IF $PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",11)=1
QUIT
+28 IF $PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",9)=1
QUIT
+29 ;S DFN=$$GET1^DIQ(9000010,VSTIEN,.05,"I") I DFN="" Q
+30 SET DFN=$PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",5)
IF DFN=""
QUIT
+31 ; Exclude deceased patients
+32 IF $PIECE($GET(^DPT(DFN,.35)),U,1)'=""
QUIT
+33 ; If patient has no active HRNs, quit
+34 IF '$$HRN^BQIUL1(DFN)
QUIT
+35 ; If patient has no visit in last 3 years, quit
+36 IF '$$VTHR^BQIUL1(DFN)
QUIT
+37 ; If the visit is already flagged, quit
+38 IF $DATA(^BQIPAT(DFN,10,"AC",VSTIEN))>0
QUIT
+39 ;S @DATA@(DFN,VSTIEN)=VSTIEN_U_$$GET1^DIQ(9000010,VSTIEN,.01,"I")
+40 SET @DATA@(DFN,VSTIEN)=VSTIEN_U_$PIECE($GET(^AUPNVSIT(VSTIEN,0)),"^",1)
End DoDot:2
End DoDot:1
+41 QUIT