Skip to main content
Version: v0.0.4

Function: convertCommand()

convertCommand(args, deps, posture?): Promise<RunResult>

Run the convert command.

Parameters

args

string[]

The arguments after the convert subcommand token.

deps

RunDeps

Injected input readers (RunDeps).

posture?

PhiPosture = VALUE_FREE

The resolved PhiPosture (governs only the opt-in unsafe excerpt on an HL7 parse-failure diagnostic; the converted bundle and the value-free findings are unaffected).

Returns

Promise<RunResult>

A RunResult: the converted FHIR Bundle on stdout (the data channel), value-free findings on stderr (or JSON under --json), and an exit code that carries the outcome: 0 clean · 1 an error-severity conversion issue · 65 the HL7 input could not be parsed or is not an HL7 v2 source · 66 no input · 2 usage.

Throws

Never CliError; may propagate a truly unexpected error for the dispatcher to map to CLI_INTERNAL.

Example

import { convertCommand } from "@cosyte/cli";

const deps = {
readFile: async () => new TextEncoder().encode("MSH|^~\\&|A|B|C|D|20240101||ADT^A01|1|P|2.5\r"),
readStdin: async () => new Uint8Array(),
};
(await convertCommand(["adt.hl7", "--to", "fhir"], deps)).exit; // => 0