private void FillMeds() { Medications.Refresh(); MedicationPats.Refresh(PatCur.PatNum); gridMeds.BeginUpdate(); gridMeds.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableMedications", "Drug Name"), 100); gridMeds.Columns.Add(col); col = new ODGridColumn(Lan.g("TableMedications", "Generic Name"), 100); gridMeds.Columns.Add(col); col = new ODGridColumn(Lan.g("TableMedications", "Notes"), 370); gridMeds.Columns.Add(col); col = new ODGridColumn(Lan.g("TableMedications", "Notes for Patient"), 370); gridMeds.Columns.Add(col); gridMeds.Rows.Clear(); ODGridRow row; for (int i = 0; i < MedicationPats.List.Length; i++) { row = new ODGridRow(); row.Cells.Add(Medications.GetMedication(MedicationPats.List[i].MedicationNum).MedName); row.Cells.Add(Medications.GetGeneric(MedicationPats.List[i].MedicationNum).MedName); row.Cells.Add(Medications.GetGeneric(MedicationPats.List[i].MedicationNum).Notes); row.Cells.Add(MedicationPats.List[i].PatNote); gridMeds.Rows.Add(row); } gridMeds.EndUpdate(); }
private void butOK_Click(object sender, System.EventArgs e) { if (textDateStart.errorProvider1.GetError(textDateStart) != "" || textDateStop.errorProvider1.GetError(textDateStop) != "" ) { MsgBox.Show(this, "Please fix data entry errors first."); return; } if (IsNewMedOrder) { if (textPatNote.Text == "" || textDateStart.Text == "") { MsgBox.Show(this, "For a new medical order, instructions and a start date are required."); return; } } //MedicationPatCur.MedicationNum is already set before entering this window, or else changed up above. if (comboProv.SelectedIndex == -1) { //don't make any changes to provnum. ProvNum is a hidden prov. } else if (comboProv.SelectedIndex == 0) { MedicationPatCur.ProvNum = 0; } else { MedicationPatCur.ProvNum = _listProviders[comboProv.SelectedIndex - 1].ProvNum; } MedicationPatCur.PatNote = textPatNote.Text; MedicationPatCur.DateStart = PIn.Date(textDateStart.Text); MedicationPatCur.DateStop = PIn.Date(textDateStop.Text); if (IsNew) { MedicationPats.Insert(MedicationPatCur); if (MedicationPatCur.MedicationNum == 0) { SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, MedicationPatCur.MedDescript + " added"); } else { SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, Medications.GetMedication(MedicationPatCur.MedicationNum).MedName + " added"); } } else { MedicationPats.Update(MedicationPatCur); if (MedicationPatCur.MedicationNum == 0) { SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, MedicationPatCur.MedDescript + " edited"); } else { SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, Medications.GetMedication(MedicationPatCur.MedicationNum).MedName + " edited"); } } DialogResult = DialogResult.OK; }
private void butRemove_Click(object sender, System.EventArgs e) { if (MessageBox.Show(Lan.g (this, "Remove this medication from this patient? Patient notes will be lost.") , "", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } MedicationPats.Delete(MedicationPatCur); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { MedicationPatCur.PatNote = textPatNote.Text; if (IsNew) { MedicationPats.Insert(MedicationPatCur); } else { MedicationPats.Update(MedicationPatCur); } DialogResult = DialogResult.OK; }
private void butConvertGeneric_Click(object sender, EventArgs e) { if (gridMissing.SelectedIndices.Length == 0) { MsgBox.Show(this, "Please select an item from the list before attempting to convert."); return; } List <MedicationPat> listMedPats = (List <MedicationPat>)gridMissing.Rows[gridMissing.SelectedIndices[0]].Tag; List <Medication> listRxCuiMeds = null; Medication medGeneric = null; if (listMedPats[0].RxCui != 0) { listRxCuiMeds = Medications.GetAllMedsByRxCui(listMedPats[0].RxCui); medGeneric = listRxCuiMeds.FirstOrDefault(x => x.MedicationNum == x.GenericNum); if (medGeneric == null && listRxCuiMeds.FirstOrDefault(x => x.MedicationNum != x.GenericNum) != null) //A Brand Medication exists with matching RxCui. { MsgBox.Show(this, "A brand medication matching the RxNorm of the selected medication already exists in the medication list. " + "You cannot create a generic for the selected medication. Use the Convert to Brand button instead."); return; } } if (listRxCuiMeds == null || listRxCuiMeds.Count == 0) //No medications found matching the RxCui { medGeneric = new Medication(); medGeneric.MedName = listMedPats[0].MedDescript; medGeneric.RxCui = listMedPats[0].RxCui; Medications.Insert(medGeneric); //To get primary key. medGeneric.GenericNum = medGeneric.MedicationNum; Medications.Update(medGeneric); //Now that we have primary key, flag the medication as a generic. FormMedicationEdit FormME = new FormMedicationEdit(); FormME.MedicationCur = medGeneric; FormME.IsNew = true; FormME.ShowDialog(); //This window refreshes the Medication cache if the user clicked OK. if (FormME.DialogResult != DialogResult.OK) { return; //User canceled. } } else if (medGeneric != null && !MsgBox.Show(this, true, "A generic medication matching the RxNorm of the selected medication already exists in the medication list. " + "Click OK to use the existing medication as the generic for the selected medication, or click Cancel to abort.")) { return; } Cursor = Cursors.WaitCursor; MedicationPats.UpdateMedicationNumForMany(medGeneric.MedicationNum, listMedPats.Select(x => x.MedicationPatNum).ToList()); FillTab(); Cursor = Cursors.Default; MsgBox.Show(this, "Done."); }
private void butRemove_Click(object sender, System.EventArgs e) { if (IsNew) { DialogResult = DialogResult.Cancel; return; } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Remove this medication from this patient? Patient notes will be lost.")) { return; } MedicationPats.Delete(MedicationPatCur); DialogResult = DialogResult.OK; }
private void FillMeds() { Medications.Refresh(); medList = MedicationPats.Refresh(PatCur.PatNum, checkDiscontinued.Checked); gridMeds.BeginUpdate(); gridMeds.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableMedications", "Medication"), 140); gridMeds.Columns.Add(col); col = new ODGridColumn(Lan.g("TableMedications", "Notes for Patient"), 225); gridMeds.Columns.Add(col); col = new ODGridColumn(Lan.g("TableMedications", "Disc"), 10, HorizontalAlignment.Center); //discontinued gridMeds.Columns.Add(col); gridMeds.Rows.Clear(); ODGridRow row; for (int i = 0; i < medList.Count; i++) { row = new ODGridRow(); if (medList[i].MedicationNum == 0) { row.Cells.Add(medList[i].MedDescript); } else { Medication generic = Medications.GetGeneric(medList[i].MedicationNum); string medName = Medications.GetMedication(medList[i].MedicationNum).MedName; if (generic.MedicationNum != medList[i].MedicationNum) //not generic { medName += " (" + generic.MedName + ")"; } row.Cells.Add(medName); } row.Cells.Add(medList[i].PatNote); if (MedicationPats.IsMedActive(medList[i])) { row.Cells.Add(""); } else //discontinued { row.Cells.Add("X"); } gridMeds.Rows.Add(row); } gridMeds.EndUpdate(); }
private void butOK_Click(object sender, System.EventArgs e) { //generic num already handled MedicationCur.MedName = textMedName.Text; if (MedicationCur.MedName == "") { MsgBox.Show(this, "Not allowed to save a medication without a Drug Name."); return; } if (CultureInfo.CurrentCulture.Name.EndsWith("US")) //United States { if (MedicationCur.RxCui == 0 && !MsgBox.Show(this, true, "Warning: RxNorm was not picked. " + "RxNorm uniquely identifies drugs in the United States and helps you keep your medications organized. " + "RxNorm is used to send information to and from eRx if you are using or plan to use eRx.\r\n" + "Click OK to continue without an RxNorm, or click Cancel to stay in this window.")) { return; } else if (MedicationCur.RxCui != 0) { List <Medication> listExistingMeds = Medications.GetAllMedsByRxCui(MedicationCur.RxCui); if (listExistingMeds.FindAll(x => x.MedicationNum != MedicationCur.MedicationNum).Count > 0) { MsgBox.Show(this, "A medication in the medication list is already using the selected RxNorm.\r\n" + "Please select a different RxNorm or use the other medication instead."); return; } } } if (MedicationCur.MedicationNum == MedicationCur.GenericNum) { MedicationCur.Notes = textNotes.Text; } else { MedicationCur.Notes = ""; } //MedicationCur has its RxCui set when the butRxNormSelect button is pressed. //The following behavior must match what happens when the user clicks the RxNorm column in FormMedications to pick RxCui. Medications.Update(MedicationCur); MedicationPats.UpdateRxCuiForMedication(MedicationCur.MedicationNum, MedicationCur.RxCui); DataValid.SetInvalid(InvalidType.Medications); DialogResult = DialogResult.OK; }
private void FillMeds() { Medications.Refresh(); medList = MedicationPats.Refresh(PatCur.PatNum, checkDiscontinued.Checked); gridMeds.BeginUpdate(); gridMeds.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableMedications", "Medication"), 120); gridMeds.Columns.Add(col); col = new ODGridColumn(Lan.g("TableMedications", "Notes"), 200); gridMeds.Columns.Add(col); col = new ODGridColumn(Lan.g("TableMedications", "Notes for Patient"), 200); gridMeds.Columns.Add(col); col = new ODGridColumn(Lan.g("TableMedications", "Status"), 60, HorizontalAlignment.Center); gridMeds.Columns.Add(col); gridMeds.Rows.Clear(); ODGridRow row; for (int i = 0; i < medList.Count; i++) { row = new ODGridRow(); Medication generic = Medications.GetGeneric(medList[i].MedicationNum); string medName = Medications.GetMedication(medList[i].MedicationNum).MedName; if (generic.MedicationNum != medList[i].MedicationNum) //not generic { medName += " (" + generic.MedName + ")"; } row.Cells.Add(medName); row.Cells.Add(Medications.GetGeneric(medList[i].MedicationNum).Notes); row.Cells.Add(medList[i].PatNote); if (medList[i].DateStop.Year > 1880) { row.Cells.Add("Inactive"); } else { row.Cells.Add("Active"); } gridMeds.Rows.Add(row); } gridMeds.EndUpdate(); }
private void FillGrid(bool isExact) { Cursor = Cursors.WaitCursor; rxList = RxNorms.GetListByCodeOrDesc(textCode.Text, isExact, checkIgnore.Checked); List <string> listMedicationRxCuis = Medications.GetWhere(x => x.RxCui != 0).Select(x => x.RxCui.ToString()).Distinct().ToList(); List <string> listMedPatRxCuis = MedicationPats.GetForRxCuis(rxList.Select(x => x.RxCui).ToList()).Select(x => x.RxCui.ToString()).ToList(); gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); GridColumn col = new GridColumn(Lan.g("FormRxNorms", "Code"), 80); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("FormRxNorms", "InMedList"), 60, HorizontalAlignment.Center); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("FormRxNorms", "MedCount"), 60, HorizontalAlignment.Center); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("FormRxNorms", "Description"), 0); gridMain.ListGridColumns.Add(col); gridMain.ListGridRows.Clear(); GridRow row; foreach (RxNorm rxNorm in rxList) { row = new GridRow(); row.Cells.Add(rxNorm.RxCui); //Code if (listMedicationRxCuis.Exists(x => x == rxNorm.RxCui)) { row.Cells.Add("X"); //InMedList } else { row.Cells.Add(""); //InMedList } row.Cells.Add(listMedPatRxCuis.FindAll(x => x == rxNorm.RxCui).Count.ToString()); //MedCount row.Cells.Add(rxNorm.Description); gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); gridMain.ScrollValue = 0; Cursor = Cursors.Default; }
private void gridAllMedications_CellClick(object sender, ODGridClickEventArgs e) { Medication med = (Medication)gridAllMedications.Rows[e.Row].Tag; if (CultureInfo.CurrentCulture.Name.EndsWith("US") && e.Col == 3) //United States RxNorm Column { FormRxNorms formRxNorm = new FormRxNorms(); formRxNorm.IsSelectionMode = true; formRxNorm.InitSearchCodeOrDescript = med.MedName; formRxNorm.ShowDialog(); if (formRxNorm.DialogResult == DialogResult.OK) { med.RxCui = PIn.Long(formRxNorm.SelectedRxNorm.RxCui); //The following behavior mimics FormMedicationEdit OK click. Medications.Update(med); MedicationPats.UpdateRxCuiForMedication(med.MedicationNum, med.RxCui); DataValid.SetInvalid(InvalidType.Medications); } FillTab(); } }
///<summary>This can happen when clicking in the grid, or when the form is Shown. The latter would happen after user unknowingly exited ehr in order to use FormMedPat. Popping back to the Orders window makes the experience seamless. This can be recursive if the user edits a series of medicationpats.</summary> private void LaunchOrdersWindow() { FormEhrMedicalOrders FormOrd = new FormEhrMedicalOrders(); FormOrd._patCur = PatCur; FormOrd.ShowDialog(); //if(FormOrd.DialogResult!=DialogResult.OK) {//There is no ok button // return; //} /*not currently used, but might be if we let users generate Rx from med order. * if(FormOrd.LaunchRx) { * if(FormOrd.LaunchRxNum==0) { * ResultOnClosing=EhrFormResult.RxSelect; * } * else { * ResultOnClosing=EhrFormResult.RxEdit; * LaunchRxNum=FormOrd.LaunchRxNum; * } * Close(); * } * else*/ if (FormOrd.LaunchMedicationPat) { //if(FormOrd.LaunchMedicationPatNum==0) { // ResultOnClosing=EhrFormResult.MedicationPatNew;//This cannot happen unless a provider is logged in with a valid ehr key //} //else { FormMedPat FormMP = new FormMedPat(); FormMP.MedicationPatCur = MedicationPats.GetOne(FormOrd.LaunchMedicationPatNum); FormMP.ShowDialog(); //ResultOnClosing=EhrFormResult.MedicationPatEdit; //LaunchMedicationPatNum=FormOrd.LaunchMedicationPatNum; //} //Close(); //} //else { FillGridMu(); } }
private void FillGridMissing() { int sortColIndex = gridMissing.SortedByColumnIdx; bool isSortAscending = gridMissing.SortedIsAscending; gridMissing.BeginUpdate(); gridMissing.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g(this, "RxNorm"), 70, GridSortingStrategy.StringCompare); gridMissing.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Drug Description"), 0, GridSortingStrategy.StringCompare); gridMissing.Columns.Add(col); gridMissing.Rows.Clear(); List <MedicationPat> listMedPats = MedicationPats.GetAllMissingMedications(); Dictionary <string, List <MedicationPat> > dictMissingUnique = new Dictionary <string, List <MedicationPat> >(); foreach (MedicationPat medPat in listMedPats) { string key = medPat.RxCui.ToString() + " - " + medPat.MedDescript.ToLower().Trim(); if (!dictMissingUnique.ContainsKey(key)) { dictMissingUnique[key] = new List <MedicationPat>(); ODGridRow row = new ODGridRow(); row.Tag = dictMissingUnique[key]; if (medPat.RxCui == 0) { row.Cells.Add(""); } else { row.Cells.Add(medPat.RxCui.ToString()); } row.Cells.Add(medPat.MedDescript); gridMissing.Rows.Add(row); } dictMissingUnique[key].Add(medPat); } gridMissing.EndUpdate(); gridMissing.SortForced(sortColIndex, isSortAscending); }
private void butOK_Click(object sender, System.EventArgs e) { //generic num already handled MedicationCur.MedName = textMedName.Text; if (MedicationCur.MedName == "") { MsgBox.Show(this, "Not allowed to save a medication without a Drug Name."); return; } if (MedicationCur.MedicationNum == MedicationCur.GenericNum) { MedicationCur.Notes = textNotes.Text; } else { MedicationCur.Notes = ""; } //MedicationCur has its RxCui set when the butRxNormSelect button is pressed. Medications.Update(MedicationCur); MedicationPats.UpdateRxCuiForMedication(MedicationCur.MedicationNum, MedicationCur.RxCui); DialogResult = DialogResult.OK; }
private void butRemove_Click(object sender, System.EventArgs e) { if (IsNew) { DialogResult = DialogResult.Cancel; return; } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Remove this medication from this patient? Patient notes will be lost.")) { return; } MedicationPats.Delete(MedicationPatCur); if (MedicationPatCur.MedicationNum == 0) { SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, MedicationPatCur.MedDescript + " deleted"); } else { SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, Medications.GetMedication(MedicationPatCur.MedicationNum).MedName + " deleted"); } DialogResult = DialogResult.OK; }
private void RxSelected() { if (gridMain.GetSelectedIndex() == -1) { //this should never happen return; } RxDef RxDefCur = RxDefList[gridMain.GetSelectedIndex()]; if (PrefC.GetBool(PrefName.ShowFeatureEhr) && RxDefCur.RxCui == 0) { string strMsgText = Lan.g(this, "The selected prescription is missing an RxNorm") + ".\r\n" + Lan.g(this, "Prescriptions without RxNorms cannot be exported in EHR documents") + ".\r\n" + Lan.g(this, "Edit RxNorm in Rx Template?"); if (MsgBox.Show(this, true, strMsgText)) { FormRxDefEdit form = new FormRxDefEdit(RxDefCur); form.ShowDialog(); RxDefCur = RxDefs.GetOne(RxDefCur.RxDefNum); //FormRxDefEdit does not modify the RxDefCur object, so we must get the updated RxCui from the db. } } //Alert if (!RxAlertL.DisplayAlerts(PatCur.PatNum, RxDefCur.RxDefNum)) { return; } //User OK with alert RxPat RxPatCur = new RxPat(); RxPatCur.RxDate = DateTime.Today; RxPatCur.PatNum = PatCur.PatNum; RxPatCur.Drug = RxDefCur.Drug; RxPatCur.IsControlled = RxDefCur.IsControlled; RxPatCur.Sig = RxDefCur.Sig; RxPatCur.Disp = RxDefCur.Disp; RxPatCur.Refills = RxDefCur.Refills; if (PrefC.GetBool(PrefName.RxSendNewToQueue)) { RxPatCur.SendStatus = RxSendStatus.InElectQueue; } else { RxPatCur.SendStatus = RxSendStatus.Unsent; } //Notes not copied: we don't want these kinds of notes cluttering things FormRxEdit FormE = new FormRxEdit(PatCur, RxPatCur); FormE.IsNew = true; FormE.ShowDialog(); if (FormE.DialogResult != DialogResult.OK) { return; } bool isProvOrder = false; if (Security.CurUser.ProvNum != 0) //The user who is currently logged in is a provider. { isProvOrder = true; } _medOrderNum = MedicationPats.InsertOrUpdateMedOrderForRx(RxPatCur, RxDefCur.RxCui, isProvOrder); //RxDefCur.RxCui can be 0. EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent = DateTime.Now; newMeasureEvent.EventType = EhrMeasureEventType.CPOE_MedOrdered; newMeasureEvent.PatNum = PatCur.PatNum; newMeasureEvent.MoreInfo = ""; newMeasureEvent.FKey = _medOrderNum; EhrMeasureEvents.Insert(newMeasureEvent); DialogResult = DialogResult.OK; }
private void RxSelected() { if (gridMain.GetSelectedIndex() == -1) { //this should never happen return; } RxDef RxDefCur = (RxDef)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag; if (PrefC.GetBool(PrefName.ShowFeatureEhr) && RxDefCur.RxCui == 0) { string strMsgText = Lan.g(this, "The selected prescription is missing an RxNorm") + ".\r\n" + Lan.g(this, "Prescriptions without RxNorms cannot be exported in EHR documents") + ".\r\n"; if (!Security.IsAuthorized(Permissions.RxEdit, true)) { //Show the message but don't allow to edit. Continue creating rx MessageBox.Show(strMsgText); } else if (MessageBox.Show(strMsgText + Lan.g(this, "Edit RxNorm in Rx Template?"), "", MessageBoxButtons.YesNo) == DialogResult.Yes) { FormRxDefEdit form = new FormRxDefEdit(RxDefCur); form.ShowDialog(); RxDefCur = RxDefs.GetOne(RxDefCur.RxDefNum); //FormRxDefEdit does not modify the RxDefCur object, so we must get the updated RxCui from the db. } } if (RxDefCur == null) //Can occur if the RxDef is deleted. Refresh list and fill grid { _arrayRxDefs = RxDefs.Refresh(); FillGrid(); return; } //Alert if (!RxAlertL.DisplayAlerts(PatCur.PatNum, RxDefCur.RxDefNum)) { return; } //User OK with alert RxPat RxPatCur = new RxPat(); RxPatCur.RxDate = DateTime.Today; RxPatCur.PatNum = PatCur.PatNum; RxPatCur.ClinicNum = PatCur.ClinicNum; RxPatCur.Drug = RxDefCur.Drug; RxPatCur.IsControlled = RxDefCur.IsControlled; if (PrefC.GetBool(PrefName.RxHasProc) && (Clinics.ClinicNum == 0 || Clinics.GetClinic(Clinics.ClinicNum).HasProcOnRx)) { RxPatCur.IsProcRequired = RxDefCur.IsProcRequired; } RxPatCur.Sig = RxDefCur.Sig; RxPatCur.Disp = RxDefCur.Disp; RxPatCur.Refills = RxDefCur.Refills; if (PrefC.GetBool(PrefName.RxSendNewToQueue)) { RxPatCur.SendStatus = RxSendStatus.InElectQueue; } else { RxPatCur.SendStatus = RxSendStatus.Unsent; } RxPatCur.PatientInstruction = RxDefCur.PatientInstruction; //Notes not copied: we don't want these kinds of notes cluttering things FormRxEdit FormE = new FormRxEdit(PatCur, RxPatCur); FormE.IsNew = true; FormE.ShowDialog(); if (FormE.DialogResult != DialogResult.OK) { return; } bool isProvOrder = false; if (Security.CurUser.ProvNum != 0) //The user who is currently logged in is a provider. { isProvOrder = true; } _medOrderNum = MedicationPats.InsertOrUpdateMedOrderForRx(RxPatCur, RxDefCur.RxCui, isProvOrder); //RxDefCur.RxCui can be 0. EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent = DateTime.Now; newMeasureEvent.EventType = EhrMeasureEventType.CPOE_MedOrdered; newMeasureEvent.PatNum = PatCur.PatNum; newMeasureEvent.MoreInfo = ""; newMeasureEvent.FKey = _medOrderNum; EhrMeasureEvents.Insert(newMeasureEvent); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { if (_listMedicationPatReconcile.Count == 0) { if (!MsgBox.Show(this, true, "The reconcile list is empty which will cause all existing medications to be removed. Continue?")) { return; } } MedicationPat medP; bool isActive; //Discontinue any current medications that are not present in the reconcile list. for (int i = 0; i < _listMedicationPatCur.Count; i++) //Start looping through all current medications { isActive = false; medP = _listMedicationPatCur[i]; for (int j = 0; j < _listMedicationPatReconcile.Count; j++) //Compare each reconcile medication to the current medication { if (medP.RxCui > 0 && medP.RxCui == _listMedicationPatReconcile[j].RxCui && _listMedicationPatReconcile[j].MedicationNum == _listMedicationPatCur[i].MedicationNum) //Has an RxNorm code and they are equal { isActive = true; break; } } if (!isActive) //Update current medications. { _listMedicationPatCur[i].DateStop = DateTime.Now; //Set the current DateStop to today (to set the medication as discontinued) MedicationPats.Update(_listMedicationPatCur[i]); } } //Always update every current medication for the patient so that DateTStamp reflects the last reconcile date. if (_listMedicationPatCur.Count > 0) { MedicationPats.ResetTimeStamps(_patCur.PatNum, true); } Medication med; int index; for (int j = 0; j < _listMedicationPatReconcile.Count; j++) { index = ListMedicationPatNew.IndexOf(_listMedicationPatReconcile[j]); if (index < 0) { continue; } if (_listMedicationPatReconcile[j] == ListMedicationPatNew[index]) { med = Medications.GetMedicationFromDbByRxCui(_listMedicationPatReconcile[j].RxCui); if (med == null) { med = new Medication(); med.MedName = ListMedicationPatNew[index].MedDescript; med.RxCui = ListMedicationPatNew[index].RxCui; ListMedicationPatNew[index].MedicationNum = Medications.Insert(med); med.GenericNum = med.MedicationNum; Medications.Update(med); } else { ListMedicationPatNew[index].MedicationNum = med.MedicationNum; } ListMedicationPatNew[index].ProvNum = 0; //Since imported, set provnum to 0 so it does not affect CPOE. MedicationPats.Insert(ListMedicationPatNew[index]); } } EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent = DateTime.Now; newMeasureEvent.EventType = EhrMeasureEventType.MedicationReconcile; newMeasureEvent.PatNum = _patCur.PatNum; newMeasureEvent.MoreInfo = ""; EhrMeasureEvents.Insert(newMeasureEvent); for (int inter = 0; inter < _listMedicationPatReconcile.Count; inter++) { if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).MedicationCDS) { Medication medInter = Medications.GetMedicationFromDbByRxCui(_listMedicationPatReconcile[inter].RxCui); FormCDSIntervention FormCDSI = new FormCDSIntervention(); FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(medInter, _patCur); FormCDSI.ShowIfRequired(false); } } DialogResult = DialogResult.OK; }
private void butGiveAccess_Click(object sender, EventArgs e) { string interval = PrefC.GetStringSilent(PrefName.MobileSyncIntervalMinutes); if (interval == "" || interval == "0") //not a paid customer or chooses not to synch { MessageBox.Show("Synch must be setup first from the Tools menu, Mobile and Patient Portal Synch. Interval must not be blank or zero."); return; } //we won't check PrefName.MobileSyncWorkstationName because we are forcing the synch if (System.Environment.MachineName.ToUpper() != PrefC.GetStringSilent(PrefName.MobileSyncWorkstationName).ToUpper()) { //Since GetStringSilent returns "" before OD is connected to db, this gracefully loops out if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning. Workstation is not entered in the Tools menu, Mobile and Patient Portal Synch. No automatic synch is taking place. Continue anyway?")) { return; } } if (PrefC.GetDate(PrefName.MobileExcludeApptsBeforeDate).Year < 1880) { MessageBox.Show("Full Synch must be run first first from the Tools menu, Mobile and Patient Portal Synch."); return; } if (butGiveAccess.Text == "Provide Online Access") //When form open opens with a blank password { Cursor = Cursors.WaitCursor; //1. Fill password. textOnlinePassword.Text = GenerateRandomPassword(8, 10); //won't save until OK or Print //2. Fill link. textOnlineLink.Text = GetPatientPortalLink(); //3. Reset timestamps for this patient to trigger all their objects to upload with the next synch LabPanels.ResetTimeStamps(PatCur.PatNum); Diseases.ResetTimeStamps(PatCur.PatNum); Allergies.ResetTimeStamps(PatCur.PatNum); MedicationPats.ResetTimeStamps(PatCur.PatNum); Statements.ResetTimeStamps(PatCur.PatNum); Documents.ResetTimeStamps(PatCur.PatNum); //4. Make the password editable in case they want to change it. textOnlinePassword.ReadOnly = false; //5. Save password to db PatCur.OnlinePassword = textOnlinePassword.Text; Patients.Update(PatCur, PatOld); PatOld.OnlinePassword = textOnlinePassword.Text; //so that subsequent Updates will work. //6. Force a synch FormMobile.SynchFromMain(true); //7. Insert EhrMeasureEvent EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent = DateTime.Now; newMeasureEvent.EventType = EhrMeasureEventType.OnlineAccessProvided; newMeasureEvent.PatNum = PatCur.PatNum; newMeasureEvent.MoreInfo = ""; EhrMeasureEvents.Insert(newMeasureEvent); //8. Rename button butGiveAccess.Text = "Remove Online Access"; Cursor = Cursors.Default; } else //remove access { Cursor = Cursors.WaitCursor; //1. Clear password textOnlinePassword.Text = ""; //2. Make in uneditable textOnlinePassword.ReadOnly = true; //3. Save password to db PatCur.OnlinePassword = textOnlinePassword.Text; Patients.Update(PatCur, PatOld); PatOld.OnlinePassword = textOnlinePassword.Text; //5. Force a synch FormMobile.SynchFromMain(true); //no event to insert //6. Rename button butGiveAccess.Text = "Provide Online Access"; Cursor = Cursors.Default; } }
private void FillExistingGrid() { gridMedExisting.BeginUpdate(); gridMedExisting.ListGridColumns.Clear(); GridColumn col = new GridColumn("Last Modified", 100, HorizontalAlignment.Center); gridMedExisting.ListGridColumns.Add(col); col = new GridColumn("Date Start", 100, HorizontalAlignment.Center); gridMedExisting.ListGridColumns.Add(col); col = new GridColumn("Date Stop", 100, HorizontalAlignment.Center); gridMedExisting.ListGridColumns.Add(col); col = new GridColumn("Description", 320); gridMedExisting.ListGridColumns.Add(col); gridMedExisting.ListGridRows.Clear(); _listMedicationPatCur = MedicationPats.GetMedPatsForReconcile(_patCur.PatNum); List <long> medicationNums = new List <long>(); for (int h = 0; h < _listMedicationPatCur.Count; h++) { if (_listMedicationPatCur[h].MedicationNum > 0) { medicationNums.Add(_listMedicationPatCur[h].MedicationNum); } } _listMedicationCur = Medications.GetMultMedications(medicationNums); GridRow row; Medication med; for (int i = 0; i < _listMedicationPatCur.Count; i++) { row = new GridRow(); med = Medications.GetMedication(_listMedicationPatCur[i].MedicationNum); //Possibly change if we decided to postpone caching medications row.Cells.Add(_listMedicationPatCur[i].DateTStamp.ToShortDateString()); if (_listMedicationPatCur[i].DateStart.Year < 1880) { row.Cells.Add(""); } else { row.Cells.Add(_listMedicationPatCur[i].DateStart.ToShortDateString()); } if (_listMedicationPatCur[i].DateStop.Year < 1880) { row.Cells.Add(""); } else { row.Cells.Add(_listMedicationPatCur[i].DateStop.ToShortDateString()); } if (med.MedName == null) { row.Cells.Add(""); } else { row.Cells.Add(med.MedName); } gridMedExisting.ListGridRows.Add(row); } gridMedExisting.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(); }
///<summary>Returns false if user does not wish to continue after seeing alert.</summary> public static bool DisplayAlerts(long patNum, long rxDefNum) { List <RxAlert> alertList = null; //if(rxDefNum==0){ // alertList=RxAlerts.RefreshByRxCui(rxCui);//for CPOE //} //else{ alertList = RxAlerts.Refresh(rxDefNum); //for Rx //} List <Disease> diseases = Diseases.Refresh(patNum); List <Allergy> allergies = Allergies.Refresh(patNum); List <MedicationPat> medicationPats = MedicationPats.Refresh(patNum, false); //Exclude discontinued, only active meds. List <string> diseaseMatches = new List <string>(); List <string> allergiesMatches = new List <string>(); List <string> medicationsMatches = new List <string>(); List <string> customMessages = new List <string>(); bool showHighSigOnly = PrefC.GetBool(PrefName.EhrRxAlertHighSeverity); for (int i = 0; i < alertList.Count; i++) { for (int j = 0; j < diseases.Count; j++) { //This does not look for matches with icd9s. if (alertList[i].DiseaseDefNum == diseases[j].DiseaseDefNum && diseases[j].ProbStatus == 0) //ProbStatus is active. { if (alertList[i].NotificationMsg == "") { diseaseMatches.Add(DiseaseDefs.GetName(diseases[j].DiseaseDefNum)); } else { customMessages.Add(alertList[i].NotificationMsg); } } } for (int j = 0; j < allergies.Count; j++) { if (alertList[i].AllergyDefNum == allergies[j].AllergyDefNum && allergies[j].StatusIsActive) { if (alertList[i].NotificationMsg == "") { allergiesMatches.Add(AllergyDefs.GetOne(alertList[i].AllergyDefNum).Description); } else { customMessages.Add(alertList[i].NotificationMsg); } } } for (int j = 0; j < medicationPats.Count; j++) { bool isMedInteraction = false; Medication medForAlert = Medications.GetMedication(alertList[i].MedicationNum); if (medForAlert == null) { continue; //MedicationNum will be 0 for all other alerts that are not medication alerts. } if (medicationPats[j].MedicationNum != 0 && alertList[i].MedicationNum == medicationPats[j].MedicationNum) //Medication from medication list. { isMedInteraction = true; } else if (medicationPats[j].MedicationNum == 0 && medForAlert.RxCui != 0 && medicationPats[j].RxCui == medForAlert.RxCui) //Medication from NewCrop. Unfortunately, neither of these RxCuis are required. { isMedInteraction = true; } if (!isMedInteraction) { continue; //No known interaction. } //Medication interaction. if (showHighSigOnly && !alertList[i].IsHighSignificance) //if set to only show high significance alerts and this is not a high significance interaction, do not show alert { continue; //Low significance alert. } if (alertList[i].NotificationMsg == "") { Medications.RefreshCache(); medicationsMatches.Add(Medications.GetMedication(alertList[i].MedicationNum).MedName); } else { customMessages.Add(alertList[i].NotificationMsg); } } } //these matches do not include ones that have custom messages. if (diseaseMatches.Count > 0 || allergiesMatches.Count > 0 || medicationsMatches.Count > 0) { string alert = ""; for (int i = 0; i < diseaseMatches.Count; i++) { if (i == 0) { alert += Lan.g("RxAlertL", "This patient has the following medical problems: "); } alert += diseaseMatches[i]; if ((i + 1) == diseaseMatches.Count) { alert += ".\r\n"; } else { alert += ", "; } } for (int i = 0; i < allergiesMatches.Count; i++) { if (i == 0 && diseaseMatches.Count > 0) { alert += "and the following allergies: "; } else if (i == 0) { alert = Lan.g("RxAlertL", "This patient has the following allergies: "); } alert += allergiesMatches[i]; if ((i + 1) == allergiesMatches.Count) { alert += ".\r\n"; } else { alert += ", "; } } for (int i = 0; i < medicationsMatches.Count; i++) { if (i == 0 && (diseaseMatches.Count > 0 || allergiesMatches.Count > 0)) { alert += "and is taking the following medications: "; } else if (i == 0) { alert = Lan.g("RxAlertL", "This patient is taking the following medications: "); } alert += medicationsMatches[i]; if ((i + 1) == medicationsMatches.Count) { alert += ".\r\n"; } else { alert += ", "; } } alert += "\r\n" + Lan.g("RxAlertL", "Continue anyway?"); if (MessageBox.Show(alert, "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK) { return(false); } } for (int i = 0; i < customMessages.Count; i++) { if (MessageBox.Show(customMessages[i] + "\r\n" + Lan.g("RxAlertL", "Continue anyway?"), "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK) { return(false); } } return(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 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(); }