@fnndsc/brasa 0.57.4 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/models.d.ts +2 -3
- package/dist/api/models.js.map +1 -1
- package/dist/buildinfo.json +1 -1
- package/dist/builtins/argumentTokens.js +25 -6
- package/dist/builtins/argumentTokens.js.map +1 -1
- package/dist/builtins/berth/berth.d.ts +0 -14
- package/dist/builtins/berth/berth.js +255 -88
- package/dist/builtins/berth/berth.js.map +1 -1
- package/dist/builtins/berth/berthClose.d.ts +66 -1
- package/dist/builtins/berth/berthClose.js +312 -26
- package/dist/builtins/berth/berthClose.js.map +1 -1
- package/dist/builtins/berth/berthClosed.d.ts +212 -0
- package/dist/builtins/berth/berthClosed.js +231 -0
- package/dist/builtins/berth/berthClosed.js.map +1 -0
- package/dist/builtins/berth/berthCube.js +27 -6
- package/dist/builtins/berth/berthCube.js.map +1 -1
- package/dist/builtins/berth/berthDisk.js +1 -1
- package/dist/builtins/berth/berthDisk.js.map +1 -1
- package/dist/builtins/berth/berthProcesses.js +15 -3
- package/dist/builtins/berth/berthProcesses.js.map +1 -1
- package/dist/builtins/berth/berthRecord.d.ts +14 -2
- package/dist/builtins/berth/berthRecord.js +20 -5
- package/dist/builtins/berth/berthRecord.js.map +1 -1
- package/dist/builtins/berth/berthState.d.ts +26 -6
- package/dist/builtins/berth/berthState.js +47 -13
- package/dist/builtins/berth/berthState.js.map +1 -1
- package/dist/builtins/debug.d.ts +0 -8
- package/dist/builtins/debug.js +1 -12
- package/dist/builtins/debug.js.map +1 -1
- package/dist/builtins/executable.js +102 -75
- package/dist/builtins/executable.js.map +1 -1
- package/dist/builtins/feedTotals.js +30 -25
- package/dist/builtins/feedTotals.js.map +1 -1
- package/dist/builtins/fs/acl.args.d.ts +3 -10
- package/dist/builtins/fs/acl.args.js +16 -24
- package/dist/builtins/fs/acl.args.js.map +1 -1
- package/dist/builtins/fs/acl.d.ts +0 -37
- package/dist/builtins/fs/acl.js +36 -58
- package/dist/builtins/fs/acl.js.map +1 -1
- package/dist/builtins/fs/archive.js +4 -7
- package/dist/builtins/fs/archive.js.map +1 -1
- package/dist/builtins/fs/cat.d.ts +0 -16
- package/dist/builtins/fs/cat.js +163 -96
- package/dist/builtins/fs/cat.js.map +1 -1
- package/dist/builtins/fs/cd.js +23 -5
- package/dist/builtins/fs/cd.js.map +1 -1
- package/dist/builtins/fs/configWrite.d.ts +0 -8
- package/dist/builtins/fs/configWrite.js +33 -46
- package/dist/builtins/fs/configWrite.js.map +1 -1
- package/dist/builtins/fs/cp.d.ts +6 -10
- package/dist/builtins/fs/cp.js +83 -86
- package/dist/builtins/fs/cp.js.map +1 -1
- package/dist/builtins/fs/deliveryIntent.d.ts +24 -0
- package/dist/builtins/fs/deliveryIntent.js +182 -0
- package/dist/builtins/fs/deliveryIntent.js.map +1 -0
- package/dist/builtins/fs/deliveryMatch.d.ts +138 -0
- package/dist/builtins/fs/deliveryMatch.js +135 -0
- package/dist/builtins/fs/deliveryMatch.js.map +1 -0
- package/dist/builtins/fs/destination.d.ts +37 -1
- package/dist/builtins/fs/destination.js +80 -0
- package/dist/builtins/fs/destination.js.map +1 -1
- package/dist/builtins/fs/download.d.ts +19 -8
- package/dist/builtins/fs/download.js +142 -72
- package/dist/builtins/fs/download.js.map +1 -1
- package/dist/builtins/fs/du.d.ts +0 -8
- package/dist/builtins/fs/du.js +23 -20
- package/dist/builtins/fs/du.js.map +1 -1
- package/dist/builtins/fs/edit.js +117 -50
- package/dist/builtins/fs/edit.js.map +1 -1
- package/dist/builtins/fs/entries.d.ts +38 -0
- package/dist/builtins/fs/entries.js +48 -1
- package/dist/builtins/fs/entries.js.map +1 -1
- package/dist/builtins/fs/find.d.ts +1 -1
- package/dist/builtins/fs/find.js +462 -271
- package/dist/builtins/fs/find.js.map +1 -1
- package/dist/builtins/fs/ls.d.ts +2 -8
- package/dist/builtins/fs/ls.js +144 -93
- package/dist/builtins/fs/ls.js.map +1 -1
- package/dist/builtins/fs/mkdir.d.ts +2 -7
- package/dist/builtins/fs/mkdir.js +110 -58
- package/dist/builtins/fs/mkdir.js.map +1 -1
- package/dist/builtins/fs/mv.d.ts +7 -10
- package/dist/builtins/fs/mv.js +155 -100
- package/dist/builtins/fs/mv.js.map +1 -1
- package/dist/builtins/fs/pull.js +155 -92
- package/dist/builtins/fs/pull.js.map +1 -1
- package/dist/builtins/fs/pwd.d.ts +0 -7
- package/dist/builtins/fs/pwd.js +0 -12
- package/dist/builtins/fs/pwd.js.map +1 -1
- package/dist/builtins/fs/rm.d.ts +6 -7
- package/dist/builtins/fs/rm.js +364 -174
- package/dist/builtins/fs/rm.js.map +1 -1
- package/dist/builtins/fs/rmdir.d.ts +0 -7
- package/dist/builtins/fs/rmdir.js +40 -21
- package/dist/builtins/fs/rmdir.js.map +1 -1
- package/dist/builtins/fs/touch.d.ts +0 -7
- package/dist/builtins/fs/touch.js +14 -27
- package/dist/builtins/fs/touch.js.map +1 -1
- package/dist/builtins/fs/transferJobs.d.ts +12 -0
- package/dist/builtins/fs/transferJobs.js +19 -0
- package/dist/builtins/fs/transferJobs.js.map +1 -1
- package/dist/builtins/fs/tree.d.ts +0 -8
- package/dist/builtins/fs/tree.js +1 -12
- package/dist/builtins/fs/tree.js.map +1 -1
- package/dist/builtins/fs/upload.d.ts +0 -8
- package/dist/builtins/fs/upload.js +23 -20
- package/dist/builtins/fs/upload.js.map +1 -1
- package/dist/builtins/fs/url.d.ts +14 -2
- package/dist/builtins/fs/url.js +6 -8
- package/dist/builtins/fs/url.js.map +1 -1
- package/dist/builtins/fs/writeReport.d.ts +40 -0
- package/dist/builtins/fs/writeReport.js +71 -0
- package/dist/builtins/fs/writeReport.js.map +1 -0
- package/dist/builtins/fs/xattr.args.d.ts +14 -13
- package/dist/builtins/fs/xattr.args.js +3 -24
- package/dist/builtins/fs/xattr.args.js.map +1 -1
- package/dist/builtins/fs/xattr.d.ts +0 -25
- package/dist/builtins/fs/xattr.js +82 -65
- package/dist/builtins/fs/xattr.js.map +1 -1
- package/dist/builtins/games/bytes.d.ts +0 -55
- package/dist/builtins/games/bytes.js +95 -120
- package/dist/builtins/games/bytes.js.map +1 -1
- package/dist/builtins/games/chimes.d.ts +0 -36
- package/dist/builtins/games/chimes.js +58 -64
- package/dist/builtins/games/chimes.js.map +1 -1
- package/dist/builtins/games/chrislab.d.ts +0 -12
- package/dist/builtins/games/chrislab.js +0 -14
- package/dist/builtins/games/chrislab.js.map +1 -1
- package/dist/builtins/games/cowsay.d.ts +0 -24
- package/dist/builtins/games/cowsay.js +0 -29
- package/dist/builtins/games/cowsay.js.map +1 -1
- package/dist/builtins/games/figlet.d.ts +0 -24
- package/dist/builtins/games/figlet.js +0 -29
- package/dist/builtins/games/figlet.js.map +1 -1
- package/dist/builtins/games/lab.d.ts +0 -36
- package/dist/builtins/games/lab.js +0 -43
- package/dist/builtins/games/lab.js.map +1 -1
- package/dist/builtins/games/lolcat.d.ts +0 -12
- package/dist/builtins/games/lolcat.js +2 -17
- package/dist/builtins/games/lolcat.js.map +1 -1
- package/dist/builtins/games/numbers.d.ts +0 -60
- package/dist/builtins/games/numbers.js +0 -71
- package/dist/builtins/games/numbers.js.map +1 -1
- package/dist/builtins/games/play.d.ts +0 -36
- package/dist/builtins/games/play.js +47 -58
- package/dist/builtins/games/play.js.map +1 -1
- package/dist/builtins/games/qr.d.ts +0 -12
- package/dist/builtins/games/qr.js +189 -68
- package/dist/builtins/games/qr.js.map +1 -1
- package/dist/builtins/games/show.d.ts +0 -73
- package/dist/builtins/games/show.js +0 -85
- package/dist/builtins/games/show.js.map +1 -1
- package/dist/builtins/games/sky.d.ts +0 -36
- package/dist/builtins/games/sky.js +25 -45
- package/dist/builtins/games/sky.js.map +1 -1
- package/dist/builtins/games/text.d.ts +0 -72
- package/dist/builtins/games/text.js +0 -85
- package/dist/builtins/games/text.js.map +1 -1
- package/dist/builtins/games/trek.d.ts +0 -12
- package/dist/builtins/games/trek.js +0 -15
- package/dist/builtins/games/trek.js.map +1 -1
- package/dist/builtins/games/wtf.d.ts +0 -12
- package/dist/builtins/games/wtf.js +0 -15
- package/dist/builtins/games/wtf.js.map +1 -1
- package/dist/builtins/help.d.ts +0 -19
- package/dist/builtins/help.js +56 -39
- package/dist/builtins/help.js.map +1 -1
- package/dist/builtins/helpSections.js +13 -1
- package/dist/builtins/helpSections.js.map +1 -1
- package/dist/builtins/index.d.ts +1 -1
- package/dist/builtins/index.js +1 -1
- package/dist/builtins/index.js.map +1 -1
- package/dist/builtins/net/connect.d.ts +1 -8
- package/dist/builtins/net/connect.js +2 -13
- package/dist/builtins/net/connect.js.map +1 -1
- package/dist/builtins/net/cubepath.js +30 -20
- package/dist/builtins/net/cubepath.js.map +1 -1
- package/dist/builtins/net/logout.d.ts +0 -8
- package/dist/builtins/net/logout.js +1 -12
- package/dist/builtins/net/logout.js.map +1 -1
- package/dist/builtins/net/netstat.d.ts +0 -8
- package/dist/builtins/net/netstat.js +1 -12
- package/dist/builtins/net/netstat.js.map +1 -1
- package/dist/builtins/net/pacs.d.ts +3 -17
- package/dist/builtins/net/pacs.js +50 -42
- package/dist/builtins/net/pacs.js.map +1 -1
- package/dist/builtins/net/pacsUtils.d.ts +0 -2
- package/dist/builtins/net/pacsUtils.js +67 -30
- package/dist/builtins/net/pacsUtils.js.map +1 -1
- package/dist/builtins/net/query.anon.d.ts +61 -0
- package/dist/builtins/net/query.anon.js +362 -0
- package/dist/builtins/net/query.anon.js.map +1 -0
- package/dist/builtins/net/query.args.d.ts +2 -1
- package/dist/builtins/net/query.args.js +1 -1
- package/dist/builtins/net/query.args.js.map +1 -1
- package/dist/builtins/net/query.cohort.d.ts +125 -0
- package/dist/builtins/net/query.cohort.js +267 -0
- package/dist/builtins/net/query.cohort.js.map +1 -0
- package/dist/builtins/net/query.csv.d.ts +26 -5
- package/dist/builtins/net/query.csv.js +61 -115
- package/dist/builtins/net/query.csv.js.map +1 -1
- package/dist/builtins/net/query.d.ts +27 -34
- package/dist/builtins/net/query.deliver.d.ts +96 -0
- package/dist/builtins/net/query.deliver.js +188 -0
- package/dist/builtins/net/query.deliver.js.map +1 -0
- package/dist/builtins/net/query.fanout.d.ts +32 -0
- package/dist/builtins/net/query.fanout.js +91 -0
- package/dist/builtins/net/query.fanout.js.map +1 -1
- package/dist/builtins/net/query.held.d.ts +60 -0
- package/dist/builtins/net/query.held.js +125 -0
- package/dist/builtins/net/query.held.js.map +1 -0
- package/dist/builtins/net/query.ignored.d.ts +3 -1
- package/dist/builtins/net/query.ignored.js +9 -3
- package/dist/builtins/net/query.ignored.js.map +1 -1
- package/dist/builtins/net/query.js +360 -634
- package/dist/builtins/net/query.js.map +1 -1
- package/dist/builtins/net/query.model.d.ts +15 -0
- package/dist/builtins/net/query.model.js +109 -46
- package/dist/builtins/net/query.model.js.map +1 -1
- package/dist/builtins/net/query.view.js +29 -8
- package/dist/builtins/net/query.view.js.map +1 -1
- package/dist/builtins/operandRuns.js +4 -3
- package/dist/builtins/operandRuns.js.map +1 -1
- package/dist/builtins/operands.js +97 -39
- package/dist/builtins/operands.js.map +1 -1
- package/dist/builtins/pluginExecute.js +311 -205
- package/dist/builtins/pluginExecute.js.map +1 -1
- package/dist/builtins/proc.d.ts +1 -13
- package/dist/builtins/proc.helpers.d.ts +0 -7
- package/dist/builtins/proc.helpers.js +0 -10
- package/dist/builtins/proc.helpers.js.map +1 -1
- package/dist/builtins/proc.js +159 -116
- package/dist/builtins/proc.js.map +1 -1
- package/dist/builtins/procWatch.d.ts +2 -2
- package/dist/builtins/procWatch.js +54 -13
- package/dist/builtins/procWatch.js.map +1 -1
- package/dist/builtins/res/compute.d.ts +0 -13
- package/dist/builtins/res/compute.js +0 -16
- package/dist/builtins/res/compute.js.map +1 -1
- package/dist/builtins/res/diagram.tree.js +36 -12
- package/dist/builtins/res/diagram.tree.js.map +1 -1
- package/dist/builtins/res/dicom.d.ts +24 -17
- package/dist/builtins/res/dicom.js +78 -79
- package/dist/builtins/res/dicom.js.map +1 -1
- package/dist/builtins/res/expect.d.ts +8 -17
- package/dist/builtins/res/expect.js +173 -101
- package/dist/builtins/res/expect.js.map +1 -1
- package/dist/builtins/res/feed.d.ts +0 -13
- package/dist/builtins/res/feed.diagram.js +89 -57
- package/dist/builtins/res/feed.diagram.js.map +1 -1
- package/dist/builtins/res/feed.js +61 -42
- package/dist/builtins/res/feed.js.map +1 -1
- package/dist/builtins/res/feed.tree.collapse.d.ts +0 -10
- package/dist/builtins/res/feed.tree.collapse.js +12 -5
- package/dist/builtins/res/feed.tree.collapse.js.map +1 -1
- package/dist/builtins/res/files.d.ts +0 -37
- package/dist/builtins/res/files.js +0 -44
- package/dist/builtins/res/files.js.map +1 -1
- package/dist/builtins/res/gather.d.ts +0 -13
- package/dist/builtins/res/gather.facts.js +24 -16
- package/dist/builtins/res/gather.facts.js.map +1 -1
- package/dist/builtins/res/gather.js +47 -36
- package/dist/builtins/res/gather.js.map +1 -1
- package/dist/builtins/res/gather.process.js +49 -15
- package/dist/builtins/res/gather.process.js.map +1 -1
- package/dist/builtins/res/gather.store.d.ts +4 -2
- package/dist/builtins/res/gather.store.js +43 -31
- package/dist/builtins/res/gather.store.js.map +1 -1
- package/dist/builtins/res/group.d.ts +0 -13
- package/dist/builtins/res/group.js +78 -40
- package/dist/builtins/res/group.js.map +1 -1
- package/dist/builtins/res/image.d.ts +0 -13
- package/dist/builtins/res/image.js +0 -15
- package/dist/builtins/res/image.js.map +1 -1
- package/dist/builtins/res/manifestRead.d.ts +65 -0
- package/dist/builtins/res/manifestRead.js +161 -0
- package/dist/builtins/res/manifestRead.js.map +1 -0
- package/dist/builtins/res/pipeline.d.ts +1 -1
- package/dist/builtins/res/pipeline.js +152 -103
- package/dist/builtins/res/pipeline.js.map +1 -1
- package/dist/builtins/res/pipeline.manifest.js +17 -7
- package/dist/builtins/res/pipeline.manifest.js.map +1 -1
- package/dist/builtins/res/play.d.ts +0 -13
- package/dist/builtins/res/play.js +367 -226
- package/dist/builtins/res/play.js.map +1 -1
- package/dist/builtins/res/plugin.d.ts +1 -13
- package/dist/builtins/res/plugin.info.js +36 -14
- package/dist/builtins/res/plugin.info.js.map +1 -1
- package/dist/builtins/res/plugin.js +1 -17
- package/dist/builtins/res/plugin.js.map +1 -1
- package/dist/builtins/res/plugin.sync.d.ts +3 -5
- package/dist/builtins/res/plugin.sync.js +175 -40
- package/dist/builtins/res/plugin.sync.js.map +1 -1
- package/dist/builtins/res/plugininstance.d.ts +0 -13
- package/dist/builtins/res/plugininstance.js +0 -16
- package/dist/builtins/res/plugininstance.js.map +1 -1
- package/dist/builtins/res/pluginmeta.d.ts +0 -13
- package/dist/builtins/res/pluginmeta.js +0 -16
- package/dist/builtins/res/pluginmeta.js.map +1 -1
- package/dist/builtins/res/record.d.ts +0 -13
- package/dist/builtins/res/record.js +2 -18
- package/dist/builtins/res/record.js.map +1 -1
- package/dist/builtins/res/runWait.js +32 -8
- package/dist/builtins/res/runWait.js.map +1 -1
- package/dist/builtins/res/tag.d.ts +0 -13
- package/dist/builtins/res/tag.js +0 -16
- package/dist/builtins/res/tag.js.map +1 -1
- package/dist/builtins/res/thumbnail.js +23 -8
- package/dist/builtins/res/thumbnail.js.map +1 -1
- package/dist/builtins/res/user.d.ts +0 -12
- package/dist/builtins/res/user.js +0 -17
- package/dist/builtins/res/user.js.map +1 -1
- package/dist/builtins/res/workflow.d.ts +0 -13
- package/dist/builtins/res/workflow.js +0 -16
- package/dist/builtins/res/workflow.js.map +1 -1
- package/dist/builtins/runEcho.js +2 -1
- package/dist/builtins/runEcho.js.map +1 -1
- package/dist/builtins/store.d.ts +0 -13
- package/dist/builtins/store.js +32 -32
- package/dist/builtins/store.js.map +1 -1
- package/dist/builtins/sys/apropos.d.ts +2 -27
- package/dist/builtins/sys/apropos.js +2 -32
- package/dist/builtins/sys/apropos.js.map +1 -1
- package/dist/builtins/sys/cal.d.ts +0 -12
- package/dist/builtins/sys/cal.js +0 -15
- package/dist/builtins/sys/cal.js.map +1 -1
- package/dist/builtins/sys/command.js +3 -7
- package/dist/builtins/sys/command.js.map +1 -1
- package/dist/builtins/sys/context.d.ts +0 -8
- package/dist/builtins/sys/context.js +1 -12
- package/dist/builtins/sys/context.js.map +1 -1
- package/dist/builtins/sys/date.d.ts +0 -12
- package/dist/builtins/sys/date.js +0 -15
- package/dist/builtins/sys/date.js.map +1 -1
- package/dist/builtins/sys/echo.d.ts +0 -12
- package/dist/builtins/sys/echo.js +54 -49
- package/dist/builtins/sys/echo.js.map +1 -1
- package/dist/builtins/sys/fortune.d.ts +0 -12
- package/dist/builtins/sys/fortune.js +0 -15
- package/dist/builtins/sys/fortune.js.map +1 -1
- package/dist/builtins/sys/grep.d.ts +14 -18
- package/dist/builtins/sys/grep.js +239 -114
- package/dist/builtins/sys/grep.js.map +1 -1
- package/dist/builtins/sys/hostGrants.d.ts +85 -0
- package/dist/builtins/sys/hostGrants.js +207 -0
- package/dist/builtins/sys/hostGrants.js.map +1 -0
- package/dist/builtins/sys/joblets.d.ts +0 -24
- package/dist/builtins/sys/joblets.js +0 -29
- package/dist/builtins/sys/joblets.js.map +1 -1
- package/dist/builtins/sys/motd.d.ts +0 -12
- package/dist/builtins/sys/motd.js +14 -21
- package/dist/builtins/sys/motd.js.map +1 -1
- package/dist/builtins/sys/notes.js +26 -16
- package/dist/builtins/sys/notes.js.map +1 -1
- package/dist/builtins/sys/physicalmode.d.ts +0 -8
- package/dist/builtins/sys/physicalmode.js +1 -12
- package/dist/builtins/sys/physicalmode.js.map +1 -1
- package/dist/builtins/sys/tasks.d.ts +0 -24
- package/dist/builtins/sys/tasks.js +30 -36
- package/dist/builtins/sys/tasks.js.map +1 -1
- package/dist/builtins/sys/textFilters.d.ts +0 -84
- package/dist/builtins/sys/textFilters.js +33 -110
- package/dist/builtins/sys/textFilters.js.map +1 -1
- package/dist/builtins/sys/timing.d.ts +0 -8
- package/dist/builtins/sys/timing.js +1 -12
- package/dist/builtins/sys/timing.js.map +1 -1
- package/dist/builtins/sys/variables.d.ts +0 -24
- package/dist/builtins/sys/variables.js +0 -29
- package/dist/builtins/sys/variables.js.map +1 -1
- package/dist/builtins/sys/version.d.ts +0 -12
- package/dist/builtins/sys/version.js +0 -15
- package/dist/builtins/sys/version.js.map +1 -1
- package/dist/builtins/sys/weather.js +46 -27
- package/dist/builtins/sys/weather.js.map +1 -1
- package/dist/builtins/sys/whoami.d.ts +0 -22
- package/dist/builtins/sys/whoami.js +16 -43
- package/dist/builtins/sys/whoami.js.map +1 -1
- package/dist/builtins/utils.d.ts +4 -39
- package/dist/builtins/utils.js +24 -55
- package/dist/builtins/utils.js.map +1 -1
- package/dist/chris/backend.js +7 -12
- package/dist/chris/backend.js.map +1 -1
- package/dist/chris/binDeclarations.d.ts +0 -44
- package/dist/chris/binDeclarations.js +111 -29
- package/dist/chris/binDeclarations.js.map +1 -1
- package/dist/chris/binExecutables.js +26 -18
- package/dist/chris/binExecutables.js.map +1 -1
- package/dist/chris/chiliDelegate.d.ts +104 -0
- package/dist/chris/chiliDelegate.js +240 -0
- package/dist/chris/chiliDelegate.js.map +1 -1
- package/dist/chris/commandFallback.d.ts +2 -2
- package/dist/chris/commandFallback.js +107 -50
- package/dist/chris/commandFallback.js.map +1 -1
- package/dist/chris/completion.d.ts +3 -1
- package/dist/chris/completion.js +5 -17
- package/dist/chris/completion.js.map +1 -1
- package/dist/chris/connect.d.ts +37 -0
- package/dist/chris/connect.js +46 -0
- package/dist/chris/connect.js.map +1 -1
- package/dist/chris/files.js +32 -2
- package/dist/chris/files.js.map +1 -1
- package/dist/chris/navigation.js +87 -53
- package/dist/chris/navigation.js.map +1 -1
- package/dist/chris/pacsResources.js +28 -11
- package/dist/chris/pacsResources.js.map +1 -1
- package/dist/chris/promptContext.js +68 -35
- package/dist/chris/promptContext.js.map +1 -1
- package/dist/chris/universeLayout.d.ts +8 -2
- package/dist/chris/universeLayout.js +40 -11
- package/dist/chris/universeLayout.js.map +1 -1
- package/dist/chris/warmup.d.ts +140 -0
- package/dist/chris/warmup.js +622 -0
- package/dist/chris/warmup.js.map +1 -0
- package/dist/core/argumentKinds.js +4 -4
- package/dist/core/argumentKinds.js.map +1 -1
- package/dist/core/assignment.js +8 -6
- package/dist/core/assignment.js.map +1 -1
- package/dist/core/backend.d.ts +44 -8
- package/dist/core/backend.js.map +1 -1
- package/dist/core/commandDeclaration.d.ts +8 -0
- package/dist/core/commandDeclaration.js.map +1 -1
- package/dist/core/commandParse.d.ts +34 -1
- package/dist/core/commandParse.js +156 -28
- package/dist/core/commandParse.js.map +1 -1
- package/dist/core/commandRegistry.d.ts +24 -5
- package/dist/core/commandRegistry.js +28 -5
- package/dist/core/commandRegistry.js.map +1 -1
- package/dist/core/dispatch.d.ts +1 -12
- package/dist/core/dispatch.js +12 -16
- package/dist/core/dispatch.js.map +1 -1
- package/dist/core/elevation.js +30 -5
- package/dist/core/elevation.js.map +1 -1
- package/dist/core/engine.d.ts +5 -11
- package/dist/core/engine.js +126 -50
- package/dist/core/engine.js.map +1 -1
- package/dist/core/expansion.d.ts +0 -6
- package/dist/core/expansion.js +0 -8
- package/dist/core/expansion.js.map +1 -1
- package/dist/core/filesystem.js +1 -1
- package/dist/core/filesystem.js.map +1 -1
- package/dist/core/handlerRun.d.ts +13 -0
- package/dist/core/handlerRun.js +21 -0
- package/dist/core/handlerRun.js.map +1 -1
- package/dist/core/holds.js +3 -3
- package/dist/core/holds.js.map +1 -1
- package/dist/core/hostGate.d.ts +62 -0
- package/dist/core/hostGate.js +72 -0
- package/dist/core/hostGate.js.map +1 -0
- package/dist/core/joblets.js +53 -27
- package/dist/core/joblets.js.map +1 -1
- package/dist/core/paths.d.ts +3 -5
- package/dist/core/paths.js +107 -36
- package/dist/core/paths.js.map +1 -1
- package/dist/core/preprocess.d.ts +12 -0
- package/dist/core/preprocess.js +42 -15
- package/dist/core/preprocess.js.map +1 -1
- package/dist/core/question.d.ts +27 -3
- package/dist/core/question.js +14 -6
- package/dist/core/question.js.map +1 -1
- package/dist/core/runner.d.ts +31 -7
- package/dist/core/runner.js +189 -37
- package/dist/core/runner.js.map +1 -1
- package/dist/core/sink.d.ts +7 -19
- package/dist/core/sink.js +56 -28
- package/dist/core/sink.js.map +1 -1
- package/dist/core/surface.js +1 -0
- package/dist/core/surface.js.map +1 -1
- package/dist/core/variables.js +37 -11
- package/dist/core/variables.js.map +1 -1
- package/dist/core/version.d.ts +0 -20
- package/dist/core/version.js +2 -26
- package/dist/core/version.js.map +1 -1
- package/dist/core/warmupFailures.d.ts +3 -6
- package/dist/core/warmupFailures.js.map +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.js +2 -0
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/completer/cfsPaths.js +66 -26
- package/dist/lib/completer/cfsPaths.js.map +1 -1
- package/dist/lib/completer/declared.js +81 -20
- package/dist/lib/completer/declared.js.map +1 -1
- package/dist/lib/completer/index.d.ts +3 -0
- package/dist/lib/completer/index.js +44 -7
- package/dist/lib/completer/index.js.map +1 -1
- package/dist/lib/parser.d.ts +0 -16
- package/dist/lib/parser.js +223 -135
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/vfs/folderListing.d.ts +85 -0
- package/dist/lib/vfs/folderListing.js +86 -0
- package/dist/lib/vfs/folderListing.js.map +1 -0
- package/dist/lib/vfs/vfs.d.ts +37 -9
- package/dist/lib/vfs/vfs.js +195 -110
- package/dist/lib/vfs/vfs.js.map +1 -1
- package/dist/lib/wildcard.d.ts +7 -34
- package/dist/lib/wildcard.js +123 -95
- package/dist/lib/wildcard.js.map +1 -1
- package/dist/notes.json +1 -1
- package/dist/session/answerAdapters.js +249 -131
- package/dist/session/answerAdapters.js.map +1 -1
- package/package.json +12 -10
- package/dist/builtins/wildcard.d.ts +0 -8
- package/dist/builtins/wildcard.js +0 -9
- package/dist/builtins/wildcard.js.map +0 -1
- package/dist/lib/quoting.d.ts +0 -40
- package/dist/lib/quoting.js +0 -70
- package/dist/lib/quoting.js.map +0 -1
- package/dist/lib/semicolonParser.d.ts +0 -41
- package/dist/lib/semicolonParser.js +0 -93
- package/dist/lib/semicolonParser.js.map +0 -1
|
@@ -6,26 +6,41 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Also exports `pacsQuery_createAndWait` for reuse by `builtin_pull`.
|
|
8
8
|
*
|
|
9
|
+
* Key components:
|
|
10
|
+
* - queryCommand, queryLine_run: the verb, and the handler `pacs query` shares.
|
|
11
|
+
* - pacsQuery_createAndWait: one question asked of a PACS, waited on.
|
|
12
|
+
*
|
|
13
|
+
* Typical usage:
|
|
14
|
+
* ```ts
|
|
15
|
+
* await declaredCommand_run(queryCommand, ['PatientID:1234', '--table']);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Dependencies: query.cohort.ts and query.fanout.ts (the questions),
|
|
19
|
+
* query.model.ts and query.held.ts (the answer), query.anon.ts (`--anon`),
|
|
20
|
+
* query.view.ts, query.csv.ts and query.deliver.ts (how it reads).
|
|
21
|
+
*
|
|
9
22
|
* @module
|
|
10
23
|
*/
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import { queryFolderName_build, answer_standIn, criteria_standIn } from '@fnndsc/salsa';
|
|
24
|
+
import { chrisContext, Context, pacsQuery_get, pacsQuery_resultDecode, pacsQueries_create, pacsServers_list, listCache_get, queryIndex_get } from '@fnndsc/cumin';
|
|
25
|
+
import { errorStack } from '@fnndsc/fond';
|
|
14
26
|
import { PACS_QUERY_MODEL_KIND, envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import { pacsQueryModel_build } from './query.model.js';
|
|
18
|
-
import { pacsAnswer_render } from './query.view.js';
|
|
19
|
-
import { ignoredKeys_hint } from './query.ignored.js';
|
|
20
|
-
import { csvFile_write, pacsAnswer_renderCsv, pacsAnswer_renderTable } from './query.csv.js';
|
|
21
|
-
import { series_cubePathGet } from './pacsUtils.js';
|
|
22
|
-
import { spinner } from '../../lib/spinner.js';
|
|
27
|
+
import { queryFolderName_build } from '@fnndsc/salsa';
|
|
28
|
+
import chalk from 'chalk';
|
|
23
29
|
import { pacsRefusal_hint, pacsRefusal_is } from './pacsAccess.js';
|
|
30
|
+
import { QUERY_ANON_FAILED, QUERY_ANON_PROGRESS, QUERY_ANON_REFUSED, anonAnswer_run, expressionShown_build, pacsModel_standIn, } from './query.anon.js';
|
|
24
31
|
import { QUERY_GRAMMAR } from './query.args.js';
|
|
32
|
+
import { cohortAsks_build, cohortTally_render, criteria_format, fanoutModel_build, inlineAsks_build, } from './query.cohort.js';
|
|
33
|
+
import { pacsAnswer_renderTable } from './query.csv.js';
|
|
34
|
+
import { csvAnswer_envelope, csv_deliver } from './query.deliver.js';
|
|
35
|
+
import { jsonTerms_parse, queryTerms_parse } from './query.fanout.js';
|
|
36
|
+
import { modelPulledState_fill } from './query.held.js';
|
|
37
|
+
import { ignoredKeys_hint } from './query.ignored.js';
|
|
38
|
+
import { pacsQueryModel_build } from './query.model.js';
|
|
39
|
+
import { pacsAnswer_render } from './query.view.js';
|
|
25
40
|
import { command_declare } from '../../core/commandDeclaration.js';
|
|
26
|
-
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
27
|
-
import { errorStack } from '@fnndsc/fond';
|
|
28
41
|
import { exitCode_set } from '../../core/handlerRun.js';
|
|
42
|
+
import { sink_get } from '../../core/sink.js';
|
|
43
|
+
import { spinner } from '../../lib/spinner.js';
|
|
29
44
|
const QUERY_POLL_INTERVAL_MS = 2_000;
|
|
30
45
|
const QUERY_TIMEOUT_MS = 60_000;
|
|
31
46
|
/**
|
|
@@ -166,90 +181,7 @@ function queryIndex_file(queryId, criteria, server, owner, hasResult) {
|
|
|
166
181
|
// The answer's model is built in its own module, so a verb that reads one
|
|
167
182
|
// answer (`gather add`) loads the projection without the whole query verb.
|
|
168
183
|
export { pacsQueryModel_build };
|
|
169
|
-
|
|
170
|
-
* What to ask CUBE, for an answer's held state.
|
|
171
|
-
*
|
|
172
|
-
* One filter per STUDY, which is the shape that matters: asking per series
|
|
173
|
-
* costs two round trips each and a patient's history runs to hundreds,
|
|
174
|
-
* while studies are counted in tens. A study the answer does not name is
|
|
175
|
-
* left out, and its series are asked about one at a time instead.
|
|
176
|
-
*
|
|
177
|
-
* @param model - The answer.
|
|
178
|
-
* @returns One filter per named study, in the answer's order.
|
|
179
|
-
*/
|
|
180
|
-
export function pulledFilters_build(model) {
|
|
181
|
-
return model.studies
|
|
182
|
-
.filter((study) => typeof study.studyUID === 'string' && study.studyUID !== '')
|
|
183
|
-
.map((study) => ({ StudyInstanceUID: study.studyUID }));
|
|
184
|
-
}
|
|
185
|
-
/** How many already-in-CUBE checks run at once, on the per-series path. */
|
|
186
|
-
const PULLED_CHECK_CONCURRENCY = 4;
|
|
187
|
-
/**
|
|
188
|
-
* Fills each series' `pulled` state by asking CUBE what it already holds.
|
|
189
|
-
*
|
|
190
|
-
* Asked by STUDY, not by series. The obvious shape — ask about each series
|
|
191
|
-
* in turn — costs two round trips per series, and a patient's history runs
|
|
192
|
-
* to hundreds: reconciling one stored answer of 299 series took twenty
|
|
193
|
-
* seconds against a live CUBE, which is why a replayed query felt exactly
|
|
194
|
-
* like a fresh one. CUBE indexes a stored series by its study, so the same
|
|
195
|
-
* reconciliation is one page per study, and a study count is small.
|
|
196
|
-
*
|
|
197
|
-
* A study whose UID the answer does not carry falls back to asking about
|
|
198
|
-
* its series one at a time, since a study that cannot be named in bulk is
|
|
199
|
-
* still owed an answer.
|
|
200
|
-
*
|
|
201
|
-
* @param model - The query model to annotate in place.
|
|
202
|
-
*/
|
|
203
|
-
async function modelPulledState_fill(model) {
|
|
204
|
-
const named = model.studies.filter((study) => typeof study.studyUID === 'string' && study.studyUID !== '');
|
|
205
|
-
const unnamed = model.studies.filter((study) => !(typeof study.studyUID === 'string' && study.studyUID !== ''));
|
|
206
|
-
if (named.length > 0) {
|
|
207
|
-
const held = await seriesStorage_resolveMany(pulledFilters_build(model));
|
|
208
|
-
if (held.ok) {
|
|
209
|
-
for (const study of named) {
|
|
210
|
-
for (const series of study.series) {
|
|
211
|
-
const state = series.seriesUID === undefined ? undefined : held.value.get(series.seriesUID);
|
|
212
|
-
if (state === undefined || state.folderPath === null)
|
|
213
|
-
continue;
|
|
214
|
-
series.pulled = true;
|
|
215
|
-
series.pulledFiles = state.fileCount;
|
|
216
|
-
// Where the series landed, so a surface can open it as an image.
|
|
217
|
-
series.folderPath = state.folderPath;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
// CUBE would not answer in bulk. Ask the old way rather than report a
|
|
223
|
-
// whole answer as unheld, which would offer PULL for series already in.
|
|
224
|
-
await seriesPulledState_fillOneByOne(named.flatMap((study) => study.series));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (unnamed.length > 0)
|
|
228
|
-
await seriesPulledState_fillOneByOne(unnamed.flatMap((study) => study.series));
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* The per-series fallback: one lookup each, a few at a time.
|
|
232
|
-
*
|
|
233
|
-
* An unreachable check leaves the flag unset rather than guessing.
|
|
234
|
-
*
|
|
235
|
-
* @param allSeries - The series to ask about.
|
|
236
|
-
*/
|
|
237
|
-
async function seriesPulledState_fillOneByOne(allSeries) {
|
|
238
|
-
for (let start = 0; start < allSeries.length; start += PULLED_CHECK_CONCURRENCY) {
|
|
239
|
-
const batch = allSeries.slice(start, start + PULLED_CHECK_CONCURRENCY);
|
|
240
|
-
await Promise.all(batch.map(async (series) => {
|
|
241
|
-
if (!series.seriesUID)
|
|
242
|
-
return;
|
|
243
|
-
const home = await series_cubePathGet(series.seriesUID, 1, 0);
|
|
244
|
-
if (home !== null) {
|
|
245
|
-
series.pulled = true;
|
|
246
|
-
series.pulledFiles = home.fileCount;
|
|
247
|
-
if (home.folderPath !== null && home.folderPath !== undefined)
|
|
248
|
-
series.folderPath = home.folderPath;
|
|
249
|
-
}
|
|
250
|
-
}));
|
|
251
|
-
}
|
|
252
|
-
}
|
|
184
|
+
export { pulledFilters_build } from './query.held.js';
|
|
253
185
|
/**
|
|
254
186
|
* Who is asking, as the index keys it.
|
|
255
187
|
*
|
|
@@ -265,25 +197,19 @@ async function seriesPulledState_fillOneByOne(allSeries) {
|
|
|
265
197
|
async function askingIdentity_get() {
|
|
266
198
|
return (await chrisContext.ChRISuser_get()) ?? '';
|
|
267
199
|
}
|
|
268
|
-
/**
|
|
269
|
-
* What each way of naming a server resolves to. Server identifiers do not
|
|
270
|
-
* change under a session, and this is on the path of every query.
|
|
271
|
-
*/
|
|
272
|
-
const pacsIdentifiers = new Map();
|
|
273
200
|
/**
|
|
274
201
|
* Resolves whatever names a PACS server into its canonical identifier.
|
|
275
202
|
*
|
|
276
203
|
* The context may hold a numeric id, a `--pacsserver` may be either, and
|
|
277
204
|
* CUBE files a query under the identifier. The index is keyed on what CUBE
|
|
278
|
-
* stores, so both the write and the lookup have to speak that.
|
|
205
|
+
* stores, so both the write and the lookup have to speak that. Asked
|
|
206
|
+
* afresh each time, of the server list cumin keeps for the client asking:
|
|
207
|
+
* what a name resolves to is that CUBE's answer to that identity.
|
|
279
208
|
*
|
|
280
209
|
* @param pacsserver - An id or an identifier.
|
|
281
210
|
* @returns The identifier, or the input unchanged when it cannot be resolved.
|
|
282
211
|
*/
|
|
283
212
|
export async function pacsIdentifier_resolve(pacsserver) {
|
|
284
|
-
const remembered = pacsIdentifiers.get(pacsserver);
|
|
285
|
-
if (remembered !== undefined)
|
|
286
|
-
return remembered;
|
|
287
213
|
const servers = await pacsServers_list();
|
|
288
214
|
// Best effort by design: this only decides what a lookup is filed under,
|
|
289
215
|
// so an unreachable or unhelpful CUBE must never fail the query itself.
|
|
@@ -300,9 +226,30 @@ export async function pacsIdentifier_resolve(pacsserver) {
|
|
|
300
226
|
break;
|
|
301
227
|
}
|
|
302
228
|
}
|
|
303
|
-
pacsIdentifiers.set(pacsserver, resolved);
|
|
304
229
|
return resolved;
|
|
305
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* The servers CUBE lists, by identifier: the only server names a
|
|
233
|
+
* screen-safe answer shows. None when CUBE will not say.
|
|
234
|
+
*
|
|
235
|
+
* @returns The identifiers.
|
|
236
|
+
*/
|
|
237
|
+
async function serverIdentifiers_list() {
|
|
238
|
+
const servers = await pacsServers_list();
|
|
239
|
+
if (!servers.ok)
|
|
240
|
+
return new Set();
|
|
241
|
+
return new Set(servers.value.flatMap((server) => (server.identifier ? [server.identifier] : [])));
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* What a screen-safe answer shows of its question, and the servers it may name.
|
|
245
|
+
*
|
|
246
|
+
* @param terms - The question's parsed terms.
|
|
247
|
+
* @param patientsArg - The `--patients` value, or null.
|
|
248
|
+
* @returns The question as shown, and the servers CUBE lists.
|
|
249
|
+
*/
|
|
250
|
+
async function answerShown_build(terms, patientsArg) {
|
|
251
|
+
return { expression: expressionShown_build(terms, patientsArg), servers: await serverIdentifiers_list() };
|
|
252
|
+
}
|
|
306
253
|
/**
|
|
307
254
|
* Says how long ago something was answered, in the coarsest true unit.
|
|
308
255
|
*
|
|
@@ -373,89 +320,8 @@ async function replay_attempt(criteria, identifier, owner) {
|
|
|
373
320
|
answeredAt: entry.answeredAt,
|
|
374
321
|
};
|
|
375
322
|
}
|
|
376
|
-
/**
|
|
377
|
-
* Reads a JSON expression as single-valued terms.
|
|
378
|
-
*
|
|
379
|
-
* The JSON form predates multi-value and stays what it was: one question,
|
|
380
|
-
* spelled as an object.
|
|
381
|
-
*
|
|
382
|
-
* @param expr - The expression, starting with `{`.
|
|
383
|
-
* @returns Terms with one value each, or null when the JSON is not an object.
|
|
384
|
-
*/
|
|
385
|
-
function termsFromJson_read(expr) {
|
|
386
|
-
const parsed = queryExpr_parse(expr);
|
|
387
|
-
if (parsed === null)
|
|
388
|
-
return null;
|
|
389
|
-
return Object.fromEntries(Object.entries(parsed).map(([key, value]) => [key, [value]]));
|
|
390
|
-
}
|
|
391
323
|
/** How many patient queries are in flight at once. */
|
|
392
324
|
const QUERY_FANOUT_CONCURRENCY = 4;
|
|
393
|
-
/**
|
|
394
|
-
* Renders criteria back into the expression syntax they were parsed from,
|
|
395
|
-
* so a single question inside a fan-out is asked exactly as one typed by
|
|
396
|
-
* hand — the create path takes an expression, not a record.
|
|
397
|
-
*
|
|
398
|
-
* @param criteria - One question's criteria.
|
|
399
|
-
* @returns The `Key:Value,Key:Value` form.
|
|
400
|
-
*/
|
|
401
|
-
function criteria_format(criteria) {
|
|
402
|
-
return Object.entries(criteria)
|
|
403
|
-
.map(([key, value]) => `${key}:${value}`)
|
|
404
|
-
.join(',');
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* One answer with a stand-in for everything it says about a person.
|
|
408
|
-
*
|
|
409
|
-
* Substituted in the DECODED payload, which is what the model, the table,
|
|
410
|
-
* the CSV and the console line are all built from — so one substitution
|
|
411
|
-
* reaches every one of them and none of them has to know.
|
|
412
|
-
*
|
|
413
|
-
* @param answer - What came back.
|
|
414
|
-
* @returns The same answer, saying nothing identifying.
|
|
415
|
-
*/
|
|
416
|
-
function answer_stoodIn(answer) {
|
|
417
|
-
if (answer.result === null)
|
|
418
|
-
return answer;
|
|
419
|
-
return {
|
|
420
|
-
...answer,
|
|
421
|
-
result: {
|
|
422
|
-
...answer.result,
|
|
423
|
-
decoded: { ...answer.result.decoded, json: answer_standIn(answer.result.decoded.json) },
|
|
424
|
-
},
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* The typed line, with stand-ins for the values in it.
|
|
429
|
-
*
|
|
430
|
-
* The line an operator typed is the first identifying thing on a screen,
|
|
431
|
-
* and it is echoed above the answer. Rewriting the VALUES rather than
|
|
432
|
-
* starring them out keeps the line honest — a PACS reads `*` as a wildcard,
|
|
433
|
-
* so a starred line is one an onlooker could run to mean something else
|
|
434
|
-
* entirely — and ties the line to the rows below it, which carry the same
|
|
435
|
-
* tokens.
|
|
436
|
-
*
|
|
437
|
-
* @param expression - The line as typed.
|
|
438
|
-
* @param asks - The questions it lowered to, holding the real values.
|
|
439
|
-
* @returns The line with each value stood in for.
|
|
440
|
-
*/
|
|
441
|
-
function expression_standIn(expression, asks) {
|
|
442
|
-
let out = expression;
|
|
443
|
-
const seen = [];
|
|
444
|
-
for (const ask of asks) {
|
|
445
|
-
for (const [field, value] of Object.entries(ask.criteria))
|
|
446
|
-
seen.push([field, value]);
|
|
447
|
-
}
|
|
448
|
-
// Longest first: a short value that is a substring of a longer one must
|
|
449
|
-
// not be replaced inside it.
|
|
450
|
-
seen.sort((a, b) => b[1].length - a[1].length);
|
|
451
|
-
for (const [field, value] of seen) {
|
|
452
|
-
if (value === '')
|
|
453
|
-
continue;
|
|
454
|
-
const stoodIn = criteria_standIn({ [field]: value })[field] ?? value;
|
|
455
|
-
out = out.split(value).join(stoodIn);
|
|
456
|
-
}
|
|
457
|
-
return out;
|
|
458
|
-
}
|
|
459
325
|
/**
|
|
460
326
|
* Asks one question, replaying it when the same question has been asked
|
|
461
327
|
* before.
|
|
@@ -550,74 +416,28 @@ async function fanout_run(asks, title, owner, fresh) {
|
|
|
550
416
|
return answers;
|
|
551
417
|
}
|
|
552
418
|
/**
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
* The studies keep their own identities and paths, each already built
|
|
556
|
-
* against the query that found it. The patient level records what was
|
|
557
|
-
* ASKED — including the questions that found nothing and the ones that
|
|
558
|
-
* could not be asked at all, which is the half of a cohort answer that
|
|
559
|
-
* cannot be derived from studies nobody has.
|
|
419
|
+
* Renders one patient row in the cohort audit table.
|
|
560
420
|
*
|
|
561
|
-
* @param
|
|
562
|
-
* @param
|
|
563
|
-
* @
|
|
421
|
+
* @param patient - The patient record.
|
|
422
|
+
* @param manyServers - Whether the SERVER column is shown.
|
|
423
|
+
* @param serverWidth - Width of the SERVER column.
|
|
424
|
+
* @returns The formatted row line.
|
|
564
425
|
*/
|
|
565
|
-
function
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
expression: criteria_format(answer.ask.criteria),
|
|
581
|
-
}).studies.map((study) => (manyServers ? { ...study, server: answer.ask.identifier } : study));
|
|
582
|
-
studies.push(...found);
|
|
583
|
-
if (answer.result !== null && (anchor === null || found.length > 0)) {
|
|
584
|
-
if (anchor === null || anchor.decoded.json === undefined)
|
|
585
|
-
anchor = answer.result;
|
|
586
|
-
}
|
|
587
|
-
const answeredAt = answer.answeredAt ?? new Date().toISOString();
|
|
588
|
-
if (answer.answeredAt === null)
|
|
589
|
-
allReplayed = false;
|
|
590
|
-
if (answer.result !== null && (oldest === null || answeredAt < oldest))
|
|
591
|
-
oldest = answeredAt;
|
|
592
|
-
if (answer.ask.patientId === undefined)
|
|
593
|
-
continue;
|
|
594
|
-
const seriesCount = found.reduce((total, study) => total + study.series.length, 0);
|
|
595
|
-
patients.push({
|
|
596
|
-
patientId: answer.ask.patientId,
|
|
597
|
-
...(manyServers ? { server: answer.ask.identifier } : {}),
|
|
598
|
-
...(found[0]?.patientName ? { patientName: found[0].patientName } : {}),
|
|
599
|
-
status: answer.result === null ? 'unasked' : (found.length > 0 ? 'found' : 'none'),
|
|
600
|
-
studyCount: found.length,
|
|
601
|
-
seriesCount,
|
|
602
|
-
...(answer.result === null ? {} : { queryId: answer.result.queryId }),
|
|
603
|
-
...(answer.result === null ? {} : {
|
|
604
|
-
provenance: { replayed: answer.answeredAt !== null, answeredAt },
|
|
605
|
-
}),
|
|
606
|
-
...(answer.error === undefined ? {} : { error: answer.error }),
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
return {
|
|
610
|
-
queryId: anchor?.queryId ?? 0,
|
|
611
|
-
vfsPath: anchor?.vfsPath ?? '',
|
|
612
|
-
pacsName: facts.pacsName,
|
|
613
|
-
expression: facts.expression,
|
|
614
|
-
studies,
|
|
615
|
-
// The set's provenance is its OLDEST row: the worst row is what decides
|
|
616
|
-
// whether an audit table can be trusted, and a set is only "replayed"
|
|
617
|
-
// when nothing in it troubled the PACS.
|
|
618
|
-
...(oldest === null ? {} : { provenance: { replayed: allReplayed, answeredAt: oldest } }),
|
|
619
|
-
...(patients.length > 0 ? { patients } : {}),
|
|
620
|
-
};
|
|
426
|
+
function cohortRow_render(patient, manyServers, serverWidth) {
|
|
427
|
+
const answered = patient.provenance === undefined
|
|
428
|
+
? null
|
|
429
|
+
: age_describe(patient.provenance.answeredAt);
|
|
430
|
+
const counts = patient.status === 'unasked'
|
|
431
|
+
? ['—', '—']
|
|
432
|
+
: [String(patient.studyCount), String(patient.seriesCount)];
|
|
433
|
+
const hue = patient.status === 'unasked'
|
|
434
|
+
? chalk.red
|
|
435
|
+
: (patient.status === 'none' ? chalk.gray : chalk.white);
|
|
436
|
+
const note = patient.status === 'unasked'
|
|
437
|
+
? chalk.red(patient.error ?? 'unasked')
|
|
438
|
+
: chalk.gray(answered ?? 'just now');
|
|
439
|
+
const server = manyServers ? (patient.server ?? '').padEnd(serverWidth) : '';
|
|
440
|
+
return ` ${hue(patient.patientId.padEnd(18))}${server}${counts[0].padEnd(10)}${counts[1].padEnd(9)}${note}`;
|
|
621
441
|
}
|
|
622
442
|
/**
|
|
623
443
|
* Renders a cohort as the audit table it is: one row per patient asked.
|
|
@@ -639,127 +459,10 @@ function cohort_render(patients) {
|
|
|
639
459
|
lines.push(` ${chalk.bold.white('MRN'.padEnd(18))}${serverCap}${chalk.bold.white('STUDIES'.padEnd(10))}${chalk.bold.white('SERIES'.padEnd(9))}${chalk.bold.white('ANSWERED')}`);
|
|
640
460
|
lines.push(` ${chalk.gray('─'.repeat(manyServers ? 74 : 60))}`);
|
|
641
461
|
for (const patient of patients) {
|
|
642
|
-
|
|
643
|
-
? null
|
|
644
|
-
: age_describe(patient.provenance.answeredAt);
|
|
645
|
-
const counts = patient.status === 'unasked'
|
|
646
|
-
? ['—', '—']
|
|
647
|
-
: [String(patient.studyCount), String(patient.seriesCount)];
|
|
648
|
-
const hue = patient.status === 'unasked'
|
|
649
|
-
? chalk.red
|
|
650
|
-
: (patient.status === 'none' ? chalk.gray : chalk.white);
|
|
651
|
-
const note = patient.status === 'unasked'
|
|
652
|
-
? chalk.red(patient.error ?? 'unasked')
|
|
653
|
-
: chalk.gray(answered ?? 'just now');
|
|
654
|
-
const server = manyServers ? server_extract(patient).padEnd(serverWidth) : '';
|
|
655
|
-
lines.push(` ${hue(patient.patientId.padEnd(18))}${server}${counts[0].padEnd(10)}${counts[1].padEnd(9)}${note}`);
|
|
462
|
+
lines.push(cohortRow_render(patient, manyServers, serverWidth));
|
|
656
463
|
}
|
|
657
464
|
return `${lines.join('\n')}\n${cohortTally_render(patients)}`;
|
|
658
465
|
}
|
|
659
|
-
/**
|
|
660
|
-
* The cohort's closing tally: found, none, unasked.
|
|
661
|
-
*
|
|
662
|
-
* @param patients - Every patient asked.
|
|
663
|
-
* @returns The tally line with a blank line either side, or '' when no patient was asked.
|
|
664
|
-
*/
|
|
665
|
-
function cohortTally_render(patients) {
|
|
666
|
-
if (patients.length === 0)
|
|
667
|
-
return '';
|
|
668
|
-
const tally = (state) => patients.filter((patient) => patient.status === state).length;
|
|
669
|
-
return ` ${chalk.green(`FOUND ${tally('found')}`)} ${chalk.gray('·')} ${chalk.gray(`NONE ${tally('none')}`)} ${chalk.gray('·')} ${chalk.red(`UNASKED ${tally('unasked')}`)}\n\n`;
|
|
670
|
-
}
|
|
671
|
-
/**
|
|
672
|
-
* Renders an answer as CSV, and writes it into ChRIS storage when asked.
|
|
673
|
-
*
|
|
674
|
-
* Two flags rather than one with an optional value: `--csv PatientID:1234`
|
|
675
|
-
* could not tell a destination from a query expression, and guessing wrong
|
|
676
|
-
* writes a file named after a patient.
|
|
677
|
-
*
|
|
678
|
-
* A local terminal needs no destination — `--csv > audit.csv` writes the
|
|
679
|
-
* operator's own disk, because engine and operator share a filesystem. A
|
|
680
|
-
* detached surface does not: the engine runs on the daemon's host, so a
|
|
681
|
-
* redirect lands on somebody else's machine. `--csv-to` puts the table in
|
|
682
|
-
* CFS instead, where a cohort's MRNs and study descriptions stay inside
|
|
683
|
-
* ChRIS rather than on whatever laptop the operator is sitting at.
|
|
684
|
-
*
|
|
685
|
-
* @param model - The answer.
|
|
686
|
-
* @param destination - A CFS path to write to, or null to render only.
|
|
687
|
-
* @returns The CSV text and where it went, or a failure already explained.
|
|
688
|
-
*/
|
|
689
|
-
async function csv_deliver(model, destination, ask = false, force = false, level = 'study', table = false) {
|
|
690
|
-
const csv = pacsAnswer_renderCsv(model, level);
|
|
691
|
-
let target = destination;
|
|
692
|
-
if (target === null && ask) {
|
|
693
|
-
// Asked only once there is something to write: a question raised before
|
|
694
|
-
// the PACS answered would be a question about a file that may never
|
|
695
|
-
// exist.
|
|
696
|
-
const chosen = await csvDestination_ask();
|
|
697
|
-
if (chosen === '')
|
|
698
|
-
return { ok: false, message: 'query: no destination given; nothing written.' };
|
|
699
|
-
target = chosen;
|
|
700
|
-
}
|
|
701
|
-
if (target === null)
|
|
702
|
-
return { ok: true, rendered: csv };
|
|
703
|
-
const written = await csvFile_write(csv, target, force);
|
|
704
|
-
if (!written.ok)
|
|
705
|
-
return { ok: false, message: `query: ${written.message}` };
|
|
706
|
-
// A folder that had to be made is said, not discovered later.
|
|
707
|
-
const made = written.created === undefined
|
|
708
|
-
? ''
|
|
709
|
-
: `${chalk.gray(` made ${written.created}`)}\n`;
|
|
710
|
-
// A file that was there and is not any more is said, for the same reason
|
|
711
|
-
// the folder is: an act nobody reported is an act nobody can check.
|
|
712
|
-
const gone = written.replaced === true
|
|
713
|
-
? `${chalk.gray(` replaced the table that was there`)}\n`
|
|
714
|
-
: '';
|
|
715
|
-
// The file went where it was sent; the screen, asked for the table,
|
|
716
|
-
// shows the same rows beside the word that they were written.
|
|
717
|
-
const shown = table ? `\n${pacsAnswer_renderTable(model, level)}` : '';
|
|
718
|
-
return { ok: true, rendered: `${made}${gone}${chalk.green(`✓ wrote ${written.path}`)}\n${shown}` };
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Asks where the table should go.
|
|
722
|
-
*
|
|
723
|
-
* The anchor is the session's own cwd — a fact, not a guess. Inventing a
|
|
724
|
-
* directory here would mean creating one behind the operator's back, which
|
|
725
|
-
* is what the surface used to do.
|
|
726
|
-
*
|
|
727
|
-
* @returns The location given, absolute, or '' when the operator abandoned the ask.
|
|
728
|
-
*/
|
|
729
|
-
async function csvDestination_ask() {
|
|
730
|
-
const { session } = await import('../../session/index.js');
|
|
731
|
-
const { repl_questionPath } = await import('../../core/question.js');
|
|
732
|
-
const stamp = new Date().toISOString().slice(0, 19).replace(/[:T]/g, '-');
|
|
733
|
-
// Where the operator is, unless they are somewhere nothing can be
|
|
734
|
-
// written: a session sitting in `/bin` or `/proc` is browsing a provider,
|
|
735
|
-
// not a place a file lands, and an errand that opens there offers a
|
|
736
|
-
// destination that is refused the moment it is committed.
|
|
737
|
-
const cwd = await session.getCWD();
|
|
738
|
-
const virtual = ['/bin', '/usr', '/etc', '/proc', '/net']
|
|
739
|
-
.some((prefix) => cwd === prefix || cwd.startsWith(`${prefix}/`));
|
|
740
|
-
try {
|
|
741
|
-
const answer = await repl_questionPath('Where should the table go? ', {
|
|
742
|
-
anchor: virtual ? '~' : cwd,
|
|
743
|
-
wantsDirectory: false,
|
|
744
|
-
suggest: `pacs-${stamp}.csv`,
|
|
745
|
-
}, 'EXPORT HERE');
|
|
746
|
-
// Absolute, against the place the question showed: other commands run
|
|
747
|
-
// while it is open, and a `cd` among them must not move the file.
|
|
748
|
-
const given = answer.trim();
|
|
749
|
-
if (given === '')
|
|
750
|
-
return '';
|
|
751
|
-
const { path_resolve } = await import('../utils.js');
|
|
752
|
-
if (given.startsWith('/') || given.startsWith('~'))
|
|
753
|
-
return await path_resolve(given);
|
|
754
|
-
const base = virtual ? '~' : cwd;
|
|
755
|
-
return await path_resolve(`${base === '/' ? '' : base}/${given}`);
|
|
756
|
-
}
|
|
757
|
-
catch {
|
|
758
|
-
// A refused or abandoned ask is not a failure of the query: the answer
|
|
759
|
-
// stands, and only the writing of it does not happen.
|
|
760
|
-
return '';
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
466
|
/**
|
|
764
467
|
* Answers a cohort: many questions, one model, one table.
|
|
765
468
|
*
|
|
@@ -768,30 +471,18 @@ async function csvDestination_ask() {
|
|
|
768
471
|
* @returns One envelope carrying every answer.
|
|
769
472
|
*/
|
|
770
473
|
async function cohort_answer(asks, facts) {
|
|
771
|
-
|
|
474
|
+
const anon = facts.shown !== null;
|
|
475
|
+
spinner.start(anon ? QUERY_ANON_PROGRESS : `Querying PACS for ${asks.length} questions...`, true);
|
|
772
476
|
const answers = await fanout_run(asks, facts.title, facts.owner, facts.fresh);
|
|
773
477
|
spinner.stop();
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
await modelPulledState_fill(model);
|
|
478
|
+
const built = fanoutModel_build(answers, { pacsName: facts.pacsserver, expression: facts.expression });
|
|
479
|
+
await modelPulledState_fill(built);
|
|
480
|
+
// Built and reconciled on the real answers; shown, under --anon, saying no patient.
|
|
481
|
+
const model = facts.shown === null ? built : pacsModel_standIn(built, facts.shown.expression, facts.shown.servers);
|
|
779
482
|
const patients = model.patients ?? [];
|
|
780
483
|
const unasked = patients.filter((patient) => patient.status === 'unasked').length;
|
|
781
484
|
if (facts.csv || facts.csvTo !== null || facts.csvToAsk) {
|
|
782
|
-
|
|
783
|
-
if (!delivered.ok) {
|
|
784
|
-
exitCode_set(1);
|
|
785
|
-
// The ANSWER stands: only the writing of it did not happen. An
|
|
786
|
-
// abandoned question, or a refused destination, is no reason to
|
|
787
|
-
// throw away a PACS answer the operator waited for — the model
|
|
788
|
-
// crosses either way, and a surface still shows what was found.
|
|
789
|
-
return {
|
|
790
|
-
...envelope_error('', undefined, `${chalk.red(delivered.message)}\n`),
|
|
791
|
-
model: { kind: PACS_QUERY_MODEL_KIND, data: model },
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
return envelope_ok(delivered.rendered, { kind: PACS_QUERY_MODEL_KIND, data: model });
|
|
485
|
+
return csvAnswer_envelope(await csv_deliver(model, facts.csvTo, facts.csvToAsk, facts.force, facts.level, facts.table, anon), model);
|
|
795
486
|
}
|
|
796
487
|
// A fan-out over something other than patients has no audit table to
|
|
797
488
|
// show; its studies are the answer, and they are already in the model.
|
|
@@ -837,7 +528,12 @@ export const queryCommand = command_declare({
|
|
|
837
528
|
+ 'A PACS matches one patient at a time, so several MRNs (PatientID:1,2,3 or --patients) is several queries, one table. '
|
|
838
529
|
+ 'Some PACS ignore keys: PACSDCM answers SeriesDescription and StudyDescription as if they were not asked (query says so); '
|
|
839
530
|
+ 'narrow the answer with grep. The keys each server ignores are in ~/.config/mise/pacs.json, as '
|
|
840
|
-
+ '{"ignoredKeys": {"PACSDCM": ["SeriesDescription", "StudyDescription"]}}.'
|
|
531
|
+
+ '{"ignoredKeys": {"PACSDCM": ["SeriesDescription", "StudyDescription"]}}. '
|
|
532
|
+
+ '--anon makes what the query itself prints or hands a surface screen-safe: names, record and accession numbers are stand-ins, '
|
|
533
|
+
+ 'dates fall to the month, descriptions, reasons and the progress line say no patient, and anything it does not recognise is withheld. '
|
|
534
|
+
+ 'It does not mask the line you typed, '
|
|
535
|
+
+ 'nor what you carry onward from it (history, variables, the next command). Paths stay real, because a surface acts on them: '
|
|
536
|
+
+ 'vfsPath, the @STD/@SER handle targets, studies[].series[].folderPath and the --csv-to destination.',
|
|
841
537
|
category: 'PACS',
|
|
842
538
|
examples: [
|
|
843
539
|
'query PatientID:1234',
|
|
@@ -864,260 +560,254 @@ export const queryCommand = command_declare({
|
|
|
864
560
|
handler: queryLine_run,
|
|
865
561
|
});
|
|
866
562
|
/**
|
|
867
|
-
*
|
|
868
|
-
*
|
|
869
|
-
* @param args - The words after `query`.
|
|
870
|
-
* @returns The answer, or the refusal of a bad line.
|
|
563
|
+
* Refuses a query line: non-zero, the reason in red.
|
|
871
564
|
*
|
|
872
|
-
* @
|
|
873
|
-
*
|
|
874
|
-
* await builtin_query(['PatientID:1234', '--table']);
|
|
875
|
-
* ```
|
|
565
|
+
* @param message - Why.
|
|
566
|
+
* @returns The error envelope.
|
|
876
567
|
*/
|
|
877
|
-
|
|
878
|
-
|
|
568
|
+
function queryLine_refuse(message) {
|
|
569
|
+
exitCode_set(1);
|
|
570
|
+
return envelope_error('', undefined, `${chalk.red(message)}\n`);
|
|
879
571
|
}
|
|
880
572
|
/**
|
|
881
|
-
*
|
|
882
|
-
*
|
|
573
|
+
* Reads what a query line asks for, refusing a line that asks for two
|
|
574
|
+
* formats for one screen or for nothing at all.
|
|
883
575
|
*
|
|
884
576
|
* @param args - The line, parsed.
|
|
885
|
-
* @returns The
|
|
886
|
-
*
|
|
887
|
-
* @example
|
|
888
|
-
* ```ts
|
|
889
|
-
* await queryLine_run({ operands: { expression: ['PatientID:1234'] }, options: { …, table: true } });
|
|
890
|
-
* ```
|
|
577
|
+
* @returns The request, or the refusal.
|
|
891
578
|
*/
|
|
892
|
-
|
|
579
|
+
function queryRequest_read(args) {
|
|
893
580
|
const { options } = args;
|
|
894
581
|
const title = options.title ?? `Query ${Date.now()}`;
|
|
895
|
-
const pacsserverOverride = options.pacsserver ?? null;
|
|
896
|
-
let tableMode = options.table;
|
|
897
|
-
const fresh = options.fresh;
|
|
898
|
-
const patientsArg = options.patients ?? null;
|
|
899
582
|
const csv = options.csv;
|
|
900
|
-
// A value-taking flag given no value is an ASK: `--csv-to` with nothing
|
|
901
|
-
// after it means "ask me where", which is how a graphical surface opens
|
|
902
|
-
// its errand and how a terminal gets a prompt.
|
|
903
|
-
const csvTo = options.csvTo ?? null;
|
|
904
|
-
const csvToAsk = options.csvTo === null;
|
|
905
|
-
const force = options.force;
|
|
906
|
-
// Standing in for what the answer says about a person is for
|
|
907
|
-
// demonstrating against a live hospital PACS, where every answer carries
|
|
908
|
-
// somebody's name and record number onto the screen.
|
|
909
|
-
const anon = options.anon;
|
|
910
583
|
const level = options.series ? 'series' : 'study';
|
|
584
|
+
const patientsArg = options.patients ?? null;
|
|
911
585
|
const positional = args.operands.expression;
|
|
912
586
|
// Two renderings for one screen: CSV is the answer's text, the table is
|
|
913
587
|
// its rows aligned. Asked for both, neither is guessed; writing the CSV
|
|
914
588
|
// to a file (`--csv-to`) leaves the screen free for the table.
|
|
915
|
-
if (csv &&
|
|
916
|
-
|
|
917
|
-
return envelope_error('', undefined, `${chalk.red('query: --csv and --table are two formats for one screen; pick one (or --csv-to <cfs-path> --table: the file gets the CSV, the screen the table)')}\n`);
|
|
589
|
+
if (csv && options.table) {
|
|
590
|
+
return queryLine_refuse('query: --csv and --table are two formats for one screen; pick one (or --csv-to <cfs-path> --table: the file gets the CSV, the screen the table)');
|
|
918
591
|
}
|
|
919
|
-
// A level is a property of rows: asked for series with no format named,
|
|
920
|
-
// the answer is the series table.
|
|
921
|
-
if (level === 'series' && !csv)
|
|
922
|
-
tableMode = true;
|
|
923
592
|
if (positional.length === 0 && patientsArg === null) {
|
|
924
|
-
|
|
925
|
-
return envelope_error('', undefined, `${chalk.red('query: Missing query expression. Usage: query <Key:Value[,...]> [--patients <list|@file>] [--title <title>]')}\n`);
|
|
593
|
+
return queryLine_refuse('query: Missing query expression. Usage: query <Key:Value[,...]> [--patients <list|@file>] [--title <title>]');
|
|
926
594
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
:
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
595
|
+
return {
|
|
596
|
+
title,
|
|
597
|
+
pacsserverOverride: options.pacsserver ?? null,
|
|
598
|
+
// A level is a property of rows: asked for series with no format named,
|
|
599
|
+
// the answer is the series table.
|
|
600
|
+
tableMode: options.table || (level === 'series' && !csv),
|
|
601
|
+
fresh: options.fresh,
|
|
602
|
+
patientsArg,
|
|
603
|
+
csv,
|
|
604
|
+
// A value-taking flag given no value is an ASK: `--csv-to` with nothing
|
|
605
|
+
// after it means "ask me where", which is how a graphical surface opens
|
|
606
|
+
// its errand and how a terminal gets a prompt.
|
|
607
|
+
csvTo: options.csvTo ?? null,
|
|
608
|
+
csvToAsk: options.csvTo === null,
|
|
609
|
+
force: options.force,
|
|
610
|
+
// Standing in for what the answer says about a person is for
|
|
611
|
+
// demonstrating against a live hospital PACS, where every answer carries
|
|
612
|
+
// somebody's name and record number onto the screen.
|
|
613
|
+
anon: options.anon,
|
|
614
|
+
level,
|
|
615
|
+
queryExpr: positional.join(' '),
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Reads the expression's terms, or refuses a line whose expression does not
|
|
620
|
+
* read: under --anon without echoing it. A cohort may narrow with terms or
|
|
621
|
+
* with none at all: `--patients @mrns.txt` is a complete question.
|
|
622
|
+
*
|
|
623
|
+
* @param queryExpr - The expression as typed.
|
|
624
|
+
* @param anon - True when the line must not be echoed.
|
|
625
|
+
* @returns The terms, or the refusal.
|
|
626
|
+
*/
|
|
627
|
+
function queryTerms_read(queryExpr, anon) {
|
|
628
|
+
if (queryExpr === '')
|
|
629
|
+
return { terms: {} };
|
|
630
|
+
const terms = queryExpr.trimStart().startsWith('{') ? jsonTerms_parse(queryExpr) : queryTerms_parse(queryExpr);
|
|
631
|
+
if (terms === 'unquoted')
|
|
632
|
+
return queryLine_refuse('query: a JSON question\'s identifiers must be strings, its other values strings or numbers (quote it: {"PatientID": "…"})');
|
|
633
|
+
if (terms === null)
|
|
634
|
+
return queryLine_refuse(`query: Invalid expression${anon ? '' : `: "${queryExpr}"`}. Use Key:Value pairs (e.g. PatientID:1234) or JSON.`);
|
|
635
|
+
return { terms };
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* The servers `--pacsserver` names. Several is a QUERY across them; one is
|
|
639
|
+
* the ordinary case. There is no sweep-everything: a fan-out is always
|
|
640
|
+
* something the operator named, because thirteen registrations of unknown
|
|
641
|
+
* liveness is thousands of C-FINDs mostly into the void.
|
|
642
|
+
*
|
|
643
|
+
* @param override - The flag's value, or null.
|
|
644
|
+
* @returns The servers named, possibly none.
|
|
645
|
+
*/
|
|
646
|
+
function serverList_parse(override) {
|
|
647
|
+
return (override ?? '')
|
|
942
648
|
.split(',')
|
|
943
649
|
.map((entry) => entry.trim())
|
|
944
650
|
.filter((entry) => entry !== '');
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* The server asked when none is named: the session's, else the first
|
|
654
|
+
* registered.
|
|
655
|
+
*
|
|
656
|
+
* @returns The one server, or the refusal when there is none.
|
|
657
|
+
*/
|
|
658
|
+
async function queryServerDefault_resolve() {
|
|
659
|
+
const inContext = await chrisContext.current_get(Context.PACSserver);
|
|
660
|
+
if (inContext)
|
|
661
|
+
return [inContext];
|
|
662
|
+
const serversResult = await pacsServers_list();
|
|
663
|
+
if (serversResult.ok && serversResult.value.length > 0)
|
|
664
|
+
return [String(serversResult.value[0].id)];
|
|
665
|
+
return queryLine_refuse('query: No PACS server available. Set one with: pacs connect <id>');
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Says, once, on the err channel and before the question goes out, each key
|
|
669
|
+
* a server ignores: it narrows nothing, and the query runs as asked (#1105).
|
|
670
|
+
*
|
|
671
|
+
* @param terms - The terms asked.
|
|
672
|
+
* @param identifiers - The servers asked.
|
|
673
|
+
* @param anon - True for the screen-safe hint: no server, nothing asked.
|
|
674
|
+
*/
|
|
675
|
+
function ignoredKeys_say(terms, identifiers, anon) {
|
|
676
|
+
// Under --anon the hint names no server and nothing asked, so one hint
|
|
677
|
+
// said for two servers is the same words: it is said once.
|
|
678
|
+
const said = new Set();
|
|
969
679
|
for (const server of [...new Set(identifiers)]) {
|
|
970
|
-
const hint = ignoredKeys_hint(terms, server);
|
|
971
|
-
if (hint !== null)
|
|
680
|
+
const hint = ignoredKeys_hint(terms, server, undefined, anon);
|
|
681
|
+
if (hint !== null && !said.has(hint))
|
|
972
682
|
sink_get().err_write(`${chalk.yellow(hint)}\n`);
|
|
683
|
+
if (hint !== null)
|
|
684
|
+
said.add(hint);
|
|
973
685
|
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
if (
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* The failure of a single question, as the error stack says it, carried
|
|
689
|
+
* directly: in -c/-f mode nothing else will. A refusal says what to do about
|
|
690
|
+
* it: PACS is a group CUBE grants. Under --anon the reason is withheld: a
|
|
691
|
+
* PACS's own words may name anyone.
|
|
692
|
+
*
|
|
693
|
+
* @param anon - True when the answer must be screen-safe.
|
|
694
|
+
* @returns The error envelope.
|
|
695
|
+
*/
|
|
696
|
+
function queryFailure_answer(anon) {
|
|
697
|
+
const errs = errorStack.stack_getAll?.() ?? [];
|
|
698
|
+
const said = errs.map((err) => (typeof err === 'string' ? err : err.message ?? String(err)));
|
|
699
|
+
const reasons = anon ? [QUERY_ANON_FAILED] : said;
|
|
700
|
+
let errOut = reasons.length > 0
|
|
701
|
+
? reasons.map((reason) => `${chalk.red(reason)}\n`).join('')
|
|
702
|
+
: `${chalk.red('query: Failed — check connection and PACS server context.')}\n`;
|
|
703
|
+
if (pacsRefusal_is(said))
|
|
704
|
+
errOut += pacsRefusal_hint();
|
|
705
|
+
exitCode_set(1);
|
|
706
|
+
return envelope_error('', undefined, errOut);
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* The text of a single answer: complete, or answered how long ago; the
|
|
710
|
+
* rows; and the path to `cd` into or `pull`, held back when standing in.
|
|
711
|
+
* Rendered FROM the model's provenance, not from a second copy of the same
|
|
712
|
+
* fact: one timestamp, one claim, however many surfaces say it.
|
|
713
|
+
*
|
|
714
|
+
* @param model - The answer's model.
|
|
715
|
+
* @param queryId - The query that answered.
|
|
716
|
+
* @param vfsPath - Where it lives.
|
|
717
|
+
* @param renderedResult - The rows, rendered.
|
|
718
|
+
* @param shownExpr - The question as shown.
|
|
719
|
+
* @param anon - True when standing in.
|
|
720
|
+
* @returns The text.
|
|
721
|
+
*/
|
|
722
|
+
function singleAnswer_text(model, queryId, vfsPath, renderedResult, shownExpr, anon) {
|
|
723
|
+
const replayed = model.provenance?.replayed === true ? model.provenance : undefined;
|
|
724
|
+
const age = replayed === undefined ? null : age_describe(replayed.answeredAt);
|
|
725
|
+
let rendered = replayed === undefined
|
|
726
|
+
? `${chalk.green(`✓ Query ${queryId} complete`)}\n`
|
|
727
|
+
: `${chalk.green(`✓ Query ${queryId} — answered ${age ?? 'earlier'}`)}\n`;
|
|
728
|
+
rendered += `${renderedResult}\n`;
|
|
729
|
+
if (anon) {
|
|
730
|
+
// The path spells the question, record number and all, and these three
|
|
731
|
+
// lines exist to be read off a screen — which is the one thing that
|
|
732
|
+
// must not happen here. The row's own controls still act on the real
|
|
733
|
+
// path, which the surface holds and never shows. The line that would
|
|
734
|
+
// ask again is held back with it: run, it would say the question.
|
|
735
|
+
return `${rendered}${chalk.gray(' the path is held back while standing in for this answer')}\n`;
|
|
736
|
+
}
|
|
737
|
+
rendered += `${chalk.bold(` VFS path: ${chalk.cyan(vfsPath)}`)}\n`;
|
|
738
|
+
rendered += `${chalk.gray(` cd ${vfsPath}`)}\n`;
|
|
739
|
+
rendered += `${chalk.gray(` pull ${vfsPath}`)}\n`;
|
|
740
|
+
// Said, never decided: mise states the age and leaves the judgement with
|
|
741
|
+
// the operator, who knows whether this question can gain an answer since.
|
|
742
|
+
if (replayed !== undefined)
|
|
743
|
+
rendered += `${chalk.gray(` query ${shownExpr} --fresh # ask the PACS again`)}\n`;
|
|
744
|
+
return rendered;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Fetches one question's answer: replayed when it was asked before, else
|
|
748
|
+
* asked of the PACS while the progress line says so. Under --anon that line
|
|
749
|
+
* names no question, and the backend's own status words are not passed on.
|
|
750
|
+
*
|
|
751
|
+
* @param request - What the line asked for.
|
|
752
|
+
* @param criteria - The one question.
|
|
753
|
+
* @param target - Where it goes, and who asks.
|
|
754
|
+
* @returns The answer (null when the question failed), and when it was answered for a replay.
|
|
755
|
+
*/
|
|
756
|
+
async function question_fetch(request, criteria, target) {
|
|
757
|
+
if (!request.fresh) {
|
|
758
|
+
const replayed = await replay_attempt(criteria, target.identifier, target.owner);
|
|
759
|
+
if (replayed !== null)
|
|
760
|
+
return replayed;
|
|
1039
761
|
}
|
|
1040
|
-
const
|
|
762
|
+
const askExpr = criteria_format(criteria);
|
|
763
|
+
const status_say = request.anon ? undefined : (msg) => spinner.updateMessage(msg);
|
|
764
|
+
spinner.start(request.anon ? QUERY_ANON_PROGRESS : `Querying PACS for ${askExpr}...`, true);
|
|
765
|
+
const result = await pacsQuery_createAndWait(askExpr, request.title, target.pacsserver, status_say);
|
|
766
|
+
spinner.stop();
|
|
767
|
+
return { result, answeredAt: null };
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Answers one question: replayed when it was asked before, else asked of
|
|
771
|
+
* the PACS; the answer modelled, marked with what CUBE already holds, and
|
|
772
|
+
* shown, written as CSV, or said to be empty.
|
|
773
|
+
*
|
|
774
|
+
* @param request - What the line asked for.
|
|
775
|
+
* @param criteria - The one question.
|
|
776
|
+
* @param target - Where it goes, and who asks.
|
|
777
|
+
* @param shown - Under --anon, the question as shown and the servers CUBE lists; null otherwise.
|
|
778
|
+
* @returns The answer, its model beside it.
|
|
779
|
+
*/
|
|
780
|
+
async function singleQuestion_answer(request, criteria, target, shown) {
|
|
781
|
+
const { tableMode, anon, level } = request;
|
|
1041
782
|
// One question, spelled as the create path wants it — which is not
|
|
1042
783
|
// necessarily what was typed: `--patients 1234` names a patient without
|
|
1043
784
|
// an expression to carry it.
|
|
1044
785
|
const askExpr = criteria_format(criteria);
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
if (replayed !== null) {
|
|
1050
|
-
result = replayed.result;
|
|
1051
|
-
answeredAt = replayed.answeredAt;
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
if (result === null) {
|
|
1055
|
-
spinner.start(`Querying PACS for ${askExpr}...`, true);
|
|
1056
|
-
result = await pacsQuery_createAndWait(askExpr, title, pacsserver, (msg) => spinner.updateMessage(msg));
|
|
1057
|
-
spinner.stop();
|
|
1058
|
-
}
|
|
1059
|
-
if (!result) {
|
|
1060
|
-
let errOut = '';
|
|
1061
|
-
const errs = errorStack.stack_getAll?.() ?? [];
|
|
1062
|
-
if (errs.length) {
|
|
1063
|
-
// Carry the stack directly: in -c/-f mode nothing else will.
|
|
1064
|
-
errs.forEach((err) => {
|
|
1065
|
-
const msg = typeof err === 'string' ? err : (err.message ?? String(err));
|
|
1066
|
-
errOut += `${chalk.red(msg)}\n`;
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
else {
|
|
1070
|
-
errOut += `${chalk.red('query: Failed — check connection and PACS server context.')}\n`;
|
|
1071
|
-
}
|
|
1072
|
-
// A refusal says what to do about it: PACS is a group CUBE grants.
|
|
1073
|
-
const said = errs.map((err) => typeof err === 'string' ? err : (err.message ?? String(err)));
|
|
1074
|
-
if (pacsRefusal_is(said))
|
|
1075
|
-
errOut += pacsRefusal_hint();
|
|
1076
|
-
exitCode_set(1);
|
|
1077
|
-
return envelope_error('', undefined, errOut);
|
|
1078
|
-
}
|
|
1079
|
-
// Everything below reads from `decoded`, so standing in here reaches the
|
|
1080
|
-
// table, the model a surface renders, and any CSV, all at once. The
|
|
1081
|
-
// DICOM identifiers are left alone: they are never shown, and they are
|
|
1082
|
-
// what the held-state reconciliation matches on.
|
|
1083
|
-
if (anon) {
|
|
1084
|
-
result = { ...result, decoded: { ...result.decoded, json: answer_standIn(result.decoded.json) } };
|
|
1085
|
-
}
|
|
1086
|
-
// What the operator typed, said in the same tokens the rows carry.
|
|
1087
|
-
const shownExpr = anon ? criteria_format(criteria_standIn(criteria)) : askExpr;
|
|
1088
|
-
let renderedResult = null;
|
|
1089
|
-
const model = pacsQueryModel_build(result.decoded, {
|
|
786
|
+
const { result, answeredAt } = await question_fetch(request, criteria, target);
|
|
787
|
+
if (!result)
|
|
788
|
+
return queryFailure_answer(anon);
|
|
789
|
+
const built = pacsQueryModel_build(result.decoded, {
|
|
1090
790
|
queryId: result.queryId,
|
|
1091
791
|
vfsPath: result.vfsPath,
|
|
1092
|
-
pacsName: identifier,
|
|
1093
|
-
expression:
|
|
1094
|
-
provenance: {
|
|
1095
|
-
replayed: answeredAt !== null,
|
|
1096
|
-
answeredAt: answeredAt ?? new Date().toISOString(),
|
|
1097
|
-
},
|
|
792
|
+
pacsName: target.identifier,
|
|
793
|
+
expression: askExpr,
|
|
794
|
+
provenance: { replayed: answeredAt !== null, answeredAt: answeredAt ?? new Date().toISOString() },
|
|
1098
795
|
});
|
|
1099
796
|
// Mark what CUBE already holds: a surface then offers gather instead of
|
|
1100
797
|
// pull for series that are already home. One bounded sweep, no retries.
|
|
1101
|
-
await modelPulledState_fill(
|
|
1102
|
-
//
|
|
1103
|
-
//
|
|
798
|
+
await modelPulledState_fill(built);
|
|
799
|
+
// Built and reconciled on the real answer; everything below (the table,
|
|
800
|
+
// the view, the CSV, the model a surface renders) reads its display form.
|
|
801
|
+
const model = shown === null ? built : pacsModel_standIn(built, shown.expression, shown.servers);
|
|
802
|
+
// The table and the default view read the model, pulled state and all, so
|
|
803
|
+
// the handles the view prints are the ones an index expands to (#1099).
|
|
804
|
+
let renderedResult = null;
|
|
1104
805
|
if (tableMode && model.studies.length > 0)
|
|
1105
806
|
renderedResult = `\n${pacsAnswer_renderTable(model, level)}`;
|
|
1106
|
-
// The default view reads the model too, so the handles it prints are the
|
|
1107
|
-
// ones an index expands to (#1099).
|
|
1108
807
|
if (!tableMode)
|
|
1109
808
|
renderedResult = pacsAnswer_render(model);
|
|
1110
|
-
if (csv || csvTo !== null || csvToAsk) {
|
|
1111
|
-
|
|
1112
|
-
if (!delivered.ok) {
|
|
1113
|
-
exitCode_set(1);
|
|
1114
|
-
// The answer stands; only the writing of it did not happen.
|
|
1115
|
-
return {
|
|
1116
|
-
...envelope_error('', undefined, `${chalk.red(delivered.message)}\n`),
|
|
1117
|
-
model: { kind: PACS_QUERY_MODEL_KIND, data: model },
|
|
1118
|
-
};
|
|
1119
|
-
}
|
|
1120
|
-
return envelope_ok(delivered.rendered, { kind: PACS_QUERY_MODEL_KIND, data: model });
|
|
809
|
+
if (request.csv || request.csvTo !== null || request.csvToAsk) {
|
|
810
|
+
return csvAnswer_envelope(await csv_deliver(model, request.csvTo, request.csvToAsk, request.force, level, tableMode, anon), model);
|
|
1121
811
|
}
|
|
1122
812
|
if (!renderedResult) {
|
|
1123
813
|
// Nothing matched: browsing or pulling the empty query would be
|
|
@@ -1125,32 +815,68 @@ export async function queryLine_run(args) {
|
|
|
1125
815
|
// graphical surface can say "no studies" in its own voice.
|
|
1126
816
|
return envelope_ok(`${chalk.yellow(`⚠ Query ${result.queryId} complete — no studies found.`)}\n`, { kind: PACS_QUERY_MODEL_KIND, data: model });
|
|
1127
817
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
818
|
+
return envelope_ok(singleAnswer_text(model, result.queryId, result.vfsPath, renderedResult, askExpr, anon), { kind: PACS_QUERY_MODEL_KIND, data: model });
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Creates a PACS query, waits for results, displays findings, and prints the
|
|
822
|
+
* VFS path: the handler of `query` and of `pacs query`. Under --anon the
|
|
823
|
+
* answer is screen-safe, and so is every reason it leaves behind.
|
|
824
|
+
*
|
|
825
|
+
* @param args - The line, parsed.
|
|
826
|
+
* @returns The answer, its model beside it.
|
|
827
|
+
*
|
|
828
|
+
* @example
|
|
829
|
+
* ```ts
|
|
830
|
+
* await queryLine_run({ operands: { expression: ['PatientID:1234'] }, options: { …, table: true } });
|
|
831
|
+
* ```
|
|
832
|
+
*/
|
|
833
|
+
export async function queryLine_run(args) {
|
|
834
|
+
if (!args.options.anon)
|
|
835
|
+
return queryLine_answer(args);
|
|
836
|
+
return anonAnswer_run(() => queryLine_answer(args));
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Answers a query line: its questions read, asked, and answered.
|
|
840
|
+
*
|
|
841
|
+
* @param args - The line, parsed.
|
|
842
|
+
* @returns The answer, its model beside it.
|
|
843
|
+
*/
|
|
844
|
+
async function queryLine_answer(args) {
|
|
845
|
+
const request = queryRequest_read(args);
|
|
846
|
+
if ('status' in request)
|
|
847
|
+
return request;
|
|
848
|
+
const { queryExpr, patientsArg, anon } = request;
|
|
849
|
+
// Validate expression early.
|
|
850
|
+
const read = queryTerms_read(queryExpr, anon);
|
|
851
|
+
if (!('terms' in read))
|
|
852
|
+
return read;
|
|
853
|
+
const terms = read.terms;
|
|
854
|
+
const named = serverList_parse(request.pacsserverOverride);
|
|
855
|
+
const servers = named.length > 0 ? named : await queryServerDefault_resolve();
|
|
856
|
+
if (!Array.isArray(servers))
|
|
857
|
+
return servers;
|
|
858
|
+
// The index is keyed on what CUBE stores, which is the identifier.
|
|
859
|
+
const identifiers = await Promise.all(servers.map((server) => pacsIdentifier_resolve(server)));
|
|
860
|
+
const target = { identifier: identifiers[0], pacsserver: servers[0], owner: await askingIdentity_get() };
|
|
861
|
+
ignoredKeys_say(terms, identifiers, anon);
|
|
862
|
+
// What the operator asked for, as the questions it stands for.
|
|
863
|
+
const asks = patientsArg !== null
|
|
864
|
+
? await cohortAsks_build(patientsArg, terms, servers, identifiers)
|
|
865
|
+
: inlineAsks_build(terms, servers, identifiers);
|
|
866
|
+
if (!Array.isArray(asks))
|
|
867
|
+
return anon ? queryLine_refuse(QUERY_ANON_REFUSED) : asks;
|
|
868
|
+
// The question as shown under --anon: built from what was parsed, never searched for in what was typed.
|
|
869
|
+
const shown = anon ? await answerShown_build(terms, patientsArg) : null;
|
|
870
|
+
if (asks.length > 1) {
|
|
871
|
+
const asked = patientsArg === null ? queryExpr : `${queryExpr} --patients ${patientsArg}`.trim();
|
|
872
|
+
return await cohort_answer(asks, {
|
|
873
|
+
// The model names the server the way CUBE does. `--pacsserver 1` and
|
|
874
|
+
// `--pacsserver PACSDCM` are the same server, and a table that says
|
|
875
|
+
// "1" tells an operator nothing about which PACS answered.
|
|
876
|
+
title: request.title, pacsserver: target.identifier, owner: target.owner, fresh: request.fresh, csv: request.csv, csvTo: request.csvTo, csvToAsk: request.csvToAsk, force: request.force, shown, level: request.level, table: request.tableMode,
|
|
877
|
+
expression: asked,
|
|
878
|
+
});
|
|
1153
879
|
}
|
|
1154
|
-
return
|
|
880
|
+
return singleQuestion_answer(request, asks[0]?.criteria ?? {}, target, shown);
|
|
1155
881
|
}
|
|
1156
882
|
//# sourceMappingURL=query.js.map
|