예제 #1
0
 public static Study GetStudyFromAccession(string accession)
 {
     var node = GetSelectedNode();
     if (node == null)
         throw new Exception("Unable to get selected DICOM node");
     StudyRootFindScu findScu = new StudyRootFindScu();
     StudyQueryIod queryMessage = new StudyQueryIod();
     queryMessage.SetCommonTags();
     queryMessage.AccessionNumber = accession;
     IList<StudyQueryIod> results = findScu.Find(node.LocalAe, node.AET, node.IP, node.Port, queryMessage);
     if (results.Count == 1)
     {
         Study st = new Study();
         st.Accession = results[0].AccessionNumber;
         st.Images = (int)results[0].NumberOfStudyRelatedInstances;
         st.PatientDob = results[0].PatientsBirthDate;
         st.PatientFirstname = results[0].PatientsName.FirstName;
         st.PatientId = results[0].PatientId;
         st.PatientSurname = results[0].PatientsName.LastName;
         st.StudyDate = results[0].StudyDate;
         st.StudyDescription = results[0].StudyDescription;
         st.StudyModality = results[0].ModalitiesInStudy;
         st.StudyUid = results[0].StudyInstanceUid;
         if (st.StudyDate != null && st.PatientDob != null)
         {
             int age = st.StudyDate.Value.Year - st.PatientDob.Value.Year;
             if (st.PatientDob.Value > st.StudyDate.Value.AddYears(-age)) age--;
             st.PatientAge = age;
         }
         StudyRootFindScu seriesFindScu = new StudyRootFindScu();
         SeriesQueryIod seriesQuery = new SeriesQueryIod();
         seriesQuery.SetCommonTags();
         seriesQuery.StudyInstanceUid = results[0].StudyInstanceUid;
         IList<SeriesQueryIod> seriesResults = seriesFindScu.Find(node.LocalAe, node.AET, node.IP, node.Port, seriesQuery);
         if (seriesResults.Count > 0)
         {
             st.Series = new List<Series>();
             foreach (var se in seriesResults)
             {
                 Series s = new Series();
                 s.StudyUid = results[0].StudyInstanceUid;
                 s.Images = (int)se.NumberOfSeriesRelatedInstances;
                 s.SeriesDescription = se.SeriesDescription;
                 s.SeriesModality = se.Modality;
                 s.SeriesUid = se.SeriesInstanceUid;
                 st.Series.Add(s);
             }
         }
         return st;
     }
     else
     {
         throw new Exception("No study found");
     }
 }
예제 #2
0
    public static List<Study> GetPatientStudiesFromId(string patientId)
    {
        var node = GetSelectedNode();
        if (node == null)
            throw new Exception("Unable to get selected DICOM node");
        StudyRootFindScu findScu = new StudyRootFindScu();
        StudyQueryIod queryMessage = new StudyQueryIod();
        queryMessage.SetCommonTags();
        queryMessage.PatientId = patientId;
        IList<StudyQueryIod> results = findScu.Find(node.LocalAe, node.AET, node.IP, node.Port, queryMessage);
        if (results.Count > 0)
        {
            List<Study> stList = new List<Study>();

            foreach(var st in results)
            {
                var nst = new Study();
                nst.Accession = st.AccessionNumber;
                nst.Images = (int)st.NumberOfStudyRelatedInstances;
                nst.PatientDob = st.PatientsBirthDate;
                nst.PatientFirstname = st.PatientsName.FirstName;
                nst.PatientId = st.PatientId;
                nst.PatientSurname = st.PatientsName.LastName;
                nst.StudyDate = st.StudyDate;
                nst.StudyDescription = st.StudyDescription;
                nst.StudyModality = st.ModalitiesInStudy;               
                nst.StudyUid = st.StudyInstanceUid;
                if (nst.StudyDate != null && nst.PatientDob != null)
                {
                    int age = nst.StudyDate.Value.Year - nst.PatientDob.Value.Year;
                    if (nst.PatientDob.Value > nst.StudyDate.Value.AddYears(-age)) age--;
                    nst.PatientAge = age;
                }
                StudyRootFindScu seriesFindScu = new StudyRootFindScu();
                SeriesQueryIod seriesQuery = new SeriesQueryIod();
                seriesQuery.SetCommonTags();
                seriesQuery.StudyInstanceUid = st.StudyInstanceUid;
                IList<SeriesQueryIod> seriesResults = seriesFindScu.Find(node.LocalAe, node.AET, node.IP, node.Port, seriesQuery);
                if (seriesResults.Count > 0)
                {
                    nst.Series = new List<Series>();
                    foreach (var se in seriesResults)
                    {
                        if((int)se.NumberOfSeriesRelatedInstances < 1) { continue; }
                        if (nst.StudyModality == "SR" && se.Modality != "SR") { nst.StudyModality = se.Modality; }
                        Series s = new Series();
                        s.StudyUid = results[0].StudyInstanceUid;
                        s.Images = (int)se.NumberOfSeriesRelatedInstances;
                        s.SeriesDescription = se.SeriesDescription;
                        s.SeriesModality = se.Modality;
                        s.SeriesUid = se.SeriesInstanceUid;
                        nst.Series.Add(s);
                    }
                }
                if (nst.StudyModality == "SR") { nst.StudyModality = ""; }
                stList.Add(nst);
            }
            return stList;
        }
        else
        {
            throw new Exception("Unable to find studies for patient on PACS");
        }
    }
예제 #3
0
 public static void DicomTestQueryStudy(string accession)
 {
     StudyRootFindScu findScu = new StudyRootFindScu();
     StudyQueryIod queryMessage = new StudyQueryIod();
     queryMessage.SetCommonTags();
     queryMessage.AccessionNumber = accession;
     IList<StudyQueryIod> results = findScu.Find("ANDYPACS3", "RMHSYNSCP", "172.28.40.151", 104, queryMessage);
     if (results.Count == 1)
     {
         Study st = new Study();
         st.Accession = results[0].AccessionNumber;
         st.Images = (int)results[0].NumberOfStudyRelatedInstances;
         st.PatientDob = results[0].PatientsBirthDate;
         st.PatientFirstname = results[0].PatientsName.FirstName;
         st.PatientId = results[0].PatientId;
         st.PatientSurname = results[0].PatientsName.LastName;
         st.StudyDate = results[0].StudyDate;
         st.StudyDescription = results[0].StudyDescription;
         st.StudyModality = results[0].ModalitiesInStudy;
         st.StudyUid = results[0].StudyInstanceUid;
         if (st.StudyDate != null && st.PatientDob != null)
         {
             int age = st.StudyDate.Value.Year - st.PatientDob.Value.Year;
             if (st.PatientDob.Value > st.StudyDate.Value.AddYears(-age)) age--;
             st.PatientAge = age;
         }            
     }
 }