Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BQIDCMPR

BQIDCMPR.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. Q
  1. ;
  1. FND(DATA,PARMS,MPARMS,FLAG) ;EP - Find patients
  1. ;
  1. ;Description
  1. ; Executable to find the patients for a specific provider where the patient
  1. ; had NVIS number of visits for the specified time frame
  1. ;Input
  1. ; PARMS = Array of parameters and their values
  1. ; MPARMS = Multiple array of a parameter (not currently used for this definition)
  1. ; FLAG = "P" is primary only, blank is both primary and secondary
  1. ;Expected to return DATA
  1. ;
  1. NEW IEN,DFN,FDT,TDT,VISIT,VSDTM,Y,X,UID,NM,TMFRAME,PROV
  1. NEW VISITS,QFL,%DT,VDATA,TMN
  1. S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
  1. S DATA=$NA(^TMP("BQIDCMPR",UID))
  1. S VDATA=$NA(^TMP("BQIFND",UID))
  1. K @DATA,@VDATA
  1. ;
  1. I '$D(PARMS) Q
  1. ;
  1. S NM=""
  1. F S NM=$O(PARMS(NM)) Q:NM="" S @NM=PARMS(NM)
  1. ;
  1. I $G(DT)="" D DT^DICRW
  1. ;
  1. S TMN=$O(^BQI(90506.9,"B",TMFRAME,""))
  1. I TMN="" S FDT="",TDT=""
  1. ;
  1. S FDT=$P(^BQI(90506.9,TMN,0),U,3),TDT=$P(^BQI(90506.9,TMN,0),U,4)
  1. S FDT=$$DATE^BQIUL1(FDT),TDT=$$DATE^BQIUL1(TDT)
  1. ;
  1. ; Go through the V PROVIDER File for the designated provider and
  1. ; find out if they are a primary or secondary provider AND if the
  1. ; visit falls within the time frame
  1. S IEN="",FLAG=$G(FLAG,"")
  1. F S IEN=$O(^AUPNVPRV("B",PROV,IEN),-1) Q:IEN="" D
  1. . I FLAG="P",$$GET1^DIQ(9000010.06,IEN_",",.04,"I")'="P" Q
  1. . S VISIT=$$GET1^DIQ(9000010.06,IEN_",",.03,"I") I VISIT="" Q
  1. . I $$GET1^DIQ(9000010,VISIT_",",.11,"I")=1 Q
  1. . S VSDTM=$$GET1^DIQ(9000010,VISIT_",",.01,"I")\1 I VSDTM=0 Q
  1. . S DFN=$$GET1^DIQ(9000010.06,IEN_",",.02,"I") I DFN="" Q
  1. . ; If patient is deceased, quit
  1. . I $P($G(^DPT(DFN,.35)),U,1)'="" Q
  1. . ; If patient has no active HRNs, quit
  1. . I '$$HRN^BQIUL1(DFN) Q
  1. . ; If patient has no visit in last 3 years, quit
  1. . ;I '$$VTHR^BQIUL1(DFN) Q
  1. . ;
  1. . I FDT'="" S QFL=0 D Q:QFL
  1. .. I VSDTM'<FDT,VSDTM'>TDT Q
  1. .. S QFL=1
  1. . ; Count number of visits for a patient
  1. . S @VDATA@(DFN)=$G(@VDATA@(DFN))+1
  1. ;
  1. S DFN=""
  1. F S DFN=$O(@VDATA@(DFN)) Q:DFN="" D
  1. . ; if the number of visits for patient doesn't match the criteria, quit
  1. . I @VDATA@(DFN)<VISITS Q ;Changed from '= to <
  1. . S @DATA@(DFN)=""
  1. ;
  1. K @VDATA
  1. Q