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

BIEXPRT2.m

Go to the documentation of this file.
  1. BIEXPRT2 ;IHS/CMI/MWR - EXPORT IMMUNIZATION RECORDS; MAY 10, 2010
  1. ;;8.5;IMMUNIZATION;**9**;OCT 01,2014
  1. ;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
  1. ;; EXPORT IMMUNIZATION RECORDS: GATHER PATIENTS ACCORDING TO
  1. ;; CRITERIA AND STORE IN ^BITMP(1,.
  1. ;
  1. ;
  1. ;********** PATCH 9, v8.5, OCT 01,2014, IHS/CMI/MWR
  1. ;---> Changes to limit export of imms to specific vaccines within
  1. ;---> a date range. Parameters BIMMR and BIRDT added below.
  1. ;----------
  1. PATIENT(BIPG,BIAG,BISVDT,BIHCF,BICC,BIMMR,BIRDT) ;EP
  1. ;---> Gather patients according to selection criteria and
  1. ;---> store in ^BITMP(.
  1. ;---> Parameters:
  1. ; 1 - BIPG (req) Patient Group
  1. ; 2 - BIAG (req) Age Range (=0 if not limited by age)
  1. ; 3 - BISVDT (req) Survey Date
  1. ; 4 - BIHCF (req) Facility array
  1. ; 5 - BICC (req) Current Community array
  1. ; 6 - BIMMR (opt) Immunizations Received, IEN's (array)
  1. ; 7 - BIRDT (opt) Date Range for Imms received (YYYMMDD:YYYMMDD)
  1. ;
  1. S BIPOP=0 K ^BITMP($J)
  1. ;
  1. ;---> If there's an Age Range *or* if the Group is not limited to
  1. ;---> the Immunization Register, then scan ^DPT(.
  1. I BIAG]""!(BIPG=3) D Q
  1. .;
  1. .;---> Set begin and end dates for search through PATIENT File.
  1. .D AGEDATE^BIAGE(BIAG,BISVDT,.BIBEGDT,.BIENDDT)
  1. .;---> Start 1 day prior to Begin Date and $O into the desired DOB's.
  1. .S N=BIBEGDT-1
  1. .F S N=$O(^DPT("ADOB",N)) Q:(N>BIENDDT!('N)) D
  1. ..S BIDFN=0
  1. ..F S BIDFN=$O(^DPT("ADOB",N,BIDFN)) Q:'BIDFN D
  1. ...D STORE(BIDFN,BISVDT,BIPG,.BIHCF,.BICC,1,.BIMMR,$G(BIRDT))
  1. ;
  1. ;---> If there is NO Age Range *and* the Group is limited to the
  1. ;---> Immunization Register, then scan ^BIP(.
  1. S BIDFN=0
  1. F S BIDFN=$O(^BIP(BIDFN)) Q:'BIDFN D
  1. .D STORE(BIDFN,BISVDT,BIPG,.BIHCF,.BICC,0,.BIMMR,$G(BIRDT))
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. STORE(BIDFN,BISVDT,BIPG,BIHCF,BICC,BIDPT,BIMMR,BIRDT) ;EP
  1. ;---> Store patients in ^BITMP if they pass all criteria.
  1. ;---> Parameters:
  1. ; 1 - BIDFN (req) Patient Group
  1. ; 2 - BISVDT (req) Survey Date
  1. ; 3 - BIPG (req) Patient Group
  1. ; 4 - BIHCF (req) Facility array
  1. ; 5 - BICC (req) Current Community array
  1. ; 6 - BIDPT (opt) =1 if searching ^DPT, =0 if searching ^BIP.
  1. ; 7 - BIMMR (opt) Immunizations Received, IEN's (array)
  1. ; 8 - BIRDT (opt) Date Range for Imms received (YYYMMDD:YYYMMDD)
  1. ;
  1. ;---> If Group is ACTIVE and patient was not ACTIVE<BISVDT, Quit.
  1. I BIPG=1 Q:$$ACTIVE(BIDFN,BISVDT)
  1. ;
  1. ;---> If Group is ACTIVE & INACTIVE and patient was not in the
  1. ;---> Register, Quit.
  1. I $G(BIDPT),BIPG=2 Q:'$D(^BIP(BIDFN))
  1. ;
  1. ;---> If patient has had NO IMMUNIZATIONS or has had none at
  1. ;---> the selected Health Care Facilities, Quit.
  1. Q:$$VIMM(BIDFN,.BIHCF)
  1. ;
  1. ;---> If patient does not have one of the selected Current
  1. ;---> Communities, Quit.
  1. Q:$$CURCOM(BIDFN,.BICC)
  1. ;
  1. ;
  1. ;********** PATCH 9, v8.5, OCT 01,2014, IHS/CMI/MWR
  1. ;---> If limited to specific vaccines within a date range, check and
  1. ;---> store patient if it's a match.
  1. I $O(BIMMR(0)) D Q
  1. .N N,Z S N=0,Z=0 F S N=$O(BIMMR(N)) Q:'N Q:Z D
  1. ..I $$GOTDOSE^BIUTL11(BIDFN,N,$G(BIRDT)) S ^BITMP($J,1,BIDFN)="",Z=1
  1. ;**********
  1. ;
  1. ;---> Store this patient for data retrieval.
  1. S ^BITMP($J,1,BIDFN)=""
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. ACTIVE(BIDFN,BISVDT) ;EP
  1. ;---> Return Active indicator: 0=Active, 1=Inactive.
  1. ;---> Called if looking for Active Only.
  1. ;---> Parameters:
  1. ; 1 - BIDFN (req) IEN of Patient in ^DPT.
  1. ; 2 - BISVDT (opt) Survey Date.
  1. ;
  1. ;
  1. N X S X=$$INACT^BIUTL1(BIDFN)
  1. ;---> If this patient is not in the Register, return 1.
  1. Q:X]"A" 1
  1. ;---> If this patient is Active, return 0.
  1. Q:X="" 0
  1. ;---> If this patient was Inactive PRIOR TO the Survey Date return 1.
  1. Q:X<$G(BISVDT) 1
  1. ;---> This patient became Inactive AFTER the Survey Date return 0.
  1. Q 0
  1. ;
  1. ;
  1. ;----------
  1. CURCOM(BIDFN,BICC) ;EP
  1. ;---> Return Current Community indicator.
  1. ;---> Return 1 if not selecting all CURRENT COMMUNITIES and if this
  1. ;---> patient's CURRENT COMMUNITY is not one of the ones selected.
  1. ;---> Parameters:
  1. ; 1 - BIDFN (req) IEN of Patient in ^DPT.
  1. ; 2 - BICC (req) Current Community array.
  1. ;
  1. Q:$D(BICC("ALL")) 0
  1. N BICUR S BICUR=$$CURCOM^BIUTL11(BIDFN)
  1. Q:'BICUR 1
  1. Q:'$D(BICC(BICUR)) 1
  1. Q 0
  1. ;
  1. ;
  1. ;----------
  1. VIMM(BIDFN,BIHCF) ;EP
  1. ;---> Return Immunization Visit indicator: 1=None, 0=Yes.
  1. ;---> Parameters:
  1. ; 1 - BIDFN (req) IEN of Patient in ^DPT.
  1. ; 2 - BIHCF (req) Current Community array.
  1. ;
  1. ;---> Return 1 if patient has no V IMMUNIZATIONS at all.
  1. Q:'$D(^AUPNVIMM("AC",BIDFN)) 1
  1. ;---> Return 0 if patient has a V IMMUNIZATION and "ALL" are selected.
  1. Q:$D(BIHCF("ALL")) 0
  1. ;---> Return 1 if patient does not have an Immunization Visit at the
  1. ;---> selected Facilities.
  1. N BIFLAG,N,X
  1. S N=0,BIFLAG=1
  1. F S N=$O(^AUPNVIMM("AC",BIDFN,N)) Q:'N Q:'BIFLAG D
  1. .Q:'$D(^AUPNVIMM(N,0))
  1. .S Y=$P(^AUPNVIMM(N,0),U,3) Q:'Y
  1. .Q:'$D(^AUPNVSIT(Y,0))
  1. .S X=$P(^AUPNVSIT(Y,0),U,6)
  1. .S:$D(BIHCF(X)) BIFLAG=0
  1. Q BIFLAG
  1. ;
  1. ;
  1. ;----------
  1. VISIT(BIDFN,BIHCF) ;EP
  1. ;---> Return Visit indicator.
  1. ;**** NOT USED FOR NOW. Might be used if some report/list wants
  1. ; all patients who have had any type of Visit at a Facility.
  1. ;
  1. ;---> Return 1 if patient has no VISITS at all.
  1. Q:'$D(^AUPNVSIT("AC",BIDFN)) 1
  1. ;---> Return 0 if patient has a VISIT and "ALL" are selected.
  1. Q:$D(BIHCF("ALL")) 0
  1. ;---> Return 1 if patient does not have a VISIT at the selected
  1. ;---> Facilities.
  1. N BIFLAG,N,X
  1. S N=0,BIFLAG=1
  1. F S N=$O(^AUPNVSIT("AC",BIDFN,N)) Q:'N Q:'BIFLAG D
  1. .Q:'$D(^AUPNVSIT(N,0))
  1. .S X=$P(^AUPNVSIT(N,0),U,6)
  1. .S:$D(BIHCF(X)) BIFLAG=0
  1. Q BIFLAG
  1. ;
  1. ;
  1. ;----------
  1. HRCN(BIDFN,BIHCF,BIACT) ;EP
  1. ;---> Return Health Record Number Indicator.
  1. ;---> Return 1 if this patient DOES NOT HAVE an Active HRCN/Chart# at any
  1. ;---> of the facilities in the BIHCF array; otherwise, return 0.
  1. ;---> Also return 1 if patient has NO Chart# ANYWHERE.
  1. ;---> Parameters:
  1. ; 1 - BIDFN (req) IEN of Patient in ^DPT.
  1. ; 2 - BIHCF (req) Health Care Facility array. Can be BIHCF("ALL").
  1. ; 3 - BIACT (opt) If BIACT=1 INCLUDE Patients whose Chart#'s are
  1. ; INACTIVE. In other words, return 0 for patients
  1. ; that have Chart#'s even if they are INACTIVE.
  1. ;
  1. Q:'$G(BIDFN) 1
  1. ;
  1. ;---> Quit if patient has no Chart# anywhere.
  1. Q:'$O(^AUPNPAT(BIDFN,41,0)) 1
  1. ;
  1. ;---> Build local array of patient's Chart#'s.
  1. N BIHRCN,BIMATCH,M,N
  1. S N=0
  1. F S N=$O(^AUPNPAT(BIDFN,41,N)) Q:'N S BIHRCN(N)=^(N,0)
  1. ;
  1. ;---> Check for match between array of Chart# Sites and array of HCF's.
  1. S BIMATCH=1,M=0
  1. F S M=$O(BIHRCN(M)) Q:'M D Q:'BIMATCH
  1. .;
  1. .;---> If there's a match or if accepting ALL, then check for Inactive.
  1. .D:($D(BIHCF(M))!($D(BIHCF("ALL"))))
  1. ..;
  1. ..;---> Quit if the Chart# is Inactive and the flag to include
  1. ..;---> Inactive is not set to 1.
  1. ..Q:($P(BIHRCN(M),U,3)&('$G(BIACT)))
  1. ..;
  1. ..;---> Got a match.
  1. ..S BIMATCH=0
  1. ;
  1. Q BIMATCH