|
| 1 | +const StaticWado = require("./StaticWado"); |
| 2 | +const adaptProgramOpts = require("./util/adaptProgramOpts"); |
| 3 | +const retrieveJson = require("./query/retrieveJson"); |
| 4 | + |
| 5 | +/** |
| 6 | + * Queries the given URL instance. |
| 7 | + * Options: |
| 8 | + * * metadata |
| 9 | + * Appends /series to the URL and tries to retrieve |
| 10 | + * Stores the data in the `series` key |
| 11 | + * Iterates over all series in the list and checks if the series is up to date |
| 12 | + * For each series not up to date: |
| 13 | + * * `series/<seriesInstanceUID>/metadata` stored to a key of the same name |
| 14 | + * * Iterates over all instances in above and adds to `StudyData` |
| 15 | + * Writes updated study data files (recreated from new deduplciated data) |
| 16 | + * * cache - will cache all queried files |
| 17 | + * * stream - will print the response directly to the standard output. |
| 18 | + * * deduplicated |
| 19 | + * Reads the /deduplicated path first |
| 20 | + * If no object, and the `metadata` option is set, then runs that path |
| 21 | + * If the object is found, then writes the deduplicated data to the deduplicated path |
| 22 | + * Runs the regular metadata create path |
| 23 | + * |
| 24 | + * Retrieving individual instances for proxying cached data. |
| 25 | + * Data can be read from disk once this is complete. |
| 26 | + * `mkdicomweb query 1.2.3/series --cache` |
| 27 | + * `mkdicomweb query 1.2.3/series/2.3.4/metadata --cache` |
| 28 | + * |
| 29 | + * Retrieving a study query for direct proxy: |
| 30 | + * Data can be streamed directly from the command line. |
| 31 | + * `mkdicomweb query 1.2.3?ModalitiesInStudy=CR --stream` |
| 32 | + * |
| 33 | + * Creates or Updates Deduplicated Metadata: |
| 34 | + * This command should be used before receiving data against remote proxies NOT supporting deduplicated |
| 35 | + * `mkdicomweb query 1.2.3 --metadata` |
| 36 | + * |
| 37 | + * Creates or Updates Deduplicated Metadata from Deduplicated Remote |
| 38 | + * This command should be used before receiving data against remote proxies supporting deduplicated |
| 39 | + * `mkdicomweb query 1.2.3 --deduplicated` |
| 40 | + * |
| 41 | + * @param {*} url to fetch |
| 42 | + * @param {*} options |
| 43 | + * @param {*} program |
| 44 | + */ |
| 45 | +module.exports = function queryMain(url, options) { |
| 46 | + const finalOptions = adaptProgramOpts(options, { |
| 47 | + ...this, |
| 48 | + isGroup: true, |
| 49 | + isStudyData: true, |
| 50 | + }); |
| 51 | + const importer = new StaticWado(finalOptions); |
| 52 | + const useUrl = url.indexOf('http')===-1 ? `${this.dicomwebUrl}/studies/${url}` : url; |
| 53 | + console.log("Import from", useUrl); |
| 54 | + retrieveJson(url, options).then(json => { |
| 55 | + console.log("Retrieved:", JSON.stringify(json,null,2)); |
| 56 | + }); |
| 57 | +}; |
0 commit comments