/** * \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"); } }
/** * \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(); } }
/** * \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(); } }
/** * \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"); } }