Ejemplo n.º 1
0
        public static bool LookLikeSameNames(string name1, string name2)
        {
            name1 = StringUtilities.EmptyIfNull(name1);
            name2 = StringUtilities.EmptyIfNull(name2);
            string normalizedS1 = DicomNameUtils.Normalize(name1, DicomNameUtils.NormalizeOptions.TrimEmptyEndingComponents | DicomNameUtils.NormalizeOptions.TrimSpaces);
            string normalizedS2 = DicomNameUtils.Normalize(name2, DicomNameUtils.NormalizeOptions.TrimEmptyEndingComponents | DicomNameUtils.NormalizeOptions.TrimSpaces);


            // if both have "^", may need manual reconciliation
            // eg: "John ^ Smith" vs  "John  Smith^^" ==> manual
            //     "John ^ Smith" vs  "John ^ Smith^^" ==> auto
            if (name1.Contains("^") && name2.Contains("^"))
            {
                PersonName n1 = new PersonName(normalizedS1);
                PersonName n2 = new PersonName(normalizedS2);
                if (n1.AreSame(n2, PersonNameComparisonOptions.CaseInsensitive))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }


            if (normalizedS1.Length != normalizedS2.Length)
            {
                return(false);
            }

            normalizedS1 = normalizedS1.ToUpper();
            normalizedS2 = normalizedS2.ToUpper();

            if (normalizedS1.Equals(normalizedS2))
            {
                return(true);
            }

            for (int i = 0; i < normalizedS1.Length; i++)
            {
                // If S1[i] is ^ or space, S2[i] must be either ^ or space to be considered being the same
                // Otherwise, S1[i] must be the same as S2[i].
                if (normalizedS1[i] == '^' || normalizedS1[i] == ' ')
                {
                    if (normalizedS2[i] != '^' && normalizedS2[i] != ' ')
                    {
                        return(false);
                    }
                }
                else
                {
                    if (normalizedS1[i] != normalizedS2[i])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public static bool LookLikeSameNames(string name1, string name2)
        {
            name1 = StringUtilities.EmptyIfNull(name1);
            name2 = StringUtilities.EmptyIfNull(name2);
            string normalizedS1 = DicomNameUtils.Normalize(name1, DicomNameUtils.NormalizeOptions.TrimEmptyEndingComponents | DicomNameUtils.NormalizeOptions.TrimSpaces);
            string normalizedS2 = DicomNameUtils.Normalize(name2, DicomNameUtils.NormalizeOptions.TrimEmptyEndingComponents | DicomNameUtils.NormalizeOptions.TrimSpaces);


            // if both have "^", may need manual reconciliation
            // eg: "John ^ Smith" vs  "John  Smith^^" ==> manual
            //     "John ^ Smith" vs  "John ^ Smith^^" ==> auto
            if (name1.Contains("^") && name2.Contains("^"))
            {
                PersonName n1 = new PersonName(normalizedS1);
                PersonName n2 = new PersonName(normalizedS2);
                if (n1.AreSame(n2, PersonNameComparisonOptions.CaseInsensitive))
                    return true;
                else
                    return false;
            }


            if (normalizedS1.Length != normalizedS2.Length) return false;

            normalizedS1 = normalizedS1.ToUpper();
            normalizedS2 = normalizedS2.ToUpper();

            if (normalizedS1.Equals(normalizedS2))
                return true;

            for (int i = 0; i < normalizedS1.Length; i++)
            {
                // If S1[i] is ^ or space, S2[i] must be either ^ or space to be considered being the same
                // Otherwise, S1[i] must be the same as S2[i].
                if (normalizedS1[i] == '^' || normalizedS1[i] == ' ')
                {
                    if (normalizedS2[i] != '^' && normalizedS2[i] != ' ')
                        return false;
                }
                else
                {
                    if (normalizedS1[i] != normalizedS2[i])
                        return false;

                }
            }
            return true;
        }
        private List<UpdateItem> GetChanges()
        {
            var changes = new List<UpdateItem>();
            var oldPatientName = new PersonName(Study.PatientsName);
            var newPatientName = PatientNamePanel.PersonName;

            if (!oldPatientName.AreSame(newPatientName, PersonNameComparisonOptions.CaseInsensitive))
            {
                var item = new UpdateItem(DicomTags.PatientsName, Study.PatientsName, PatientNamePanel.PersonName);
                changes.Add(item);
            }

            String dicomBirthDate = !(string.IsNullOrEmpty(PatientBirthDate.Text))
                                        ? DateTime.ParseExact(PatientBirthDate.Text, InputDateParser.DateFormat, null).ToString(DicomConstants.DicomDate)
                                        : "";
            if (AreDifferent(Study.PatientsBirthDate, dicomBirthDate))
            {
                var item = new UpdateItem(DicomTags.PatientsBirthDate, Study.PatientsBirthDate, dicomBirthDate);
                changes.Add(item);
            }

            string newPatientAge = String.IsNullOrEmpty(PatientAge.Text)? String.Empty:String.Format("{0}{1}", PatientAge.Text.PadLeft(3, '0'), PatientAgePeriod.SelectedValue);

            if (AreDifferent(Study.PatientsAge, newPatientAge))
            {
                var item = new UpdateItem(DicomTags.PatientsAge, Study.PatientsAge, newPatientAge);
                changes.Add(item);
            }

            // PatientGender is a required field.
            if (AreDifferent(Study.PatientsSex, PatientGender.Text))
            {
                var item = new UpdateItem(DicomTags.PatientsSex, Study.PatientsSex, PatientGender.Text);
                changes.Add(item);
            }

            //PatientID.Text is a required field.
            if (AreDifferent(Study.PatientId, PatientID.Text))
            {
                var item = new UpdateItem(DicomTags.PatientId, Study.PatientId, PatientID.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.StudyDescription, StudyDescription.Text))
            {
                var item = new UpdateItem(DicomTags.StudyDescription, Study.StudyDescription, StudyDescription.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.StudyId, StudyID.Text))
            {
                var item = new UpdateItem(DicomTags.StudyId, Study.StudyId, StudyID.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.AccessionNumber, AccessionNumber.Text))
            {
                var item = new UpdateItem(DicomTags.AccessionNumber, Study.AccessionNumber, AccessionNumber.Text);
                changes.Add(item);
            }

            var oldPhysicianName = new PersonName(Study.ReferringPhysiciansName);
            var newPhysicianName = ReferringPhysicianNamePanel.PersonName;

            if (!newPhysicianName.AreSame(oldPhysicianName, PersonNameComparisonOptions.CaseInsensitive))
            {
                var item = new UpdateItem(DicomTags.ReferringPhysiciansName, Study.ReferringPhysiciansName, ReferringPhysicianNamePanel.PersonName.ToString());
                changes.Add(item);
            }

            string newDicomStudyDate=string.Empty;
            if (!string.IsNullOrEmpty(StudyDate.Text))
            {
                DateTime newStudyDate;
                newDicomStudyDate = InputDateParser.TryParse(StudyDate.Text, out newStudyDate)
                                        ? newStudyDate.ToString(DicomConstants.DicomDate)
                                        : string.Empty;
            }

            if (AreDifferent(Study.StudyDate, newDicomStudyDate))
            {
                var item = new UpdateItem(DicomTags.StudyDate, Study.StudyDate, newDicomStudyDate);
                changes.Add(item);
            }

            int hh = String.IsNullOrEmpty(StudyTimeHours.Text)? 0:int.Parse(StudyTimeHours.Text);
            int mm = int.Parse(StudyTimeMinutes.Text);
            int ss = int.Parse(StudyTimeSeconds.Text);
            String dicomStudyTime = String.Format("{0:00}{1:00}{2:00}", hh, mm, ss);

            if (AreDifferent(Study.StudyTime, dicomStudyTime))
            {
                var item = new UpdateItem(DicomTags.StudyTime, Study.StudyTime, dicomStudyTime);
                changes.Add(item);
            }

            return changes;
        }
Ejemplo n.º 4
0
        private List <UpdateItem> GetChanges()
        {
            var changes        = new List <UpdateItem>();
            var oldPatientName = new PersonName(Study.PatientsName);
            var newPatientName = PatientNamePanel.PersonName;

            if (!oldPatientName.AreSame(newPatientName, PersonNameComparisonOptions.CaseInsensitive))
            {
                var item = new UpdateItem(DicomTags.PatientsName, Study.PatientsName, PatientNamePanel.PersonName);
                changes.Add(item);
            }

            String dicomBirthDate = !(string.IsNullOrEmpty(PatientBirthDate.Text))
                                        ? DateTime.ParseExact(PatientBirthDate.Text, InputDateParser.DateFormat, null).ToString(DicomConstants.DicomDate)
                                        : "";

            if (AreDifferent(Study.PatientsBirthDate, dicomBirthDate))
            {
                var item = new UpdateItem(DicomTags.PatientsBirthDate, Study.PatientsBirthDate, dicomBirthDate);
                changes.Add(item);
            }

            string newPatientAge = String.IsNullOrEmpty(PatientAge.Text)? String.Empty:String.Format("{0}{1}", PatientAge.Text.PadLeft(3, '0'), PatientAgePeriod.SelectedValue);

            if (AreDifferent(Study.PatientsAge, newPatientAge))
            {
                var item = new UpdateItem(DicomTags.PatientsAge, Study.PatientsAge, newPatientAge);
                changes.Add(item);
            }

            // PatientGender is a required field.
            if (AreDifferent(Study.PatientsSex, PatientGender.Text))
            {
                var item = new UpdateItem(DicomTags.PatientsSex, Study.PatientsSex, PatientGender.Text);
                changes.Add(item);
            }

            //PatientID.Text is a required field.
            if (AreDifferent(Study.PatientId, PatientID.Text))
            {
                var item = new UpdateItem(DicomTags.PatientId, Study.PatientId, PatientID.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.StudyDescription, StudyDescription.Text))
            {
                var item = new UpdateItem(DicomTags.StudyDescription, Study.StudyDescription, StudyDescription.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.StudyId, StudyID.Text))
            {
                var item = new UpdateItem(DicomTags.StudyId, Study.StudyId, StudyID.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.AccessionNumber, AccessionNumber.Text))
            {
                var item = new UpdateItem(DicomTags.AccessionNumber, Study.AccessionNumber, AccessionNumber.Text);
                changes.Add(item);
            }

            var oldPhysicianName = new PersonName(Study.ReferringPhysiciansName);
            var newPhysicianName = ReferringPhysicianNamePanel.PersonName;

            if (!newPhysicianName.AreSame(oldPhysicianName, PersonNameComparisonOptions.CaseInsensitive))
            {
                var item = new UpdateItem(DicomTags.ReferringPhysiciansName, Study.ReferringPhysiciansName, ReferringPhysicianNamePanel.PersonName.ToString());
                changes.Add(item);
            }

            string newDicomStudyDate = string.Empty;

            if (!string.IsNullOrEmpty(StudyDate.Text))
            {
                DateTime newStudyDate;
                newDicomStudyDate = InputDateParser.TryParse(StudyDate.Text, out newStudyDate)
                                        ? newStudyDate.ToString(DicomConstants.DicomDate)
                                        : string.Empty;
            }

            if (AreDifferent(Study.StudyDate, newDicomStudyDate))
            {
                var item = new UpdateItem(DicomTags.StudyDate, Study.StudyDate, newDicomStudyDate);
                changes.Add(item);
            }

            int    hh             = String.IsNullOrEmpty(StudyTimeHours.Text)? 0:int.Parse(StudyTimeHours.Text);
            int    mm             = int.Parse(StudyTimeMinutes.Text);
            int    ss             = int.Parse(StudyTimeSeconds.Text);
            String dicomStudyTime = String.Format("{0:00}{1:00}{2:00}", hh, mm, ss);

            if (AreDifferent(Study.StudyTime, dicomStudyTime))
            {
                var item = new UpdateItem(DicomTags.StudyTime, Study.StudyTime, dicomStudyTime);
                changes.Add(item);
            }

            return(changes);
        }
        private List<UpdateItem> GetChanges()
        {
            var changes = new List<UpdateItem>();
            var oldPatientName = new PersonName(Study.PatientsName);
            var newPatientName = PatientNamePanel.PersonName;

            if (!oldPatientName.AreSame(newPatientName, PersonNameComparisonOptions.CaseSensitive))
            {
                var item = new UpdateItem(DicomTags.PatientsName, Study.PatientsName, PatientNamePanel.PersonName);
                changes.Add(item);
            }

	        String dicomBirthDate = string.IsNullOrEmpty(PatientBirthDate.Text)
		        ? ""
		        : DateTime.Parse(PatientBirthDate.Text).ToString(DicomConstants.DicomDate, CultureInfo.InvariantCulture);

            if (AreDifferent(Study.PatientsBirthDate, dicomBirthDate))
            {
                var item = new UpdateItem(DicomTags.PatientsBirthDate, Study.PatientsBirthDate, dicomBirthDate);
                changes.Add(item);
            }

            string newPatientAge = String.IsNullOrEmpty(PatientAge.Text)? String.Empty:String.Format("{0}{1}", PatientAge.Text.PadLeft(3, '0'), PatientAgePeriod.SelectedValue);

            if (AreDifferent(Study.PatientsAge, newPatientAge))
            {
                var item = new UpdateItem(DicomTags.PatientsAge, Study.PatientsAge, newPatientAge);
                changes.Add(item);
            }

            // PatientGender is a required field.
            if (AreDifferent(Study.PatientsSex, PatientGender.Text))
            {
                var item = new UpdateItem(DicomTags.PatientsSex, Study.PatientsSex, PatientGender.Text);
                changes.Add(item);
            }

            //PatientID.Text is a required field.
            if (AreDifferent(Study.PatientId, PatientID.Text))
            {
                var item = new UpdateItem(DicomTags.PatientId, Study.PatientId, PatientID.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.StudyDescription, StudyDescription.Text))
            {
                var item = new UpdateItem(DicomTags.StudyDescription, Study.StudyDescription, StudyDescription.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.StudyId, StudyID.Text))
            {
                var item = new UpdateItem(DicomTags.StudyId, Study.StudyId, StudyID.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.AccessionNumber, AccessionNumber.Text))
            {
                var item = new UpdateItem(DicomTags.AccessionNumber, Study.AccessionNumber, AccessionNumber.Text);
                changes.Add(item);
            }

            var oldPhysicianName = new PersonName(Study.ReferringPhysiciansName);
            var newPhysicianName = ReferringPhysicianNamePanel.PersonName;

            if (!newPhysicianName.AreSame(oldPhysicianName, PersonNameComparisonOptions.CaseSensitive))
            {
                var item = new UpdateItem(DicomTags.ReferringPhysiciansName, Study.ReferringPhysiciansName, ReferringPhysicianNamePanel.PersonName.ToString());
                changes.Add(item);
            }

            string newDicomStudyDate=string.Empty;
            if (!string.IsNullOrEmpty(StudyDate.Text))
            {
                DateTime newStudyDate;
                newDicomStudyDate = InputDateParser.TryParse(StudyDate.Text, out newStudyDate)
                                        ? newStudyDate.ToString(DicomConstants.DicomDate, CultureInfo.InvariantCulture) /* to ISO yyyyMMdd */
                                        : string.Empty;
            }

            if (AreDifferent(Study.StudyDate, newDicomStudyDate))
            {
                var item = new UpdateItem(DicomTags.StudyDate, Study.StudyDate, newDicomStudyDate);
                changes.Add(item);
            }

            int hh = String.IsNullOrEmpty(StudyTimeHours.Text)? 0:int.Parse(StudyTimeHours.Text);
            int mm = String.IsNullOrEmpty(StudyTimeMinutes.Text) ? 0 : int.Parse(StudyTimeMinutes.Text);
            int ss = String.IsNullOrEmpty(StudyTimeSeconds.Text) ? 0 : int.Parse(StudyTimeSeconds.Text);
            String dicomStudyTime = String.Format("{0:00}{1:00}{2:00}", hh, mm, ss);

            // #9475 : if fraction is in the original time, it should be preserved unless the hours, minutes or seconds are modified.
            var originalTime = Study.StudyTime;
            if (!string.IsNullOrEmpty(originalTime) && originalTime.Contains("."))
            {
                originalTime = originalTime.Substring(0, originalTime.IndexOf(".", StringComparison.InvariantCultureIgnoreCase));
            }

            if (AreDifferent(originalTime, dicomStudyTime))
            {
                var item = new UpdateItem(DicomTags.StudyTime, Study.StudyTime, dicomStudyTime);
                changes.Add(item);
            }

            return changes;
        }
Ejemplo n.º 6
0
        private List <UpdateItem> GetChanges()
        {
            var changes        = new List <UpdateItem>();
            var oldPatientName = new PersonName(Study.PatientsName);
            var newPatientName = PatientNamePanel.PersonName;

            if (!oldPatientName.AreSame(newPatientName, PersonNameComparisonOptions.CaseSensitive))
            {
                var item = new UpdateItem(DicomTags.PatientsName, Study.PatientsName, PatientNamePanel.PersonName);
                changes.Add(item);
            }

            String dicomBirthDate = string.IsNullOrEmpty(PatientBirthDate.Text)
                        ? ""
                        : DateTime.Parse(PatientBirthDate.Text).ToString(DicomConstants.DicomDate, CultureInfo.InvariantCulture);

            if (AreDifferent(Study.PatientsBirthDate, dicomBirthDate))
            {
                var item = new UpdateItem(DicomTags.PatientsBirthDate, Study.PatientsBirthDate, dicomBirthDate);
                changes.Add(item);
            }

            string newPatientAge = String.IsNullOrEmpty(PatientAge.Text)? String.Empty:String.Format("{0}{1}", PatientAge.Text.PadLeft(3, '0'), PatientAgePeriod.SelectedValue);

            if (AreDifferent(Study.PatientsAge, newPatientAge))
            {
                var item = new UpdateItem(DicomTags.PatientsAge, Study.PatientsAge, newPatientAge);
                changes.Add(item);
            }

            // PatientGender is a required field.
            if (AreDifferent(Study.PatientsSex, PatientGender.Text))
            {
                var item = new UpdateItem(DicomTags.PatientsSex, Study.PatientsSex, PatientGender.Text);
                changes.Add(item);
            }

            //PatientID.Text is a required field.
            if (AreDifferent(Study.PatientId, PatientID.Text))
            {
                var item = new UpdateItem(DicomTags.PatientId, Study.PatientId, PatientID.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.StudyDescription, StudyDescription.Text))
            {
                var item = new UpdateItem(DicomTags.StudyDescription, Study.StudyDescription, StudyDescription.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.StudyId, StudyID.Text))
            {
                var item = new UpdateItem(DicomTags.StudyId, Study.StudyId, StudyID.Text);
                changes.Add(item);
            }

            if (AreDifferent(Study.AccessionNumber, AccessionNumber.Text))
            {
                var item = new UpdateItem(DicomTags.AccessionNumber, Study.AccessionNumber, AccessionNumber.Text);
                changes.Add(item);
            }

            var oldPhysicianName = new PersonName(Study.ReferringPhysiciansName);
            var newPhysicianName = ReferringPhysicianNamePanel.PersonName;

            if (!newPhysicianName.AreSame(oldPhysicianName, PersonNameComparisonOptions.CaseSensitive))
            {
                var item = new UpdateItem(DicomTags.ReferringPhysiciansName, Study.ReferringPhysiciansName, ReferringPhysicianNamePanel.PersonName.ToString());
                changes.Add(item);
            }

            string newDicomStudyDate = string.Empty;

            if (!string.IsNullOrEmpty(StudyDate.Text))
            {
                DateTime newStudyDate;
                newDicomStudyDate = InputDateParser.TryParse(StudyDate.Text, out newStudyDate)
                                        ? newStudyDate.ToString(DicomConstants.DicomDate, CultureInfo.InvariantCulture) /* to ISO yyyyMMdd */
                                        : string.Empty;
            }

            if (AreDifferent(Study.StudyDate, newDicomStudyDate))
            {
                var item = new UpdateItem(DicomTags.StudyDate, Study.StudyDate, newDicomStudyDate);
                changes.Add(item);
            }

            int    hh             = String.IsNullOrEmpty(StudyTimeHours.Text)? 0:int.Parse(StudyTimeHours.Text);
            int    mm             = String.IsNullOrEmpty(StudyTimeMinutes.Text) ? 0 : int.Parse(StudyTimeMinutes.Text);
            int    ss             = String.IsNullOrEmpty(StudyTimeSeconds.Text) ? 0 : int.Parse(StudyTimeSeconds.Text);
            String dicomStudyTime = String.Format("{0:00}{1:00}{2:00}", hh, mm, ss);

            // #9475 : if fraction is in the original time, it should be preserved unless the hours, minutes or seconds are modified.
            var originalTime = Study.StudyTime;

            if (!string.IsNullOrEmpty(originalTime) && originalTime.Contains("."))
            {
                originalTime = originalTime.Substring(0, originalTime.IndexOf(".", StringComparison.InvariantCultureIgnoreCase));
            }

            if (AreDifferent(originalTime, dicomStudyTime))
            {
                var item = new UpdateItem(DicomTags.StudyTime, Study.StudyTime, dicomStudyTime);
                changes.Add(item);
            }

            return(changes);
        }