private static void DoSectraBuild(SelOru oldSELExam) { // make new sectra object Sectra patientObj = new Sectra(); // begin by populatig the main exam/patient/org objects SectraDAO.GetSectraExamPatientOrganizationDetail(patientObj, oldSELExam.accessionNo); // gather the doctor info SectraDAO.GetSectraDoctorLocationDetail(patientObj, patientObj.wsExam.requestedBy); // gather the report List <WsReport> reports = SectraDAO.GetSectraReportDetail(patientObj.wsExam.examId); // let's see if this is a grouped account if (reports.Count == 0) { List <int> examids = SectraDAO.GetGroupedExamsSectra(patientObj.wsExam.examId); // if there are grouped exams, search for correct grouped report if (examids.Count > 0) { foreach (int examid_temp in examids) { reports = SectraDAO.GetSectraReportDetail(examid_temp); // we found the grouping w/ the reports if (reports.Count > 0) { break; } } } } // get the first and only report in the list - we handle addendums sperately if (reports.Count != 0) { patientObj.wsReport = reports[0]; } // set the radiologist if you have a report if (reports.Count != 0) { SectraDAO.GetSectraDoctorLocationDetail(patientObj, patientObj.wsReport.radiologistUserNo, true); } // pass the patient object and reports for inserting DoInsertUpdate(patientObj, reports); }
public static Sectra GetSectraDoctorLocationDetail(Sectra patientObject, int userNo, bool isRadiologist = false) { SqlCommand sqlCommand = new SqlCommand(); using (SqlConnection sqlConnection = new SqlConnection(CONNNECTION_STRING)) { try { // open sqlConnection.Open(); // set command attributes sqlCommand.CommandText = DOCTOR_LOCATION_QUERY; sqlCommand.CommandType = CommandType.Text; sqlCommand.Connection = sqlConnection; // add the parameter to the view sqlCommand.Parameters.AddWithValue("@USER_NO", userNo); // run query SqlDataReader reader = sqlCommand.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { // if it's not a radiologist, then it's a referring - get the location as well if (!isRadiologist) { // populate objects patientObject.referringDoctor = new WsDoctor(reader); patientObject.wsReferringDoctorLocation = new WsLocation(reader); } else { patientObject.radiologistDoctor = new WsDoctor(reader); } } } } catch (Exception e) { ErrorLogger.LogError(e, "GetSectraDoctorLocationDetail()"); } } return(patientObject); }
// returns a sectra object that contains the exam, patient, and organization details public static Sectra GetSectraExamPatientOrganizationDetail(Sectra patientObject, string accessionNo) { SqlCommand sqlCommand = new SqlCommand(); using (SqlConnection sqlConnection = new SqlConnection(CONNNECTION_STRING)) { try { // open sqlConnection.Open(); // set command attributes sqlCommand.CommandText = EXAM_PATIENT_REFERRING_ORGANIZATION_QUERY; sqlCommand.CommandType = CommandType.Text; sqlCommand.Connection = sqlConnection; // add the parameter to the view sqlCommand.Parameters.AddWithValue("@ACCESSION_NO", accessionNo); // run query SqlDataReader reader = sqlCommand.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { // populate objects patientObject.wsExam = new WsExam(reader); patientObject.wsPatient = new WsPatient(reader); patientObject.wsOrganization = new WsOrganization(reader); } } } catch (Exception e) { ErrorLogger.LogError(e, "GetSectraExamPatientOrganizationDetail()"); } } return(patientObject); }
private static void DoInsertUpdate(Sectra sectraPatient, List <WsReport> Reports) { StringBuilder serviceMessage = new StringBuilder(); // make SEL exam object WSShieldsApps.Exam exam = new WSShieldsApps.Exam(); WSShieldsApps.Location location = new WSShieldsApps.Location(); WSShieldsApps.Patient patient = new WSShieldsApps.Patient(); WSShieldsApps.Organization organization = new WSShieldsApps.Organization(); WSShieldsApps.Doctor referring = new WSShieldsApps.Doctor(); // make SEL report object WSShieldsApps.Report report = new WSShieldsApps.Report(); WSShieldsApps.Doctor radiologist = new WSShieldsApps.Doctor(); // even though we use inhertiance, it doesn't appear the WS can serialize the object setExam(exam, sectraPatient.wsExam); setLocation(location, sectraPatient.wsReferringDoctorLocation); setPatient(patient, sectraPatient.wsPatient); setDoctor(radiologist, sectraPatient.radiologistDoctor); setDoctor(referring, sectraPatient.referringDoctor); setReport(report, sectraPatient.wsReport); setOrganization(organization, sectraPatient.wsOrganization); serviceMessage.AppendLine("ACCESSION: " + exam.AccessionNo); if (referring.Npi == "" || referring.Npi == null) { // apply fake npi referring.Npi = "9999999998"; referring.FirstName = "Doctor"; referring.LastName = "Exception"; } if (radiologist.Npi == "" || radiologist.Npi == null) { // apply fake npi radiologist.EnterpriseId = 1; radiologist.Npi = "9999999999"; radiologist.FirstName = "Radiologist"; radiologist.LastName = "Exception"; } // assign the correct attributes exam.Location = location; exam.Doctor = referring; exam.Organization = organization; exam.Patient = patient; // make a new exam object WSShieldsApps.Exam exam2Object = new WSShieldsApps.Exam(); // pass the accession so we don't override exam2Object.AccessionNo = exam.AccessionNo; // get the updated exam id only exam.ExamId = ShieldsAppsDAO.GetExamByAccessionNo(exam2Object).ExamId; // put radiologist serviceMessage.AppendLine("Radiologist: " + ShieldsAppsDAO.PutDoctor(radiologist)); // put exam serviceMessage.AppendLine("Exam: " + ShieldsAppsDAO.PutExam(exam)); // post orignal report, but make sure you update the exam id and rad id report.ExamId = exam.ExamId; report.RadiologistId = radiologist.DoctorId; if (Reports.Count > 0) { serviceMessage.AppendLine("Original Report:" + ShieldsAppsDAO.PostReport(report)); } // if there is more than 1 report, then there is an addendum we need to get if (Reports.Count > 1) { // for each report text starting at "1" (0 == orignal report) get all addendums after for (int reportIteration = 1, n = Reports.Count; reportIteration < n; reportIteration++) { // set the addendum flag report.IsAddendum = true; // re-define report text and observation date report.ReportText = Reports[reportIteration].ReportText; // handle inserting of addendum report serviceMessage.AppendLine("Report Addendum " + reportIteration.ToString() + ":" + ShieldsAppsDAO.PostReport(report, reportIteration)); } } }