/// <summary> /// In case patient Id is not available get patient Id using accession number /// </summary> /// <param name="recipe"></param> /// <param name="localNode"></param> /// <param name="sourceNode"></param> /// <returns></returns> private string GetPatientId(Recipe recipe, IDicomService dicomSource) { if (!string.IsNullOrEmpty(recipe.PatientId)) { return(recipe.PatientId); } if (!string.IsNullOrEmpty(recipe.PatientFullName) && !string.IsNullOrEmpty(recipe.PatientBirthDate)) { return(dicomSource.GetPatientIdFromPatientDetails(recipe.PatientFullName, recipe.PatientBirthDate).PatientId); } if (string.IsNullOrEmpty(recipe.CurrentAccession)) { throw new NoNullAllowedException("Either patient details or study accession number should be defined!"); } try { var study = dicomSource.GetStudyForAccession(recipe.CurrentAccession); return(study.PatientId); } catch { _log.Error($"Failed to find accession {recipe.CurrentAccession} in source {recipe.SourceAet}"); throw new StudyNotFoundException($"Failed to find accession {recipe.CurrentAccession} in source {recipe.SourceAet}"); } }
public virtual bool Bind(String uid, IDicomService service) { Guard.ArgumentNotNull(service, "service"); if (Contains(StringUtils.CheckUID(uid))) { return false; } Add(uid, service); return true; }
/// <summary> /// Find all studies for patient first trying patient Id and if not provided using patient full name and birth date. /// </summary> /// <param name="patientId"></param> /// <param name="patientFullName"></param> /// <param name="patientBirthDate"></param> /// <param name="localNode">This machine dicome node details</param> /// <param name="sourceNode">Dicom archive where studies reside</param> /// <returns></returns> private List <IDicomStudy> GetStudiesForPatient( string patientId, string patientFullName, string patientBirthDate, IDicomService dicomSource) { var patientIdIsProvided = !string.IsNullOrEmpty(patientId) && !string.IsNullOrWhiteSpace(patientId); var result = patientIdIsProvided ? dicomSource.GetStudiesForPatientId(patientId) : dicomSource.GetStudiesForPatient(patientFullName, patientBirthDate); return(result.OrderByDescending(s => s.StudyDate).ToList()); }
/// <summary> /// Check series for studies and return ones which contain series matching criteria passed /// </summary> /// <param name="studies"></param> /// <param name="criteria"></param> /// <param name="localNode"></param> /// <param name="sourceNode"></param> /// <returns></returns> private List <IDicomStudy> GetStudiesContainingMatchingSeries( IEnumerable <IDicomStudy> studies, IEnumerable <SeriesSelectionCriteria> criteria, IDicomService dicomSource) { // A list of studies where... return(studies .Where(study => { // The study matches true to all criteria... return criteria.All(criterion => { var seriesList = dicomSource.GetSeriesForStudy(study.StudyInstanceUid); var matchingSeries = seriesList.Where(series => _valueComparer.CompareStrings( series.SeriesDescription, criterion.SeriesDescription, criterion.SeriesDescriptionOperand, criterion.SeriesDescriptionDelimiter) ).ToList(); if (!matchingSeries.Any()) { return false; } // Not sure why this is a problem. We may need to determine "best match" at some point though. //if (matchingSeries.Count > 1) //{ // throw new Exception("More than one matching series were found"); //} return true; }); }).ToList()); }