BQIDCREM ;GDIT/HS/ALA-Reminders Panel Definition ; 07 Dec 2012 2:18 PM
;;2.5;ICARE MANAGEMENT SYSTEM;**2**;May 24, 2016;Build 14
;
Q
;
EN(DATA,PARMS,MPARMS) ;EP - Find records
;
;Description
; Executable that finds all patients who have a reminder
;Input
; PARMS = Array of parameters and their values
; MPARMS = Multiple array of a parameter
;Expected to return FDATA
;
NEW UID,VDATA,DFN,RIEN,PTMFRAME,PVISITS,FUT,OVD,RMDFROM,RMDTHRU
NEW CAT,TYP,PROV,NOTA,SPEC,QFL,VISIT,VSDTM,RMDRANGE
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BQIDCREM",UID))
S FDATA=$NA(^TMP("BQIFND",UID))
S VDATA=$NA(^TMP("BQIVIS",UID))
S DCRIT=$NA(^TMP("BQICRIT",UID))
K @DATA,@DCRIT,@VDATA,@FDATA
;
; Set the parameters into variables
I '$D(PARMS) Q
;
S NM="" F S NM=$O(PARMS(NM)) Q:NM="" S @NM=PARMS(NM)
S REMCODE=$G(REMCODE,""),OVD=$G(OVD,""),FUT=$G(FUT,"")
S PROV=$G(PROV,""),RMDFROM=$G(RMDFROM,""),RMDTHRU=$G(RMDTHRU,"")
I $G(RMDRANGE)'="" D
. I $G(PPIEN)'="" D RANGE^BQIDCAH1(RMDRANGE,PPIEN,"RMDRANGE")
. S RFDT=$S($G(RFROM)'="":RFROM,1:$G(RMDFROM))
. S REDT=$S($G(RTHRU)'="":RTHRU,1:$G(RMDTHRU))
I $G(RMDFROM)'="" S RFDT=RMDFROM,REDT=$G(RMDTHRU)
D PROV
;
I $D(MPARMS("REMCODE")) D Q
. S REMCODE=""
. F S REMCODE=$O(MPARMS("REMCODE",REMCODE)) Q:REMCODE="" D SRC
D SRC
K @FDATA
Q
;
SRC ;EP - Search and find
I $D(@FDATA) S DFN="" D
. F S DFN=$O(@FDATA@(DFN)) Q:DFN="" D RMF
Q
;
RMF ;EP - Find reminder
S RIEN=$O(^BQIPAT(DFN,40,"B",REMCODE,""))
I RIEN="" Q
S RDATA=$G(^BQIPAT(DFN,40,RIEN,0)) I RDATA="" Q
I $P(RDATA,U,3)=""!($P(RDATA,U,3)="N/A") Q
;
I FUT'="" D Q
. I $P(RDATA,U,3)="DUE NOW" Q
. ;I $P(RDATA,U,3)="RESOLVED" S @DATA@(DFN)="" Q
. I $P(RDATA,U,3)="RESOLVED" Q
. I $P(RDATA,U,3)="DONE" Q
. I $P(RDATA,U,4)'="" D
.. I $G(RFDT)'="" D
... I $P(RDATA,U,4)<RFDT!($P(RDATA,U,4)>REDT) Q
... S @DATA@(DFN)="",@DCRIT@("REM",DFN,REMCODE)=""
.. I $G(RFDT)="",$P(RDATA,U,4)>DT S @DATA@(DFN)="",@DCRIT@("REM",DFN,REMCODE)="" Q
;
I OVD'="" D Q
. I $P(RDATA,U,3)="RESOLVED" Q
. I $P(RDATA,U,3)="DONE" Q
. I $P(RDATA,U,4)>DT Q
. S @DATA@(DFN)="",@DCRIT@("REM",DFN,REMCODE)=""
Q
;
PROV ;EP -
;
NEW TMFRAME,VISITS,FDT,TDT,IEN,RFROM,RTHRU
I $G(DT)="" D DT^DICRW
S VISITS=$G(PVISITS,"")
I $G(PPIEN)'="",$G(PTMFRAME)'="" D RANGE^BQIDCAH1(PTMFRAME,PPIEN,"PTMFRAME")
S FDT=$S($G(RFROM)'="":RFROM,1:$G(PFROM))
S TDT=$S($G(RTHRU)'="":RTHRU,1:$G(PTHRU))
S TDT=DT
I $G(PROV)'="" D PV Q
Q
;
; 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
PV ;
S IEN=""
F S IEN=$O(^AUPNVPRV("B",PROV,IEN),-1) Q:IEN="" D
. S VISIT=$$GET1^DIQ(9000010.06,IEN_",",.03,"I") I VISIT="" 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
. ;
. 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 @FDATA@(DFN)=""
;
K @VDATA
Q
BQIDCREM ;GDIT/HS/ALA-Reminders Panel Definition ; 07 Dec 2012 2:18 PM
+1 ;;2.5;ICARE MANAGEMENT SYSTEM;**2**;May 24, 2016;Build 14
+2 ;
+3 QUIT
+4 ;
EN(DATA,PARMS,MPARMS) ;EP - Find records
+1 ;
+2 ;Description
+3 ; Executable that finds all patients who have a reminder
+4 ;Input
+5 ; PARMS = Array of parameters and their values
+6 ; MPARMS = Multiple array of a parameter
+7 ;Expected to return FDATA
+8 ;
+9 NEW UID,VDATA,DFN,RIEN,PTMFRAME,PVISITS,FUT,OVD,RMDFROM,RMDTHRU
+10 NEW CAT,TYP,PROV,NOTA,SPEC,QFL,VISIT,VSDTM,RMDRANGE
+11 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+12 SET DATA=$NAME(^TMP("BQIDCREM",UID))
+13 SET FDATA=$NAME(^TMP("BQIFND",UID))
+14 SET VDATA=$NAME(^TMP("BQIVIS",UID))
+15 SET DCRIT=$NAME(^TMP("BQICRIT",UID))
+16 KILL @DATA,@DCRIT,@VDATA,@FDATA
+17 ;
+18 ; Set the parameters into variables
+19 IF '$DATA(PARMS)
QUIT
+20 ;
+21 SET NM=""
FOR
SET NM=$ORDER(PARMS(NM))
IF NM=""
QUIT
SET @NM=PARMS(NM)
+22 SET REMCODE=$GET(REMCODE,"")
SET OVD=$GET(OVD,"")
SET FUT=$GET(FUT,"")
+23 SET PROV=$GET(PROV,"")
SET RMDFROM=$GET(RMDFROM,"")
SET RMDTHRU=$GET(RMDTHRU,"")
+24 IF $GET(RMDRANGE)'=""
Begin DoDot:1
+25 IF $GET(PPIEN)'=""
DO RANGE^BQIDCAH1(RMDRANGE,PPIEN,"RMDRANGE")
+26 SET RFDT=$SELECT($GET(RFROM)'="":RFROM,1:$GET(RMDFROM))
+27 SET REDT=$SELECT($GET(RTHRU)'="":RTHRU,1:$GET(RMDTHRU))
End DoDot:1
+28 IF $GET(RMDFROM)'=""
SET RFDT=RMDFROM
SET REDT=$GET(RMDTHRU)
+29 DO PROV
+30 ;
+31 IF $DATA(MPARMS("REMCODE"))
Begin DoDot:1
+32 SET REMCODE=""
+33 FOR
SET REMCODE=$ORDER(MPARMS("REMCODE",REMCODE))
IF REMCODE=""
QUIT
DO SRC
End DoDot:1
QUIT
+34 DO SRC
+35 KILL @FDATA
+36 QUIT
+37 ;
SRC ;EP - Search and find
+1 IF $DATA(@FDATA)
SET DFN=""
Begin DoDot:1
+2 FOR
SET DFN=$ORDER(@FDATA@(DFN))
IF DFN=""
QUIT
DO RMF
End DoDot:1
+3 QUIT
+4 ;
RMF ;EP - Find reminder
+1 SET RIEN=$ORDER(^BQIPAT(DFN,40,"B",REMCODE,""))
+2 IF RIEN=""
QUIT
+3 SET RDATA=$GET(^BQIPAT(DFN,40,RIEN,0))
IF RDATA=""
QUIT
+4 IF $PIECE(RDATA,U,3)=""!($PIECE(RDATA,U,3)="N/A")
QUIT
+5 ;
+6 IF FUT'=""
Begin DoDot:1
+7 IF $PIECE(RDATA,U,3)="DUE NOW"
QUIT
+8 ;I $P(RDATA,U,3)="RESOLVED" S @DATA@(DFN)="" Q
+9 IF $PIECE(RDATA,U,3)="RESOLVED"
QUIT
+10 IF $PIECE(RDATA,U,3)="DONE"
QUIT
+11 IF $PIECE(RDATA,U,4)'=""
Begin DoDot:2
+12 IF $GET(RFDT)'=""
Begin DoDot:3
+13 IF $PIECE(RDATA,U,4)<RFDT!($PIECE(RDATA,U,4)>REDT)
QUIT
+14 SET @DATA@(DFN)=""
SET @DCRIT@("REM",DFN,REMCODE)=""
End DoDot:3
+15 IF $GET(RFDT)=""
IF $PIECE(RDATA,U,4)>DT
SET @DATA@(DFN)=""
SET @DCRIT@("REM",DFN,REMCODE)=""
QUIT
End DoDot:2
End DoDot:1
QUIT
+16 ;
+17 IF OVD'=""
Begin DoDot:1
+18 IF $PIECE(RDATA,U,3)="RESOLVED"
QUIT
+19 IF $PIECE(RDATA,U,3)="DONE"
QUIT
+20 IF $PIECE(RDATA,U,4)>DT
QUIT
+21 SET @DATA@(DFN)=""
SET @DCRIT@("REM",DFN,REMCODE)=""
End DoDot:1
QUIT
+22 QUIT
+23 ;
PROV ;EP -
+1 ;
+2 NEW TMFRAME,VISITS,FDT,TDT,IEN,RFROM,RTHRU
+3 IF $GET(DT)=""
DO DT^DICRW
+4 SET VISITS=$GET(PVISITS,"")
+5 IF $GET(PPIEN)'=""
IF $GET(PTMFRAME)'=""
DO RANGE^BQIDCAH1(PTMFRAME,PPIEN,"PTMFRAME")
+6 SET FDT=$SELECT($GET(RFROM)'="":RFROM,1:$GET(PFROM))
+7 SET TDT=$SELECT($GET(RTHRU)'="":RTHRU,1:$GET(PTHRU))
+8 SET TDT=DT
+9 IF $GET(PROV)'=""
DO PV
QUIT
+10 QUIT
+11 ;
+12 ; Go through the V PROVIDER File for the designated provider and
+13 ; find out if they are a primary or secondary provider AND if the
+14 ; visit falls within the time frame
PV ;
+1 SET IEN=""
+2 FOR
SET IEN=$ORDER(^AUPNVPRV("B",PROV,IEN),-1)
IF IEN=""
QUIT
Begin DoDot:1
+3 SET VISIT=$$GET1^DIQ(9000010.06,IEN_",",.03,"I")
IF VISIT=""
QUIT
+4 SET VSDTM=$$GET1^DIQ(9000010,VISIT_",",.01,"I")\1
IF VSDTM=0
QUIT
+5 SET DFN=$$GET1^DIQ(9000010.06,IEN_",",.02,"I")
IF DFN=""
QUIT
+6 ;
+7 IF FDT'=""
SET QFL=0
Begin DoDot:2
+8 IF VSDTM'<FDT
IF VSDTM'>TDT
QUIT
+9 SET QFL=1
End DoDot:2
IF QFL
QUIT
+10 ; Count number of visits for a patient
+11 SET @VDATA@(DFN)=$GET(@VDATA@(DFN))+1
End DoDot:1
+12 ;
+13 SET DFN=""
+14 FOR
SET DFN=$ORDER(@VDATA@(DFN))
IF DFN=""
QUIT
Begin DoDot:1
+15 ; if the number of visits for patient doesn't match the criteria, quit
+16 ;Changed from '= to <
IF @VDATA@(DFN)<VISITS
QUIT
+17 SET @FDATA@(DFN)=""
End DoDot:1
+18 ;
+19 KILL @VDATA
+20 QUIT