public decimal getMorphineEquivalentDose(DateTime intervalDate) { List <PatientMedication> patientMedication = database.getPatientMedications(this) .Where(pm => pm.Start_Date <= intervalDate && pm.End_Date > intervalDate).ToList(); decimal morphineEquivalentDose = 0; patientMedication.ForEach(pm => morphineEquivalentDose += (pm.Mg * pm.Medication.Morphine_Equivalent__mg_)); return(morphineEquivalentDose); }
public List <PatientMedication> getPatientMedication(bool currentOnly) { if (currentOnly) { return(database.getPatientMedications(patient).Where(pm => pm.End_Date.Equals(DateTime.Parse("12/31/9999"))).ToList()); } else { return(database.getPatientMedications(patient)); } }
private void DisplayMedication() { dgvPatientProperties.Columns.Add("cName", "Name"); dgvPatientProperties.Columns.Add("cMg", "Mg"); dgvPatientProperties.Columns.Add("cStartDate", "Start Date"); dgvPatientProperties.Columns.Add("cEndDate", "End Date"); patientMedication = database.getPatientMedications(patient); patientMedication.ForEach(pm => dgvPatientProperties.Rows.Add(pm.Medication.Name, pm.Mg, pm.Start_Date.ToShortDateString(), getEndDateDisplay(pm.End_Date))); btnViewDetails.Text = "View Medication Details"; }
private void loadMorphineEquivalentDose(TreeView tvMedicalData) { tvMedicalData.Nodes.Add("Morphine Equivalent Dose"); tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].ImageIndex = 0; tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].SelectedImageIndex = 0; List <PatientMedication> patientMedications = database.getPatientMedications(patient); Dictionary <DateTime, MorphineEquivalentDose> patientDateMEDs = new Dictionary <DateTime, MorphineEquivalentDose>(); foreach (PatientMedication pm in patientMedications) { if (!patientDateMEDs.ContainsKey(pm.Start_Date)) { patientDateMEDs.Add(pm.Start_Date, new MorphineEquivalentDose( patient.getMorphineEquivalentDose(pm.Start_Date), patientMedications .Where(pm_ => pm_.Start_Date <= pm.Start_Date && pm_.End_Date > pm.Start_Date) .ToList())); } if (!patientDateMEDs.ContainsKey(pm.End_Date) && pm.End_Date <= DateTime.Now) { patientDateMEDs.Add(pm.End_Date, new MorphineEquivalentDose( patient.getMorphineEquivalentDose(pm.End_Date), patientMedications .Where(pm_ => pm_.Start_Date <= pm.End_Date && pm_.End_Date > pm.End_Date) .ToList())); } } List <PatientMorphineEquivalentDose> patientMEDs = new List <PatientMorphineEquivalentDose>(); foreach (KeyValuePair <DateTime, MorphineEquivalentDose> pdm in patientDateMEDs) { patientMEDs.Add(new PatientMorphineEquivalentDose(pdm.Key, pdm.Value)); } patientMEDs = patientMEDs.OrderByDescending(pm => pm.Date).ToList(); foreach (PatientMorphineEquivalentDose pm in patientMEDs) { tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].Nodes.Add(pm.MED.MED + "mg - " + pm.Date.ToShortDateString()); tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.ImageIndex = 0; tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.SelectedImageIndex = 0; foreach (PatientMedication pm_ in pm.MED.MakeUp) { tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.Nodes.Add( pm_.Medication.Name + " - " + pm_.Mg + "mg"); } } //// start by adding current MED at this very moment //tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].Nodes.Add("Current"); //tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.ImageIndex = 0; //tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.SelectedImageIndex = 0; //tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.Nodes.Add( // patient.getMorphineEquivalentDose(DateTime.Now) + "mg"); //tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.ImageIndex = 0; //tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.SelectedImageIndex = 0; //List<PatientMedication> patientCurrentMedications = database.getPatientMedications(patient) // .Where(pm => pm.Start_Date <= DateTime.Now && pm.End_Date >= DateTime.Now) // .ToList(); //foreach (PatientMedication pm in patientCurrentMedications) //{ // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.Nodes // .Add(pm.Medication.Name + " - " + pm.Mg + "mg"); // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.LastNode.ImageIndex = 0; // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.LastNode.SelectedImageIndex = 0; //} //// later add MED breakdown into intervals from most recent to baseline //DateTime baseDate = patient.Date_Entered_Into_System; //LocalDate start = new LocalDate(baseDate.Year, baseDate.Month, baseDate.Day); //LocalDate end = new LocalDate(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); //Period period = Period.Between(start, end, PeriodUnits.Months); //int months = (int)period.Months; //int monthIntervals = months / 3; //DateTime intervalDate = baseDate.AddMonths(monthIntervals); //for (int i = monthIntervals; i >= 0; i--) //{ // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].Nodes.Add((i * 3) + " Months"); // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.ImageIndex = 0; // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.SelectedImageIndex = 0; // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.Nodes.Add( // patient.getMorphineEquivalentDose(intervalDate) + "mg" // ); // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.ImageIndex = 0; // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.SelectedImageIndex = 0; // List<PatientMedication> patientMedications = database.getPatientMedications(patient) // .Where(pm => pm.Start_Date <= intervalDate && pm.End_Date >= intervalDate) // .ToList(); // foreach (PatientMedication pm in patientMedications) // { // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.Nodes // .Add(pm.Medication.Name + " - " + pm.Mg + "mg"); // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.ImageIndex = 0; // tvMedicalData.Nodes[tvMedicalData.Nodes.Count - 1].LastNode.LastNode.SelectedImageIndex = 0; // } // intervalDate.AddMonths(-3); //} }