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

BIREPQ4.m

Go to the documentation of this file.
  1. BIREPQ4 ;IHS/CMI/MWR - REPORT, QUARTERLY IMM; MAY 10, 2010
  1. ;;8.5;IMMUNIZATION;;SEP 01,2011
  1. ;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
  1. ;; QUARTERLY IMM REPORT, GATHER/STORE PATIENTS.
  1. ;
  1. ;
  1. ;----------
  1. GETPATS(BIBEGDT,BIENDDT,BIAGRP,BICC,BIHCF,BICM,BIBEN,BIQDT,BIHPV,BIUP) ;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 - BIAGRP (req) Node/number for this Age Group.
  1. ; 4 - BICC (req) Current Community array.
  1. ; 5 - BIHCF (req) Health Care Facility array.
  1. ; 6 - BICM (req) Case Manager array.
  1. ; 7 - BIBEN (req) Beneficiary Type array.
  1. ; 8 - BIQDT (req) Quarter Ending Date.
  1. ; 9 - BIHPV (req) 1=Include Varicella & Pneumo.
  1. ; 10 - BIUP (req) User Population/Group (Registered, Imm, User, Active).
  1. ;
  1. ;---> Set begin and end dates for search through PATIENT File.
  1. ;
  1. Q:'$G(BIBEGDT) Q:'$G(BIENDDT) Q:'$G(BIAGRP)
  1. ;---> Start 1 day prior to Begin Date and $O into the desired DOB's.
  1. N N 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 CHKSET(BIDFN,.BICC,.BIHCF,.BICM,.BIBEN,BIAGRP,BIQDT,BIHPV,BIUP)
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. CHKSET(BIDFN,BICC,BIHCF,BICM,BIBEN,BIAGRP,BIQDT,BIHPV,BIUP) ;EP
  1. ;---> Check if this patient fits criteria; if so, set DFN
  1. ;---> in ^TMP("BIREPQ1".
  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 - BIAGRP (req) Node/number for this Age Group.
  1. ; 7 - BIQDT (req) Quarter Ending Date.
  1. ; 8 - BIHPV (req) 1=Include Varicella & Pneumo.
  1. ; 9 - BIUP (req) User Population/Group (Registered, Imm, User, Active).
  1. ;
  1. Q:'$G(BIDFN)
  1. Q:'$D(BICC)
  1. Q:'$D(BIHCF)
  1. Q:'$D(BICM)
  1. Q:'$D(BIBEN)
  1. Q:'$G(BIAGRP)
  1. Q:'$G(BIQDT)
  1. Q:'$D(BIHPV)
  1. Q:$G(BIUP)=""
  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. ;---> Store Patient in Age Group.
  1. S ^TMP("BIREPQ1",$J,"PATS",BIAGRP,BIDFN)=""
  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. ;---> 65=Invalid Dose (1-4).
  1. F I=30,55,56,65 S BIDE(I)=""
  1. ;---> Fourth parameter=0: Do not return Skin Tests.
  1. ;---> Fifth parameter=0: Split out combinations as if given individually.
  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)=""
  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 BIHIB,BIPCV,I,Y
  1. ;
  1. ;---> Loop through "^"-pieces of Imm History, getting data.
  1. F I=1:1 S Y=$P(BIHX,U,I) Q:Y="" D
  1. .;
  1. .;---> BIIEN=Vaccine IEN, BIVGRP=Vaccine Group, BIVDAT=Visit Date, BINVLD=Invalid Code.
  1. .N BIDOSE,BIIEN,BINVLD,BIVDAT,BIVGRP,Q
  1. .S BIIEN=$P(Y,"|",2),BIVGRP=$P(Y,"|",3),BIVDAT=$P(Y,"|",4),BINVLD=$P(Y,"|",5)
  1. .;
  1. .;---> Quit (don't count) if Visit was AFTER Quarter Ending Date.
  1. .Q:(BIVDAT>BIQDT) Q:'$G(BIVGRP)
  1. .;
  1. .;---> Quit if this dose has been overrided as Invalid (1-4).
  1. .Q:(1234[+BINVLD)
  1. .;
  1. .;---> Set this immunization in the STATS array by: Vaccine Group, Dose#, and Age Group.
  1. .;---> Set Dose# (increment by 1's to assign highest/latest dose#).
  1. .N Q S BIDOSE=1,Q=0
  1. .F Q:Q D
  1. ..I $D(BIHX(BIVGRP,BIDOSE)) S BIDOSE=BIDOSE+1 Q
  1. ..S BIHX(BIVGRP,BIDOSE)="",Q=1
  1. .;
  1. .N Z S Z=$G(BITMP("STATS",BIVGRP,BIDOSE,BIAGRP))
  1. .S BITMP("STATS",BIVGRP,BIDOSE,BIAGRP)=Z+1
  1. .;
  1. .;---> If this was a Hib or PCV, store it in local array for UTD eval:
  1. .;---> BIHIB(age_in_mths,IEN_of_vaccine)
  1. .I BIVGRP=3 S BIHIB($$AGE^BIUTL1(BIDFN,2,BIVDAT),BIIEN)=""
  1. .I BIVGRP=11 S BIPCV($$AGE^BIUTL1(BIDFN,2,BIVDAT),BIIEN)=""
  1. ;
  1. ;
  1. ;---> Now check whether the first 2 Hibs were Hibs=127; if so, BIH127=2.
  1. N BIH127,I,N S BIH127=0,N=""
  1. F I=1:1:2 S N=$O(BIHIB(N)) Q:'N D
  1. .I $O(BIHIB(N,0))=127 S BIH127=BIH127+1
  1. ;
  1. ;
  1. ;---> Now calculate Hib Need (BIHNEED).
  1. N BIHNEED
  1. D
  1. .;---> If patient is 1st age group, need 1 Hib.
  1. .I BIAGRP=1 S BIHNEED=1 Q
  1. .;---> If patient is 2nd age group, need 2 Hibs.
  1. .I BIAGRP=2 S BIHNEED=2 Q
  1. .;
  1. .I BIAGRP=3 D Q
  1. ..;---> If patient is 3rd age group:
  1. ..;---> If at least 2 Hibs recvd at 7 mths or greater, then need only 2 Hibs.
  1. ..I $$NEED(.BIHIB,7,2) S BIHNEED=2 Q
  1. ..;---> If patient rcvd 2 127's, then need only 2 Hibs.
  1. ..I BIH127=2 S BIHNEED=2 Q
  1. ..;---> Otherwise, 3rd group needs 3 Hibs.
  1. ..S BIHNEED=3
  1. .;
  1. .;
  1. .;---> BIAGRP must =4, 5, or 6.
  1. .;---> If at least 1 Hib recvd at 15 mths or greater, then need only 1 Hib.
  1. .I $$NEED(.BIHIB,15,1) S BIHNEED=1 Q
  1. .;
  1. .;---> If at least 2 Hibs recvd at 12 mths or greater, then need only 2 Hibs.
  1. .I $$NEED(.BIHIB,12,2) S BIHNEED=2 Q
  1. .;
  1. .;---> If at least 3 Hibs recvd at 7 mths or greater, then need only 3 Hibs.
  1. .I $$NEED(.BIHIB,7,3) S BIHNEED=3 Q
  1. .;
  1. .;---> If patient rcvd at least 2 127's, then need only 3 Hibs.
  1. .I BIH127=2 S BIHNEED=3 Q
  1. .;
  1. .;---> Otherwise, 4th-6th group needs 4 Hibs.
  1. .S BIHNEED=4
  1. ;
  1. ;
  1. ;---> Now calculate PCV Need (BIPNEED).
  1. N BIPNEED
  1. D
  1. .;---> If patient is 1st age group, need 1 PCV.
  1. .I BIAGRP=1 S BIPNEED=1 Q
  1. .;---> If patient is 2nd age group, need 2 PCVs.
  1. .I BIAGRP=2 S BIPNEED=2 Q
  1. .;
  1. .I BIAGRP=3 D Q
  1. ..;---> If patient is 3rd age group:
  1. ..;---> If at least 2 PCVs recvd at 7 mths or greater, then need only 2 PCVs.
  1. ..I $$NEED(.BIPCV,7,2) S BIPNEED=2 Q
  1. ..;---> Otherwise, 3rd group needs 3 PCVs.
  1. ..S BIPNEED=3
  1. .;
  1. .;
  1. .;---> BIAGRP must =4, 5, or 6.
  1. .;---> If at least 1 PCV recvd at 15 mths or greater, then need only 1 PCV.
  1. .I $$NEED(.BIPCV,15,1) S BIPNEED=1 Q
  1. .;
  1. .;---> If at least 2 PCVs recvd at 12 mths or greater, then need only 2 PCVs.
  1. .I $$NEED(.BIPCV,12,2) S BIPNEED=2 Q
  1. .;
  1. .;---> If at least 3 PCVs recvd at 7 mths or greater, then need only 3 PCVs.
  1. .I $$NEED(.BIPCV,7,3) S BIPNEED=3 Q
  1. .;
  1. .;---> Otherwise, 4th-6th group needs 4 Hibs.
  1. .S BIPNEED=4
  1. ;
  1. ;
  1. ;---> Next Section:
  1. ;---> If this patient has the minimum required immunizations for
  1. ;---> his/her Age Group, then increment by 1 the "Appro for Age"
  1. ;---> tally for that Age Group.
  1. ;---> The code examines Imm Hx array BIHX(VacGrp,Dose#) for each patient.
  1. ;---> Each Quit represents a condition that a child in that age group
  1. ;---> must meet in order to be "appropriate for age."
  1. ;
  1. ;---> Following lines matrix: Vaccine Group, Dose#.
  1. ;---> Relies on the following Vaccine Group IEN's in ^BISERT:
  1. ;---> DTP=1, OPV=2, HIB=3, HEPB=4, MMR=6, VAR=7, HEPA=9, FLU=10, PCV=11, ROT=15
  1. ;
  1. N X S X=1
  1. I BIAGRP=1 D D STOR(BIDFN,BIQDT,X) Q
  1. .Q:'$D(BIHX(1,1))
  1. .Q:'$D(BIHX(2,1))
  1. .Q:'$D(BIHX(3,BIHNEED))
  1. .Q:'$D(BIHX(4,1))
  1. .;Q:'$D(BIHX(15,1)) ;Rotavirus, "not at this time" says Ros Singleton, 4-24-07
  1. .Q:(($G(BIHPV))&('$D(BIHX(11,BIPNEED))))
  1. .D APPRO(BIAGRP) S X=2
  1. ;
  1. I BIAGRP=2 D D STOR(BIDFN,BIQDT,X) Q
  1. .Q:'$D(BIHX(1,2))
  1. .Q:'$D(BIHX(2,2))
  1. .Q:'$D(BIHX(3,BIHNEED))
  1. .Q:'$D(BIHX(4,2))
  1. .;Q:'$D(BIHX(15,2))
  1. .Q:(($G(BIHPV))&('$D(BIHX(11,BIPNEED))))
  1. .D APPRO(BIAGRP) S X=2
  1. ;
  1. I BIAGRP=3 D D STOR(BIDFN,BIQDT,X) Q
  1. .Q:'$D(BIHX(1,3))
  1. .Q:'$D(BIHX(2,2))
  1. .Q:'$D(BIHX(3,BIHNEED))
  1. .Q:'$D(BIHX(4,2))
  1. .;Q:'$D(BIHX(15,3))
  1. .Q:(($G(BIHPV))&('$D(BIHX(11,BIPNEED))))
  1. .D APPRO(BIAGRP) S X=2
  1. ;
  1. I BIAGRP=4 D D STOR(BIDFN,BIQDT,X) Q
  1. .Q:'$D(BIHX(1,3))
  1. .Q:'$D(BIHX(2,2))
  1. .Q:'$D(BIHX(3,BIHNEED))
  1. .Q:'$D(BIHX(4,2))
  1. .Q:'$D(BIHX(6,1))
  1. .;Q:'$D(BIHX(15,3))
  1. .Q:(($G(BIHPV))&('$D(BIHX(11,BIPNEED))))
  1. .Q:(($G(BIHPV))&('$D(BIHX(7,1))))
  1. .D APPRO(BIAGRP) S X=2
  1. ;
  1. I BIAGRP=5 D D STOR(BIDFN,BIQDT,X) Q
  1. .Q:'$D(BIHX(1,4))
  1. .Q:'$D(BIHX(2,3))
  1. .Q:'$D(BIHX(3,BIHNEED))
  1. .Q:'$D(BIHX(4,3))
  1. .Q:'$D(BIHX(6,1))
  1. .;Q:'$D(BIHX(15,3))
  1. .Q:(($G(BIHPV))&('$D(BIHX(11,BIPNEED))))
  1. .Q:(($G(BIHPV))&('$D(BIHX(7,1))))
  1. .D APPRO(BIAGRP) S X=2
  1. ;
  1. I BIAGRP=6 D D STOR(BIDFN,BIQDT,X) Q
  1. .Q:'$D(BIHX(1,4))
  1. .Q:'$D(BIHX(2,3))
  1. .Q:'$D(BIHX(3,BIHNEED))
  1. .Q:'$D(BIHX(4,3))
  1. .Q:'$D(BIHX(6,1))
  1. .;Q:'$D(BIHX(15,3))
  1. .Q:(($G(BIHPV))&('$D(BIHX(11,BIPNEED))))
  1. .Q:(($G(BIHPV))&('$D(BIHX(7,1))))
  1. .;Q:(($G(BIHPV))&('$D(BIHX(9,1)))) ;Never include Hep A.
  1. .D APPRO(BIAGRP) S X=2
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. APPRO(BIAGRP) ;EP
  1. ;---> Store Patient in Appropriate for Age Group.
  1. ;---> Parameters:
  1. ; 1 - BIAGRP (req) Node/number for this Age Group.
  1. ;
  1. ;---> Store Patient in Age Group.
  1. N Z S Z=$G(BITMP("STATS","APPRO",BIAGRP))
  1. S BITMP("STATS","APPRO",BIAGRP)=Z+1
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. STOR(BIDFN,BIQDT,BIVAL) ;EP
  1. ;---> Store in ^TMP for displaying List of Patients.
  1. ;---> Parameters:
  1. ; 1 - BIDFN (req) Patient IEN.
  1. ; 2 - BIQDT (req) Quarter Ending Date.
  1. ; 3 - BIVAL (opt) Value to set ^TMP(Pat...) node equal to.
  1. ;
  1. Q:'$G(BIDFN) S:'$G(BIQDT) BIQDT=DT
  1. D UPDATE^BIPATUP(BIDFN,DT,,1)
  1. D STORE^BIDUR1(BIDFN,BIQDT,1,,$G(BIVAL))
  1. Q
  1. ;
  1. ;
  1. NEED(BIARR,BIAGE,BIREQ) ;EP
  1. ;---> Return 1 if BIARRay contains required number of doses (BIREQ) after BIAGE.
  1. ;---> Parameters:
  1. ; 1 - BIARR (req) Array contains doses of vaccine in question.
  1. ; 2 - BIAGE (req) Age in months after which doses need to have been received.
  1. ; 3 - BIREQ (req) Required number of doses received after BIAGE.
  1. ;
  1. ;---> If at least 2 Hibs recvd at 12 mths or greater, then need only 2 Hibs.
  1. N M,N S M=0,N=""
  1. F S N=$O(BIARR(N)) Q:N="" S:(N'<BIAGE) M=M+1
  1. I M'<BIREQ Q 1
  1. Q 0