示例#1
0
        // Validate Patient ID exists in database
        protected void PatientIdValidate(object sender,
                                         ServerValidateEventArgs e)
        {
            try
            {
                // User input
                int id;

                // If input is an int
                if (int.TryParse(e.Value, out id))
                {
                    // Get patient from id
                    Patient patient = PatientUtility.GetPatient(id);
                    // If not found throw exception
                    if (patient == null)
                    {
                        throw new Exception();
                    }
                }
                // Validation fails if input not an int
                else
                {
                    throw new Exception();
                }

                // If patient found input is valid
                e.IsValid = true;
            }
            // Input invalid if any exception is caught
            catch (Exception)
            {
                e.IsValid = false;
                return;
            }
        }
示例#2
0
        // Validate Patient Id exists in Database
        protected void PatientIdValidate(object sender,
                                         ServerValidateEventArgs e)
        {
            try
            {
                int id;
                // Try parse input to int
                if (int.TryParse(e.Value, out id))
                {
                    // Get patient from database with provided id
                    // using stored procedure
                    Patient patient = PatientUtility.GetPatient(id);

                    // Valid if found
                    if (patient != null)
                    {
                        e.IsValid = true;
                        return;
                    }
                }

                // Throw exception if no valid doctor found
                // or input not parsable to int
                throw new Exception();
            }
            // Invalid if any exception caught
            catch (Exception)
            {
                e.IsValid = false;
            }
        }
示例#3
0
        // Find and bind search results to grid view based
        // on radio button choice
        protected void SearchClick(object sender, EventArgs e)
        {
            List <Visit> visits       = VisitUtility.GetVisits();
            List <Visit> searchReturn = new List <Visit>();
            string       choice       = radiolist1.SelectedItem.Text;

            // Hide error message
            NotFoundError.Visible = false;

            // If name selected search for name
            if (choice == "Name")
            {
                foreach (Visit visit in visits)
                {
                    if (PatientUtility.GetPatient(visit.patientId).
                        name.ToString().Contains(Search.Text))
                    {
                        searchReturn.Add(visit);
                    }
                }
            }

            // If date of visit selected search for date
            if (choice == "Date of Visit")
            {
                foreach (Visit visit in visits)
                {
                    if (visit.date.ToString().Contains(Search.Text))
                    {
                        searchReturn.Add(visit);
                    }
                }
            }

            // If date of discharge selected search for date
            if (choice == "Date of Discharge")
            {
                foreach (Visit visit in visits)
                {
                    if (visit.discharge.ToString().Contains(Search.Text))
                    {
                        searchReturn.Add(visit);
                    }
                }
            }

            // If results found bind to grid view
            if (searchReturn.Any())
            {
                VisitGridView.DataSource = searchReturn;
                VisitGridView.DataBind();
            }
            // If no results found show error
            else
            {
                NotFoundError.Visible = true;
            }
        }
示例#4
0
        // Check if patient is a current inpatient
        protected void InpatientValidate(object sender,
                                         ServerValidateEventArgs e)
        {
            int id;

            try
            {
                // Try parse input to int
                if (int.TryParse(e.Value, out id))
                {
                    // Try to get patient from database
                    Patient patient = PatientUtility.GetPatient(id);

                    // If no patient found throw exception
                    if (patient == null)
                    {
                        throw new Exception();
                    }

                    // Try to get visits from database
                    List <Visit> visits = VisitUtility.GetVisits();

                    // Check eacb visit for patient
                    foreach (Visit visit in visits)
                    {
                        // If patient is found
                        if (visit.patientId == id)
                        {
                            // And visit type is invisit
                            if (visit.type == 0)
                            {
                                // without a discharge date
                                if (visit.discharge == null)
                                {
                                    // patient is busy and fails validation
                                    throw new Exception();
                                }
                            }
                        }
                    }

                    // If input located existing patient and patient
                    // is not current inpatient validation succeeds
                    e.IsValid = true;
                    return;
                }

                // Throw exception if unable to parse input to int
                throw new Exception();
            }
            // Invalid if any exception caught
            catch (Exception)
            {
                e.IsValid = false;
            }
        }
示例#5
0
        // Validate patient ID has current invisit
        protected void InpatientValidate(object sender,
                                         ServerValidateEventArgs e)
        {
            try
            {
                int id;

                // // If input is an int
                if (int.TryParse(e.Value, out id))
                {
                    // Create patient from id
                    Patient patient = PatientUtility.GetPatient(id);

                    // If not found fails PatientIdValidate
                    // and invisit validation can halt
                    if (patient == null)
                    {
                        return;
                    }

                    // Create list of all visits
                    List <Visit> visits = VisitUtility.GetVisits();
                    // For each visit in list
                    foreach (Visit visit in visits)
                    {
                        // If patient id matches and patient
                        // has current invisit
                        if (visit.patientId == patient.id &&
                            visit.type == 0 && visit.discharge == null)
                        {
                            // e is valid
                            e.IsValid = true;
                            return;
                        }
                    }
                }

                // If no valid visit is found throw exception
                throw new Exception();
            }
            // Any exceptions caught input is invalid
            catch (Exception)
            {
                e.IsValid = false;
                return;
            }
        }
示例#6
0
 // Get patient name for gridview
 protected string GetPatientName(object patientId)
 {
     return(PatientUtility.GetPatient(
                Convert.ToInt32(patientId.ToString())).name);
 }
示例#7
0
        // Return amount Patient owes for current visit if exists
        protected void InfoClick(object sender, EventArgs e)
        {
            // Reset panel
            InpatientGridView.Visible = false;
            DischargePanel.Visible    = false;
            AmountOwingLabel.Visible  = false;
            PayButton.Visible         = false;

            try
            {
                int id;

                // Parse input to int
                int.TryParse(PatientId.Text, out id);

                // Get patient with provided ID
                Patient patient = PatientUtility.GetPatient(id);

                // Get all visits
                List <Visit> visits = VisitUtility.GetVisits();

                // Id of valid visit
                int resultId = 0;

                // Get ID of valid visit
                foreach (Visit visit in visits)
                {
                    if (visit.type == 0 && visit.patientId == id &&
                        visit.discharge == null)
                    {
                        resultId = visit.id;
                    }
                }

                // If a valid visit is found
                if (resultId != 0)
                {
                    // Create new list to bind gridview to
                    List <InVisit> visit = new List <InVisit>();
                    // Add found visit to list from id
                    visit.Add(VisitUtility.GetInVisit(resultId));

                    // Grey out ID textbox
                    PatientId.Enabled = false;
                    // And info submit button
                    InfoSubmitButton.Enabled = false;

                    // Bind visit to gridview
                    InpatientGridView.DataSource = visit;
                    InpatientGridView.DataBind();
                    // Show gridview
                    InpatientGridView.Visible = true;

                    // Show discharge panel
                    DischargePanel.Visible = true;
                    AmountOwingLabel.Text  = String.Format(
                        "Total Price = ${0}", VisitUtility.GetPrice(visit[0]));
                    AmountOwingLabel.Visible = true;

                    // Enable pay button
                    PayButton.Visible = true;
                }
                // If not visit found throw exception
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                // If anything went wrong
                // hide panels, error message
                // will be displayed by validators
                InpatientGridView.Visible = false;
                DischargePanel.Visible    = false;
                PayButton.Visible         = false;
            }
        }
示例#8
0
        // Add new visit submit
        protected void AssignClick(object sender, EventArgs e)
        {
            try
            {
                // Hide error messages when assign button is clicked
                DatabaseError.Visible = false;
                AssignSuccess.Visible = false;
                AssignFail.Visible    = false;

                // Get patient and doctor
                Patient patient = PatientUtility.GetPatient(
                    int.Parse(PatientId.Text));
                Doctor doctor = DoctorUtility.GetDoctor(
                    int.Parse(DoctorId.Text));

                // Break if either not found, error messages will
                // be given by validators
                if (patient == null || doctor == null)
                {
                    return;
                }

                // Generate pseudo id for object creation
                // (real id assigned by database)
                int visitId = VisitUtility.GetNewId();
                // Get system date
                string fullDate = DateTime.Now.ToString();
                // Split date from time
                string[] fullDateSplit = fullDate.Split(' ');
                // Split date into 3 parts (D,M,Y)
                string[] dateArray = fullDateSplit[0].Split('/');
                // Recreate date in MM/DD/YYYY format for storing
                string date = String.Format("{0}/{1}/{2} {3}", dateArray[1],
                                            dateArray[0], dateArray[2], fullDateSplit[1]);

                // Set type to outpatient
                int visitType = 1;

                // If inpatient
                if (PatientTypeRadioButtonList.SelectedItem.ToString() ==
                    "Inpatient")
                {
                    // Change type
                    visitType = 0;
                    // Get Bed
                    Bed bed = BedUtility.GetBed(int.Parse(Bed.Text));
                    // Create new invisit
                    InVisit inVisit = new InVisit(visitId, patient.id, visitType,
                                                  doctor.id, date, "", bed.id);

                    // Attempt to add object to database throw exception
                    // on failure
                    if (!VisitUtility.AddVisit(inVisit))
                    {
                        throw new Exception();
                    }
                }
                // If outpatient
                else
                {
                    // Set discharge date to visit date
                    string discharge = date;
                    // Create new outvisit object
                    OutVisit outVisit = new OutVisit(visitId, patient.id,
                                                     visitType, doctor.id, date, discharge);

                    // Attempt to add object to database throw exception
                    // on failure
                    if (!VisitUtility.AddVisit(outVisit))
                    {
                        throw new Exception();
                    }
                }

                // If no exception thrown operation was a success, show
                // confirmation message and hide errors
                AssignFail.Visible    = false;
                AssignSuccess.Visible = true;
                AssignSubmit.Enabled  = false;
            }
            // If exception is caught there is an issue with database connection
            // show appropriate error messages
            catch (Exception)
            {
                AssignSuccess.Visible = false;
                AssignFail.Visible    = true;
                DatabaseError.Visible = true;
            }
        }