// This example builds a IDbCommand // for querying the MyPatient table // The generated WHERE clause contains PatientName and PatientSex public void MyExample() { MatchingParameterCollection matchingParamCollection = new MatchingParameterCollection(); MatchingParameterList matchingParamList = new MatchingParameterList(); MyPatient myPatient = new MyPatient(); myPatient.PatientName = "Smith"; myPatient.PatientSex = "M"; matchingParamList.Add(myPatient); matchingParamCollection.Add(matchingParamList); IDbCommand command = new SqlCommand(); // This reads the storage catalog // Before you run this, make sure and add the following to your application configuration file //<configSections> // <section name="xmlStorageCatalogSettings" type="Leadtools.Medical.Storage.DataAccessLayer.XmlStorageCatalogSettings, Leadtools.Medical.Storage.DataAccessLayer" /> //</configSections> StorageCatalog myCatalog = new StorageCatalog(); Collection <CatalogElement[]> catalogElements = CatalogDescriptor.GetElementsCollection(matchingParamCollection, myCatalog, true); PreparePatientsQueryCommand(command, catalogElements, ExtraQueryOptions.Typical); // The 'WHERE' clause of command.CommandText is the following: // WHERE ( ( MyPatientTable.PatientName LIKE 'Smith' ) AND ( MyPatientTable.PatientSex LIKE 'M' ) ) Console.WriteLine(command.CommandText); }
private void btnFilter_Click(object sender, RoutedEventArgs e) { Cursor = Cursors.Wait; _viewModel.Patients.Clear(); if (_viewModel.Filter == null || _viewModel.Filter == "*") { foreach (PatientSummary patientSummary in _application.PatientSummaries) { MyPatient myPatient = new MyPatient(); myPatient.PatientId = patientSummary.Id; myPatient.LastName = patientSummary.LastName; myPatient.FirstName = patientSummary.FirstName; _viewModel.Patients.Add(myPatient); } } else { foreach (PatientSummary patientSummary in _application.PatientSummaries.Where(s => s.LastName.StartsWith(_viewModel.Filter, true, null))) { MyPatient myPatient = new MyPatient(); myPatient.PatientId = patientSummary.Id; myPatient.LastName = patientSummary.LastName; myPatient.FirstName = patientSummary.FirstName; _viewModel.Patients.Add(myPatient); } } Cursor = Cursors.Arrow; }
protected void btnApply_Click(object sender, EventArgs e) { if (GetCheckedPatient() && OnApply != null && Session["User"] != null) { patientApplyArgs.HealthIDList = GetRecordNO(); if (Session["Select"] != null) { MyPatient patient = Session["Select"] as MyPatient; patientApplyArgs.Patient = patient; } if (txtReason.Value.Trim().Length > 51) { patientApplyArgs.Reason = txtReason.Value.Trim().Substring(0, 50); } else if (txtReason.Value.Trim() == "最多输入汉字50个!!!") { patientApplyArgs.Reason = ""; } else { patientApplyArgs.Reason = txtReason.Value.Trim(); } patientApplyArgs.UserData = Session["User"] as DataTable; OnApply(sender, patientApplyArgs); lblMeg.Text = ""; txtReason.Value = "最多输入汉字50个!!!"; } else { lblMeg.Text = "请勾选病案"; } }
public MainWindow(VMS.TPS.Common.Model.API.Application Application) { _application = Application; _viewModel = new ViewModel(); InitializeComponent(); this.DataContext = _viewModel; //lstPatients.SelectedIndex = 1; //lstPlans.SelectedIndex=0; foreach (PatientSummary patientSummary in _application.PatientSummaries) { MyPatient myPatient = new MyPatient(); myPatient.PatientId = patientSummary.Id; myPatient.LastName = patientSummary.LastName; myPatient.FirstName = patientSummary.FirstName; Patient patient = _application.OpenPatient(patientSummary); foreach (Course course in patient.Courses) { MyCourse vmCourse = new MyCourse(); vmCourse.CourseId = course.Id; foreach (PlanSetup planSetup in course.PlanSetups) { vmCourse.PlanItems.Add(new MyPlanItem { pItemId = planSetup.Id, IsInScope = false, IsPlanSum = false }); } foreach (PlanSum planSum in course.PlanSums) { vmCourse.PlanItems.Add(new MyPlanItem { pItemId = planSum.Id, IsInScope = false, IsPlanSum = true }); } myPatient.Courses.Add(vmCourse); } _application.ClosePatient(); _viewModel.Patients.Add(myPatient); } OpenSelections(); }
public void ExeBindSelectRecord(DataTable data) { if (data != null) { Session["PatientData"] = new DataTable(); Session["PatientData"] = data; Session["Select"] = new MyPatient(); Session["Select"] = GetUserSelect(); Response.Redirect("PatientApplyView.aspx"); } else { lblMsg.Text = "没有您要查询的结果!"; } }
private void btnStart_Click(object sender, RoutedEventArgs e) { MyPatient myPatient = _viewModel.SelectedPatient; string patientId = myPatient.PatientId; PatientSummary patientSummary = _application.PatientSummaries.FirstOrDefault(s => s.Id == patientId); if (patientSummary == null) { return; } Patient patient = _application.OpenPatient(patientSummary); List <Course> courses = new List <Course>(); foreach (var vmCourse in _viewModel.SelectedPatient.Courses.Where(s => s.IsSelected)) { Course course = patient.Courses.FirstOrDefault(s => s.Id == vmCourse.CourseId); if (course != null) { courses.Add(course); } } if (courses.Count == 0) { MessageBox.Show("Can't find selected courses in Aria"); return; } //Plan items in scope List <PlanningItem> PlansInScope = new List <PlanningItem>(); PlanningItem pItem = null; foreach (var pitem in _viewModel.CoursePlanItems.Where(s => s.IsInScope)) { //check if planSetup foreach (var course in courses) { pItem = course.PlanSetups.FirstOrDefault(s => s.Id == pitem.pItemId); if (pItem == null) { pItem = course.PlanSums.FirstOrDefault(s => s.Id == pitem.pItemId); } if (pItem != null) { PlansInScope.Add(pItem); break; } } if (pItem == null) { MessageBox.Show("No Planning Item found with Id = " + pitem.pItemId, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } //Opened plan Item string openPlanId = string.Empty; foreach (var pitem in _viewModel.PlansInScope) { if (pitem.IsOpened) { openPlanId = pitem.pItemId; break; } } //check if planSetup foreach (var course in courses) { pItem = course.PlanSetups.FirstOrDefault(s => s.Id == openPlanId); if (pItem == null) { pItem = course.PlanSums.FirstOrDefault(s => s.Id == openPlanId); } if (pItem != null) { break; } } if (pItem == null) { MessageBox.Show("No Planning Item found with Id = " + openPlanId, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Window window = new Window(); window.Closing += WindowClosingHandler; window.Show(); //Save selections for use in next run SaveToRecent(); try { StartPlugin(patient, courses, PlansInScope, pItem, _application.CurrentUser, window); } catch (Exception ex) { MessageBox.Show("Caught exception from Script\n" + ex.Message + "\n" + ex.StackTrace); return; } }
// To use a custom database schema with the Database Manager, you must define a custom MyPrepareSearch method // and assign it to the StorageDatabaseManager.PrepareSearch delegate. After doing this, the search fields in the Database Manager //will properly refine any database manager search. The MyPrepareSearch() method gets the search fields specified in the database manager // by calling StorageDatabaseManager.GetDicomQueryParams(). This returns any query parameters specified. // The MyPrepareSearch() method then needs to create a MatchingParameterCollection that corresponds to the specified search. // Note that the database manager search fields correspond to items contained in the patient, study, and series tables only. // There are no search fields that correspond to the image table. // Therefore MyPrepareSearch() only needs to add MyPatient, MyStudy, and MySeries objects to the MatchingParameterList. // For more details, see the "Changing the LEAD Medical Storage Server to use a different database schema" tutorial. private void MyPrepareSearch(MatchingParameterCollection matchingCollection) { DicomQueryParams q = __DbManager.GetDicomQueryParams(); try { MatchingParameterList matchingList = new MatchingParameterList(); MyPatient patient = new MyPatient(); MyStudy study = new MyStudy(); MySeries series = new MySeries(); matchingList.Add(patient); matchingList.Add(study); matchingList.Add(series); matchingCollection.Add(matchingList); study.StudyAccessionNumber = q.AccessionNumber; patient.PatientIdentification = q.PatientId; if (!string.IsNullOrEmpty(q.PatientName.FamilyName)) { patient.PatientName = q.PatientName.FamilyName.TrimEnd('*') + "*"; } if (!string.IsNullOrEmpty(q.PatientName.GivenName)) { patient.PatientName = q.PatientName.GivenName.TrimEnd('*') + "*"; } if (!string.IsNullOrEmpty(q.Modalities)) { series.SeriesModality = q.Modalities.Replace(",", "\\"); } ; if (!string.IsNullOrEmpty(q.SeriesDescription)) { series.SeriesSeriesDescription = q.SeriesDescription.TrimEnd('*') + "*"; } if (!string.IsNullOrEmpty(q.ReferringPhysiciansName.FamilyName)) { study.StudyReferringPhysiciansName = q.ReferringPhysiciansName.FamilyName.TrimEnd('*') + "*"; } ; if (!string.IsNullOrEmpty(q.ReferringPhysiciansName.GivenName)) { study.StudyReferringPhysiciansName = q.ReferringPhysiciansName.GivenName.TrimEnd('*') + "*"; } ; if (q.StudyFromChecked || q.StudyToChecked) { DateRange studyDateRange = new DateRange(); if (q.StudyFromChecked) { studyDateRange.StartDate = q.StudyFromDate; } if (q.StudyToChecked) { studyDateRange.EndDate = q.StudyToDate; } study.StudyStudyDate = studyDateRange; } if (q.StorageDateChecked) { MyInstance instance = new MyInstance(); DateRange dateRange = new DateRange(); DateRangeFilter StorageDateRangeFilter = q.StorageDateRange; string startDate = StorageDateRangeFilter.DateRangeFrom; string endDate = StorageDateRangeFilter.DateRangeTo; if (StorageDateRangeFilter.SelectedDateFilter == DateRangeFilter.RangeFilterType.DateRange) { if (!string.IsNullOrEmpty(startDate)) { dateRange.StartDate = DateTime.Parse(startDate); } if (!string.IsNullOrEmpty(endDate)) { dateRange.EndDate = DateTime.Parse(endDate); } } else if (StorageDateRangeFilter.SelectedDateFilter == DateRangeFilter.RangeFilterType.Months) { DateTime lastMonthsDate = DateTime.Now.SubtractMonths(Convert.ToInt32(StorageDateRangeFilter.LastMonths)); dateRange.StartDate = lastMonthsDate; dateRange.EndDate = DateTime.Now; } else { TimeSpan subtractionDays = new TimeSpan(Convert.ToInt32(StorageDateRangeFilter.LastDays), DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); dateRange.StartDate = DateTime.Now.Subtract(subtractionDays); dateRange.EndDate = DateTime.Now; } instance.ImageLastStoreDate = dateRange; matchingList.Add(instance); } study.StudyStudyId = q.StudyId; } catch (Exception exception) { throw exception; } finally { // do nothing ; } }
/// <summary> /// 根据病人条件查询病案资料 /// </summary> /// <param name="patient"></param> /// <returns></returns> public DataTable QueryPatient(MyPatient patient) { string str = ""; if (patient.StartDate != DateTime.MinValue) { str = str + " and p.out_hospital_date between to_date('" + patient.StartDate.ToShortDateString() + "','yyyy/MM/dd') and to_date('" + patient.EndDate.ToShortDateString() + "','yyyy/MM/dd')"; } if (patient.RecordNO != null) { str = str + " and p.recordno='" + patient.RecordNO + "'"; } if (patient.PatientID != null) { str = str + " and p.patient_id='" + patient.PatientID + "'"; } if (patient.CYZD != null && patient.ZLJG == null) { str = str + " and (p.outdia_name1 like '%" + patient.CYZD + "%' or p.outdia_name2 like '%" + patient.CYZD + "%' or p.outdia_name3 like '%" + patient.CYZD + "%' or p.outdia_name4 like '%" + patient.CYZD + "%') "; } else if (patient.CYZD != null && patient.ZLJG != null) { str = str + " and ((p.outdia_name1 like '%" + patient.CYZD + "%' and p.treat_result1 = '" + patient.ZLJG + "') or (p.outdia_name2 like '%" + patient.CYZD + "%' and p.treat_result2 = '" + patient.ZLJG + "') or (p.outdia_name3 like '%" + patient.CYZD + "%' and p.treat_result3 = '" + patient.ZLJG + "') or (p.outdia_name4 like '%" + patient.CYZD + "%' and p.treat_result4 = '" + patient.ZLJG + "'))"; } else if (patient.ZLJG != null && patient.CYZD == null) { str = str + " and (p.treat_result1= '" + patient.ZLJG + "' or p.treat_result2= '" + patient.ZLJG + "' or p.treat_result3= '" + patient.ZLJG + "' or p.treat_result4 = '" + patient.ZLJG + "')"; } if (patient.SSMC != null) { str = str + " and (p.surgery_name1 like '%" + patient.SSMC + "%' or p.surgery_name2 like '%" + patient.SSMC + "%' or p.surgery_name3 like '%" + patient.SSMC + "%' or p.surgery_name4 like '%" + patient.SSMC + "%') "; } if (patient.YNGR != null) { str = str + " and (p.yngr_name1 like '%" + patient.YNGR + "%' or p.yngr_name2 like '%" + patient.YNGR + "%')"; } if (patient.BLZD != null) { str = str + " and (p.blzd_name1 like '%" + patient.BLZD + "%' or p.blzd_name2 like '%" + patient.BLZD + "%')"; } if (patient.PatientName != null) { str = str + " and p.patient_name like '%" + patient.PatientName + "%'"; } if (patient.Provice != null) { str = str + " and p.province='" + patient.Provice + "'"; } if (patient.City != null) { str = str + " and p.city='" + patient.City + "'"; } if (patient.RYDept != null) { str = str + " and p.in_hospital_dept='" + patient.RYDept + "'"; } if (patient.RYDoctor != null) { str = str + " and p.in_hospital_doctor='" + patient.RYDoctor + "'"; } if (patient.CYDept != null) { str = str + " and p.out_hospital_dept='" + patient.CYDept + "'"; } if (patient.CYDoctor != null) { str = str + " and p.out_hospital_doctor='" + patient.CYDoctor + "'"; } if (str.Length == 0) { str = str + " and 1=0"; } string newsqlStr = string.Format(SqlTools.SqlQueryPatient, str); DataTable dtResult = CJia.DefaultOleDb.Query(newsqlStr); if (dtResult != null && dtResult.Rows.Count > 0) { return(dtResult); } else { return(null); } //string str = ""; //if (patient.StartDate != DateTime.MinValue) //{ // str = str + " and p.out_hospital_date between to_date('" + patient.StartDate.ToShortDateString() + "','yyyy/MM/dd') and to_date('" + patient.EndDate.ToShortDateString() + "','yyyy/MM/dd')"; //} //if (patient.RecordNO != null) //{ // str = str + " and p.recordno='" + patient.RecordNO + "'"; //} //if (patient.PatientID != null) //{ // str = str + " and p.patient_id='" + patient.PatientID + "'"; //} //if (patient.CYZD != null && patient.ZLJG == null) //{ // str = str + " and (p.outdia_name1 like '%" + patient.CYZD + "%' or p.outdia_name2 like '%" + patient.CYZD + "%' or p.outdia_name3 like '%" + patient.CYZD + "%' or p.outdia_name4 like '%" + patient.CYZD + "%') "; //} //else if (patient.CYZD != null && patient.ZLJG != null) //{ // str = str + " and ((p.outdia_name1 like '%" + patient.CYZD + "%' and p.treat_result1 = '" + patient.ZLJG + "') or (p.outdia_name2 like '%" + patient.CYZD + "%' and p.treat_result2 = '" + patient.ZLJG + "') or (p.outdia_name3 like '%" + patient.CYZD + "%' and p.treat_result3 = '" + patient.ZLJG + "') or (p.outdia_name4 like '%" + patient.CYZD + "%' and p.treat_result4 = '" + patient.ZLJG + "'))"; //} //else if (patient.ZLJG != null && patient.CYZD == null) //{ // str = str + " and (p.treat_result1= '" + patient.ZLJG + "' or p.treat_result2= '" + patient.ZLJG + "' or p.treat_result3= '" + patient.ZLJG + "' or p.treat_result4 = '" + patient.ZLJG + "')"; //} //if (patient.SSMC != null) //{ // str = str + " and (p.surgery_name1 like '%" + patient.SSMC + "%' or p.surgery_name2 like '%" + patient.SSMC + "%' or p.surgery_name3 like '%" + patient.SSMC + "%' or p.surgery_name4 like '%" + patient.SSMC + "%') "; //} //if (patient.YNGR != null) //{ // str = str + " and (p.yngr_name1 like '%" + patient.YNGR + "%' or p.yngr_name2 like '%" + patient.YNGR + "%')"; //} //if (patient.BLZD != null) //{ // str = str + " and (p.blzd_name1 like '%" + patient.BLZD + "%' or p.blzd_name2 like '%" + patient.BLZD + "%')"; //} //if (patient.PatientName != null) //{ // str = str + " and p.patient_name like '%" + patient.BLZD + "%'"; //} //if (patient.Provice != null) //{ // str = str + " and p.province='" + patient.Provice + "'"; //} //if (patient.City != null) //{ // str = str + " and p.city='" + patient.City + "'"; //} //if (patient.RYDept != null) //{ // str = str + " and p.in_hospital_dept='" + patient.RYDept + "'"; //} //if (patient.RYDoctor != null) //{ // str = str + " and p.in_hospital_doctor='" + patient.RYDoctor + "'"; //} //if (patient.CYDept != null) //{ // str = str + " and p.out_hospital_dept='" + patient.CYDept + "'"; //} //if (patient.CYDoctor != null) //{ // str = str + " and p.out_hospital_doctor='" + patient.CYDoctor + "'"; //} //if (str.Length == 0) //{ // str = str + " and 1=0"; //} //string newsqlStr = string.Format(SqlTools.SqlQueryPatient, str); //DataTable dtResult = CJia.DefaultOleDb.Query(newsqlStr); //if (dtResult != null && dtResult.Rows.Count > 0) //{ // return dtResult; //} //else //{ // return null; //} }
private void btnStart_Click(object sender, RoutedEventArgs e) { MyPatient myPatient = _viewModel.SelectedPatient; string patientId = myPatient.PatientId; PatientSummary patientSummary = _application.PatientSummaries.FirstOrDefault(s => s.Id == patientId); if (patientSummary == null) { return; } Patient patient = _application.OpenPatient(patientSummary); Course course = patient.Courses.FirstOrDefault(s => s.Id == _viewModel.SelectedCourse.CourseId); if (course == null) { MessageBox.Show("Can't find selected course in Aria"); return; } //planId items in scope List <PlanSetup> PlansInScope = new List <PlanSetup>(); foreach (var pitem in _viewModel.PlansInScope) { //check if planSetup PlanSetup plan = (PlanSetup)course.PlanSetups.FirstOrDefault(s => s.Id == pitem.pItemId); if (plan != null) { PlansInScope.Add(plan); } } //Opened plan Item string openPlanId = string.Empty; foreach (var pitem in _viewModel.PlansInScope) { if (pitem.IsOpened) { openPlanId = pitem.pItemId; break; } } //check if planSetup PlanSetup openedPlan = course.PlanSetups.FirstOrDefault(s => s.Id == openPlanId); if (openedPlan == null) { MessageBox.Show("No PlanSetup found with Id = " + openPlanId, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Window window = new Window(); window.Closing += WindowClosingHandler; window.Show(); //Save selections for use in next run SaveSelections(); try { VMS.TPS.Script.Start(patient, course, PlansInScope, openedPlan, _application.CurrentUser, window); } catch (Exception ex) { MessageBox.Show("Caught exception from Script\n" + ex.Message + "\n" + ex.StackTrace); return; } }
/// <summary> /// 获得查询条件 /// </summary> public MyPatient GetUserSelect() { MyPatient patient = new MyPatient(); if (txtRecordNO.Text.Trim().Length > 0)//ckRecord.Checked && { patient.RecordNO = txtRecordNO.Text.Trim(); } //if (ckPatientID.Checked && txtPatientID.Text.Trim().Length > 0) //{ // patient.PatientID = txtPatientID.Text.Trim(); //} if (startDate.Text.Trim().Length > 0 && endDate.Text.Trim().Length > 0)//ckDate.Checked && { DateTime date = DateTime.Parse(startDate.Text.Trim()); DateTime date1 = DateTime.Parse(endDate.Text.Trim()); patient.StartDate = DateTime.Parse(date.Year.ToString() + "/" + date.Month.ToString() + "/" + date.Day.ToString()); patient.EndDate = DateTime.Parse(date1.Year.ToString() + "/" + date1.Month.ToString() + "/" + date1.Day.ToString()); } if (CYZD.Text.Trim().Length > 0)//ckCYZD.Checked && { patient.CYZD = CYZD.Text.Trim(); } //if (ckYNGR.Checked && YNGR.Text.Trim().Length > 0) //{ // patient.YNGR = YNGR.Text.Trim(); //} if (SSMC.Text.Trim().Length > 0)//ckSSMC.Checked && { patient.SSMC = SSMC.Text.Trim(); } //if (ckZLJG.Checked && cbZLJG.SelectedValue.Length > 0) //{ // patient.ZLJG = cbZLJG.SelectedValue; //} //if (ckBLZD.Checked && BLZD.Text.Trim().Length > 0) //{ // patient.BLZD = BLZD.Text.Trim(); //} if (ckPatientName.Checked && txtPatientName.Text.Trim().Length > 0) { patient.PatientName = txtPatientName.Text.Trim(); } //if (cbSheng.SelectedValue.Length > 0)//ckBirth.Checked && //{ // patient.Provice = cbSheng.SelectedValue; // if (cbShi.SelectedValue.Length > 0) // { // patient.City = cbShi.SelectedValue; // } //} if (cbRYKS.SelectedValue.Length > 0 && cbRYKS.SelectedValue != "0")//ckRYDept.Checked && { patient.RYDept = cbRYKS.SelectedValue; } //if (ckRYDoctor.Checked && cbRYYS.SelectedValue.Length > 0) //{ // patient.RYDoctor = cbRYYS.SelectedValue; //} if (cbCYKS.SelectedValue.Length > 0 && cbCYKS.SelectedValue != "0")//ckCYDept.Checked && { patient.CYDept = cbCYKS.SelectedValue; } //if (ckCYDoctor.Checked && cbCYYS.SelectedValue.Length > 0) //{ // patient.CYDoctor = cbCYYS.SelectedValue; //} return(patient); }
// Returns a DataSet that reflects the existence of PatientID, StudyInstanceUID, SeriesInstanceUID, and SOPInstanceUID // * If the patient does not exist, returns an empty DataSet // * If patient exists but no study returns a DataSet where MyPatientTable has row with PatientID of DicomDataSet // * If patient exists, study exists but no series, returns a DataSet that has PatientID (MyPatientTable), and StudyInstanceUID (MyStudyTable) // * If patient, study, series exist but no Instance, returns a DataSet with PatientID, StudyInstanceUID, and SeriesInstanceUID // * If patinet, study series, instance exist, returns empty dataset private DataSet GetUpdateDataSet ( DicomDataSet ds, bool updateExistentPatient, bool updateExistentStudy, bool updateExistentSeries, bool updateExistentInstances ) { MatchingParameterCollection matchingEntitiesCollection = new MatchingParameterCollection(); MatchingParameterList matchingEntitiesList = new MatchingParameterList(); matchingEntitiesCollection.Add(matchingEntitiesList); MyInstance instance = new MyInstance(); instance.SOPInstanceUID = ds.MyGetStringValue(DicomTag.SOPInstanceUID); bool instanceExists = IsCompositeInstancesExists(instance.SOPInstanceUID); if (instanceExists) { matchingEntitiesList.Add(instance); DeleteInstance(matchingEntitiesCollection); matchingEntitiesList.Remove(instance); instanceExists = false; } MyPatient patient = new MyPatient(); patient.PatientIdentification = ds.MyGetStringValue(DicomTag.PatientID); if (null != patient.PatientIdentification) { matchingEntitiesList.Add(patient); } bool patientExist = IsPatientsExists(patient.PatientIdentification); if (updateExistentPatient && patientExist) { // case #1 return(QueryCompositeInstances(matchingEntitiesCollection)); } else if (!patientExist) { // case #2 return(new MyDataSet()); } else { // case #3 // (!updateExistentPatient) && (patientExist) // int ? patientId = GetIntValue(patient.PatientIdentification); MyStudy study = new MyStudy(); study.StudyStudyInstanceUID = ds.MyGetStringValue(DicomTag.StudyInstanceUID); if (null != study.StudyStudyInstanceUID) { matchingEntitiesList.Add(study); } bool studyExists = IsStudyExists(study.StudyStudyInstanceUID); if (updateExistentStudy && studyExists) { return(QueryCompositeInstances(matchingEntitiesCollection)); } else if (!studyExists) { if (matchingEntitiesList.Contains(study)) { matchingEntitiesList.Remove(study); } return(QueryPatients(matchingEntitiesCollection)); } else { MySeries series = new MySeries(); series.SeriesSeriesInstanceUID = ds.MyGetStringValue(DicomTag.SeriesInstanceUID); if (!string.IsNullOrEmpty(series.SeriesSeriesInstanceUID)) { matchingEntitiesList.Add(series); } bool seriesExists = IsSeriesExists(series.SeriesSeriesInstanceUID); if (updateExistentSeries && seriesExists) { return(QueryCompositeInstances(matchingEntitiesCollection)); } else if (!seriesExists) { if (matchingEntitiesList.Contains(series)) { matchingEntitiesList.Remove(series); } return(QueryStudies(matchingEntitiesCollection)); } else { if (!string.IsNullOrEmpty(instance.SOPInstanceUID)) { matchingEntitiesList.Add(instance); } if (updateExistentInstances && instanceExists) { return(QueryCompositeInstances(matchingEntitiesCollection)); } else { MyDataSet.MyPatientTableRow patientRow; MyDataSet.MyStudyTableRow studyRow; MyDataSet.MySeriesTableRow seriesRow; MyDataSet myDataSet = new MyDataSet(); myDataSet.EnforceConstraints = false; myDataSet.MyPatientTable.BeginLoadData(); myDataSet.MyStudyTable.BeginLoadData(); myDataSet.MySeriesTable.BeginLoadData(); myDataSet.MyInstanceTable.BeginLoadData(); patientRow = myDataSet.MyPatientTable.AddMyPatientTableRow(patient.PatientIdentification, string.Empty, DateTime.MinValue, string.Empty, string.Empty); //if (patientId != null) //{ // patientRow.PatientId = patientId.Value; //} //dicomDataSet.MyPatientTable.Rows[0]["PatientId"] = patientId; studyRow = myDataSet.MyStudyTable.AddMyStudyTableRow(patientRow, study.StudyStudyInstanceUID, DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty); seriesRow = myDataSet.MySeriesTable.AddMySeriesTableRow( studyRow, series.SeriesSeriesInstanceUID, string.Empty, 0, string.Empty, DateTime.MinValue, string.Empty); //1. if updateInstance and instance exist not valid (will be in the above IF //2. if updateInstance and instance NOT exist don't fill from Db //3. if NOT updateInstance and instance exist then insert SOP Instance UID //4. if NOT updateInstnace and NOT instance exist then don't fill from Db //case 3 above if (instanceExists) { myDataSet.MyInstanceTable.AddMyInstanceTableRow(seriesRow, instance.SOPInstanceUID, 0, DateTime.MinValue, string.Empty, string.Empty, 0, 0, 0); } myDataSet.AcceptChanges(); myDataSet.MyPatientTable.EndLoadData(); myDataSet.MyStudyTable.EndLoadData(); myDataSet.MySeriesTable.EndLoadData(); myDataSet.MyInstanceTable.EndLoadData(); myDataSet.EnforceConstraints = true; return(myDataSet); } } } } }