Exemplo n.º 1
0
		private static void GenerateCommunicationEntry(EhrCqmProblem probCur) {
			_isWriterW=false;
			Start("entry","typeCode","DRIV");
			Start("act","classCode","ACT","moodCode","EVN");
			_x.WriteComment("Communication from Patient to Provider Template");
			TemplateId("2.16.840.1.113883.10.20.24.3.2");
			StartAndEnd("id","root",_strOIDInternalCQMRoot,"extension",CqmItemAbbreviation.Prob.ToString()+probCur.EhrCqmProblemNum.ToString());
			Start("code","code",probCur.CodeValue,"displayName",probCur.Description,"codeSystem",probCur.CodeSystemOID,"codeSystemName",probCur.CodeSystemName);
			_x.WriteAttributeString("sdtc","valueSet",null,probCur.ValueSetOID);
			End("code");
			_x.WriteElementString("text","Communication, From patient to provider: "+probCur.ValueSetName);
			StartAndEnd("statusCode","code","completed");
			Start("effectiveTime");
			DateElement("low",probCur.DateStart);
			End("effectiveTime");
			Start("participant","typeCode","AUT");
			Start("participantRole","classCode","PAT");
			StartAndEnd("code","code","116154003","displayName","Patient","codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed);
			End("participantRole");
			End("participant");
			Start("participant","typeCode","IRCP");
			Start("participantRole","classCode","ASSIGNED");
			StartAndEnd("code","code","158965000","displayName","Medical Practitioner","codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed);
			End("participantRole");
			End("participant");
			End("act");
			End("entry");
			_isWriterW=true;
		}
Exemplo n.º 2
0
		private static void GenerateRiskAssessEntry(EhrCqmProblem probCur) {
			_isWriterW=false;
			Start("entry","typeCode","DRIV");
			Start("observation","classCode","OBS","moodCode","EVN");
			_x.WriteComment("Assessment Scale Observation Template");
			TemplateId("2.16.840.1.113883.10.20.22.4.69");
			_x.WriteComment("Risk Category Assessment Template");
			TemplateId("2.16.840.1.113883.10.20.24.3.69");
			StartAndEnd("id","root",_strOIDInternalCQMRoot,"extension",CqmItemAbbreviation.Prob.ToString()+probCur.EhrCqmProblemNum.ToString());
			Start("code","code",probCur.CodeValue,"displayName",probCur.Description,"codeSystem",probCur.CodeSystemOID,"codeSystemName",probCur.CodeSystemName);
			_x.WriteAttributeString("sdtc","valueSet",null,probCur.ValueSetOID);
			End("code");
			_x.WriteElementString("text","Risk Category Assessment: "+probCur.ValueSetName);
			StartAndEnd("statusCode","code","completed");
			Start("effectiveTime");
			_x.WriteComment("Attribute: Start Datetime");
			DateElement("low",probCur.DateStart);
			_x.WriteComment("Attribute: Stop Datetime");
			DateElement("high",probCur.DateStop);
			End("effectiveTime");
			End("observation");
			End("entry");
			_isWriterW=true;
		}
Exemplo n.º 3
0
		private static void GenerateDiagnosisEntry(EhrCqmProblem probCur) {
			_isWriterW=false;
			Start("entry","typeCode","DRIV");
			Start("observation","classCode","OBS","moodCode","EVN");
			_x.WriteComment("Problem Observation Template");
			TemplateId("2.16.840.1.113883.10.20.22.4.4");
			_x.WriteComment("Diagnosis Active Template");
			TemplateId("2.16.840.1.113883.10.20.24.3.11");
			StartAndEnd("id","root",_strOIDInternalCQMRoot,"extension",CqmItemAbbreviation.Prob.ToString()+probCur.EhrCqmProblemNum.ToString());
			StartAndEnd("code","code","282291009","displayName","diagnosis","codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed);
			_x.WriteElementString("text","Diagnosis Active: "+probCur.ValueSetName);
			StartAndEnd("statusCode","code","completed");
			Start("effectiveTime");
			_x.WriteComment("Attribute: Start Datetime");
			DateElement("low",probCur.DateStart);
			_x.WriteComment("Attribute: Stop Datetime");
			DateElement("high",probCur.DateStop);
			End("effectiveTime");
			Start("value");
			_x.WriteAttributeString("xsi","type",null,"CD");
			Attribs("code",probCur.CodeValue,"displayName",probCur.Description,"codeSystem",probCur.CodeSystemOID,"codeSystemName",probCur.CodeSystemName);
			_x.WriteAttributeString("sdtc","valueSet",null,probCur.ValueSetOID);
			End("value");
			_x.WriteComment("Status");
			Start("entryRelationship","typeCode","REFR");
			Start("observation","classCode","OBS","moodCode","EVN");
			_x.WriteComment("Problem Status Template");
			TemplateId("2.16.840.1.113883.10.20.22.4.6");
			_x.WriteComment("Problem Status Active Template");
			TemplateId("2.16.840.1.113883.10.20.24.3.94");
			StartAndEnd("code","code","33999-4","displayName","Status","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc);
			StartAndEnd("statusCode","code","completed");
			Start("value");
			_x.WriteAttributeString("xsi","type",null,"CD");
			Attribs("code","55561003","displayName","active","codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed);
			End("value");
			End("observation");
			End("entryRelationship");
			End("observation");
			End("entry");
			_isWriterW=true;
		}
Exemplo n.º 4
0
		///<summary>Either a proc or a problem will be sent in, the other will be null.  If probCur then Procedure, Order: item, if procCur then Procedure, Perforemed: item.</summary>
		private static void GenerateProcedureEntry(EhrCqmProc procCur,EhrCqmProblem probCur) {
			_isWriterW=false;
			Start("entry","typeCode","DRIV");
			if(probCur!=null) {
				Start("procedure","classCode","PROC","moodCode","RQO");
				_x.WriteComment("Plan of Care Activity Procedure Template");
				TemplateId("2.16.840.1.113883.10.20.22.4.41");
				_x.WriteComment("QRDA Procedure Order Template");
				TemplateId("2.16.840.1.113883.10.20.24.3.63");
				StartAndEnd("id","root",_strOIDInternalCQMRoot,"extension",CqmItemAbbreviation.Prob.ToString()+probCur.EhrCqmProblemNum.ToString());
				Start("code","code",probCur.CodeValue,"displayName",probCur.Description,"codeSystem",probCur.CodeSystemOID,"codeSystemName",probCur.CodeSystemName);
				_x.WriteAttributeString("sdtc","valueSet",null,probCur.ValueSetOID);
				End("code");
				_x.WriteElementString("text","Procedure, Order: "+probCur.ValueSetName);
				StartAndEnd("statusCode","code","completed");
				_x.WriteComment("Attribute: datetime");
				Start("author");
				TimeElement("time",probCur.DateStart);
				Start("assignedAuthor");
				StartAndEnd("id","nullFlavor","NA");
				End("assignedAuthor");
				End("author");
				End("procedure");
			}
			if(procCur!=null) {
				Start("procedure","classCode","PROC","moodCode","EVN");
				_x.WriteComment("Procedure Activity Procedure Template");
				TemplateId("2.16.840.1.113883.10.20.22.4.14");
				_x.WriteComment("Procedure Performed Template");
				TemplateId("2.16.840.1.113883.10.20.24.3.64");
				StartAndEnd("id","root",_strOIDInternalCQMRoot,"extension",CqmItemAbbreviation.Proc.ToString()+procCur.EhrCqmProcNum.ToString());
				Start("code","code",procCur.ProcCode,"displayName",procCur.Description,"codeSystem",procCur.CodeSystemOID,"codeSystemName",procCur.CodeSystemName);
				_x.WriteAttributeString("sdtc","valueSet",null,procCur.ValueSetOID);
				End("code");
				_x.WriteElementString("text","Procedure, Performed: "+procCur.ValueSetName);
				StartAndEnd("statusCode","code","completed");
				Start("effectiveTime");
				_x.WriteComment("Attribute: Start Datetime");
				DateElement("low",procCur.ProcDate);
				_x.WriteComment("Attribute: Stop Datetime");
				DateElement("high",procCur.ProcDate);
				End("effectiveTime");
				End("procedure");
			}
			End("entry");
			_isWriterW=true;
		}
Exemplo n.º 5
0
		///<summary>Get all problems that started before or during the date range, that have a code that belong to the value sets in listProbOIDs, and that either have no stop date or the stop date is after dateStart.</summary>
		private static Dictionary<long,List<EhrCqmProblem>> GetProblems(List<long> listPatNums,List<string> listValueSetOIDs,DateTime dateStart,DateTime dateEnd) {
			Dictionary<long,List<EhrCqmProblem>> retval=new Dictionary<long,List<EhrCqmProblem>>();
			//if no patients, return a new empty dictionary
			if(listPatNums!=null && listPatNums.Count==0) {
				return retval;
			}
			List<EhrCode> listValidProbs=EhrCodes.GetForValueSetOIDs(listValueSetOIDs,false);
			string icd9CodeList="";
			string icd10CodeList="";
			string snomedCodeList="";
			for(int i=0;i<listValidProbs.Count;i++) {
				if(listValidProbs[i].CodeSystem=="ICD9CM") {
					if(icd9CodeList!="") {
						icd9CodeList+=",";
					}
					icd9CodeList+="'"+listValidProbs[i].CodeValue+"'";
				}
				else if(listValidProbs[i].CodeSystem=="ICD10CM") {
					if(icd10CodeList!="") {
						icd10CodeList+=",";
					}
					icd10CodeList+="'"+listValidProbs[i].CodeValue+"'";
				}
				else if(listValidProbs[i].CodeSystem=="SNOMEDCT") {
					if(snomedCodeList!="") {
						snomedCodeList+=",";
					}
					snomedCodeList+="'"+listValidProbs[i].CodeValue+"'";
				}
			}
			string command="SELECT disease.DiseaseNum,disease.PatNum,disease.DateStart,disease.DateStop,"
				+"diseasedef.SnomedCode,diseasedef.ICD9Code,diseasedef.Icd10Code,"
				+"COALESCE(snomed.Description,icd9.Description,icd10.Description,diseasedef.DiseaseName) AS Description "
				+"FROM disease INNER JOIN diseasedef ON disease.DiseaseDefNum=diseasedef.DiseaseDefNum "
				+"LEFT JOIN snomed ON snomed.SnomedCode=diseasedef.SnomedCode "
				+"LEFT JOIN icd9 ON icd9.ICD9Code=diseasedef.ICD9Code "
				+"LEFT JOIN icd10 ON icd10.Icd10Code=diseasedef.Icd10Code "
				+"WHERE disease.DateStart<="+POut.Date(dateEnd)+" "
				+"AND (YEAR(disease.DateStop)<1880 OR disease.DateStop>"+POut.Date(dateStart)+") ";
			if(listPatNums!=null && listPatNums.Count>0) {
				command+="AND disease.PatNum IN("+string.Join(",",listPatNums)+") ";
			}
			if(icd9CodeList!="" || icd10CodeList!="" || snomedCodeList!="") {
				command+="AND (";
				if(icd9CodeList!="") {
					command+="diseasedef.ICD9Code IN("+icd9CodeList+") ";
				}
				if(icd10CodeList!="") {
					if(icd9CodeList!="") {
						command+="OR ";
					}
					command+="diseasedef.ICD10Code IN("+icd10CodeList+") ";
				}
				if(snomedCodeList!="") {
					if(icd9CodeList!="" || icd10CodeList!="") {
						command+="OR ";
					}
					command+="diseasedef.SnomedCode IN("+snomedCodeList+") ";
				}
				command+=") ";
			}
			command+="ORDER BY disease.PatNum,disease.DateStart DESC";
			DataTable tableAllProbs=Db.GetTable(command);
			if(tableAllProbs.Rows.Count==0) {
				return retval;
			}
			Dictionary<long,EhrCode> dictDiseaseNumEhrCode=new Dictionary<long,EhrCode>();
			for(int i=tableAllProbs.Rows.Count-1;i>-1;i--) {
				for(int j=0;j<listValidProbs.Count;j++) {//all problems are either SNOMED, ICD9, or ICD10 codes
					if((listValidProbs[j].CodeSystem=="SNOMEDCT" && tableAllProbs.Rows[i]["SnomedCode"].ToString()==listValidProbs[j].CodeValue)
						|| (listValidProbs[j].CodeSystem=="ICD9CM" && tableAllProbs.Rows[i]["ICD9Code"].ToString()==listValidProbs[j].CodeValue)
						|| (listValidProbs[j].CodeSystem=="ICD10CM" && tableAllProbs.Rows[i]["Icd10Code"].ToString()==listValidProbs[j].CodeValue)) {
						dictDiseaseNumEhrCode.Add(PIn.Long(tableAllProbs.Rows[i]["DiseaseNum"].ToString()),listValidProbs[j]);//link the problem to the EhrCode object for retrieving information
						break;
					}
				}
			}
			for(int i=0;i<tableAllProbs.Rows.Count;i++) {
				EhrCqmProblem ehrProblemCur=new EhrCqmProblem();
				ehrProblemCur.EhrCqmProblemNum=PIn.Long(tableAllProbs.Rows[i]["DiseaseNum"].ToString());
				ehrProblemCur.PatNum=PIn.Long(tableAllProbs.Rows[i]["PatNum"].ToString());
				ehrProblemCur.DateStart=PIn.Date(tableAllProbs.Rows[i]["DateStart"].ToString());
				ehrProblemCur.DateStop=PIn.Date(tableAllProbs.Rows[i]["DateStop"].ToString());
				ehrProblemCur.Description=tableAllProbs.Rows[i]["Description"].ToString();
				EhrCode ehrCodeCur=dictDiseaseNumEhrCode[ehrProblemCur.EhrCqmProblemNum];
				ehrProblemCur.CodeValue=ehrCodeCur.CodeValue;//use the code value from the ehrcode object because diseasedef can have an ICD9CM, ICD10CM, and SNOMEDCT code, and the codes do not have to be for the same thing, so use the code that belongs to the ValueSetOID that makes it valid for this measure
				ehrProblemCur.CodeSystemName=ehrCodeCur.CodeSystem;
				ehrProblemCur.CodeSystemOID=ehrCodeCur.CodeSystemOID;
				ehrProblemCur.ValueSetName=ehrCodeCur.ValueSetName;
				ehrProblemCur.ValueSetOID=ehrCodeCur.ValueSetOID;
				if(retval.ContainsKey(ehrProblemCur.PatNum)) {
					retval[ehrProblemCur.PatNum].Add(ehrProblemCur);
				}
				else {
					retval.Add(ehrProblemCur.PatNum,new List<EhrCqmProblem>() { ehrProblemCur });
				}
			}
			return retval;
		}