BQIDCMPR ;PRXM/HC/ALA-"MY PATIENTS-PRIMARY or PRIMARY/SECONDARY" ; 20 Oct 2005 9:52 AM
;;2.3;ICARE MANAGEMENT SYSTEM;**3,4**;Apr 18, 2012;Build 66
;
Q
;
FND(DATA,PARMS,MPARMS,FLAG) ;EP - Find patients
;
;Description
; Executable to find the patients for a specific provider where the patient
; had NVIS number of visits for the specified time frame
;Input
; PARMS = Array of parameters and their values
; MPARMS = Multiple array of a parameter (not currently used for this definition)
; FLAG = "P" is primary only, blank is both primary and secondary
;Expected to return DATA
;
NEW IEN,DFN,FDT,TDT,VISIT,VSDTM,Y,X,UID,NM,TMFRAME,PROV
NEW VISITS,QFL,%DT,VDATA,TMN
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BQIDCMPR",UID))
S VDATA=$NA(^TMP("BQIFND",UID))
K @DATA,@VDATA
;
I '$D(PARMS) Q
;
S NM=""
F S NM=$O(PARMS(NM)) Q:NM="" S @NM=PARMS(NM)
;
I $G(DT)="" D DT^DICRW
;
S TMN=$O(^BQI(90506.9,"B",TMFRAME,""))
I TMN="" S FDT="",TDT=""
;
S FDT=$P(^BQI(90506.9,TMN,0),U,3),TDT=$P(^BQI(90506.9,TMN,0),U,4)
S FDT=$$DATE^BQIUL1(FDT),TDT=$$DATE^BQIUL1(TDT)
;
; Go through the V PROVIDER File for the designated provider and
; find out if they are a primary or secondary provider AND if the
; visit falls within the time frame
S IEN="",FLAG=$G(FLAG,"")
F S IEN=$O(^AUPNVPRV("B",PROV,IEN),-1) Q:IEN="" D
. I FLAG="P",$$GET1^DIQ(9000010.06,IEN_",",.04,"I")'="P" Q
. S VISIT=$$GET1^DIQ(9000010.06,IEN_",",.03,"I") I VISIT="" Q
. I $$GET1^DIQ(9000010,VISIT_",",.11,"I")=1 Q
. S VSDTM=$$GET1^DIQ(9000010,VISIT_",",.01,"I")\1 I VSDTM=0 Q
. S DFN=$$GET1^DIQ(9000010.06,IEN_",",.02,"I") I DFN="" Q
. ; If patient is deceased, quit
. 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
. ;
. I FDT'="" S QFL=0 D Q:QFL
.. I VSDTM'<FDT,VSDTM'>TDT Q
.. S QFL=1
. ; Count number of visits for a patient
. S @VDATA@(DFN)=$G(@VDATA@(DFN))+1
;
S DFN=""
F S DFN=$O(@VDATA@(DFN)) Q:DFN="" D
. ; if the number of visits for patient doesn't match the criteria, quit
. I @VDATA@(DFN)<VISITS Q ;Changed from '= to <
. S @DATA@(DFN)=""
;
K @VDATA
Q
BQIDCMPR ;PRXM/HC/ALA-"MY PATIENTS-PRIMARY or PRIMARY/SECONDARY" ; 20 Oct 2005 9:52 AM
+1 ;;2.3;ICARE MANAGEMENT SYSTEM;**3,4**;Apr 18, 2012;Build 66
+2 ;
+3 QUIT
+4 ;
FND(DATA,PARMS,MPARMS,FLAG) ;EP - Find patients
+1 ;
+2 ;Description
+3 ; Executable to find the patients for a specific provider where the patient
+4 ; had NVIS number of visits for the specified time frame
+5 ;Input
+6 ; PARMS = Array of parameters and their values
+7 ; MPARMS = Multiple array of a parameter (not currently used for this definition)
+8 ; FLAG = "P" is primary only, blank is both primary and secondary
+9 ;Expected to return DATA
+10 ;
+11 NEW IEN,DFN,FDT,TDT,VISIT,VSDTM,Y,X,UID,NM,TMFRAME,PROV
+12 NEW VISITS,QFL,%DT,VDATA,TMN
+13 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+14 SET DATA=$NAME(^TMP("BQIDCMPR",UID))
+15 SET VDATA=$NAME(^TMP("BQIFND",UID))
+16 KILL @DATA,@VDATA
+17 ;
+18 IF '$DATA(PARMS)
QUIT
+19 ;
+20 SET NM=""
+21 FOR
SET NM=$ORDER(PARMS(NM))
IF NM=""
QUIT
SET @NM=PARMS(NM)
+22 ;
+23 IF $GET(DT)=""
DO DT^DICRW
+24 ;
+25 SET TMN=$ORDER(^BQI(90506.9,"B",TMFRAME,""))
+26 IF TMN=""
SET FDT=""
SET TDT=""
+27 ;
+28 SET FDT=$PIECE(^BQI(90506.9,TMN,0),U,3)
SET TDT=$PIECE(^BQI(90506.9,TMN,0),U,4)
+29 SET FDT=$$DATE^BQIUL1(FDT)
SET TDT=$$DATE^BQIUL1(TDT)
+30 ;
+31 ; Go through the V PROVIDER File for the designated provider and
+32 ; find out if they are a primary or secondary provider AND if the
+33 ; visit falls within the time frame
+34 SET IEN=""
SET FLAG=$GET(FLAG,"")
+35 FOR
SET IEN=$ORDER(^AUPNVPRV("B",PROV,IEN),-1)
IF IEN=""
QUIT
Begin DoDot:1
+36 IF FLAG="P"
IF $$GET1^DIQ(9000010.06,IEN_",",.04,"I")'="P"
QUIT
+37 SET VISIT=$$GET1^DIQ(9000010.06,IEN_",",.03,"I")
IF VISIT=""
QUIT
+38 IF $$GET1^DIQ(9000010,VISIT_",",.11,"I")=1
QUIT
+39 SET VSDTM=$$GET1^DIQ(9000010,VISIT_",",.01,"I")\1
IF VSDTM=0
QUIT
+40 SET DFN=$$GET1^DIQ(9000010.06,IEN_",",.02,"I")
IF DFN=""
QUIT
+41 ; If patient is deceased, quit
+42 IF $PIECE($GET(^DPT(DFN,.35)),U,1)'=""
QUIT
+43 ; If patient has no active HRNs, quit
+44 IF '$$HRN^BQIUL1(DFN)
QUIT
+45 ; If patient has no visit in last 3 years, quit
+46 ;I '$$VTHR^BQIUL1(DFN) Q
+47 ;
+48 IF FDT'=""
SET QFL=0
Begin DoDot:2
+49 IF VSDTM'<FDT
IF VSDTM'>TDT
QUIT
+50 SET QFL=1
End DoDot:2
IF QFL
QUIT
+51 ; Count number of visits for a patient
+52 SET @VDATA@(DFN)=$GET(@VDATA@(DFN))+1
End DoDot:1
+53 ;
+54 SET DFN=""
+55 FOR
SET DFN=$ORDER(@VDATA@(DFN))
IF DFN=""
QUIT
Begin DoDot:1
+56 ; if the number of visits for patient doesn't match the criteria, quit
+57 ;Changed from '= to <
IF @VDATA@(DFN)<VISITS
QUIT
+58 SET @DATA@(DFN)=""
End DoDot:1
+59 ;
+60 KILL @VDATA
+61 QUIT