Exemplo n.º 1
0
 /// <summary>
 /// Handles the RowDataBound event of the gridAdmission control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridViewRowEventArgs"/> instance containing the event data.</param>
 protected void gridAdmission_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         Entities.Administration.WardAdmission rowView = (Entities.Administration.WardAdmission)e.Row.DataItem;
         string discharged = rowView.Discharged ? "Yes" : "No";
         e.Row.Cells[6].Text = discharged;
         if (!rowView.Discharged)
         {
             TextBox dichargeText = e.Row.FindControl("textDischargeDate") as TextBox;
             if (dichargeText != null)
             {
                 dichargeText.Text = DateTime.Now.ToString("dd-MMM-yyyy");
             }
             Button btn = e.Row.FindControl("buttonDischarge") as Button;
             if (btn != null)
             {
                 //id, date,status
                 btn.OnClientClick = string.Format("javascript:showDiag('{0}','{1}','{2}');return false;"
                                                   , rowView.AdmissionID
                                                   , rowView.AdmissionDate.ToString("dd-MMM-yyyy")
                                                   , discharged);
             }
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Populates the details.
 /// </summary>
 /// <param name="admissionid">The admissionid.</param>
 void BindAdmissionDetails()
 {
     try
     {
         IWardsMaster wardMaster = (IWardsMaster)ObjectFactory.CreateInstance("BusinessProcess.Administration.BWardMaster, BusinessProcess.Administration");
         Entities.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.Text = 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.Text           = 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
 }
Exemplo n.º 3
0
        /// <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");
                }
                DateTime dateAdmitted = DateTime.Now;
                if (!string.IsNullOrEmpty(textAdmissionDate.Text))
                {
                    dateAdmitted = Convert.ToDateTime(textAdmissionDate.Text);
                }
                else
                {
                    throw new Exception("Admission date cannot be blank");
                }
                if (dateAdmitted > DateTime.Now)
                {
                    throw new Exception("Admission date cannot be after today");
                }
                DateTime?expectedDOD = null;
                if (!string.IsNullOrEmpty(textExpectedDOD.Text.Trim()))
                {
                    expectedDOD = Convert.ToDateTime(textExpectedDOD.Text.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
                Entities.Administration.WardAdmission admission = new Entities.Administration.WardAdmission()
                {
                    WardID            = wardId,
                    AdmissionDate     = dateAdmitted,
                    AdmissionNumber   = admissionNumber,
                    ReferredFrom      = referredFrom,
                    BedNumber         = bedNumber,
                    AdmittedBy        = this.UserID,
                    PatientID         = this.PatientID,
                    Active            = true,
                    ExpectedDischarge = expectedDOD
                };
                if (this.OpenMode == "EDIT")
                {
                    admission.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", "The operation has completed successfully: Admission number is " + admissionNumber));
                list.Add(new KeyValuePair <string, string>("Title", "Successful 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));
            }
        }