private void butExportMedications_Click(object sender, EventArgs e) { if (!Security.IsAuthorized(Permissions.Setup)) { return; } int countExportedMeds = 0; string fileName; if (ODBuild.IsWeb()) { fileName = "ExportedMedications.txt"; } else { //Prompt for file. fileName = GetFilenameFromUser(false); } if (string.IsNullOrEmpty(fileName)) { return; } try { Cursor = Cursors.WaitCursor; countExportedMeds = MedicationL.ExportMedications(fileName, Medications.GetList()); } catch (Exception ex) { Cursor = Cursors.Default; string msg = Lans.g(this, "Error: "); MessageBox.Show(this, msg + ": " + ex.Message); } Cursor = Cursors.Default; MessageBox.Show(this, POut.Int(countExportedMeds) + " " + Lan.g(this, "medications exported to:") + " " + fileName); }
private void FillGrid() { medList = Medications.GetList(textSearch.Text); gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g(this, "Drug Name"), 120); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Generic Name"), 120); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Notes for Generic"), 250); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; for (int i = 0; i < medList.Count; i++) { row = new ODGridRow(); if (medList[i].MedicationNum == medList[i].GenericNum) //isGeneric { row.Cells.Add(medList[i].MedName); row.Cells.Add(""); } else { row.Cells.Add(medList[i].MedName); row.Cells.Add(Medications.GetGenericName(medList[i].GenericNum)); } row.Cells.Add(medList[i].Notes); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
private void FillGridAllMedications(bool shouldRetainSelection = true) { Medication medSelected = null; if (shouldRetainSelection && gridAllMedications.GetSelectedIndex() != -1) { medSelected = (Medication)gridAllMedications.Rows[gridAllMedications.GetSelectedIndex()].Tag; } List <long> listInUseMedicationNums = Medications.GetAllInUseMedicationNums(); int sortColIndex = gridAllMedications.SortedByColumnIdx; bool isSortAscending = gridAllMedications.SortedIsAscending; gridAllMedications.BeginUpdate(); gridAllMedications.Columns.Clear(); //The order of these columns is important. See gridAllMedications_CellClick() ODGridColumn col = new ODGridColumn(Lan.g(this, "Drug Name"), 120, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Generic Name"), 120, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "InUse"), 55, HorizontalAlignment.Center, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); if (CultureInfo.CurrentCulture.Name.EndsWith("US")) //United States { col = new ODGridColumn(Lan.g(this, "RxNorm"), 70, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); } col = new ODGridColumn(Lan.g(this, "Notes for Generic"), 250, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); gridAllMedications.Rows.Clear(); List <Medication> listMeds = Medications.GetList(textSearch.Text); foreach (Medication med in listMeds) { ODGridRow row = new ODGridRow(); row.Tag = med; if (med.MedicationNum == med.GenericNum) //isGeneric { row.Cells.Add(med.MedName); row.Cells.Add(""); } else { row.Cells.Add(med.MedName); row.Cells.Add(Medications.GetGenericName(med.GenericNum)); } if (listInUseMedicationNums.Contains(med.MedicationNum)) { row.Cells.Add("X"); //InUse } else { row.Cells.Add(""); //InUse } if (CultureInfo.CurrentCulture.Name.EndsWith("US")) //United States { if (med.RxCui == 0) { row.Cells.Add(Lan.g(this, "(select)")); row.Cells[row.Cells.Count - 1].Bold = YN.Yes; } else { row.Cells.Add(med.RxCui.ToString()); } } row.Cells.Add(med.Notes); gridAllMedications.Rows.Add(row); } gridAllMedications.EndUpdate(); gridAllMedications.SortForced(sortColIndex, isSortAscending); if (medSelected != null) //Will be null if nothing is selected. { for (int i = 0; i < gridAllMedications.Rows.Count; i++) { Medication medCur = (Medication)gridAllMedications.Rows[i].Tag; if (medCur.MedicationNum == medSelected.MedicationNum) { gridAllMedications.SetSelected(i, true); break; } } } }
private void butImportMedications_Click(object sender, EventArgs e) { if (!Security.IsAuthorized(Permissions.Setup)) { return; } List <ODTuple <Medication, string> > listImportMeds = new List <ODTuple <Medication, string> >(); //Leaving code here to include later when we have developed a default medications list available for download. //if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Click Yes to download and import default medication list.\r\nClick No to import from a file.")) { // Cursor=Cursors.WaitCursor; // listImportMeds=DownloadDefaultMedications();//Import from OpenDental.com //} //else {//Prompt for file. string fileName = GetFilenameFromUser(true); if (string.IsNullOrEmpty(fileName)) { return; } try { Cursor = Cursors.WaitCursor; listImportMeds = MedicationL.GetMedicationsFromFile(fileName); } catch (Exception ex) { Cursor = Cursors.Default; string msg = Lans.g(this, "Error accessing file. Close all programs using file and try again."); MessageBox.Show(this, msg + "\r\n: " + ex.Message); return; } //} int countImportedMedications = MedicationL.ImportMedications(listImportMeds, Medications.GetList()); int countDuplicateMedications = listImportMeds.Count - countImportedMedications; DataValid.SetInvalid(InvalidType.Medications); Cursor = Cursors.Default; MessageBox.Show(this, POut.Int(countDuplicateMedications) + " " + Lan.g(this, "duplicate medications found.") + "\r\n" + POut.Int(countImportedMedications) + " " + Lan.g(this, "medications imported.")); FillTab(); }