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 FormFormularies_Load(object sender, EventArgs e) { if (!IsSelectionMode) { labelSelect.Visible = false; } Medications.Refresh(); FillList(); }
private void butEdit_Click(object sender, System.EventArgs e) { Medications.Refresh(); FormMedicationEdit FormME = new FormMedicationEdit(); FormME.MedicationCur = Medications.GetMedication(MedicationPatCur.MedicationNum); FormME.ShowDialog(); if (FormME.DialogResult != DialogResult.OK) { return; } textMedName.Text = Medications.GetMedication(MedicationPatCur.MedicationNum).MedName; textGenericName.Text = Medications.GetGeneric(MedicationPatCur.MedicationNum).MedName; textMedNote.Text = Medications.GetGeneric(MedicationPatCur.MedicationNum).Notes; }
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 butEdit_Click(object sender, System.EventArgs e) { Medications.Refresh(); FormMedicationEdit FormME = new FormMedicationEdit(); FormME.MedicationCur = Medications.GetMedication(MedicationPatCur.MedicationNum); //The edit button is not visible if MedicationNum=0. FormME.ShowDialog(); if (FormME.DialogResult != DialogResult.OK) { return; } MedicationPatCur.RxCui = FormME.MedicationCur.RxCui; textMedName.Text = Medications.GetMedication(MedicationPatCur.MedicationNum).MedName; //The edit button is not visible if MedicationNum=0. textGenericName.Text = Medications.GetGeneric(MedicationPatCur.MedicationNum).MedName; //The edit button is not visible if MedicationNum=0. textMedNote.Text = Medications.GetGeneric(MedicationPatCur.MedicationNum).Notes; //The edit button is not visible if MedicationNum=0. textRxNormDesc.Text = RxNorms.GetDescByRxCui(MedicationPatCur.RxCui.ToString()); }
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 FillAlerts() { RxAlertList = RxAlerts.Refresh(RxDefCur.RxDefNum); listAlerts.Items.Clear(); for (int i = 0; i < RxAlertList.Count; i++) { if (RxAlertList[i].DiseaseDefNum > 0) { listAlerts.Items.Add(DiseaseDefs.GetName(RxAlertList[i].DiseaseDefNum)); } if (RxAlertList[i].AllergyDefNum > 0) { listAlerts.Items.Add(AllergyDefs.GetOne(RxAlertList[i].AllergyDefNum).Description); } if (RxAlertList[i].MedicationNum > 0) { Medications.Refresh(); listAlerts.Items.Add(Medications.GetMedication(RxAlertList[i].MedicationNum).MedName); } } }
private void FillMedList() { listMeds.Items.Clear(); //if(SelectGenericMode){ // Medications.RefreshGeneric(); //} //else{//SelectMode and standard Medications.Refresh(); //} string s; for (int i = 0; i < Medications.List.Length; i++) { s = Medications.List[i].MedName; if (Medications.List[i].MedicationNum == Medications.List[i].GenericNum && Medications.List[i].Notes == "") { s += " *"; } listMeds.Items.Add(s); } }
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; Description = gridMain.Rows[gridMain.GetSelectedIndex()].Cells[2].Text; } //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") { //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.Refresh(); //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; 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>Returns false if user does not with to continue after seeing alert. If called from FormRxSelect, then rxCui will be 0. If called from CPOE, then rxDefNum will be 0.</summary> public static bool DisplayAlerts(long patNum, long rxCui, 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 <Medication> medications = Medications.GetMedicationsByPat(patNum); List <string> diseaseMatches = new List <string>(); List <string> allergiesMatches = new List <string>(); List <string> medicationsMatches = new List <string>(); List <string> customMessages = new List <string>(); for (int i = 0; i < alertList.Count; i++) { for (int j = 0; j < diseases.Count; j++) { //This does not look for matches with icd9s. //The only reason we support diseases anyway is for allergies that may have been entered as diseases. 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 < medications.Count; j++) { if (alertList[i].MedicationNum == medications[j].MedicationNum) { if (alertList[i].NotificationMsg == "") { Medications.Refresh(); 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); }
///<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 (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.Refresh(); 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); }