///<summary>If using the Add button on FormEhrNotPerformed, an input box will allow the user to select from the list of available items that are not being performed. The SelectedItemIndex will hold the index of the item selected wich corresponds to the enum EhrNotPerformedItem. We will use this selected item index to set the EhrNotPerformed code and code system.</summary> private void FormEhrNotPerformedEdit_Load(object sender, EventArgs e) { if (IsDateReadOnly) { textDate.ReadOnly = true; } List <string> listValueSetOIDs = new List <string>(); switch (SelectedItemIndex) { case 0: //BMIExam listValueSetOIDs = new List <string> { "2.16.840.1.113883.3.600.1.681" }; //'BMI LOINC Value' value set break; case 1: //InfluenzaVaccination listValueSetOIDs = new List <string> { "2.16.840.1.113883.3.526.3.402", "2.16.840.1.113883.3.526.3.1254" }; //'Influenza Vaccination' and 'Influenza Vaccine' value sets radioMedReason.Visible = true; radioPatReason.Visible = true; radioSysReason.Visible = true; break; case 2: //TobaccoScreening listValueSetOIDs = new List <string> { "2.16.840.1.113883.3.526.3.1278" }; //'Tobacco Use Screening' value set break; case 3: //DocumentCurrentMeds listValueSetOIDs = new List <string> { "2.16.840.1.113883.3.600.1.462" }; //'Current Medications Documented SNMD' value set break; default: //should never happen break; } List <EhrCode> listEhrCodes = EhrCodes.GetForValueSetOIDs(listValueSetOIDs, true); if (listEhrCodes.Count == 0) //This should only happen if the EHR.dll does not exist or if the codes in the ehrcode list do not exist in the corresponding table { MsgBox.Show(this, "The codes used for Not Performed items do not exist in the table in your database. You should run the Code System Importer tool in Setup | Chart | EHR."); DialogResult = DialogResult.Cancel; return; } if (EhrNotPerfCur.IsNew) //if new, CodeValue and CodeSystem are not set, might have to select one { if (listEhrCodes.Count == 1) //only one code in the selected value set, use it { EhrNotPerfCur.CodeValue = listEhrCodes[0].CodeValue; EhrNotPerfCur.CodeSystem = listEhrCodes[0].CodeSystem; } else { List <string> listCodeDescripts = new List <string>(); for (int i = 0; i < listEhrCodes.Count; i++) { listCodeDescripts.Add(listEhrCodes[i].CodeValue + " - " + listEhrCodes[i].Description); } InputBox chooseItem = new InputBox(Lan.g(this, "Select the " + Enum.GetNames(typeof(EhrNotPerformedItem))[SelectedItemIndex] + " not being performed from the list below."), listCodeDescripts); if (SelectedItemIndex == (int)EhrNotPerformedItem.InfluenzaVaccination) { //chooseItem.comboSelection.DropDownWidth=730; } if (chooseItem.ShowDialog() != DialogResult.OK) { DialogResult = DialogResult.Cancel; return; } if (chooseItem.comboSelection.SelectedIndex == -1) { MsgBox.Show(this, "You must select the " + Enum.GetNames(typeof(EhrNotPerformedItem))[SelectedItemIndex] + " not being performed."); DialogResult = DialogResult.Cancel; return; } EhrNotPerfCur.CodeValue = listEhrCodes[chooseItem.comboSelection.SelectedIndex].CodeValue; EhrNotPerfCur.CodeSystem = listEhrCodes[chooseItem.comboSelection.SelectedIndex].CodeSystem; } } for (int i = 0; i < listEhrCodes.Count; i++) { if (listEhrCodes[i].CodeValue == EhrNotPerfCur.CodeValue && listEhrCodes[i].CodeSystem == EhrNotPerfCur.CodeSystem) { textDescription.Text = listEhrCodes[i].Description; } } textCode.Text = EhrNotPerfCur.CodeValue; textCodeSystem.Text = EhrNotPerfCur.CodeSystem; textDate.Text = EhrNotPerfCur.DateEntry.ToShortDateString(); textNote.Text = EhrNotPerfCur.Note; FillReasonList(); if (comboCodeReason.SelectedIndex > 0) { textCodeSystemReason.Text = listEhrCodesReason[comboCodeReason.SelectedIndex - 1].CodeSystem; textDescriptionReason.Text = listEhrCodesReason[comboCodeReason.SelectedIndex - 1].Description; } }
private void FillGrid() { gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col; if (_showingInfoButton) //Security.IsAuthorized(Permissions.EhrInfoButton,true)) { { col = new ODGridColumn("", 18); //infoButton col.ImageList = imageListInfoButton; gridMain.Columns.Add(col); } col = new ODGridColumn("SNOMED CT", 100); gridMain.Columns.Add(col); //col=new ODGridColumn("Deprecated",75,HorizontalAlignment.Center); //gridMain.Columns.Add(col); col = new ODGridColumn("Description", 500); gridMain.Columns.Add(col); col = new ODGridColumn("Used By CQM's", 75); gridMain.Columns.Add(col); //col=new ODGridColumn("Date Of Standard",100); //gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; if (textCode.Text.Contains(",")) { SnomedList = Snomeds.GetByCodes(textCode.Text); } else { SnomedList = Snomeds.GetByCodeOrDescription(textCode.Text); } if (SnomedList.Count >= 10000) //Max number of results returned. { MsgBox.Show(this, "Too many results. Only the first 10,000 results will be shown."); } List <ODGridRow> listAll = new List <ODGridRow>(); for (int i = 0; i < SnomedList.Count; i++) { row = new ODGridRow(); if (_showingInfoButton) //Security.IsAuthorized(Permissions.EhrInfoButton,true)) { { row.Cells.Add("0"); //index of infobutton } row.Cells.Add(SnomedList[i].SnomedCode); //row.Cells.Add("");//IsActive==NotDeprecated row.Cells.Add(SnomedList[i].Description); row.Cells.Add(EhrCodes.GetMeasureIdsForCode(SnomedList[i].SnomedCode, "SNOMEDCT")); row.Tag = SnomedList[i]; //row.Cells.Add(""); listAll.Add(row); } listAll.Sort(SortMeasuresMet); for (int i = 0; i < listAll.Count; i++) { gridMain.Rows.Add(listAll[i]); } gridMain.EndUpdate(); }
private void FillGrid() { gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn("Code", 70); gridMain.Columns.Add(col); col = new ODGridColumn("CodeSystem", 90); gridMain.Columns.Add(col); col = new ODGridColumn("Description", 200); gridMain.Columns.Add(col); string selectedValue = comboCodeSet.SelectedItem.ToString(); List <string> listValSetOIDs = new List <string>(); if (selectedValue == "All") { listValSetOIDs = new List <string>(dictValueCodeSets.Values); } else //this will limit the codes to only one value set oid { listValSetOIDs.Add(dictValueCodeSets[selectedValue]); } listCodes = EhrCodes.GetForValueSetOIDs(listValSetOIDs, true); //these codes will exist in the corresponding table or will not be in the list gridMain.Rows.Clear(); ODGridRow row; int selectedIdx = -1; for (int i = 0; i < listCodes.Count; i++) { row = new ODGridRow(); row.Cells.Add(listCodes[i].CodeValue); row.Cells.Add(listCodes[i].CodeSystem); //Retrieve description from the associated table string descript = ""; switch (listCodes[i].CodeSystem) { case "CPT": Cpt cCur = Cpts.GetByCode(listCodes[i].CodeValue); if (cCur != null) { descript = cCur.Description; } break; case "HCPCS": Hcpcs hCur = Hcpcses.GetByCode(listCodes[i].CodeValue); if (hCur != null) { descript = hCur.DescriptionShort; } break; case "ICD9CM": ICD9 i9Cur = ICD9s.GetByCode(listCodes[i].CodeValue); if (i9Cur != null) { descript = i9Cur.Description; } break; case "ICD10CM": Icd10 i10Cur = Icd10s.GetByCode(listCodes[i].CodeValue); if (i10Cur != null) { descript = i10Cur.Description; } break; case "RXNORM": descript = RxNorms.GetDescByRxCui(listCodes[i].CodeValue); break; case "SNOMEDCT": Snomed sCur = Snomeds.GetByCode(listCodes[i].CodeValue); if (sCur != null) { descript = sCur.Description; } break; } row.Cells.Add(descript); gridMain.Rows.Add(row); if (listCodes[i].CodeValue == InterventionCur.CodeValue && listCodes[i].CodeSystem == InterventionCur.CodeSystem) { selectedIdx = i; } } gridMain.EndUpdate(); if (selectedIdx > -1) { gridMain.SetSelected(selectedIdx, true); gridMain.ScrollToIndex(selectedIdx); } }
private void FillReasonList() { List <string> listValueSetOIDsReason = new List <string>(); string medicalReason = "2.16.840.1.113883.3.526.3.1007"; //'Medical Reason' value set string patientReason = "2.16.840.1.113883.3.526.3.1008"; //'Patient Reason' value set string systemReason = "2.16.840.1.113883.3.526.3.1009"; //'System Reason' value set string patientRefusedReason = "2.16.840.1.113883.3.600.1.1503"; //'Patient Reason Refused' value set string medicalOrOtherReason = "2.16.840.1.113883.3.600.1.1502"; //'Medical or Other reason not done' value set string limitedLifeExpectancy = "2.16.840.1.113883.3.526.3.1259"; //'Limited Life Expectancy' value set switch (SelectedItemIndex) { case 0: //BMIExam listValueSetOIDsReason = new List <string> { patientRefusedReason, medicalOrOtherReason }; break; case 1: //InfluenzaVaccination if (radioPatReason.Checked) { listValueSetOIDsReason = new List <string> { patientReason }; } else if (radioSysReason.Checked) { listValueSetOIDsReason = new List <string> { systemReason }; } else if (radioMedReason.Checked) { listValueSetOIDsReason = new List <string> { medicalReason }; } else //if new or loading a previously saved item not performed, no radio is selected, set the appropriate radio and fill the list { if (EhrNotPerfCur.IsNew) { radioMedReason.Checked = true; listValueSetOIDsReason = new List <string> { medicalReason }; //default to medical reason list if new and no radio selected yet } else //if previously saved, find the sub list this reason belongs to { List <List <string> > listSublists = new List <List <string> > { new List <string> { medicalReason }, new List <string> { patientReason }, new List <string> { systemReason } }; bool found = false; for (int i = 0; i < listSublists.Count; i++) { listEhrCodesReason = EhrCodes.GetForValueSetOIDs(listSublists[i], true); for (int j = 0; j < listEhrCodesReason.Count; j++) { if (listEhrCodesReason[j].CodeValue == EhrNotPerfCur.CodeValueReason && listEhrCodesReason[j].CodeSystem == EhrNotPerfCur.CodeSystemReason) { found = true; break; } } if (found) { if (i == 0) { radioMedReason.Checked = true; } else if (i == 1) { radioPatReason.Checked = true; } else { radioSysReason.Checked = true; } listValueSetOIDsReason = listSublists[i]; break; } } } } break; case 2: //TobaccoScreening listValueSetOIDsReason = new List <string> { medicalReason, limitedLifeExpectancy }; break; case 3: //DocumentCurrentMeds listValueSetOIDsReason = new List <string> { medicalOrOtherReason }; break; default: //should never happen break; } listEhrCodesReason = EhrCodes.GetForValueSetOIDs(listValueSetOIDsReason, true); //these are all SNOMEDCT codes and will only show if they exist in the snomed table. if (listEhrCodesReason.Count == 0) { MsgBox.Show(this, "There are no codes in the database for reasons not performed. You must run the Code System Importer tool in Setup | Chart | EHR to import the SNOMEDCT table in order to enter a valid reason."); } comboCodeReason.Items.Clear(); comboCodeReason.Items.Add("none"); comboCodeReason.SelectedIndex = 0; //default to 'none' if no reason set for the not performed item for (int i = 0; i < listEhrCodesReason.Count; i++) { comboCodeReason.Items.Add(listEhrCodesReason[i].CodeValue); if (EhrNotPerfCur.CodeValueReason == listEhrCodesReason[i].CodeValue && EhrNotPerfCur.CodeSystemReason == listEhrCodesReason[i].CodeSystem) { comboCodeReason.SelectedIndex = i + 1; //+1 for 'none' textCodeSystemReason.Text = listEhrCodesReason[i].CodeSystem; textDescriptionReason.Text = listEhrCodesReason[i].Description; } } }
private void butOK_Click(object sender, EventArgs e) { //validate-------------------------------------- DateTime date; if (textDate.Text == "") { MsgBox.Show(this, "Please enter a date."); return; } try { date = DateTime.Parse(textDate.Text); } catch { MsgBox.Show(this, "Please fix date first."); return; } string codeVal = ""; string codeSys = ""; if (gridMain.GetSelectedIndex() == -1) //no intervention code selected { MsgBox.Show(this, "You must select a code for this intervention."); return; } else { codeVal = listCodes[gridMain.GetSelectedIndex()].CodeValue; codeSys = listCodes[gridMain.GetSelectedIndex()].CodeSystem; } //save-------------------------------------- //Intervention grid may contain medications, have to insert a new med if necessary and load FormMedPat for user to input data if (codeSys == "RXNORM" && !checkPatientDeclined.Checked) { //codeVal will be RxCui of medication, see if it already exists in Medication table Medication medCur = Medications.GetMedicationFromDbByRxCui(PIn.Long(codeVal)); if (medCur == null) //no med with this RxCui, create one { medCur = new Medication(); Medications.Insert(medCur); //so that we will have the primary key medCur.GenericNum = medCur.MedicationNum; medCur.RxCui = PIn.Long(codeVal); medCur.MedName = RxNorms.GetDescByRxCui(codeVal); Medications.Update(medCur); Medications.RefreshCache(); //refresh cache to include new medication } MedicationPat medPatCur = new MedicationPat(); medPatCur.PatNum = InterventionCur.PatNum; medPatCur.ProvNum = InterventionCur.ProvNum; medPatCur.MedicationNum = medCur.MedicationNum; medPatCur.RxCui = medCur.RxCui; medPatCur.DateStart = date; FormMedPat FormMP = new FormMedPat(); FormMP.MedicationPatCur = medPatCur; FormMP.IsNew = true; FormMP.ShowDialog(); if (FormMP.DialogResult != DialogResult.OK) { return; } if (FormMP.MedicationPatCur.DateStart.Date < InterventionCur.DateEntry.AddMonths(-6).Date || FormMP.MedicationPatCur.DateStart.Date > InterventionCur.DateEntry.Date) { MsgBox.Show(this, "The medication order just entered is not within the 6 months prior to the date of this intervention. You can modify the date of the medication order in the patient's medical history section."); } DialogResult = DialogResult.OK; return; } InterventionCur.DateEntry = date; InterventionCur.CodeValue = codeVal; InterventionCur.CodeSystem = codeSys; InterventionCur.Note = textNote.Text; InterventionCur.IsPatDeclined = checkPatientDeclined.Checked; string selectedCodeSet = comboCodeSet.SelectedItem.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]; if (IsAllTypes) //CodeSet will be set by calling function unless showing all types, in which case we need to determine which InterventionCodeSet to assign { if (selectedCodeSet == "All") //All types showing and set to All, have to determine which InterventionCodeSet this code belongs to { List <string> listVSFound = new List <string>(); foreach (KeyValuePair <string, string> kvp in dictValueCodeSets) { List <EhrCode> listCodes = EhrCodes.GetForValueSetOIDs(new List <string> { kvp.Value }, true); for (int i = 0; i < listCodes.Count; i++) { if (listCodes[i].CodeValue == codeVal) { listVSFound.Add(kvp.Key); break; } } } if (listVSFound.Count > 1) //Selected code found in more than one value set, ask the user which InterventionCodeSet to assign to this intervention { InputBox chooseSet = new InputBox(Lan.g(this, "The selected code belongs to more than one intervention code set. Select the code set to assign to this intervention from the list below."), listVSFound); if (chooseSet.ShowDialog() != DialogResult.OK) { return; } if (chooseSet.comboSelection.SelectedIndex == -1) { MsgBox.Show(this, "You must select an intervention code set for the selected code."); return; } selectedCodeSet = chooseSet.comboSelection.SelectedItem.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]; } else //the code must belong to at least one value set, since count in listVSFound is not greater than 1, it must be a code from exactly one set, use that for the InterventionCodeSet { selectedCodeSet = listVSFound[0].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]; } } InterventionCur.CodeSet = (InterventionCodeSet)Enum.Parse(typeof(InterventionCodeSet), selectedCodeSet); } //Nutrition is used for both nutrition and physical activity counseling for children, we have to determine which set this code belongs to else if (InterventionCur.CodeSet == InterventionCodeSet.Nutrition && selectedCodeSet != "Nutrition") //Nutrition set by calling form, user is showing all or physical activity codes only { if (selectedCodeSet == "All") //showing all codes from Nutrition and PhysicalActivity interventions, determine which set it belongs to //No codes exist in both code sets, so if it is not in the PhysicalActivity code set, we can safely assume this is a Nutrition intervention { List <EhrCode> listCodes = EhrCodes.GetForValueSetOIDs(new List <string> { dictValueCodeSets[InterventionCodeSet.PhysicalActivity.ToString() + " Counseling"] }, true); for (int i = 0; i < listCodes.Count; i++) { if (listCodes[i].CodeValue == codeVal) { InterventionCur.CodeSet = InterventionCodeSet.PhysicalActivity; break; } } } else { InterventionCur.CodeSet = InterventionCodeSet.PhysicalActivity; } } else { //if not all types, and not Nutrition with All or PhysicalActivity selected in combo box, the code set sent in by calling form will remain the code set for this intervention } if (InterventionCur.IsNew) { Interventions.Insert(InterventionCur); } else { Interventions.Update(InterventionCur); } DialogResult = DialogResult.OK; }
///<summary></summary> private void FormInterventionEdit_Load(object sender, EventArgs e) { comboCodeSet.Enabled = IsSelectionMode; //only allow changing code set if IsSelectionMode gridMain.AllowSelection = IsSelectionMode; //only allow changing the selected intervention code if IsSelectionMode dictValueCodeSets = new Dictionary <string, string>(); comboCodeSet.Items.Add("All"); if (IsAllTypes || InterventionCur.CodeSet == InterventionCodeSet.AboveNormalWeight) { comboCodeSet.Items.Add(InterventionCodeSet.AboveNormalWeight.ToString() + " Follow-up"); dictValueCodeSets.Add(InterventionCodeSet.AboveNormalWeight.ToString() + " Follow-up", "2.16.840.1.113883.3.600.1.1525"); comboCodeSet.Items.Add(InterventionCodeSet.AboveNormalWeight.ToString() + " Referral"); dictValueCodeSets.Add(InterventionCodeSet.AboveNormalWeight.ToString() + " Referral", "2.16.840.1.113883.3.600.1.1527"); comboCodeSet.Items.Add(InterventionCodeSet.AboveNormalWeight.ToString() + " Medication"); dictValueCodeSets.Add(InterventionCodeSet.AboveNormalWeight.ToString() + " Medication", "2.16.840.1.113883.3.600.1.1498"); } if (IsAllTypes || InterventionCur.CodeSet == InterventionCodeSet.BelowNormalWeight) { comboCodeSet.Items.Add(InterventionCodeSet.BelowNormalWeight.ToString() + " Follow-up"); dictValueCodeSets.Add(InterventionCodeSet.BelowNormalWeight.ToString() + " Follow-up", "2.16.840.1.113883.3.600.1.1528"); comboCodeSet.Items.Add(InterventionCodeSet.BelowNormalWeight.ToString() + " Referral"); dictValueCodeSets.Add(InterventionCodeSet.BelowNormalWeight.ToString() + " Referral", "2.16.840.1.113883.3.600.1.1527"); comboCodeSet.Items.Add(InterventionCodeSet.BelowNormalWeight.ToString() + " Medication"); dictValueCodeSets.Add(InterventionCodeSet.BelowNormalWeight.ToString() + " Medication", "2.16.840.1.113883.3.600.1.1499"); } if (IsAllTypes || InterventionCur.CodeSet == InterventionCodeSet.Nutrition || InterventionCur.CodeSet == InterventionCodeSet.PhysicalActivity) { comboCodeSet.Items.Add(InterventionCodeSet.Nutrition.ToString() + " Counseling"); dictValueCodeSets.Add(InterventionCodeSet.Nutrition.ToString() + " Counseling", "2.16.840.1.113883.3.464.1003.195.12.1003"); comboCodeSet.Items.Add(InterventionCodeSet.PhysicalActivity.ToString() + " Counseling"); dictValueCodeSets.Add(InterventionCodeSet.PhysicalActivity.ToString() + " Counseling", "2.16.840.1.113883.3.464.1003.118.12.1035"); } if (IsAllTypes || InterventionCur.CodeSet == InterventionCodeSet.TobaccoCessation) { comboCodeSet.Items.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Counseling"); dictValueCodeSets.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Counseling", "2.16.840.1.113883.3.526.3.509"); comboCodeSet.Items.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication"); dictValueCodeSets.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication", "2.16.840.1.113883.3.526.3.1190"); } if (IsAllTypes || InterventionCur.CodeSet == InterventionCodeSet.Dialysis) { comboCodeSet.Items.Add(InterventionCodeSet.Dialysis.ToString() + " Education"); dictValueCodeSets.Add(InterventionCodeSet.Dialysis.ToString() + " Education", "2.16.840.1.113883.3.464.1003.109.12.1016"); comboCodeSet.Items.Add(InterventionCodeSet.Dialysis.ToString() + " Related Services"); dictValueCodeSets.Add(InterventionCodeSet.Dialysis.ToString() + " Related Services", "2.16.840.1.113883.3.464.1003.109.12.1015"); } comboCodeSet.SelectedIndex = 0; //need to set the comboCodeSet based on InterventionCur sent in int codeSetIdx = 0; //this will be the index to set the comboCodeSet to if found in a subset of codes, otherwise defaults to All (index 0). foreach (string val in dictValueCodeSets.Values) { codeSetIdx++; listCodes = EhrCodes.GetForValueSetOIDs(new List <string> { val }, true); for (int i = 0; i < listCodes.Count; i++) { if (listCodes[i].CodeValue == InterventionCur.CodeValue && listCodes[i].CodeSystem == InterventionCur.CodeSystem) { comboCodeSet.SelectedIndex = codeSetIdx; break; } } } textDate.Text = InterventionCur.DateEntry.ToShortDateString(); textNote.Text = InterventionCur.Note; checkPatientDeclined.Checked = InterventionCur.IsPatDeclined; FillGrid(); }
private void FormPatientSmoking_Load(object sender, EventArgs e) { _patOld = PatCur.Copy(); textDateAssessed.Text = DateTime.Now.ToString(); textDateIntervention.Text = DateTime.Now.ToString(); #region ComboSmokeStatus comboSmokeStatus.Items.Add("None"); //First and default index //Smoking statuses add in the same order as they appear in the SmokingSnoMed enum (Starting at comboSmokeStatus index 1). //Changes to the enum order will change the order added so they will always match for (int i = 0; i < Enum.GetNames(typeof(SmokingSnoMed)).Length; i++) { //if snomed code exists in the snomed table, use the snomed description for the combo box, otherwise use the original abbreviated description Snomed smokeCur = Snomeds.GetByCode(((SmokingSnoMed)i).ToString().Substring(1)); if (smokeCur != null) { comboSmokeStatus.Items.Add(smokeCur.Description); } else { switch ((SmokingSnoMed)i) { case SmokingSnoMed._266927001: comboSmokeStatus.Items.Add("UnknownIfEver"); break; case SmokingSnoMed._77176002: comboSmokeStatus.Items.Add("SmokerUnknownCurrent"); break; case SmokingSnoMed._266919005: comboSmokeStatus.Items.Add("NeverSmoked"); break; case SmokingSnoMed._8517006: comboSmokeStatus.Items.Add("FormerSmoker"); break; case SmokingSnoMed._428041000124106: comboSmokeStatus.Items.Add("CurrentSomeDay"); break; case SmokingSnoMed._449868002: comboSmokeStatus.Items.Add("CurrentEveryDay"); break; case SmokingSnoMed._428061000124105: comboSmokeStatus.Items.Add("LightSmoker"); break; case SmokingSnoMed._428071000124103: comboSmokeStatus.Items.Add("HeavySmoker"); break; } } } comboSmokeStatus.SelectedIndex = 0; //None try { comboSmokeStatus.SelectedIndex = (int)Enum.Parse(typeof(SmokingSnoMed), "_" + PatCur.SmokingSnoMed, true) + 1; } catch { //if not one of the statuses in the enum, get the Snomed object from the patient's current smoking snomed code Snomed smokeCur = Snomeds.GetByCode(PatCur.SmokingSnoMed); if (smokeCur != null) //valid snomed code, set the combo box text to this snomed description { comboSmokeStatus.SelectedIndex = -1; comboSmokeStatus.Text = smokeCur.Description; } } #endregion //This takes a while the first time the window loads due to Code Systems. Cursor = Cursors.WaitCursor; FillGridAssessments(); FillGridInterventions(); Cursor = Cursors.Default; #region ComboAssessmentType _listAssessmentCodes = EhrCodes.GetForValueSetOIDs(new List <string> { "2.16.840.1.113883.3.526.3.1278" }, true); //'Tobacco Use Screening' value set if (_listAssessmentCodes.Count == 0) //This should only happen if the EHR.dll does not exist or if the codes in the ehrcode list do not exist in the corresponding table { MsgBox.Show(this, "The codes used for Tobacco Use Screening assessments do not exist in the LOINC table in your database. You must run the Code System Importer tool in Setup | Chart | EHR to import this code set."); DialogResult = DialogResult.Cancel; return; } _listAssessmentCodes.ForEach(x => comboAssessmentType.Items.Add(x.Description)); string mostRecentAssessmentCode = ""; if (gridAssessments.Rows.Count > 1) { //gridAssessments.Rows are tagged with all TobaccoUseAssessed events for the patient ordered by DateTEvent, last is most recent mostRecentAssessmentCode = ((EhrMeasureEvent)gridAssessments.Rows[gridAssessments.Rows.Count - 1].Tag).CodeValueResult; } //use Math.Max so that if _listAssessmentCodes doesn't contain the mostRecentAssessment code the combobox will default to the first in the list comboAssessmentType.SelectedIndex = Math.Max(0, _listAssessmentCodes.FindIndex(x => x.CodeValue == mostRecentAssessmentCode)); #endregion ComboAssessmentType #region ComboTobaccoStatus //list is filled with the EhrCodes for all tobacco user statuses using the CQM value set _listUserCodes = EhrCodes.GetForValueSetOIDs(new List <string> { "2.16.840.1.113883.3.526.3.1170" }, true).OrderBy(x => x.Description).ToList(); //list is filled with the EhrCodes for all tobacco non-user statuses using the CQM value set _listNonUserCodes = EhrCodes.GetForValueSetOIDs(new List <string> { "2.16.840.1.113883.3.526.3.1189" }, true).OrderBy(x => x.Description).ToList(); _listRecentTobaccoCodes = EhrCodes.GetForEventTypeByUse(EhrMeasureEventType.TobaccoUseAssessed); //list is filled with any SNOMEDCT codes that are attached to EhrMeasureEvents for the patient that are not in the User and NonUser lists _listCustomTobaccoCodes = new List <EhrCode>(); //codeValues is an array of all user and non-user tobacco codes string[] codeValues = _listUserCodes.Concat(_listNonUserCodes).Concat(_listRecentTobaccoCodes).Select(x => x.CodeValue).ToArray(); //listEventCodes will contain all unique tobacco codes that are not in the user and non-user lists List <string> listEventCodes = new List <string>(); foreach (ODGridRow row in gridAssessments.Rows) { string eventCodeCur = ((EhrMeasureEvent)row.Tag).CodeValueResult; if (codeValues.Contains(eventCodeCur) || listEventCodes.Contains(eventCodeCur)) { continue; } listEventCodes.Add(eventCodeCur); } Snomed sCur; foreach (string eventCode in listEventCodes.OrderBy(x => x)) { sCur = Snomeds.GetByCode(eventCode); if (sCur == null) //don't add invalid SNOMEDCT codes { continue; } _listCustomTobaccoCodes.Add(new EhrCode { CodeValue = sCur.SnomedCode, Description = sCur.Description }); } _listCustomTobaccoCodes = _listCustomTobaccoCodes.OrderBy(x => x.Description).ToList(); //list will contain all of the tobacco status EhrCodes currently in comboTobaccoStatus _listTobaccoStatuses = new List <EhrCode>(); //default to all tobacco statuses (custom, user, and non-user) in the status dropdown box radioRecentStatuses.Checked = true; //causes combo box and _listTobaccoStatuses to be filled with all statuses #endregion ComboTobaccoStatus #region ComboInterventionType and ComboInterventionCode //list is filled with EhrCodes for counseling interventions using the CQM value set _listCounselInterventionCodes = EhrCodes.GetForValueSetOIDs(new List <string> { "2.16.840.1.113883.3.526.3.509" }, true).OrderBy(x => x.Description).ToList(); //list is filled with EhrCodes for medication interventions using the CQM value set _listMedInterventionCodes = EhrCodes.GetForValueSetOIDs(new List <string> { "2.16.840.1.113883.3.526.3.1190" }, true).OrderBy(x => x.Description).ToList(); _listRecentIntvCodes = EhrCodes.GetForIntervAndMedByUse(InterventionCodeSet.TobaccoCessation, new List <string> { "2.16.840.1.113883.3.526.3.1190" }); _listInterventionCodes = new List <EhrCode>(); //default to all interventions (couseling and medication) in the intervention dropdown box radioRecentInterventions.Checked = true; //causes combo box and _listInterventionCodes to be filled with all intervention codes #endregion ComboInterventionType and ComboInterventionCode _comboToolTip = new ToolTip() { InitialDelay = 1000, ReshowDelay = 1000, ShowAlways = true }; }
private void FillGridInterventions() { gridInterventions.BeginUpdate(); gridInterventions.Columns.Clear(); gridInterventions.Columns.Add(new ODGridColumn("Date", 70)); gridInterventions.Columns.Add(new ODGridColumn("Type", 150)); gridInterventions.Columns.Add(new ODGridColumn("Description", 160)); gridInterventions.Columns.Add(new ODGridColumn("Declined", 60) { TextAlign = HorizontalAlignment.Center }); gridInterventions.Columns.Add(new ODGridColumn("Documentation", 140)); gridInterventions.Rows.Clear(); //build list of rows of CessationInterventions and CessationMedications so we can order the list by date and type before filling the grid List <ODGridRow> listRows = new List <ODGridRow>(); ODGridRow row; #region CessationInterventions List <Intervention> listInterventions = Interventions.Refresh(PatCur.PatNum, InterventionCodeSet.TobaccoCessation); foreach (Intervention iCur in listInterventions) { row = new ODGridRow(); row.Cells.Add(iCur.DateEntry.ToShortDateString()); string type = InterventionCodeSet.TobaccoCessation.ToString() + " Counseling"; string descript = ""; switch (iCur.CodeSystem) { case "CPT": Cpt cptCur = Cpts.GetByCode(iCur.CodeValue); descript = cptCur != null?cptCur.Description:""; break; case "SNOMEDCT": Snomed sCur = Snomeds.GetByCode(iCur.CodeValue); descript = sCur != null?sCur.Description:""; break; case "RXNORM": //if the user checks the "Patient Declined" checkbox, we enter the tobacco cessation medication as an intervention that was declined type = InterventionCodeSet.TobaccoCessation.ToString() + " Medication"; RxNorm rCur = RxNorms.GetByRxCUI(iCur.CodeValue); descript = rCur != null?rCur.Description:""; break; } row.Cells.Add(type); row.Cells.Add(descript); row.Cells.Add(iCur.IsPatDeclined?"X":""); row.Cells.Add(iCur.Note); row.Tag = iCur; listRows.Add(row); } #endregion #region CessationMedications //Tobacco Use Cessation Pharmacotherapy Value Set string[] arrayRxCuiStrings = EhrCodes.GetForValueSetOIDs(new List <string> { "2.16.840.1.113883.3.526.3.1190" }, true) .Select(x => x.CodeValue).ToArray(); //arrayRxCuiStrings will contain 41 RxCui strings for tobacco cessation medications if those exist in the rxnorm table List <MedicationPat> listMedPats = MedicationPats.Refresh(PatCur.PatNum, true).FindAll(x => arrayRxCuiStrings.Contains(x.RxCui.ToString())); foreach (MedicationPat medPatCur in listMedPats) { row = new ODGridRow(); List <string> listMedDates = new List <string>(); if (medPatCur.DateStart.Year > 1880) { listMedDates.Add(medPatCur.DateStart.ToShortDateString()); } if (medPatCur.DateStop.Year > 1880) { listMedDates.Add(medPatCur.DateStop.ToShortDateString()); } if (listMedDates.Count == 0) { listMedDates.Add(medPatCur.DateTStamp.ToShortDateString()); } row.Cells.Add(string.Join(" - ", listMedDates)); row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication"); row.Cells.Add(RxNorms.GetDescByRxCui(medPatCur.RxCui.ToString())); row.Cells.Add(medPatCur.PatNote); row.Tag = medPatCur; listRows.Add(row); } #endregion listRows.OrderBy(x => PIn.Date(x.Cells[0].Text)) //rows ordered by date, oldest first .ThenBy(x => x.Cells[3].Text != "") //interventions at the top, declined med interventions below normal interventions .ThenBy(x => x.Tag.GetType().Name != "Intervention" || ((Intervention)x.Tag).CodeSystem == "RXNORM").ToList() .ForEach(x => gridInterventions.Rows.Add(x)); //then add rows to gridInterventions gridInterventions.EndUpdate(); }
private void FormPatientSmoking_Load(object sender, EventArgs e) { PatOld = PatCur.Copy(); _TobaccoCodeSelected = PatCur.SmokingSnoMed; textDateAssessed.Text = DateTime.Now.ToString(); #region ComboSmokeStatus comboSmokeStatus.Items.Add("None"); //First and default index //Smoking statuses add in the same order as they appear in the SmokingSnoMed enum (Starting at comboSmokeStatus index 1). Changes to the enum order will change the order added so they will always match for (int i = 0; i < Enum.GetNames(typeof(SmokingSnoMed)).Length; i++) { //if snomed code exists in the snomed table, use the code - description for the combo box, otherwise use the original abbreviated description Snomed smokeCur = Snomeds.GetByCode(((SmokingSnoMed)i).ToString().Substring(1)); if (smokeCur != null) { comboSmokeStatus.Items.Add(smokeCur.Description); } else { switch ((SmokingSnoMed)i) { case SmokingSnoMed._266927001: comboSmokeStatus.Items.Add("UnknownIfEver"); break; case SmokingSnoMed._77176002: comboSmokeStatus.Items.Add("SmokerUnknownCurrent"); break; case SmokingSnoMed._266919005: comboSmokeStatus.Items.Add("NeverSmoked"); break; case SmokingSnoMed._8517006: comboSmokeStatus.Items.Add("FormerSmoker"); break; case SmokingSnoMed._428041000124106: comboSmokeStatus.Items.Add("CurrentSomeDay"); break; case SmokingSnoMed._449868002: comboSmokeStatus.Items.Add("CurrentEveryDay"); break; case SmokingSnoMed._428061000124105: comboSmokeStatus.Items.Add("LightSmoker"); break; case SmokingSnoMed._428071000124103: comboSmokeStatus.Items.Add("HeavySmoker"); break; } } } comboSmokeStatus.SelectedIndex = 0; //None try { comboSmokeStatus.SelectedIndex = (int)Enum.Parse(typeof(SmokingSnoMed), "_" + _TobaccoCodeSelected, true) + 1; } catch { //if not one of the statuses in the enum, get the Snomed object from the patient's current smoking snomed code Snomed smokeCur = Snomeds.GetByCode(_TobaccoCodeSelected); if (smokeCur != null) //valid snomed code, set the combo box text to this snomed description { comboSmokeStatus.SelectedIndex = -1; comboSmokeStatus.Text = smokeCur.Description; } } #endregion //This takes a while the first time the window loads due to Code Systems. Cursor = Cursors.WaitCursor; FillGrid(); Cursor = Cursors.Default; #region ComboAssessmentType _ListAssessmentCodes = EhrCodes.GetForValueSetOIDs(new List <string> { "2.16.840.1.113883.3.526.3.1278" }, true); //'Tobacco Use Screening' value set if (_ListAssessmentCodes.Count == 0) //This should only happen if the EHR.dll does not exist or if the codes in the ehrcode list do not exist in the corresponding table { MsgBox.Show(this, "The codes used for Tobacco Use Screening assessments do not exist in the LOINC table in your database. You must run the Code System Importer tool in Setup | EHR to import this code set."); DialogResult = DialogResult.Cancel; return; } EhrMeasureEvent mostRecentAssessment = new EhrMeasureEvent(); for (int i = _ListEvents.Count - 1; i > -1; i--) { if (_ListEvents[i].EventType == EhrMeasureEventType.TobaccoUseAssessed) { mostRecentAssessment = _ListEvents[i]; //_ListEvents filled ordered by DateTEvent, most recent assessment is last one in the list of type assessed break; } } for (int i = 0; i < _ListAssessmentCodes.Count; i++) { comboAssessmentType.Items.Add(_ListAssessmentCodes[i].Description); if (i == 0) { comboAssessmentType.SelectedIndex = i; //default to the first one in the list, 'History of tobacco use Narrative' } if (mostRecentAssessment.CodeValueEvent == _ListAssessmentCodes[i].CodeValue && mostRecentAssessment.CodeSystemEvent == _ListAssessmentCodes[i].CodeSystem) { comboAssessmentType.SelectedIndex = i; //set to most recent assessment } } #endregion }
private void FillGrid() { gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn("Date", 70); gridMain.Columns.Add(col); col = new ODGridColumn("Type", 170); gridMain.Columns.Add(col); col = new ODGridColumn("Description", 170); gridMain.Columns.Add(col); col = new ODGridColumn("Documentation", 170); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; List <ODGridRow> listRows = new List <ODGridRow>(); #region AssessedEvents _ListEvents = EhrMeasureEvents.RefreshByType(PatCur.PatNum, EhrMeasureEventType.TobaccoUseAssessed); for (int i = 0; i < _ListEvents.Count; i++) { row = new ODGridRow(); row.Cells.Add(_ListEvents[i].DateTEvent.ToShortDateString()); Loinc lCur = Loincs.GetByCode(_ListEvents[i].CodeValueEvent); //TobaccoUseAssessed events can be one of three types, all LOINC codes if (lCur != null) { row.Cells.Add(lCur.NameLongCommon); } else { row.Cells.Add(_ListEvents[i].EventType.ToString()); } Snomed sCur = Snomeds.GetByCode(_ListEvents[i].CodeValueResult); if (sCur != null) { row.Cells.Add(sCur.Description); } else { row.Cells.Add(""); } row.Cells.Add(_ListEvents[i].MoreInfo); row.Tag = _ListEvents[i]; listRows.Add(row); } #endregion #region CessationInterventions _ListInterventions = Interventions.Refresh(PatCur.PatNum, InterventionCodeSet.TobaccoCessation); for (int i = 0; i < _ListInterventions.Count; i++) { row = new ODGridRow(); row.Cells.Add(_ListInterventions[i].DateEntry.ToShortDateString()); row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Counseling"); string descript = ""; switch (_ListInterventions[i].CodeSystem) { case "CPT": Cpt cptCur = Cpts.GetByCode(_ListInterventions[i].CodeValue); if (cptCur != null) { descript = cptCur.Description; } break; case "SNOMEDCT": Snomed sCur = Snomeds.GetByCode(_ListInterventions[i].CodeValue); if (sCur != null) { descript = sCur.Description; } break; } row.Cells.Add(descript); row.Cells.Add(_ListInterventions[i].Note); row.Tag = _ListInterventions[i]; listRows.Add(row); } #endregion #region CessationMedications _ListMedPats = MedicationPats.Refresh(PatCur.PatNum, true); List <EhrCode> listEhrMeds = EhrCodes.GetForValueSetOIDs(new List <string> { "2.16.840.1.113883.3.526.3.1190" }, true); //Tobacco Use Cessation Pharmacotherapy Value Set //listEhrMeds will contain 41 medications for tobacco cessation if those exist in the rxnorm table for (int i = _ListMedPats.Count - 1; i > -1; i--) { bool found = false; for (int j = 0; j < listEhrMeds.Count; j++) { if (_ListMedPats[i].RxCui.ToString() == listEhrMeds[j].CodeValue) { found = true; break; } } if (!found) { _ListMedPats.RemoveAt(i); } } for (int i = 0; i < _ListMedPats.Count; i++) { row = new ODGridRow(); string dateRange = ""; if (_ListMedPats[i].DateStart.Year > 1880) { dateRange = _ListMedPats[i].DateStart.ToShortDateString(); } if (_ListMedPats[i].DateStop.Year > 1880) { if (dateRange != "") { dateRange += " - "; } dateRange += _ListMedPats[i].DateStop.ToShortDateString(); } if (dateRange == "") { dateRange = _ListMedPats[i].DateTStamp.ToShortDateString(); } row.Cells.Add(dateRange); row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication"); string medDescript = RxNorms.GetDescByRxCui(_ListMedPats[i].RxCui.ToString()); row.Cells.Add(medDescript); row.Cells.Add(_ListMedPats[i].PatNote); row.Tag = _ListMedPats[i]; listRows.Add(row); } #endregion listRows.Sort(SortDate); for (int i = 0; i < listRows.Count; i++) { gridMain.Rows.Add(listRows[i]); } gridMain.EndUpdate(); }
private void FillGrid() { gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn("Date", 70); gridMain.Columns.Add(col); col = new ODGridColumn("Prov", 50); gridMain.Columns.Add(col); col = new ODGridColumn("Intervention Type", 115); gridMain.Columns.Add(col); col = new ODGridColumn("Code", 70); gridMain.Columns.Add(col); col = new ODGridColumn("Code System", 85); gridMain.Columns.Add(col); col = new ODGridColumn("Code Description", 300); gridMain.Columns.Add(col); col = new ODGridColumn("Note", 100); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; #region Interventions listIntervention = Interventions.Refresh(PatCur.PatNum); for (int i = 0; i < listIntervention.Count; i++) { row = new ODGridRow(); row.Cells.Add(listIntervention[i].DateEntry.ToShortDateString()); row.Cells.Add(Providers.GetAbbr(listIntervention[i].ProvNum)); row.Cells.Add(listIntervention[i].CodeSet.ToString()); row.Cells.Add(listIntervention[i].CodeValue); row.Cells.Add(listIntervention[i].CodeSystem); //Description of Intervention--------------------------------------------- //to get description, first determine which table the code is from. Interventions are allowed to be SNOMEDCT, ICD9, ICD10, HCPCS, or CPT. string descript = ""; switch (listIntervention[i].CodeSystem) { case "SNOMEDCT": Snomed sCur = Snomeds.GetByCode(listIntervention[i].CodeValue); if (sCur != null) { descript = sCur.Description; } break; case "ICD9CM": ICD9 i9Cur = ICD9s.GetByCode(listIntervention[i].CodeValue); if (i9Cur != null) { descript = i9Cur.Description; } break; case "ICD10CM": Icd10 i10Cur = Icd10s.GetByCode(listIntervention[i].CodeValue); if (i10Cur != null) { descript = i10Cur.Description; } break; case "HCPCS": Hcpcs hCur = Hcpcses.GetByCode(listIntervention[i].CodeValue); if (hCur != null) { descript = hCur.DescriptionShort; } break; case "CPT": Cpt cptCur = Cpts.GetByCode(listIntervention[i].CodeValue); if (cptCur != null) { descript = cptCur.Description; } break; } row.Cells.Add(descript); row.Cells.Add(listIntervention[i].Note); row.Tag = listIntervention[i]; gridMain.Rows.Add(row); } #endregion #region MedicationPats listMedPats = MedicationPats.Refresh(PatCur.PatNum, true); if (listMedPats.Count > 0) { //The following medications are used as interventions for some measures. Include them in the intervention window if they belong to these value sets. //Above Normal Medications RxNorm Value Set, Below Normal Medications RxNorm Value Set, Tobacco Use Cessation Pharmacotherapy Value Set List <string> listVS = new List <string> { "2.16.840.1.113883.3.600.1.1498", "2.16.840.1.113883.3.600.1.1499", "2.16.840.1.113883.3.526.3.1190" }; List <EhrCode> listEhrMeds = EhrCodes.GetForValueSetOIDs(listVS, true); for (int i = listMedPats.Count - 1; i > -1; i--) { bool found = false; for (int j = 0; j < listEhrMeds.Count; j++) { if (listMedPats[i].RxCui.ToString() == listEhrMeds[j].CodeValue) { found = true; break; } } if (!found) { listMedPats.RemoveAt(i); } } } for (int i = 0; i < listMedPats.Count; i++) { row = new ODGridRow(); row.Cells.Add(listMedPats[i].DateStart.ToShortDateString()); row.Cells.Add(Providers.GetAbbr(listMedPats[i].ProvNum)); if (listMedPats[i].RxCui == 314153 || listMedPats[i].RxCui == 692876) { row.Cells.Add(InterventionCodeSet.AboveNormalWeight.ToString() + " Medication"); } else if (listMedPats[i].RxCui == 577154 || listMedPats[i].RxCui == 860215 || listMedPats[i].RxCui == 860221 || listMedPats[i].RxCui == 860225 || listMedPats[i].RxCui == 860231) { row.Cells.Add(InterventionCodeSet.BelowNormalWeight.ToString() + " Medication"); } else //There are 48 total medications that can be used as interventions. The remaining 41 medications are tobacco cessation medications { row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication"); } row.Cells.Add(listMedPats[i].RxCui.ToString()); row.Cells.Add("RXNORM"); //Medications that are used as interventions are all RxNorm codes, get description from that table string descript = RxNorms.GetDescByRxCui(listMedPats[i].RxCui.ToString()); row.Cells.Add(descript); row.Cells.Add(listMedPats[i].PatNote); row.Tag = listMedPats[i]; gridMain.Rows.Add(row); } #endregion gridMain.EndUpdate(); }