Ejemplo n.º 1
0
		///<summary>Used in measure 165, Controlling High Blood Pressure.  Get all vitalsigns with DateTaken in the date range with valid BP.  Only one code available for Systolic BP, LOINC 8480-6, and one code for Diastolic, LOINC 8462-4.  Results ordered by PatNum then DateTaken DESC, so MOST RECENT for each patient will be the first one in the list for that pat (i.e. dict[PatNum][0]).</summary>
		private static Dictionary<long,List<EhrCqmVitalsign>> GetVitalsignsForBP(List<long> listPatNums,DateTime dateStart,DateTime dateEnd) {
			Dictionary<long,List<EhrCqmVitalsign>> retval=new Dictionary<long,List<EhrCqmVitalsign>>();
			//if no patients, return a new empty dictionary
			if(listPatNums!=null && listPatNums.Count==0) {
				return retval;
			}
			string command="SELECT * FROM vitalsign "
				+"WHERE DATE(DateTaken) BETWEEN "+POut.Date(dateStart)+" AND "+POut.Date(dateEnd)+" "
				+"AND vitalsign.BpSystolic>0 AND vitalsign.BpDiastolic>0 ";
			if(listPatNums!=null && listPatNums.Count>0) {
				command+="AND vitalsign.PatNum IN("+string.Join(",",listPatNums)+") ";
			}
			command+="ORDER BY vitalsign.PatNum,vitalsign.DateTaken DESC";
			List<Vitalsign> listVitalsigns=Crud.VitalsignCrud.SelectMany(command);
			if(listVitalsigns.Count==0) {
				return retval;
			}
			//No need to get EhrCode objects from dll, every vitalsign exam with valid Systolic BP is assumed LOINC 8480-6 and valid Diastolic BP is assumed LOINC 8462-4
			for(int i=0;i<listVitalsigns.Count;i++) {
				EhrCqmVitalsign ehrVitalsignCur=new EhrCqmVitalsign();
				ehrVitalsignCur.BMI=-1;
				ehrVitalsignCur.BMIPercentile=listVitalsigns[i].BMIPercentile;
				ehrVitalsignCur.EhrCqmVitalsignNum=listVitalsigns[i].VitalsignNum;
				ehrVitalsignCur.PatNum=listVitalsigns[i].PatNum;
				ehrVitalsignCur.BpSystolic=listVitalsigns[i].BpSystolic;//LOINC 8480-6
				ehrVitalsignCur.BpDiastolic=listVitalsigns[i].BpDiastolic;//LOINC 8462-4
				ehrVitalsignCur.DateTaken=listVitalsigns[i].DateTaken;
				if(retval.ContainsKey(ehrVitalsignCur.PatNum)) {
					retval[ehrVitalsignCur.PatNum].Add(ehrVitalsignCur);
				}
				else {
					retval.Add(ehrVitalsignCur.PatNum,new List<EhrCqmVitalsign>() { ehrVitalsignCur });
				}
			}
			return retval;
		}
Ejemplo n.º 2
0
		private static void GenerateVitalsignEntry(EhrCqmVitalsign vCur,string vType) {
			_isWriterW=false;
			Start("entry","typeCode","DRIV");
			Start("observation","classCode","OBS","moodCode","EVN");
			_x.WriteComment("Result Observation Template");
			TemplateId("2.16.840.1.113883.10.20.22.4.2");
			_x.WriteComment("Physical Exam Finding Template");
			TemplateId("2.16.840.1.113883.10.20.24.3.57");
			StartAndEnd("id","root",_strOIDInternalCQMRoot,"extension",CqmItemAbbreviation.Vital.ToString()+vType+vCur.EhrCqmVitalsignNum.ToString());
			switch(vType) {
				//for BP Diastolic exam: CodeValue=8462-4, CodeSystemName=LOINC, CodeSystemOID=2.16.840.1.113883.6.1, Description=Diastolic blood pressure, ValueSetName=Diastolic Blood Pressure, ValueSetOID=2.16.840.1.113883.3.526.3.1033
				case "BPd":
					Start("code","code","8462-4","displayName","Diastolic blood pressure","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc);
					_x.WriteAttributeString("sdtc","valueSet",null,"2.16.840.1.113883.3.526.3.1033");
					End("code");
					_x.WriteElementString("text","Physical Exam, Finding: Diastolic Blood Pressure");
					StartAndEnd("statusCode","code","completed");
					Start("effectiveTime");
					DateElement("low",vCur.DateTaken);
					DateElement("high",vCur.DateTaken);
					End("effectiveTime");
					Start("value");
					_x.WriteAttributeString("xsi","type",null,"PQ");
					Attribs("value",vCur.BpDiastolic.ToString(),"unit","mmHg");
					End("value");
					break;
				//for BP Systolic exam: CodeValue=8480-6, CodeSystemName=LOINC, CodeSystemOID=2.16.840.1.113883.6.1, Description=Systolic blood pressure, ValueSetName=Systolic Blood Pressure, ValueSetOID=2.16.840.1.113883.3.526.3.1032
				case "BPs":
					Start("code","code","8480-6","displayName","Systolic Blood Pressure","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc);
					_x.WriteAttributeString("sdtc","valueSet",null,"2.16.840.1.113883.3.526.3.1032");
					End("code");
					_x.WriteElementString("text","Physical Exam, Finding: Systolic Blood Pressure");
					StartAndEnd("statusCode","code","completed");
					Start("effectiveTime");
					DateElement("low",vCur.DateTaken);
					DateElement("high",vCur.DateTaken);
					End("effectiveTime");
					Start("value");
					_x.WriteAttributeString("xsi","type",null,"PQ");
					Attribs("value",vCur.BpSystolic.ToString(),"unit","mmHg");
					End("value");
					break;
				//ValueSetOID=2.16.840.1.113883.3.464.1003.121.12.1014
				case "Ht":
					Start("code","code",vCur.HeightExamCode,"displayName",vCur.HeightExamDescript,"codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc);
					_x.WriteAttributeString("sdtc","valueSet",null,"2.16.840.1.113883.3.464.1003.121.12.1014");
					End("code");
					_x.WriteElementString("text","Physical Exam, Finding: Height");
					StartAndEnd("statusCode","code","completed");
					Start("effectiveTime");
					DateElement("low",vCur.DateTaken);
					DateElement("high",vCur.DateTaken);
					End("effectiveTime");
					Start("value");
					_x.WriteAttributeString("xsi","type",null,"PQ");
					Attribs("value",vCur.Height.ToString(),"unit","[in_us]");
					End("value");
					break;
				//ValueSetOID=2.16.840.1.113883.3.464.1003.121.12.1015
				case "Wt":
					Start("code","code",vCur.WeightExamCode,"displayName",vCur.WeightExamDescript,"codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc);
					_x.WriteAttributeString("sdtc","valueSet",null,"2.16.840.1.113883.3.464.1003.121.12.1015");
					End("code");
					_x.WriteElementString("text","Physical Exam, Finding: Weight");
					StartAndEnd("statusCode","code","completed");
					Start("effectiveTime");
					DateElement("low",vCur.DateTaken);
					DateElement("high",vCur.DateTaken);
					End("effectiveTime");
					Start("value");
					_x.WriteAttributeString("xsi","type",null,"PQ");
					Attribs("value",vCur.Weight.ToString(),"unit","[lb_av]");
					End("value");
					break;
				//in kg/m2, if valid BMI value: CodeValue=39156-5, CodeSystemName=LOINC, CodeSystemOID=2.16.840.1.113883.6.1, Description=Body mass index (BMI) [Ratio], ValueSetName=BMI LOINC Value, ValueSetOID=2.16.840.1.113883.3.600.1.681
				case "BMI":
					Start("code","code","39156-5","displayName","Body mass index (BMI) [Ratio]","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc);
					_x.WriteAttributeString("sdtc","valueSet",null,"2.16.840.1.113883.3.600.1.681");
					End("code");
					_x.WriteElementString("text","Physical Exam, Finding: BMI LOINC Value");
					StartAndEnd("statusCode","code","completed");
					Start("effectiveTime");
					DateElement("low",vCur.DateTaken);
					DateElement("high",vCur.DateTaken);
					End("effectiveTime");
					Start("value");
					_x.WriteAttributeString("xsi","type",null,"PQ");
					Attribs("value",vCur.BMI.ToString(),"unit","kg/m2");
					End("value");
					break;
				//ValueSetOID=2.16.840.1.113883.3.464.1003.121.12.1012
				case "BMIp":
					Start("code","code",vCur.BMIExamCode,"displayName",vCur.BMIPercentileDescript,"codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc);
					_x.WriteAttributeString("sdtc","valueSet",null,"2.16.840.1.113883.3.464.1003.121.12.1012");
					End("code");
					_x.WriteElementString("text","Physical Exam, Finding: BMI Percentile");
					StartAndEnd("statusCode","code","completed");
					Start("effectiveTime");
					DateElement("low",vCur.DateTaken);
					DateElement("high",vCur.DateTaken);
					End("effectiveTime");
					Start("value");
					_x.WriteAttributeString("xsi","type",null,"PQ");
					Attribs("value",vCur.BMIPercentile.ToString(),"unit","{percentile}");
					End("value");
					break;
			}
			End("observation");
			End("entry");
			_isWriterW=true;
		}
Ejemplo n.º 3
0
		///<summary>Used in measure 69, BMI Screening and Follow-up and measure 155, Weight Assessment and Counseling for Nutrition and Physical Activity for Children and Adolescents.  Get all vitalsigns with DateTaken in the date range with valid height and weight.  Only one code available for a BMI exam - LOINC 39156-5 Body mass index (BMI) [Ratio].  Any vitalsign object with valid height and weight is assumed to be a LOINC 39156-5, not stored explicitly.  Results ordered by PatNum then DateTaken DESC, so MOST RECENT for each patient will be the first one in the list for that pat (i.e. dict[PatNum][0]).</summary>
		private static Dictionary<long,List<EhrCqmVitalsign>> GetVitalsignsForBMI(List<long> listPatNums,DateTime dateStart,DateTime dateEnd) {
			Dictionary<long,List<EhrCqmVitalsign>> retval=new Dictionary<long,List<EhrCqmVitalsign>>();
			//if no patients, return a new empty dictionary
			if(listPatNums!=null && listPatNums.Count==0) {
				return retval;
			}
			string command="SELECT * FROM vitalsign "
				+"WHERE DATE(DateTaken) BETWEEN "+POut.Date(dateStart)+" AND "+POut.Date(dateEnd)+" "
				+"AND vitalsign.Height>0 AND vitalsign.Weight>0 ";
			if(listPatNums!=null && listPatNums.Count>0) {
				command+="AND vitalsign.PatNum IN("+string.Join(",",listPatNums)+") ";
			}
			command+="ORDER BY vitalsign.PatNum,vitalsign.DateTaken DESC";
			List<Vitalsign> listVitalsigns=Crud.VitalsignCrud.SelectMany(command);
			if(listVitalsigns.Count==0) {
				return retval;
			}
			//every row in the table has valid height and weight, so they are all in the value set for BMI LOINC Value LOINC Value Set - 2.16.840.1.113883.3.600.1.681 which is one code: LOINC 39156-5 Body mass index (BMI) [Ratio].
			for(int i=0;i<listVitalsigns.Count;i++) {
				EhrCqmVitalsign ehrVitalsignCur=new EhrCqmVitalsign();
				ehrVitalsignCur.BpDiastolic=-1;
				ehrVitalsignCur.BpSystolic=-1;
				ehrVitalsignCur.EhrCqmVitalsignNum=listVitalsigns[i].VitalsignNum;
				ehrVitalsignCur.PatNum=listVitalsigns[i].PatNum;
				float h=listVitalsigns[i].Height;
				ehrVitalsignCur.Height=h;
				float w=listVitalsigns[i].Weight;
				ehrVitalsignCur.Weight=w;
				ehrVitalsignCur.BMI=Math.Round((decimal)((w*703)/(h*h)),2,MidpointRounding.AwayFromZero);
				ehrVitalsignCur.HeightExamCode=listVitalsigns[i].HeightExamCode;
				Loinc lCur=Loincs.GetByCode(ehrVitalsignCur.HeightExamCode);
				if(lCur!=null) {
					ehrVitalsignCur.HeightExamDescript=lCur.NameLongCommon;
				}
				ehrVitalsignCur.WeightExamCode=listVitalsigns[i].WeightExamCode;
				lCur=Loincs.GetByCode(ehrVitalsignCur.WeightExamCode);
				if(lCur!=null) {
					ehrVitalsignCur.WeightExamDescript=lCur.NameLongCommon;
				}
				ehrVitalsignCur.BMIPercentile=listVitalsigns[i].BMIPercentile;
				ehrVitalsignCur.BMIExamCode=listVitalsigns[i].BMIExamCode;//percentile code
				lCur=Loincs.GetByCode(ehrVitalsignCur.BMIExamCode);
				if(lCur!=null) {
					ehrVitalsignCur.BMIPercentileDescript=lCur.NameLongCommon;
				}
				ehrVitalsignCur.DateTaken=listVitalsigns[i].DateTaken;
				if(retval.ContainsKey(ehrVitalsignCur.PatNum)) {
					retval[ehrVitalsignCur.PatNum].Add(ehrVitalsignCur);
				}
				else {
					retval.Add(ehrVitalsignCur.PatNum,new List<EhrCqmVitalsign>() { ehrVitalsignCur });
				}
			}
			return retval;
		}