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

BIREPD4.m

Go to the documentation of this file.
  1. BIREPD4 ;IHS/CMI/MWR - REPORT, ADOLESCENT RATES; AUG 10,2010
  1. ;;8.5;IMMUNIZATION;**3**;SEP 10,2012
  1. ;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
  1. ;; VIEW ADOLESCENT IMMUNIZATION RATES REPORT, WRITE HEADERS, ETC.
  1. ;; PATCH 1: Fix to count only one Flu dose per season; do not affect
  1. ;; other Vaccine Groups. CHECKSET+158
  1. ;; PATCH 3: Include new "1-Td 1-Men 3-HPV" lines. CHKSET+215
  1. ;
  1. ;
  1. ;----------
  1. GETPATS(BIBEGDT,BIENDDT,BICC,BIHCF,BICM,BIBEN,BIQDT,BIAGRPS,BISITE,BIUP,BITMP) ;EP
  1. ;---> Get patients from VA PATIENT File, ^DPT(.
  1. ;---> Parameters:
  1. ; 1 - BIBEGDT (req) Begin DOB for this group.
  1. ; 2 - BIENDDT (req) End DOB for this group.
  1. ; 3 - BICC (req) Current Community array.
  1. ; 4 - BIHCF (req) Health Care Facility array.
  1. ; 5 - BICM (req) Case Manager array.
  1. ; 6 - BIBEN (req) Beneficiary Type array.
  1. ; 7 - BIQDT (req) Quarter Ending Date.
  1. ; 8 - BIAGRPS (req) String of Age Groups ("1112,1313,1317").
  1. ; 9 - BISITE (req) Site IEN.
  1. ; 10 - BIUP (req) User Population/Group (All, Imm, User, Active).
  1. ; 11 - BITMP (ret) Stores Patient Totals by Age Group and Sex.
  1. ;
  1. ;---> Set begin and end dates for search through PATIENT File.
  1. ;
  1. Q:'$G(BIBEGDT) Q:'$G(BIENDDT) Q:'$G(BIQDT) Q:'$G(BIAGRPS)
  1. ;
  1. ;---> Start 1 day prior to Begin Date and $O into the desired DOB's.
  1. N BIDOB S BIDOB=BIBEGDT-1
  1. F S BIDOB=$O(^DPT("ADOB",BIDOB)) Q:(BIDOB>BIENDDT!('BIDOB)) D
  1. .S BIDFN=0
  1. .F S BIDFN=$O(^DPT("ADOB",BIDOB,BIDFN)) Q:'BIDFN D
  1. ..D CHKSET(BIDFN,.BICC,.BIHCF,.BICM,.BIBEN,BIDOB,BIQDT,.BIVAL,BIAGRPS,BIUP,.BITMP)
  1. ..;---> Set ^TMP("BIDUL",$J,CURCOM,1,HRCN,BIDFN)=$G(BIVAL) for Patient Roster.
  1. ..D:$G(BIVAL) STORE^BIDUR1(BIDFN,DT,9,,BIVAL,BISITE)
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. CHKSET(BIDFN,BICC,BIHCF,BICM,BIBEN,BIDOB,BIQDT,BIVAL,BIAGRPS,BIUP,BITMP) ;EP
  1. ;---> Check if this patient fits criteria; if so, set DFN
  1. ;---> in ^TMP("BIREPD1".
  1. ;---> Parameters:
  1. ; 1 - BIDFN (req) Patient IEN.
  1. ; 2 - BICC (req) Current Community array.
  1. ; 3 - BIHCF (req) Health Care Facility array.
  1. ; 4 - BICM (req) Case Manager array.
  1. ; 5 - BIBEN (req) Beneficiary Type array.
  1. ; 6 - BIDOB (req) Patient's Date of Birth.
  1. ; 7 - BIQDT (req) Quarter Ending Date.
  1. ; 8 - BIVAL (ret) 1=Not appropriate/complete, 2=1321 complete.
  1. ; 9 - BIAGRPS (req) String of Age Groups ("1112,1313,1317").
  1. ; 10 - BIUP (req) User Population/Group (All, Imm, User, Active).
  1. ; 11 - BITMP (ret) Stores Patient Totals by Age Group and Sex.
  1. ;
  1. Q:'$G(BIDFN)
  1. Q:'$D(BICC)
  1. Q:'$D(BIHCF)
  1. Q:'$D(BICM)
  1. Q:'$D(BIBEN)
  1. I '$G(BIDOB) S BIDOB=$$DOB^BIUTL1(BIDFN)
  1. Q:'$G(BIQDT)
  1. Q:'$G(BIAGRPS)
  1. Q:$G(BIUP)=""
  1. ;
  1. ;---> Don't include this patient in Roster unless set below.
  1. S BIVAL=0
  1. ;
  1. ;---> Filter for standard Patient Population parameter.
  1. Q:'$$PPFILTR^BIREP(BIDFN,.BIHCF,BIQDT,BIUP)
  1. ;
  1. ;---> Quit if Current Community doesn't match.
  1. Q:$$CURCOM^BIEXPRT2(BIDFN,.BICC)
  1. ;
  1. ;---> Quit if Case Manager doesn't match.
  1. Q:$$CMGR^BIDUR(BIDFN,.BICM)
  1. ;
  1. ;---> Quit if Beneficiary Type doesn't match.
  1. Q:$$BENT^BIDUR1(BIDFN,.BIBEN)
  1. ;
  1. ;---> Get patient gender.
  1. N BISEX S BISEX=$$SEX^BIUTL1(BIDFN)
  1. Q:((BISEX'="F")&(BISEX'="M"))
  1. ;
  1. ;---> Get patient age in years on report date.
  1. N BIAGE S BIAGE=$$AGE^BIUTL1(BIDFN,1,BIQDT)
  1. Q:'BIAGE Q:(BIAGE<11) Q:(BIAGE>18)
  1. ;
  1. ;---> Set patient's Age Group for this report; either 1112 or 1317.
  1. N BIAGRP S BIAGRP=$S(BIAGE<13:1112,1:1317)
  1. ;
  1. ;---> Store Patient in appropriate totals.
  1. ;---> Total patients.
  1. N Z S Z=$G(BITMP("STATS","TOTLPTS")) S BITMP("STATS","TOTLPTS")=Z+1
  1. ;---> Total patients in Age Group.
  1. S Z=$G(BITMP("STATS","TOTLPTS",BIAGRP)) S BITMP("STATS","TOTLPTS",BIAGRP)=Z+1
  1. ;----> * NOTE! Here's an example where I build column for 13-yr-olds!
  1. ;---> Duplicate tracking of 13-yr-olds.
  1. D:BIAGE=13
  1. .S Z=$G(BITMP("STATS","TOTLPTS",1313)) S BITMP("STATS","TOTLPTS",1313)=Z+1
  1. ;
  1. ;
  1. ;---> Set node for female or male denominators.
  1. N BISXNOD S BISXNOD=$S(BISEX="F":"TOTLFPTS",1:"TOTLMPTS")
  1. ;---> Total Female patients.
  1. S Z=$G(BITMP("STATS",BISXNOD)) S BITMP("STATS",BISXNOD)=Z+1
  1. ;---> Total female patients in Age Group.
  1. S Z=$G(BITMP("STATS",BISXNOD,BIAGRP)) S BITMP("STATS",BISXNOD,BIAGRP)=Z+1
  1. ;---> Duplicate tracking of 13-yr-olds.
  1. D:BIAGE=13
  1. .S Z=$G(BITMP("STATS",BISXNOD,1313)) S BITMP("STATS",BISXNOD,1313)=Z+1
  1. ;
  1. ;
  1. ;---> Store for Patient Report Roster (not yet determined if complete 1321).
  1. S BIVAL=1
  1. ;
  1. ;---> RPC to gather Immunization History.
  1. N BI31,BIDE,BIRETVAL,BIRETERR,I S BI31=$C(31)_$C(31),BIRETVAL=""
  1. ;---> 30=Vaccine IEN, 55=Vaccine Group IEN, 56=Date of Visit(Fileman).
  1. F I=30,55,56 S BIDE(I)=""
  1. ;
  1. ;---> Fourth parameter=0: Do not return Skin Tests.
  1. ;---> Fifth parameter=0: Means the components of a combination vaccine will
  1. ;---> be split out.
  1. D IMMHX^BIRPC(.BIRETVAL,BIDFN,.BIDE,0,0)
  1. ;
  1. ;---> If BIRETERR has a value, store it and quit.
  1. S BIRETERR=$P(BIRETVAL,BI31,2)
  1. Q:BIRETERR]""
  1. ;
  1. ;---> Add refusals, if any.
  1. N Z D CONTRA^BIUTL11(BIDFN,.Z,1) I $O(Z(0)) S BITMP("REFUSALS",BIDFN)="" K Z
  1. ;
  1. ;
  1. ;---> Check for Hx of Chicken Pox (as a reason for contra to Var & MMRV.
  1. ;---> If HX of Chicken Pox to add to Varicella Stats Line and to 1:3:2:1 line.
  1. N BIHXX,Z
  1. D CONTRA^BIUTL11(BIDFN,.Z,2) I ($G(Z(21))=12)!($G(Z(94))=12) D
  1. .S Z=$G(BITMP("STATS",132,1,BIAGRP)) S BITMP("STATS",132,1,BIAGRP)=Z+1
  1. .;---> Duplicate tracking of 13-yr-olds.
  1. .I BIAGE=13 S Z=$G(BITMP("STATS",132,1,1313)) S BITMP("STATS",132,1,1313)=Z+1
  1. .;---> Also set for 1:3:2:1 line.
  1. .S BIHXX(132,1,BIAGRP)=""
  1. ;
  1. ;---> Set BIHX=to a valid Immunization History.
  1. N BIHX S BIHX=$P(BIRETVAL,BI31,1)
  1. ;
  1. ;---> Add this Patient's History to stats.
  1. N I,Y
  1. ;---> Loop through "^"-pieces of Imm History, getting data.
  1. F I=1:1 S Y=$P(BIHX,U,I) Q:Y="" D
  1. .;---> Age (A), Dose# (D), Visit Date (J), sratch variable (Q),
  1. .;---> Vaccine Group IEN (V), Vaccine IEN (W).
  1. .N A,D,J,Q,V,W
  1. .S W=$P(Y,"|",2),V=$P(Y,"|",3),J=$P(Y,"|",4)
  1. .;
  1. .;---> Select for Vaccine Group IEN's:
  1. .;---> 4-HEPB, 6-MMR, 7-VAR, 8-Td_B, 9-HEPA, 10-FLU, 16-MEN, 17-HPV
  1. .Q:'$G(V)
  1. .N Q F Q=1,2,3,5,11:1:15 Q:V=Q
  1. .Q:V=Q
  1. .;
  1. .;---> Exclude immunization visits after the Quarter Ending Date, BIQDT.
  1. .Q:(J>BIQDT)
  1. .;
  1. .;********** v8.5, MAY 15,2011, IHS/CMI/MWR
  1. .;---> This code moved up from below. BIHX(10,D) was getting set for a prior
  1. .;---> year's dose, then quitting (because >1year), but also blocking this
  1. .;---> year's dose--since BIHX(10 already existed.
  1. .;---> Quit if V=FLU and Date of Visit is more than 1 year before Report Date.
  1. .Q:((V=10)&($$FMDIFF^XLFDT(BIQDT,J,1)>365))
  1. .;**********
  1. .;
  1. .;---> Quit if one Flu dose has already been recorded (only want one Flu
  1. .;---> dose per patient per season).
  1. .Q:((V=10)&($D(BIHX(10))))
  1. .;
  1. .;---> Build local array for setting combinations stats below.
  1. .;
  1. .;---> Set Dose# (increment by 1's to assign highest/latest dose#)
  1. .S D=1,Q=0
  1. .F Q:Q D
  1. ..I $D(BIHX(V,D)) S D=D+1 Q
  1. ..S BIHX(V,D)="",Q=1
  1. .;
  1. .;---> For Flu count every dose as a "dose #1". Might want to go to dose #2. MWRZZZ
  1. .I V=10 S D=1
  1. .;
  1. .;---> Set each immunization in the STATS array by Vaccine Group (V),
  1. .;---> Dose (D), and Age Group (BIAGRP).
  1. .;
  1. .;---> If this is HPV, separate female and male by appending sex to age group.
  1. .I V=17 D Q
  1. ..N Z S Z=$G(BITMP("STATS",V,D,BIAGRP_BISEX)) S BITMP("STATS",V,D,BIAGRP_BISEX)=Z+1
  1. ..S BIHX(V,D,BIAGRP)=""
  1. ..;---> Duplicate tracking of 13-yr-olds.
  1. ..D:BIAGE=13
  1. ...S Z=$G(BITMP("STATS",V,D,1313_BISEX)) S BITMP("STATS",V,D,1313_BISEX)=Z+1
  1. .;
  1. .;---> Okay, not HPV (don't append sex).
  1. .N Z S Z=$G(BITMP("STATS",V,D,BIAGRP)) S BITMP("STATS",V,D,BIAGRP)=Z+1
  1. .S BIHX(V,D,BIAGRP)=""
  1. .;---> Duplicate tracking of 13-yr-olds.
  1. .D:BIAGE=13
  1. ..S Z=$G(BITMP("STATS",V,D,1313)) S BITMP("STATS",V,D,1313)=Z+1
  1. .;
  1. .;
  1. .;---> If this is Td and the vaccine was Tdap, add a Tdap line.
  1. .;---> Substitute Vaccine IEN 221 for Vaccine Group.
  1. .Q:(W'=221) Q:$D(BIHX(221))
  1. .S Z=$G(BITMP("STATS",221,1,BIAGRP)) S BITMP("STATS",221,1,BIAGRP)=Z+1
  1. .;---> Duplicate tracking of 13-yr-olds.
  1. .D:BIAGE=13
  1. ..S Z=$G(BITMP("STATS",221,1,1313)) S BITMP("STATS",221,1,1313)=Z+1
  1. .;---> Flag to ensure only 1 dose is counted per patient.
  1. .S BIHX(221)=""
  1. ;
  1. ;---> Now calculate vaccine combination stats.
  1. ;---> NOTE: DO NOT GENERALIZE CODE BELOW (highly iterative).
  1. ;---> Relies on the following Vaccine Group IEN's in ^BISERT:
  1. ;---> 4-HEPB, 6-MMR, 7-VAR, 8-Td_B, 9-HEPA, 16-MEN, 17-HPV
  1. ;
  1. N K
  1. ;
  1. ;---> 1-Td_B, 3-HEPB, 2-MMR, 1-VAR
  1. F K=1:1 S A=$P(BIAGRPS,",",K) Q:'A D
  1. .Q:'$D(BIHX(8,1,A))
  1. .Q:'$D(BIHX(4,3,A))
  1. .Q:'$D(BIHX(6,2,A))
  1. .;---> Either 1-VAR or Hx of Chicken Pox will count as "1:3:2:1 Current."
  1. .Q:(('$D(BIHX(7,1,A)))&('$D(BIHXX(132,1,A))))
  1. .D COMBO("8|1^4|3^6|2^7|1",A,.BITMP,BIAGE)
  1. .;---> Store for Patient Report Roster (complete 1321).
  1. .;S BIVAL=2
  1. ;
  1. ;---> 1-Td_B, 3-HEPB, 2-MMR, 1-MEN, 2-VAR
  1. F K=1:1 S A=$P(BIAGRPS,",",K) Q:'A D
  1. .Q:'$D(BIHX(8,1,A))
  1. .Q:'$D(BIHX(4,3,A))
  1. .Q:'$D(BIHX(6,2,A))
  1. .Q:'$D(BIHX(16,1,A))
  1. .Q:'$D(BIHX(7,2,A))
  1. .D COMBO("8|1^4|3^6|2^16|1^7|2",A,.BITMP,BIAGE)
  1. .;---> Store for Patient Report Roster (complete 13212).
  1. .;S BIVAL=2
  1. ;
  1. ;---> 1-Td_B, 1-MEN
  1. F K=1:1 S A=$P(BIAGRPS,",",K) Q:'A D
  1. .Q:'$D(BIHX(8,1,A))
  1. .Q:'$D(BIHX(16,1,A))
  1. .D COMBO("8|1^16|1",A,.BITMP,BIAGE)
  1. .;---> Store for Patient Report Roster (complete 11).
  1. .;********** PATCH 3, v8.5, SEP 10,2012, IHS/CMI/MWR
  1. .;---> 11 no longer complete. Now 113, see immediately below.
  1. .;S BIVAL=2
  1. ;
  1. ;********** PATCH 3, v8.5, SEP 10,2012, IHS/CMI/MWR
  1. ;---> Include new "1-Td 1-Men 3-HPV" lines, combined as well as sex specific.
  1. ;---> 1-Td_B, 1-MEN, 3-HPV (because HPV include BISEX).
  1. F K=1:1 S A=$P(BIAGRPS,",",K) Q:'A D
  1. .Q:'$D(BIHX(8,1,A))
  1. .Q:'$D(BIHX(16,1,A))
  1. .Q:'$D(BIHX(17,3,A))
  1. .;---> Store both combined and sex specific lines.
  1. .D COMBO("8|1^16|1^17|3",A,.BITMP,BIAGE)
  1. .D COMBO("8|1^16|1^17|3",A_BISEX,.BITMP,BIAGE,BISEX)
  1. .;---> Store for Patient Report Roster (complete 113).
  1. .S BIVAL=2
  1. ;**********
  1. ;
  1. ;
  1. ;---> 1-Td_B, 3-HEPB, 2-MMR, 1-MEN, 2-VAR, 3-HPV (because HPV include BISEX).
  1. F K=1:1 S A=$P(BIAGRPS,",",K) Q:'A D
  1. .Q:'$D(BIHX(8,1,A))
  1. .Q:'$D(BIHX(4,3,A))
  1. .Q:'$D(BIHX(6,2,A))
  1. .Q:'$D(BIHX(16,1,A))
  1. .Q:'$D(BIHX(7,2,A))
  1. .Q:'$D(BIHX(17,3,A))
  1. .D COMBO("8|1^4|3^6|2^16|1^7|2^17|3",A_BISEX,.BITMP,BIAGE,BISEX)
  1. ;
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. COMBO(BICOMB,BIAGRP,BITMP,BIAGE,BISEX) ;EP
  1. ;---> Store Patient vaccine combination for Age Group.
  1. ;---> Parameters:
  1. ; 1 - BICOMB (req) Combination number.
  1. ; 2 - BIAGRP (req) Node/number for this Age Group.
  1. ; 3 - BITMP (ret) Stores Patient Totals by Age Group and Sex.
  1. ; 4 - BIAGE (opt) Age of patient (if 13, duplicate stats).
  1. ; 5 - BISEX (opt) F or M for HPV.
  1. ;
  1. ;---> Store Patient in Age Group.
  1. N Z S Z=$G(BITMP("STATS",BICOMB,BIAGRP))
  1. S BITMP("STATS",BICOMB,BIAGRP)=Z+1
  1. ;---> Duplicate tracking of 13-yr-olds.
  1. D:BIAGE=13
  1. .;---> If this is the HPV combo, include BISEX.
  1. .I ((BIAGRP["F")!(BIAGRP["M")) D Q
  1. ..S Z=$G(BITMP("STATS",BICOMB,1313_BISEX)) S BITMP("STATS",BICOMB,1313_BISEX)=Z+1
  1. .;
  1. .S Z=$G(BITMP("STATS",BICOMB,1313)) S BITMP("STATS",BICOMB,1313)=Z+1
  1. ;
  1. Q