BQIDCMYC ;PRXM/HC/ALA-"MY PATIENTS-COMMUNITY" ; 14 Oct 2005 4:09 PM
;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
;
Q
;
LST(DATA,PARMS,MPARMS) ;EP **not used yet**
;Description
; This returns a maximum count of patients based on a passed in
; community and provider. Corresponds with the predefined panel
; MY PATIENTS-COMMUNITY.
;Input
; PARMS = Array of parameters and their values
; MPARMS = Multiple array of a parameter
;Expected to return DATA
;
NEW UID
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BQIDCMYC",UID))
K @DATA
;
FND ; Find patients in one or more communities
NEW IEN,NM,COMM,PROV
S NM="",COMM="",PROV=""
I '$D(PARMS) Q
;
F S NM=$O(PARMS(NM)) Q:NM="" S @NM=PARMS(NM)
;
I $G(COMM)]"" D FND1
I $D(MPARMS("COMM")) S COMM="" F S COMM=$O(MPARMS("COMM",COMM)) Q:COMM="" D FND1
Q
FND1 ; Check one community
N COMM1
S COMM1=COMM
;
; X-ref uses the community name and not IEN.
I COMM?1.N S COMM=$$GET1^DIQ(9999999.05,COMM,.01,"E")
; For now quit. Should eventually jump to process by provider.
I COMM="" Q
;
S IEN=""
F S IEN=$O(^AUPNPAT("AC",COMM,IEN)) Q:IEN="" D
. ; If patient is deceased, quit
. I $P($G(^DPT(IEN,.35)),U,1)'="" Q
. ; If patient has no active HRNs, quit
. I '$$HRN^BQIUL1(IEN) Q
. ; If patient has no visit in last 3 years, quit
. ;I '$$VTHR^BQIUL1(IEN) Q
. S LOC=0
. F S LOC=$O(^AUPNPAT(IEN,41,LOC)) Q:'LOC D
.. I $P($G(^AUPNPAT(IEN,41,LOC,0)),U,3)'="" Q
.. I PROV'="",$$GET1^DIQ(9000001,IEN_",",.14,"I")'=PROV Q
.. ; Check whether the IEN matches the community IEN that was filed.
.. ; There are some with duplicate names.
.. I COMM1?1.N,$$GET1^DIQ(9000001,IEN_",",1117,"I")'=COMM1 Q
.. S @DATA@(IEN)=""
Q
BQIDCMYC ;PRXM/HC/ALA-"MY PATIENTS-COMMUNITY" ; 14 Oct 2005 4:09 PM
+1 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
+2 ;
+3 QUIT
+4 ;
LST(DATA,PARMS,MPARMS) ;EP **not used yet**
+1 ;Description
+2 ; This returns a maximum count of patients based on a passed in
+3 ; community and provider. Corresponds with the predefined panel
+4 ; MY PATIENTS-COMMUNITY.
+5 ;Input
+6 ; PARMS = Array of parameters and their values
+7 ; MPARMS = Multiple array of a parameter
+8 ;Expected to return DATA
+9 ;
+10 NEW UID
+11 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+12 SET DATA=$NAME(^TMP("BQIDCMYC",UID))
+13 KILL @DATA
+14 ;
FND ; Find patients in one or more communities
+1 NEW IEN,NM,COMM,PROV
+2 SET NM=""
SET COMM=""
SET PROV=""
+3 IF '$DATA(PARMS)
QUIT
+4 ;
+5 FOR
SET NM=$ORDER(PARMS(NM))
IF NM=""
QUIT
SET @NM=PARMS(NM)
+6 ;
+7 IF $GET(COMM)]""
DO FND1
+8 IF $DATA(MPARMS("COMM"))
SET COMM=""
FOR
SET COMM=$ORDER(MPARMS("COMM",COMM))
IF COMM=""
QUIT
DO FND1
+9 QUIT
FND1 ; Check one community
+1 NEW COMM1
+2 SET COMM1=COMM
+3 ;
+4 ; X-ref uses the community name and not IEN.
+5 IF COMM?1.N
SET COMM=$$GET1^DIQ(9999999.05,COMM,.01,"E")
+6 ; For now quit. Should eventually jump to process by provider.
+7 IF COMM=""
QUIT
+8 ;
+9 SET IEN=""
+10 FOR
SET IEN=$ORDER(^AUPNPAT("AC",COMM,IEN))
IF IEN=""
QUIT
Begin DoDot:1
+11 ; If patient is deceased, quit
+12 IF $PIECE($GET(^DPT(IEN,.35)),U,1)'=""
QUIT
+13 ; If patient has no active HRNs, quit
+14 IF '$$HRN^BQIUL1(IEN)
QUIT
+15 ; If patient has no visit in last 3 years, quit
+16 ;I '$$VTHR^BQIUL1(IEN) Q
+17 SET LOC=0
+18 FOR
SET LOC=$ORDER(^AUPNPAT(IEN,41,LOC))
IF 'LOC
QUIT
Begin DoDot:2
+19 IF $PIECE($GET(^AUPNPAT(IEN,41,LOC,0)),U,3)'=""
QUIT
+20 IF PROV'=""
IF $$GET1^DIQ(9000001,IEN_",",.14,"I")'=PROV
QUIT
+21 ; Check whether the IEN matches the community IEN that was filed.
+22 ; There are some with duplicate names.
+23 IF COMM1?1.N
IF $$GET1^DIQ(9000001,IEN_",",1117,"I")'=COMM1
QUIT
+24 SET @DATA@(IEN)=""
End DoDot:2
End DoDot:1
+25 QUIT