@synanetics/fhir-operation-validator
v0.1.1
Published
Validates Parameters resources or URLSearchParams against FHIR OperationDefinitions
Downloads
233
Readme
@synanetics/fhir-operation-validator
Validates FHIR operation invocation parameters against the FHIR operation specification and against a supplied OperationDefinition.
Usage
import { validateOperationInput } from '@synanetics/fhir-operation-validator';
const result = validateOperationInput({
httpVerb: 'GET',
path: 'Patient/$summary',
parameters: new URLSearchParams([['identifier', 'https://fhir.nhs.uk/Id/nhs-number|9998887771']]);
}, {
// OperationDefinition resource object
});
// Returns an OperationOutcome. The "issue" array will be empty (length 0) if validation was
// successful. If the operation is not properly invoked in accordance with both the supplied
// OperationDefinition, and the [Operations specification](https://hl7.org/fhir/STU3/operations.html),
// the "issue" array will contain details of all of the ways in which the specification has been
// contravened (i.e. not just the first).
expect(result.issue).toHaveLength(0);@ts-ignore prevalence
There is a large number of instances of @ts-ignore in this codebase. This is due to the fact that the "Signature" data type changes between STU3 and R4, which causes the LSP to complain. Given that the code in the repository is the author of all of the OperationOutcomes, and given that no extensions are added (which are the only place in which a "Signature" data type could appear), it is safe for us to ignore this TypeScript issue. The alternative is to somewhat painstakingly define an OperationOutcome-like type on which extensions are not present.
