fhir-ndr-et@0.1.7
This adaptor exports the following namespaced functions:
- utils.addExtension(resource, url, value)
- utils.cc()
- utils.coding(code, system)
- utils.composite(object, key, value)
- utils.concept()
- utils.findExtension(obj, targetUrl, [path])
- utils.id()
- utils.identifier(input, [system])
- utils.ref()
- utils.reference(ref)
- utils.setSystemMap()
- builders.carePlan(type, props)
- builders.encounter(type, props)
- builders.medication(type, props)
- builders.medicationAdministration(type, props)
- builders.medicationDispense(type, props)
- builders.medicationRequest(type, props)
- builders.observation(type, props)
- builders.patient(type, props)
- builders.relatedPerson(type, props)
This adaptor exports the following from common:
Functions
create
create(resourceType, resource, params, callback) ⇒ Operation
Creates a new resource with a server assigned resourceType. The resource object doesn't need resourceType or id
Param | Type | Description |
---|---|---|
resourceType | FhirResourceTypes | The resource type to create |
resource | FhirResource | The resource to create |
params | object | (Optional) FHIR parameters to control and configure resource creation. You can specify a version ie r4 here. |
callback | function | (Optional) callback function |
This operation writes the following keys to state:
State Key | Description |
---|
Example: Create a new patient
create('Patient', {
name: [
{
use: 'official',
family: 'La Paradisio',
given: ['Josephine', 'Nessa'],
},
],
});
utils
These functions belong to the utils namespace.
utils.addExtension
addExtension(resource, url, value)
Add an extension to a resource (or object).
An object will be created and added to an extension
array on the provided resource.
The extension array will be set if it does not exist on the resource.
The value will be smartly written to the object, ie, valueDateTime or valueReference or valueString
Param | Type | Description |
---|---|---|
resource | a FHIR resource object to add an extension too | |
url | string | the URL to set for the extension |
value | the value that the extension should contain |
utils.cc
cc()
Alias for util.concept()
utils.coding
coding(code, system)
Create a coding object { code, system }. Systems will be mapped using the system map.
Param | Type | Description |
---|---|---|
code | string | the code value |
system | string | URL to the system. Well be mapped using the system map. |
utils.composite
composite(object, key, value)
Write a value to the target object using a typed key
Ie, if key is value
and the value is a date time string,
this function will write valueDateTime
to the object.
This function is poorly named.
Param | Type | Description |
---|---|---|
object | the object to write the composite key to | |
key | string | the base key to use to write the value |
value | some value to write to the object |
utils.concept
concept()
Create a codeableConcept. Codings can be coding objects or [code, system] tuples if the first argument is a string, it will be set as the text. Systems will be mapped with the system map
Example: <Create a codeableConcept
const myConcept = util.concept(['abc', 'http://moh.gov.et/fhir/hiv/identifier/SmartCareID'])
* @example <caption><Create a codeableConcept with text</caption>
const myConcept = util.concept('smart care id', ['abc', 'http://moh.gov.et/fhir/hiv/identifier/SmartCareID'])
utils.findExtension
findExtension(obj, targetUrl, [path])
Find an extension with a given url in some array
Param | Type | Description |
---|---|---|
obj | a fhir resource | |
targetUrl | string | the extension URL you want to find |
[path] | string | a path to extract from the resource. Optional. |
utils.id
id()
Alias for util.identifier()
utils.identifier
identifier(input, [system])
Create an identifier resource. Systems will be mapped against the system map. The input can be a string value, or an identifier object. If input is an array of identifiers, an array of mapped/parsed values will be returned.
Param | Type | Description |
---|---|---|
input | an array of strings, or a identifier value as a string or object | |
[system] | string | the string system to use by default if |
utils.ref
ref()
Alias for util.reference()
utils.reference
reference(ref)
Create a reference object of the form { reference } If ref is an array, each item will be mapped and an array returned. If ref is a FHIR resource, a reference to it will be generated If ref is a string, it'll be treated as a reference id and returned as an object If ref is a valid FHIR reference, it'll just be returned.
Param | Description |
---|---|
ref | the thing to generate a reference from |
utils.setSystemMap
setSystemMap()
Define a set of mapped system values.
Builder functions will use this mappings when they encounter them in system keys. Useful for setting shortcuts.
Example: Set shortcut sustem mappings
util.setSystemMap({
SmartCareID: 'http://moh.gov.et/fhir/hiv/identifier/SmartCareID'
});
builders.patient('patient', { identifier: util.identifier('xyz', 'SmartCareId') })
};
builders
These functions belong to the builders namespace.
builders.carePlan
carePlan(type, props)
Create a FHIR CarePlan resource.
Param | Type | Description |
---|---|---|
type | string | The profile id for the resource variant |
props | Properties to apply to the resource |
builders.encounter
encounter(type, props)
Create a FHIR Encounter resource.
Param | Type | Description |
---|---|---|
type | string | The profile id for the resource variant |
props | Properties to apply to the resource |
builders.medication
medication(type, props)
Create a FHIR Medication resource.
Param | Type | Description |
---|---|---|
type | string | The profile id for the resource variant |
props | Properties to apply to the resource |
builders.medicationAdministration
medicationAdministration(type, props)
Create a FHIR MedicationAdministration resource.
Param | Type | Description |
---|---|---|
type | string | The profile id for the resource variant |
props | Properties to apply to the resource |
builders.medicationDispense
medicationDispense(type, props)
Create a FHIR MedicationDispense resource.
Param | Type | Description |
---|---|---|
type | string | The profile id for the resource variant |
props | Properties to apply to the resource |
builders.medicationRequest
medicationRequest(type, props)
Create a FHIR MedicationRequest resource.
Param | Type | Description |
---|---|---|
type | string | The profile id for the resource variant |
props | Properties to apply to the resource |
builders.observation
observation(type, props)
Create a FHIR Observation resource.
Param | Type | Description |
---|---|---|
type | string | The profile id for the resource variant |
props | Properties to apply to the resource |
builders.patient
patient(type, props)
Create a FHIR Patient resource.
Param | Type | Description |
---|---|---|
type | string | The profile id for the resource variant |
props | Properties to apply to the resource |
builders.relatedPerson
relatedPerson(type, props)
Create a FHIR RelatedPerson resource.
Param | Type | Description |
---|---|---|
type | string | The profile id for the resource variant |
props | Properties to apply to the resource |