public async Task Study( [Option("r", "Uniform Resource Locator (URL) of the DICOMweb service")] string rootUrl, [Option("u", "username for authentication with the DICOMweb service")] string username, [Option("p", "password for authentication with the DICOMweb service")] string password, [Option("s", "unique study identifier; Study Instance UID")] string studyInstanceUid, [Option("f", "output format: json, dicom")] OutputFormat format = OutputFormat.Dicom, [Option("o", "output directory, default: current directory(.)", DefaultValue = ".")] string outputDir = ".", [Option("t", "transfer syntaxes, separated by comma")] string transferSyntaxes = "*" ) { Uri rootUri; List <DicomTransferSyntax> dicomTransferSyntaxes; ValidateOptions(rootUrl, transferSyntaxes, out rootUri, out dicomTransferSyntaxes); ValidateOutputDirectory(ref outputDir); _dicomWebClient.ConfigureServiceUris(rootUri); _dicomWebClient.ConfigureAuthentication(Utils.GenerateFromUsernamePassword(username, password)); _logger.LogInformation($"Retrieving study {studyInstanceUid}..."); if (format == OutputFormat.Dicom) { await SaveFiles(outputDir, _dicomWebClient.Wado.Retrieve(studyInstanceUid, transferSyntaxes: dicomTransferSyntaxes.ToArray())); } else { await SaveJson(outputDir, _dicomWebClient.Wado.RetrieveMetadata <string>(studyInstanceUid)); } }
public async Task Store( [Option("r", "Uniform Resource Locator (URL) of the DICOMweb service")] string rootUrl, [Option("u", "Username for authentication with the DICOMweb service")] string username, [Option("p", "Password for authentication with the DICOMweb service")] string password, [Option("i", "DICOM file or directory containing multiple DICOM files")] string input, [Option("o", "Output filename")] string outputFilename = "", [Option("s", "Unique study identifier; Study Instance UID")] string studyInstanceUid = "", [Option("t", "Time to wait before the request times out, in minutes. Default 5 minutes.")] int timeout = 5 ) { Uri rootUri; ValidateOptions(rootUrl, out rootUri); var files = ScanFiles(input); _logger.LogInformation($"Storing {files.Count} instances..."); _dicomWebClient.ConfigureServiceUris(rootUri); _dicomWebClient.ConfigureAuthentication(Utils.GenerateFromUsernamePassword(username, password)); DicomWebResponse <string> response = null; try { response = await _dicomWebClient.Stow.Store(studyInstanceUid, files); } catch (ResponseDecodeException ex) { _logger.LogError($"Error decoding response: {ex.Message}"); return; } try { if (string.IsNullOrWhiteSpace(outputFilename)) { outputFilename = $"{DateTime.Now.ToString("yyyyMMdd-hhmmss-fffff")}-.json"; } await Utils.SaveJson(_logger, outputFilename, response.Result); } catch (Exception ex) { _logger.LogError($"Error saving results: {ex.Message}"); } }
public async Task Study( [Option("r", "Uniform Resource Locator (URL) of the DICOMweb service")] string rootUrl, [Option("u", "username for authentication with the DICOMweb service")] string username, [Option("p", "password for authentication with the DICOMweb service")] string password, [Option("q", "query parameters. e.g. \"PatientID=Bob*,00080060=CT\"")] string query, [Option("d", "fields to include. e.g. [PatientName, 00080020].")] List <string> fieldsToInclude = null, [Option("f", "fuzzy matching")] bool fuzzyMatching = false, [Option("o", "output directory, default: current directory(.)", DefaultValue = ".")] string outputDir = "." ) { Uri rootUri; ValidateOptions(rootUrl, out rootUri); ValidateOutputDirectory(ref outputDir); _dicomWebClient.ConfigureServiceUris(rootUri); _dicomWebClient.ConfigureAuthentication(Utils.GenerateFromUsernamePassword(username, password)); _logger.LogInformation($"Querying studies..."); var queryParameters = ParseQueryString(query); await SaveJson(outputDir, _dicomWebClient.Qido.SearchForStudies <string>(queryParameters, fieldsToInclude, fuzzyMatching)); }