/// <summary> /// Selecteds the ward changed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void SelectedWardChanged(object sender, EventArgs e) { if (ddlPatientWard.SelectedIndex == 0) { return; } int wardId = int.Parse(ddlPatientWard.SelectedValue); IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); PatientWard ward = wardMaster.GetWards(this.FacilityID, wardId).DefaultIfEmpty(null).FirstOrDefault(); if (ward != null) { int availableBeds = ward.Capacity - ward.Occupancy; if (availableBeds > 0) { labelAvailablity.Text = string.Format("{0} beds available", availableBeds); } else { labelAvailablity.Text = string.Format("Overbooked by {0} beds", availableBeds * -1); } } this.EnableModelDialog(true); }
/// <summary> /// Popultes the ward admission. /// </summary> /// <param name="admissions">The admissions.</param> void PopulateWardAdmission() { if (ddlPatientWard.SelectedIndex == -1) { return; } // if (ddlPatientWard.SelectedIndex == 0) return; int wardId = int.Parse(ddlPatientWard.SelectedValue); if (wardId == -1) { return; } int? _wardID = null; bool excludeDischarged = rblOption.SelectedValue == "No"; if (wardId != 0) { _wardID = wardId; } IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); List <WardAdmission> _admissions; _admissions = wardMaster.GetWardAdmission(this.LocationID, _wardID, null, null, excludeDischarged); gridAdmission.DataSource = _admissions; gridAdmission.DataBind(); divGridComponent.Update(); //Bug ID 405 }
/// <summary> /// Populates the details. /// </summary> /// <param name="admissionid">The admissionid.</param> void BindAdmissionDetails() { try { IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); WardAdmission admission = wardMaster.GetWardAdmission(this.FacilityID, null, this.AdmissionID, null).DefaultIfEmpty(null).FirstOrDefault(); if (admission == null) { throw new Exception("Could not load details for the selected admission"); } // textAdmissionNumber.Text = labelAdmissionNumber.Text = admission.AdmissionNumber; textAdmissionDate.Value = labelAdmissionDate.Text = admission.AdmissionDate.ToString("dd-MMM-yyyy"); //calendarButtonExtender.SelectedDate = admission.AdmissionDate; textBedNumber.Text = labelBedNumber.Text = admission.BedNumber; labelWard.Text = admission.WardName; labelReferred.Text = admission.ReferredFrom; labelAdmittedBy.Text = this.GetUserDetails(admission.AdmittedBy); labelDischarge.Text = "Not yet discharged"; if (admission.Discharged) { string dischargedBy = this.GetUserDetails(admission.DischargedBy.Value); labelDischarge.Text = dischargedBy + " on " + admission.DischargeDate.Value.ToString("dd-MMM-yyyy"); } if (admission.ExpectedDischarge.HasValue) { textExpectedDOD.Value = labelExpectedDOD.Text = admission.ExpectedDischarge.Value.ToString("dd-MMM-yyyy"); //CalendarExtender1.SelectedDate = admission.ExpectedDischarge.Value; } if (this.OpenMode == "EDIT") { ListItem refItem = ddlReferral.Items.FindByValue(admission.ReferredFrom); if (refItem != null) { refItem.Selected = true; } else { ddlReferral.Items.FindByText("Others").Selected = true; textReferral.Text = admission.ReferredFrom; } //ddlReferral.SelectedItem.Text = admission.ReferredFrom; ListItem item = ddlPatientWard.Items.FindByValue(admission.WardID.ToString()); if (item != null) { item.Selected = true; } } } catch (Exception ex) { this.OnErrorOccured(this, new CommandEventArgs("Error", ex)); this.EnableModelDialog(false); } //todo bind control }
/// <summary> /// Handles the Click event of the buttonDischarge control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void buttonDischarge_Click(object sender, EventArgs e) { int _admissionID = int.Parse(HSelectedID.Value); bool discharged = HStatus.Value.Equals("Yes"); string dWardID = ddlPatientWard.SelectedValue; if (!this.CanDischarge || discharged) { return; } try { string stradmissionDate = (HDate.Value); DateTime admissionDate = Convert.ToDateTime(stradmissionDate); DateTime dischargeDate; if (!DateTime.TryParse(textDischargeDate.Value.Trim(), out dischargeDate)) { NotifyAction("Invalid Date Format", "Discharge Operation", true); return; } //DateTime dischargeDate = Convert.ToDateTime(textDischargeDate.Value.Trim()); if (admissionDate > dischargeDate) { // throw new Exception("Date of discharge cannot be earlier than date of admission"); NotifyAction("Date of discharge cannot be earlier than date of admission", "Discharge Operation", true); return; } if (dischargeDate > DateTime.Now) { NotifyAction("Date of discharge cannot be after today", "Discharge Operation", true); return; //throw new Exception("Date of discharge cannot be after today"); } IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); wardMaster.DischargeAdmission(_admissionID, this.UserID, this.UserID, dischargeDate); this.PopulateWards(); ddlPatientWard.SelectedValue = dWardID; this.PopulateWardAdmission(); this.NotifyAction("Patient successfully discharged", "Discharge Operation", false); return; } catch (Exception ex) { this.showErrorMessage(ref ex); } finally { HDate.Value = HStatus.Value = HSelectedID.Value = textDischargeDate.Value = ""; modalDischarge.Hide(); } }
/// <summary> /// Saves the ward. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void SaveWard(object sender, EventArgs e) { string errorMessage = ""; string actionType = ActionType.ToUpper().Trim(); bool haserror = false; if (string.IsNullOrEmpty(textWardName.Text.Trim())) { haserror = true; errorMessage += "Missing: Ward Name"; } if (string.IsNullOrEmpty(textCapacity.Text.Trim())) { haserror = true; errorMessage += "<br /> Missing: Bed capacity"; } if (ddlPatientCategory.SelectedValue == "") { haserror = true; errorMessage += "<br /> Missing: Ward's patient category"; } if (haserror) { // isError = true; errorLabel.Text = errorMessage; panelError.Visible = true; mpeWardPopup.Show(); //parameterPopup.Show(); return; } try { //database action IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); PatientWard ward = new PatientWard() { WardID = this.ActionType == "EDIT"? this.SelectedWardID : null, WardName = textWardName.Text.Trim(), Active = rblStatus.SelectedValue == "1", Capacity = int.Parse(textCapacity.Text), PatientCategory = ddlPatientCategory.SelectedValue, LocationID = this.LocationID }; wardMaster.SaveWard(ward, this.UserID); this.PopulateWardList(); this.ActionType = "VIEW"; } catch (Exception ex) { this.NotifyAction(string.Format("{0} {1} ", actionType, ex.Message), "Error occurred ..", true); this.ActionType = "VIEW"; } }
/// <summary> /// Populates the wards. /// </summary> void PopulateWards() { IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); var wards = wardMaster.GetWards(this.FacilityID) .Where(wd => wd.Active == true && wd.PatientCategory.ToLower() == this.PatientWardCategory.ToLower() || wd.PatientCategory.ToLower() == "all" || this.OpenMode == "EDIT") .OrderBy(wd => wd.WardName); ddlPatientWard.Items.Clear(); ddlPatientWard.Items.Add(new ListItem("Select", "-1")); foreach (PatientWard wd in wards) { ddlPatientWard.Items.Add(new ListItem(string.Format("{0} ({1})", wd.WardName, wd.Capacity - wd.Occupancy), wd.WardID.ToString())); } }
/// <summary> /// Populates the ward list. /// </summary> void PopulateWardList() { try { IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); List <PatientWard> wards = wardMaster.GetWards(this.LocationID); gridWardList.DataSource = wards; gridWardList.DataBind(); } catch (Exception ex) { this.showErrorMessage(ref ex); } }
/// <summary> /// Patients the has pending admission. /// </summary> /// <param name="PatientID">The patient identifier.</param> /// <param name="LocationID">The location identifier.</param> /// <returns></returns> private bool PatientHasPendingAdmission(int PatientID, int LocationID) { try { IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); List <Ward.WardAdmission> _patientAdmissions = wardMaster.GetWardAdmission(LocationID, null, null, PatientID, true); if (_patientAdmissions != null && _patientAdmissions.Count > 0) { this.NotifyAction(string.Format("The selected patient is still admitted in {0}.", _patientAdmissions[0].WardName), "Error: Double Admission", true, ""); return(true); } return(false); } catch (Exception ex) { this.showErrorMessage(ref ex); return(true); } }
/// <summary> /// Populates the wards. /// </summary> void PopulateWards(int selectedWard = -1) { IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); var wards = wardMaster.GetWards(this.LocationID).Where(wd => wd.Active == true).OrderBy(wd => wd.WardName); ddlPatientWard.Items.Clear(); if (selectedWard == -1) { int.TryParse(ddlPatientWard.SelectedValue.ToString(), out selectedWard); } foreach (PatientWard wd in wards) { ddlPatientWard.Items.Add(new ListItem(string.Format("{0} ({1})", wd.WardName, wd.Capacity - wd.Occupancy), wd.WardID.ToString())); } int wardCount = ddlPatientWard.Items.Count; //Defect - Redmine #567 ListItem item = new ListItem("All wards", "0"); ddlPatientWard.Items.Insert(0, item); if (wardCount > 1) { // ddlPatientWard.Items.Add(new ListItem("All wards", "0")); //ListItem item = new ListItem("All wards", "0"); //ddlPatientWard.Items.Insert(0, item); } else if (wardCount == 1) { ddlPatientWard.SelectedIndex = 0; } else { ListItem selectedItem = ddlPatientWard.Items.FindByValue(selectedWard.ToString()); if (selectedItem != null) { selectedItem.Selected = true; } } }
/// <summary> /// Handles the Click event of the buttonAdmit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void buttonAdmit_Click(object sender, EventArgs e) { try { this.EnableModelDialog(true); //todo validation; if (ddlPatientWard.SelectedIndex == -1) { throw new Exception("Please select the ward"); } int wardId = int.Parse(ddlPatientWard.SelectedValue); if (wardId == -1) { throw new Exception("Please select the ward"); } if (ddlReferral.SelectedValue == "") { throw new Exception("Please specify where patient has been referred from"); } if (textBedNumber.Text.Trim() == "") { throw new Exception("Bed number cannot be blank"); } DateTime dateAdmitted = DateTime.Now; if (!string.IsNullOrEmpty(textAdmissionDate.Value)) { dateAdmitted = Convert.ToDateTime(textAdmissionDate.Value); } else { throw new Exception("Admission date cannot be blank"); } if (dateAdmitted > DateTime.Now) { throw new Exception("Admission date cannot be greater than today"); } DateTime?expectedDOD = null; if (!string.IsNullOrEmpty(textExpectedDOD.Value.Trim())) { expectedDOD = Convert.ToDateTime(textExpectedDOD.Value.Trim()); } if (expectedDOD.HasValue && expectedDOD.Value < dateAdmitted) { throw new Exception("Expected date of discharge cannot be before than the admission date"); } string admissionNumber = ""; //if (!chkAutoCode.Checked) // admissionNumber = textAdmissionNumber.Text.Trim(); string referredFrom = ddlReferral.SelectedItem.Text; string bedNumber = textBedNumber.Text.Trim(); //eo validation WardAdmission admission = new WardAdmission() { WardID = wardId, AdmissionDate = dateAdmitted, AdmissionNumber = admissionNumber, ReferredFrom = referredFrom, BedNumber = bedNumber, AdmittedBy = this.UserID, PatientID = this.PatientID, Active = true, ExpectedDischarge = expectedDOD, AdmissionID = this.AdmissionID }; IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration"); admissionNumber = wardMaster.SaveAdmission(admission, this.UserID); var list = new List <KeyValuePair <string, string> >(); list.Add(new KeyValuePair <string, string>("Message", "Patient admission is completed.")); list.Add(new KeyValuePair <string, string>("Title", "Patient Admission")); list.Add(new KeyValuePair <string, string>("errorFlag", "false")); this.EnableModelDialog(false); this.OnNotifyCommand(this, new CommandEventArgs("Notify", list)); } catch (Exception ex) { this.EnableModelDialog(true); this.errorLabel.Text = ex.Message; this.IsError = true; this.DataBind(); //this.OnErrorOccured(this, new CommandEventArgs("Error", ex)); } }