clinical_quality_language icon indicating copy to clipboard operation
clinical_quality_language copied to clipboard

Fixing bug with outputting success to StdError

Open alexgwalley opened this issue 3 years ago • 1 comments

Changes unnecessary System.Error.println commands to System.out.println so that developers can easily determine if translation completed successfully.

alexgwalley avatar Oct 07 '22 16:10 alexgwalley

This is linked to this issue: https://github.com/cqframework/clinical_quality_language/issues/818

alexgwalley avatar Oct 07 '22 16:10 alexgwalley

posix cli conventions require such message to go to std err, while output (in this case, the actual ELM) would be written to std out:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html

At program start-up, three streams shall be predefined and need not be opened explicitly: standard input (for reading conventional input), standard output (for writing conventional output), and standard error (for writing diagnostic output).

This allows cli commands to be composable:

// compile and run
cql -l Test.cql | cql-execute -data whatever/data -context patient=123

or:

// look for ValueSetRef nodes
cql -l Test.cql | grep 'ValueSetRef'

or:

// upload ELM to a server
cql -l Test.cql --output json | curl -X https://some.server.com/recieve-some-elm

If you write status message to std out you pollute the elm output with status messages, thus creating invalid ELM that you can't immediately consume. Granted, the current cli tooling doesn't support patterns like this but that is the intent of outputting to err rather than out. Given that we're already following the standard conventions I'd prefer to keep doing that but I could be convinced otherwise.

JPercival avatar Jun 02 '23 18:06 JPercival

Closing due to inactivity.

JPercival avatar Aug 07 '23 18:08 JPercival