Beispiel #1
0
        /**
         * \brief <b>Brief Description</b> - Demographics <b><i>class method</i></b> - This method is used to add the newly created patient to the database. and update the patient roster
         * \details <b>Details</b>
         *
         * This method adds the newly created patients to the database and update the patient roster with GetPatientList Function which will refill the patient roster
         *
         * \param patient -<b>Patient</b> - This method takes the newly created patient object to add that in database
         *
         * \return none - <b>void</b> - This method returns nothing
         *
         * \see GetPatientList();
         */
        public void AddNewPatient(Patient patient)
        {
            if (patient != null)
            {
                var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://ems-api.azurewebsites.net/api/hcn/update");
                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";

                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string json = '{' + string.Format("\"hcn\":\"{0}\", \"hcv\":\"{1}\", \"post\":\"{2}\"", patient.HCN.Substring(0, 10), patient.HCN.Substring(10, 2), patient.PostalCode) + '}';

                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                }

                FileIO.AddRecordToDataTable(patient.ToStringArray(), FileIO.TableNames.Patients);
                Logging.Log("Demographics", "AddNewPatient", String.Format("Adding new patient with PatientHCN {0} to the database file", patient.HCN));
                GetPatientList();
            }
        }
Beispiel #2
0
        public void Functional_MergeDataTable()
        {
            FileIO.GenerateEmptyDataset().WriteXml(FileIO.GetFullPath(), XmlWriteMode.WriteSchema);
            try
            {
                int currRows = 0;

                foreach (FileIO.TableNames t in Enum.GetValues(typeof(FileIO.TableNames)))
                {
                    dt = FileIO.GetDataTable(t);
                    dt.Rows.Add(new string[] { "FileIOMergeDataTable", "FileIOMergeDataTable", "FileIOMergeDataTable" });
                    FileIO.AddRecordToDataTable(new string[] { "FileIOMergeDataTable", "FileIOMergeDataTable", "FileIOMergeDataTable" }, t);
                    currRows = FileIO.GenerateTableID(t);
                    FileIO.MergeDataTable(dt, t);
                    if (currRows != FileIO.GenerateTableID(t))
                    {
                        throw new Exception("Not saved");
                    }
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
            FileIO.GenerateEmptyDataset().WriteXml(FileIO.GetFullPath(), XmlWriteMode.WriteSchema);
        }
Beispiel #3
0
 /**
  * \brief <b>Brief Description</b> - Billing<b> <i>class method</i></b> - This will save the appointment billing records to file
  * \details <b>Details</b>
  *
  * This method will look at the dictionary called appointmentBillingRecords and save every record to a file. It will use the FileIO
  * class from FileIO.cs to add the record to a table and then add that table to a file.
  *
  * \return none - <b>void</b> - this method returns nothing
  *
  * <exception cref="ArgumentNullException">Thrown if appointmentBillingRecords is null. Must confirm not null as null values cannot have a .Values field.</exception>
  */
 public void SaveApptBillingRecords()
 {
     FileIO.SetDataTable(FileIO.GetDataTableStructure(FileIO.TableNames.AppointmentBills), FileIO.TableNames.AppointmentBills);
     foreach (ApptBillRecord a in appointmentBillingRecords.Values)
     {
         FileIO.AddRecordToDataTable(a.ToStringArray(), FileIO.TableNames.AppointmentBills);
     }
 }
Beispiel #4
0
 public void Null_AddRecordToTable()
 {
     try
     {
         FileIO.AddRecordToDataTable((DataRow)null, FileIO.TableNames.Patients);
         FileIO.AddRecordToDataTable((string[])null, FileIO.TableNames.Patients);
     }
     catch (Exception) { Assert.Fail(); }
 }
Beispiel #5
0
 /**
  * \brief <b>Brief Description</b> - Demographics <b><i>class method</i></b> - This method is used to add the newly created patient to the database. and update the patient roster
  * \details <b>Details</b>
  *
  * This method adds the newly created patients to the database and update the patient roster with GetPatientList Function which will refill the patient roster
  *
  * \param patient -<b>Patient</b> - This method takes the newly created patient object to add that in database
  *
  * \return none - <b>void</b> - This method returns nothing
  *
  * \see GetPatientList();
  */
 public void AddNewPatient(Patient patient)
 {
     if (patient != null)
     {
         FileIO.AddRecordToDataTable(patient.ToStringArray(), FileIO.TableNames.Patients);
         Logging.Log("Demographics", "AddNewPatient", String.Format("Adding new patient with PatientHCN {0} to the database file", patient.HCN));
         GetPatientList();
     }
 }
Beispiel #6
0
 /**
  * \brief <b>Brief Description</b> - Program <b><i>class method</i></b> - Get a single week of appointments.
  * \details <b>Details</b>
  *
  * This method will pull a single week from the schedule
  *
  * \return <b>Week</b> - return a week object
  */
 public Week GetScheduleByWeek(DateTime startOfWeek)
 {
     startOfWeek = startOfWeek.AddDays(-((int)startOfWeek.DayOfWeek));
     foreach (Week week in dSchedule.Values)
     {
         if (week.StartDate.Date == startOfWeek.Date)
         {
             Logging.Log("Scheduling", "GetScheduleByWeek", string.Format("Returning Week of {0} (WeekID: {1}).", startOfWeek.Date.ToString(DATE_FORMAT), week.WeekID));
             return(week);
         }
     }
     Logging.Log("Scheduling", "GetScheduleByDay", string.Format("Week not in schedule, adding new week to tblSchedule (start date: {0}).", startOfWeek.Date.ToString(DATE_FORMAT)));
     FileIO.AddRecordToDataTable(new Week(startOfWeek).ToStringArray(), FileIO.TableNames.Schedule);
     return(null);
 }
Beispiel #7
0
 /**
  * \brief <b>Brief Description</b> - Demographics <b><i>class method</i></b> - this method used to save new patient or updated patient to the patient roster
  * \details <b>Details</b>
  *
  * This method will first check that the patient is available in patient roster. If it is, then it will update the patient in roster. If it is new patient then it will add new patient to the patient roster.
  *
  * \param patient - <b>Patient</b> - this method takes no parameters
  *
  * \return none - <b>void</b> - this method returns nothing
  */
 public void UpdatePatient(Patient patient)
 {
     if (patient != null)
     {
         dPatientRoster[patient.PatientID] = patient;
         FileIO.UpdateRecordFromTable(patient.ToStringArray(), FileIO.TableNames.Patients);
         Logging.Log("Demographics", "UpdatePatient", "Update the patient to the patient roster");
     }
     else
     {
         dPatientRoster.Add(patient.PatientID, patient);
         FileIO.AddRecordToDataTable(patient.ToStringArray(), FileIO.TableNames.Patients);
         Logging.Log("Demographics", "UpdatePatient", "Adding the patient to the patient roster");
     }
 }
Beispiel #8
0
        /**
         * \brief <b>Brief Description</b> - Program <b><i>class method</i></b> - Get the day object for a given date.
         * \details <b>Details</b>
         *
         * This method will pull a single day object.
         *
         * \return <b>Day</b> - return a Day object
         */
        public Day GetScheduleByDay(DateTime requestDate)
        {
            DateTime startOfWeek = requestDate.AddDays(-((int)requestDate.DayOfWeek));

            foreach (Week week in dSchedule.Values)
            {
                if (week.StartDate.Date == startOfWeek.Date)
                {
                    Logging.Log("Scheduling", "GetScheduleByDay", string.Format("Returning Day {0} (WeekID: {1}).", requestDate.Date.ToString(DATE_FORMAT), week.WeekID));
                    return(week.dDays[requestDate.DayOfWeek]);
                }
            }
            Logging.Log("Scheduling", "GetScheduleByDay", string.Format("Day given is not in the schedule, adding new week to tblSchedule (start date: {0}).", startOfWeek.Date.ToString(DATE_FORMAT)));
            FileIO.AddRecordToDataTable(new Week(requestDate.AddDays(-((int)requestDate.DayOfWeek))).ToStringArray(), FileIO.TableNames.Schedule);
            dSchedule = GetScheduleFromDatabase();
            return(GetScheduleByDay(requestDate));
        }
Beispiel #9
0
 /**
  * \brief <b>Brief Description</b> - Program <b><i>class method</i></b> - Schedule an appointment
  * \details <b>Details</b>
  *
  * This method will allow to schedule an appointment in a specific time slot of a specific day.
  *
  * \return <b>Appointment</b> - return a code on whether the scheduling succeeded or failed.
  */
 public bool ScheduleAppointment(Appointment appointment, DateTime appointmentDate, int timeSlot)
 {
     if (appointment != null)
     {
         Logging.Log("Scheduling", "ScheduleAppointment", string.Format("Scheduling new Appointment (ID: {0}) for {1}, timeslot {2}", appointment.AppointmentID, appointmentDate.ToString(DATE_FORMAT), timeSlot));
         if (GetScheduleByDay(appointmentDate).AddAppointment(appointment, timeSlot))
         {
             Logging.Log("Scheduling", "ScheduleAppointment", string.Format("Appointment (ID: {0}) scheduled successfully.", appointment.AppointmentID));
             SaveScheduleToDatabase();
             FileIO.AddRecordToDataTable(appointment.ToStringArray(), FileIO.TableNames.Appointments);
             dAppointments = GetAppointmentsFromDatabase();
             dSchedule     = GetScheduleFromDatabase();
             return(true);
         }
         Logging.Log("Scheduling", "ScheduleAppointment", string.Format("Appointment (ID: {0}) failed to schedule, timeslot full.", appointment.AppointmentID));
     }
     return(false);
 }
Beispiel #10
0
        /**
         * \brief <b>Brief Description</b> - Demographics <b><i>class method</i></b> - this method used to save new patient or updated patient to the patient roster
         * \details <b>Details</b>
         *
         * This method will first check that the patient is available in patient roster. If it is, then it will update the patient in roster. If it is new patient then it will add new patient to the patient roster.
         *
         * \param patient - <b>Patient</b> - this method takes no parameters
         *
         * \return none - <b>void</b> - this method returns nothing
         */
        public void UpdatePatient(Patient patient)
        {
            if (patient != null)
            {
                var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://ems-api.azurewebsites.net/api/hcn/validate");
                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";

                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string json = '{' + string.Format("\"hcn\":\"{0}\", \"hcv\":\"{1}\", \"post\":\"{2}\"", patient.HCN.Substring(0, 10), patient.HCN.Substring(10, 2), patient.PostalCode) + '}';

                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var    result = streamReader.ReadToEnd();
                    string s      = result.Split(':')[1];
                    string t      = s.Split('\"')[1];
                    patient.ResponseCode = t;
                }

                dPatientRoster[patient.PatientID] = patient;
                FileIO.UpdateRecordFromTable(patient.ToStringArray(), FileIO.TableNames.Patients);
                Logging.Log("Demographics", "UpdatePatient", "Update the patient to the patient roster");
            }
            else
            {
                dPatientRoster.Add(patient.PatientID, patient);
                FileIO.AddRecordToDataTable(patient.ToStringArray(), FileIO.TableNames.Patients);
                Logging.Log("Demographics", "UpdatePatient", "Adding the patient to the patient roster");
            }
        }