private static void GenerateInterventionEntry(EhrCqmIntervention iCur) { _isWriterW=false; Start("entry","typeCode","DRIV"); //these are the value sets used by BMI for adults, interventions for above/below weight follow up or referrals for weight assessment //these are Intervention, Order if(iCur.ValueSetOID=="2.16.840.1.113883.3.600.1.1525" || iCur.ValueSetOID=="2.16.840.1.113883.3.600.1.1527" || iCur.ValueSetOID=="2.16.840.1.113883.3.600.1.1528") { Start("act","classCode","ACT","moodCode","RQO"); _x.WriteComment("Plan of Care Activity Act Template"); TemplateId("2.16.840.1.113883.10.20.22.4.39"); _x.WriteComment("Intervention Order Template"); TemplateId("2.16.840.1.113883.10.20.24.3.63"); StartAndEnd("id","root",_strOIDInternalCQMRoot,"extension",CqmItemAbbreviation.Ivn.ToString()+iCur.EhrCqmInterventionNum.ToString()); Start("code","code",iCur.CodeValue,"displayName",iCur.Description,"codeSystem",iCur.CodeSystemOID,"codeSystemName",iCur.CodeSystemName); _x.WriteAttributeString("sdtc","valueSet",null,iCur.ValueSetOID); End("code"); _x.WriteElementString("text","Intervention Order: "+iCur.ValueSetName); StartAndEnd("statusCode","code","completed"); Start("effectiveTime"); DateElement("low",iCur.DateEntry); DateElement("high",iCur.DateEntry); End("effectiveTime"); Start("author"); DateElement("time",iCur.DateEntry); Start("assignedAuthor"); StartAndEnd("id","root",_strOIDInternalProvRoot,"extension",iCur.ProvNum.ToString()); End("assignedAuthor"); End("author"); End("act"); } //all others are Intervention, Performed else { Start("act","classCode","ACT","moodCode","EVN"); _x.WriteComment("Procedure Activity Act Template"); TemplateId("2.16.840.1.113883.10.20.22.4.12"); _x.WriteComment("Intervention Performed Template"); TemplateId("2.16.840.1.113883.10.20.24.3.32"); StartAndEnd("id","root",_strOIDInternalCQMRoot,"extension",CqmItemAbbreviation.Ivn.ToString()+iCur.EhrCqmInterventionNum.ToString()); Start("code","code",iCur.CodeValue,"displayName",iCur.Description,"codeSystem",iCur.CodeSystemOID,"codeSystemName",iCur.CodeSystemName); _x.WriteAttributeString("sdtc","valueSet",null,iCur.ValueSetOID); End("code"); _x.WriteElementString("text","Intervention Performed: "+iCur.ValueSetName); StartAndEnd("statusCode","code","completed"); Start("effectiveTime"); DateElement("low",iCur.DateEntry); DateElement("high",iCur.DateEntry); End("effectiveTime"); End("act"); } End("entry"); _isWriterW=true; }
///<summary>Get all data needed for reporting QRDA's for interventions from the supplied command where the code belongs to the value set(s) sent in. Command orders interventions by patnum, then date entered so the first one found for patient is most recent intervention when looping through table.</summary> private static Dictionary<long,List<EhrCqmIntervention>> GetInterventions(string command,List<string> listValueSetOIDs) { Dictionary<long,List<EhrCqmIntervention>> retval=new Dictionary<long,List<EhrCqmIntervention>>(); List<Intervention> listInterventions=Crud.InterventionCrud.SelectMany(command); if(listInterventions.Count==0) { return retval; } //remove any interventions that are not in the Tobacco Use Cessation Counseling Grouping Value Set List<EhrCode> listAllInterventionCodes=EhrCodes.GetForValueSetOIDs(listValueSetOIDs,false);//Tobacco Use Cessation Counseling Grouping Value Set Dictionary<long,EhrCode> dictInterventionNumEhrCode=new Dictionary<long,EhrCode>(); for(int i=listInterventions.Count-1;i>-1;i--) { bool isValidIntervention=false; for(int j=0;j<listAllInterventionCodes.Count;j++) { if(listInterventions[i].CodeValue==listAllInterventionCodes[j].CodeValue && listInterventions[i].CodeSystem==listAllInterventionCodes[j].CodeSystem) { isValidIntervention=true; dictInterventionNumEhrCode.Add(listInterventions[i].InterventionNum,listAllInterventionCodes[j]); break; } } if(!isValidIntervention) { listInterventions.RemoveAt(i); } } for(int i=0;i<listInterventions.Count;i++) { EhrCqmIntervention interventionCur=new EhrCqmIntervention(); interventionCur.EhrCqmInterventionNum=listInterventions[i].InterventionNum; interventionCur.PatNum=listInterventions[i].PatNum; interventionCur.ProvNum=listInterventions[i].ProvNum; interventionCur.CodeValue=listInterventions[i].CodeValue; interventionCur.CodeSystemName=listInterventions[i].CodeSystem; interventionCur.DateEntry=listInterventions[i].DateEntry; EhrCode ehrCodeCur=dictInterventionNumEhrCode[listInterventions[i].InterventionNum]; interventionCur.CodeSystemOID=ehrCodeCur.CodeSystemOID; interventionCur.ValueSetName=ehrCodeCur.ValueSetName; interventionCur.ValueSetOID=ehrCodeCur.ValueSetOID; string descript=ehrCodeCur.Description;//if not in table or not a CPT, ICD9CM, ICD10CM, HCPCS, or SNOMEDCT code, default to EhrCode object description switch(listInterventions[i].CodeSystem) { case "CPT": Cpt cCur=Cpts.GetByCode(listInterventions[i].CodeValue); if(cCur!=null) { descript=cCur.Description; } break; case "HCPCS": Hcpcs hCur=Hcpcses.GetByCode(listInterventions[i].CodeValue); if(hCur!=null) { descript=hCur.DescriptionShort; } break; case "ICD9CM": ICD9 i9Cur=ICD9s.GetByCode(listInterventions[i].CodeValue); if(i9Cur!=null) { descript=i9Cur.Description; } break; case "ICD10CM": Icd10 i10Cur=Icd10s.GetByCode(listInterventions[i].CodeValue); if(i10Cur!=null) { descript=i10Cur.Description; } break; case "SNOMEDCT": Snomed sCur=Snomeds.GetByCode(listInterventions[i].CodeValue); if(sCur!=null) { descript=sCur.Description; } break; } interventionCur.Description=descript; if(retval.ContainsKey(interventionCur.PatNum)) { retval[interventionCur.PatNum].Add(interventionCur); } else { retval.Add(interventionCur.PatNum,new List<EhrCqmIntervention>() { interventionCur }); } } return retval; }