Exemple #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;
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Hide database error on page load
            DataBaseError.Visible = false;

            // Enable submit button on page load
            SubmitButton.Enabled = true;

            // Redirect to login if not logged in
            if (Session[Global.user] == null)
            {
                Response.Redirect("Login.aspx");
            }

            // If logged in attempt to pull data from database
            try
            {
                // Bind patient data to gridview
                List <Patient> patients = PatientUtility.GetPatients();
                PatientGridView.DataSource = patients;
                PatientGridView.DataBind();
            }
            // If exception caught show database error and
            // disable submit button
            catch (Exception)
            {
                DataBaseError.Visible = true;
                SubmitButton.Enabled  = false;
            }
        }
Exemple #3
0
        // Find and bind search results to grid view
        protected void SearchClick(object sender, EventArgs e)
        {
            List <Patient> patients     = PatientUtility.GetPatients();
            List <Patient> searchReturn = new List <Patient>();

            // Hide result not found error message
            NotFoundError.Visible = false;

            // Check input name against list of patients
            foreach (Patient patient in patients)
            {
                if (patient.name.ToString().Contains(Search.Text))
                {
                    searchReturn.Add(patient);
                }
            }

            // Bind to grid view if any result found
            if (searchReturn.Any())
            {
                PatientGridView.DataSource = searchReturn;
                PatientGridView.DataBind();
            }
            // Show error message if no results found
            else
            {
                NotFoundError.Visible = true;
            }
        }
Exemple #4
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;
            }
        }
Exemple #5
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;
            }
        }
Exemple #6
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;
            }
        }
        // Add new patient submit
        protected void PatientClick(object sender, EventArgs e)
        {
            try
            {
                // Hide Error Messages every time button pressed
                PatientSuccessMessage.Visible = false;
                PatientErrorMessage.Visible   = false;
                DatabaseErrorMessage.Visible  = false;

                // Get form data for new patient
                int    newId        = PatientUtility.GetNewId();
                string newName      = name.Text;
                string newAddress   = address.Text;
                string dateOfBirth  = dob.Text;
                string newPhone     = phone.Text;
                string newEmergency = econtact.Text;

                // Get time and split to Database datetime format
                string   time             = DateTime.Now.ToString();
                string[] timeSplit        = time.Split(' ');
                string[] dateSplit        = timeSplit[0].Split('/');
                string   registrationTime = String.Format("{0}/{1}/{2} {3}",
                                                          dateSplit[2], dateSplit[1], dateSplit[0], timeSplit[1]);

                // Create new patient
                Patient patient = new Patient(newId, newName, newAddress, dateOfBirth,
                                              newPhone, newEmergency, registrationTime);

                // Attempt to load new patient into database
                if (PatientUtility.AddPatient(patient))
                {
                    PatientSuccessMessage.Visible = true;
                    PatientErrorMessage.Visible   = false;
                }
                // Throw exception on database update failure
                else
                {
                    throw new Exception();
                }
            }
            // Display error message if an exception is caught
            catch (Exception)
            {
                PatientSuccessMessage.Visible = false;
                PatientErrorMessage.Visible   = true;
                DatabaseErrorMessage.Visible  = true;
            }
        }
Exemple #8
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;
            }
        }
        public Identity(IDataRecord record, bool isLastIdCheck = false)
        {
            if (!isLastIdCheck)
            {
                this.ida                  = DALUtility.GetData <string>(record, IdentityController.IDA);
                this.identId              = DALUtility.GetData <int>(record, IdentityController.IDENT_ID);
                this.createDateTime       = DALUtility.GetData <DateTime>(record, IdentityController.CREATE_DTTM);
                this.firstName            = DALUtility.GetData <string>(record, PatientController.FIRST_NAME);
                this.lastName             = DALUtility.GetData <string>(record, PatientController.LAST_NAME);
                this.dateOfBirth          = DALUtility.GetData <string>(record, PatientController.BIRTH_DTTM);
                this.socialSecurityNumber = DALUtility.GetData <string>(record, PatientController.SOCIAL_SECURITY_NUMBER);

                // handle the patient date of birth
                PatientUtility.handleDateOfBirth(this);
            }
            else
            {
                this.lastId = DALUtility.GetData <int>(record, IdentityController.LAST_ID);
            }
        }
Exemple #10
0
 // Get patient name for gridview
 protected string GetPatientName(object patientId)
 {
     return(PatientUtility.GetPatient(
                Convert.ToInt32(patientId.ToString())).name);
 }
Exemple #11
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;
            }
        }
Exemple #12
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;
            }
        }