private long mySqlAddNewMedicationDose() { DBConnection dbCon = MySqlHelper.dbCon; Patient pat = PatientPoolControl.SelectedPatient; Medication med = MedicationPoolWindow.SelectedMedication; ArrayList response = dbCon.selectQuery( string.Format("SELECT add_dose({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', {7})", "NULL", med.Id, pat.Id, 0, scheduleTextBox.Text, Convert.timeStrToMySqlDateStr(timePeriodTextBox.Text), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "NULL")); MySqlHelper.disconnect(); if ((long)(response[0] as ArrayList)[0] == 0) MessageBox.Show("Medication dose not saved.", "Save Error", MessageBoxButton.OK, MessageBoxImage.Error); else MedicationDose.refreshMedicationDosePool(PatientPoolControl.SelectedPatient.Id); return (long)(response[0] as ArrayList)[0]; }
private sbyte mySqlUpdateMedicationDose() { DBConnection dbCon = MySqlHelper.dbCon; MedicationDose dose = MedicationAdministrationControl.SelectedDose; Patient pat = dose.ForPatient; Medication med = dose.ForMedication; ArrayList response = dbCon.selectQuery( string.Format("SELECT update_dose({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', {7})", dose.Id, med.Id, pat.Id, 0, scheduleTextBox.Text, Convert.timeStrToMySqlDateStr(timePeriodTextBox.Text), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "NULL")); MySqlHelper.disconnect(); if ((sbyte)(response[0] as ArrayList)[0] == 0) MessageBox.Show("Medication dose not updated.", "Update Error", MessageBoxButton.OK, MessageBoxImage.Error); else MedicationDose.refreshMedicationDosePool(PatientPoolControl.SelectedPatient.Id); return (sbyte)(response[0] as ArrayList)[0]; }
public static void fillDoseInfo(MedicationDose dose) { if (dose == null) return; Instance.scheduleTextBox.Text = dose.Schedule; Instance.timePeriodTextBox.Text = dose.TimePeriod.ToString("HHmm"); Instance.ActionMode = ActionMode.EditMode; }
public static void reconcile(MedicationDose dose) { MedicationReconciliationWindow recon = new MedicationReconciliationWindow(); Mar.ForDose = dose; Mar.ForPatient = dose.ForPatient; Mar.AdministrationTime = DateTime.Now; recon.ShowDialog(); }
/// <summary> /// Used to extract the string display for the second time period of this /// medication dose. /// </summary> /// <param name="dose">A reference to the medication dose which the second /// time period is to be extracted from.</param> /// <returns>A string representing the time period extract, or an empty /// string if the dose schedule is PRN or is a time period mismatch.</returns> public static string get2ndTimePeriod(MedicationDose dose) { if (dose.Schedule.ToUpper() == "PRN") return string.Empty; DateTime dateTime = dose.TimePeriod; TimeSpan seven = new TimeSpan(7, 0, 0); TimeSpan beforeThreePm = new TimeSpan(14, 59, 0); if (dateTime.TimeOfDay.CompareTo(seven) >= 0 && dateTime.TimeOfDay.CompareTo(beforeThreePm) <= 0) return dateTime.ToString("HHmm"); return string.Empty; }
/// <summary> /// Used to extract the string display for the first time period of this /// medication dose. /// </summary> /// <param name="dose">A reference to the medication dose which the first /// time period is to be extracted from.</param> /// <returns>A string representing the time period extract, or an empty /// string if the dose schedule is PRN or is a time period mismatch.</returns> public static string get1stTimePeriod(MedicationDose dose) { if (dose.Schedule.ToUpper() == "PRN") return string.Empty; DateTime dateTime = dose.TimePeriod; TimeSpan elevenPm = new TimeSpan(23, 0, 0); TimeSpan beforeSeven = new TimeSpan(6, 59, 0); if (dateTime.TimeOfDay.CompareTo(elevenPm) >= 0 || dateTime.TimeOfDay.CompareTo(beforeSeven) <= 0) return dateTime.ToString("HHmm"); return string.Empty; }
private void saveButton_Click(object sender, RoutedEventArgs e) { if(isInputValid() == false) return; Mar.Initials = initialsTextBox.Text; Mar.ForDose.InjectionSite = injectionSiteComboBox.SelectedIndex; Mar.AdministrationNotes = notesTextBox.Text; if (MySqlHelper.connect() == false) return; mySqlAddNewMar(); MedicationDose.refreshRemainingMedicationDosePool(Mar.ForPatient.Id); Close(); }
public static MedicationAdminstrationRecord fromArrayList(ArrayList arrayList) { MedicationAdminstrationRecord mar = new MedicationAdminstrationRecord(); Medication med = null; MedicationDose dose = new MedicationDose(); Patient pat = new Patient(); //---keys med = Medication.fromMySqlMedication((long)arrayList[0]); pat.ParentSimulation = Simulation.fromMySql((long)arrayList[1]); pat.Id = (long)arrayList[2]; //---unique fields mar.Initials = (string)arrayList[3]; //mar.AdministrationTime = null; /*if (arrayList[4].GetType() != typeof(DBNull))*/ mar.AdministrationTime = (DateTime)arrayList[4]; mar.ReasonCode = (sbyte)arrayList[5]; mar.AdministrationNotes = (string)arrayList[6]; mar.ReasonNotes = (string)arrayList[7]; //patient pool field pat.AdmissionDate = (DateTime)arrayList[8]; //---patient duplication pat.Name = (string)arrayList[9]; pat.DateOfBirth = (DateTime)arrayList[10]; pat.Allergies = (string)arrayList[11]; pat.Diagnosis = (string)arrayList[12]; pat.DrName = (string)arrayList[13]; pat.Diet = (string)arrayList[14]; pat.RoomNumber = (string)arrayList[15]; pat.Weight = (short)arrayList[16]; pat.Gender = ((string)arrayList[17]) == "MALE" ? PatientGender.Male : PatientGender.Female; pat.Notes = (string)arrayList[18]; //---medication dose duplication dose.InjectionSite = (sbyte)arrayList[19]; dose.Schedule = (string)arrayList[20]; dose.TimePeriod = (DateTime)arrayList[21]; dose.StartTime = (DateTime)arrayList[22]; dose.Id = (long)arrayList[23]; dose.ForMedication = med; mar.ForDose = dose; mar.ForPatient = pat; return mar; } //End fromArrayList()
public PatientViewer(long patId, DateTime date) { this.InitializeComponent(); this.patientId = patId; this.date = date; fillPatientInfo(PatientPoolControl.SelectedPatient); MedicationDose.refreshRemainingMedicationDosePool(patientId); marPool.DataContext = MedicationAdminstrationRecord.Records; MedicationAdminstrationRecord.refreshRecords(patientId, date); VisualStateManager.GoToState(medAdminPool, "StationVisualState", false); marPool.VisualState = "StationVisualState"; }
public static MedicationDose fromArrayList(ArrayList arrayList) { MedicationDose dose = new MedicationDose(); dose.Id = (long)arrayList[0]; dose.ForMedication = Medication.fromMySqlMedication((long)arrayList[1]); dose.ForPatient = Patient.fromMySqlPatient((long)arrayList[2]); dose.InjectionSite = (sbyte)arrayList[3]; dose.Schedule = (string)arrayList[4]; dose.TimePeriod = (DateTime)arrayList[5]; dose.StartTime = (DateTime)arrayList[6]; dose.StopTime = null; if(arrayList[7].GetType() != typeof(DBNull)) dose.StopTime = (DateTime)arrayList[6]; return dose; }
private void MedicationPoolWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = true; MedicationDose.refreshMedicationDosePool(PatientPoolControl.SelectedPatient.Id); Hide(); }
private void generateMarButton_Click(object sender, RoutedEventArgs e) { StreamWriter sWriter = new StreamWriter("mar.html"); if (sWriter == null) { MessageBox.Show("mar.html could not be created.", "Write Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Patient pat = patientPoolListView.SelectedItem as Patient; MedicationDose.refreshMedicationDosePool(pat.Id); ObservableCollection<MedicationDose> doses = MedicationDose.MedicationDosePool; string style = @"<style>body {margin: auto;font-size: 10pt;font-family: Arial, Verdana, sans-serif;}" + ".border {border: 1px solid black; border-collapse: collapse; border-spacing: 0;} .border td {border: 1px solid black;}" + "table {width: 100%;table-layout: fixed;border-collapse: collapse; border-spacing: 0;} bottom-border {border: 0;} .bottom-border td {border-bottom: 1px solid black;}</style>"; sWriter.WriteLine(@"<!doctype html><html lang='en'><head><title>MAR Sheet</title><meta charset='utf-8'>" + style + "</head><body>"); sWriter.WriteLine(@"<table>"); sWriter.WriteLine(string.Format("<tr><td colspan='2'> {0}</td><td colspan='7'>MEDICATION ADMINISTRATION RECORD</td></tr>", DateTime.Today.ToString("MM/dd/yyyy"))); sWriter.WriteLine("<tr><td colspan='2'>Time Verified 2300</td><td colspan='7'>Gulf Coast State College Nursing Hospital</td></tr><tr><td colspan='9'> <br> </td></tr>"); sWriter.WriteLine("<tr><td colspan='9'>Checked by:__________________________________</td></tr>"); sWriter.WriteLine(string.Format("<tr><td>Diagnosis:</td><td colspan='2'>{0}</td></tr>", pat.Diagnosis)); sWriter.WriteLine(string.Format("<tr><td>Allergies:</td><td colspan='2'>{0}</td><td>Diet:</td><td colspan='2'>{1}</td>" + "<td colspan='3'><b>{2}</b></td></tr>", pat.Allergies, pat.Diet, pat.Name)); sWriter.WriteLine(string.Format("<tr><td colspan='6'> </td><td colspan='3'>Rm {0}</td></tr>", pat.RoomNumber)); sWriter.WriteLine(string.Format("<tr><td colspan='3'>Notes:</td><td colspan='3'>Admission Date: {0}</td>" + "<td colspan='3'>{1}</td></tr>", pat.AdmissionDate.ToString("MM/dd/yyyy"), pat.DrName)); sWriter.WriteLine(string.Format("<tr class='bottom-border'><td colspan='3'> </td><td colspan='2'>Wt: {0} lbs.</td>" + "<td colspan='1'>Age: 34</td><td colspan='1'>Gender: {1}</td><td colspan='2'>DOB: {2}</td></tr>", pat.Weight, pat.Gender == PatientGender.Male ? 'M' : 'F', pat.DateOfBirth.ToString("MM/dd/yyyy"))); sWriter.WriteLine(string.Format("<tr><td colspan='4' style='text-align: right;'>Administration Period</td><td> </td>" + "<td colspan='4'>2300 {0} to 2259 {1}</td></tr></table>", DateTime.Today.Subtract(new TimeSpan(1, 0, 0, 0)).ToString("MM/dd/yyyy"), DateTime.Today.ToString("MM/dd/yyyy"))); //--- sWriter.WriteLine("<table class='border'>"); sWriter.WriteLine("<tr class='border'><td style='text-align: left;' colspan='4'>Drug Name, Strength, Route, Schedule</td>" + "<td style='text-align: center;'>Start</td><td style='text-align: center;'>Stop</td><td style='text-align: center;'>2300-0659</td>" + "<td style='text-align: center;'>0700-1459</td><td style='text-align: center;'>1500-2259</td></tr>"); //preformatted text for medication doses string preformatted = "<tr class='border'><td colspan='4'>{0}, {1}, {2}, {3}<br> </td>" + "<td>{4}<br> </td><td> </td><td>{5}<br> </td><td>{6}<br> </td><td>{7}<br> </td></tr>"; //write the doses out foreach (MedicationDose d in doses) sWriter.WriteLine(string.Format(preformatted, d.ForMedication.Name, d.ForMedication.Strength, Medication.Routes[d.ForMedication.Route], d.Schedule, d.StartTime.ToString("MM/dd/yyyy"), Util.get1stTimePeriod(d), Util.get2ndTimePeriod(d), Util.get3rdTimePeriod(d))); sWriter.WriteLine("</table>"); //--- sWriter.WriteLine("<table>"); sWriter.WriteLine("<tr><td colspan='3'>INJECTION CODE:</td><td colspan='4'>DOCUMENT EACH INJ. SITE</td>" + "<td colspan='2'>WITH A CODE LETTER</td></tr>"); sWriter.WriteLine("<tr><td colspan='2'>A.= L.U.Q.</td><td colspan='2'>B.= R.U.Q.</td><td colspan='2'>C.= L. Thigh</td>" + "<td colspan='2'>D.= R. Thigh</td><td>E.= L. Arm</td></tr>"); sWriter.WriteLine("<tr><td colspan='2'>F.= R. Arm</td><td colspan='2'>G.= L. ABD.</td><td colspan='2'>H.= R. ABD.</td>" + "<td colspan='2'>I.= RVG</td><td>J.= LVG</td></tr>"); sWriter.WriteLine(@"</table>"); //--- sWriter.WriteLine("<table class='border' style='border-style: double;'>"); sWriter.WriteLine("<tr><td>Initials</td><td colspan='2'>Signature</td><td>Initials</td>" + "<td colspan='2'>Signature</td><td>Initials</td><td colspan='2'>Signature</td></tr>"); sWriter.WriteLine("<tr><td> </td><td colspan='2'> </td><td> </td>" + "<td colspan='2'> </td><td> </td><td colspan='2'> </td></tr>"); sWriter.WriteLine("<tr><td>Initials</td><td colspan='2'>Signature</td><td>Initials</td>" + "<td colspan='2'>Signature</td><td>Initials</td><td colspan='2'>Signature</td></tr>"); sWriter.WriteLine("<tr><td> </td><td colspan='2'> </td><td> </td>" + "<td colspan='2'> </td><td> </td><td colspan='2'> </td></tr>"); sWriter.WriteLine("<tr><td>Initials</td><td colspan='2'>Signature</td><td>Initials</td>" + "<td colspan='2'>Signature</td><td>Initials</td><td colspan='2'>Signature</td></tr>"); sWriter.WriteLine(@"</table>"); //--- sWriter.WriteLine(@"<table>"); sWriter.WriteLine("<tr><td> </td><td colspan='2'> </td><td> </td>" + "<td colspan='2'> </td><td> </td><td colspan='2'> </td></tr>"); sWriter.WriteLine(string.Format("<table><tr><td colspan='6'> <br> <br>Room: {0}</td>" + "<td colspan='3'> <br> <br>Physician: {1}</td></tr>", pat.RoomNumber, pat.DrName)); sWriter.WriteLine(@"</table>"); sWriter.WriteLine(@"</body></html>"); sWriter.Close(); //launch in default browser Process.Start("mar.html"); } //End generateMarButton_Click()
private void removeButton_Click(object sender, RoutedEventArgs e) { MySqlHelper.removeMedicationDose(SelectedDose.Id); MedicationDose.refreshMedicationDosePool(SelectedDose.ForPatient.Id); }
private void editButton_Click(object sender, RoutedEventArgs e) { PatientEditorWindow.Instance.ActionMode = ActionMode.EditMode; MedicationDose.refreshMedicationDosePool(PatientPoolControl.SelectedPatient.Id); PatientEditorWindow.Instance.ShowDialog(); }