Skip to main content

fhir-ndr-et@0.1.0

create(resourceType, resource, params, callback)

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:

cursor()
dataPath()
dataValue()
each()
field()
fields()
fn()
lastReferenceValue()
merge()
sourceValue()

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

ParamTypeDescription
resourceTypeFhirResourceTypesThe resource type to create
resourceFhirResourceThe resource to create
paramsobject(Optional) FHIR parameters to control and configure resource creation. You can specify a version ie r4 here.
callbackfunction(Optional) callback function

This operation writes the following keys to state:

State KeyDescription

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

ParamTypeDescription
resourcea FHIR resource object to add an extension too
urlstringthe URL to set for the extension
valuethe 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.

ParamTypeDescription
codestringthe code value
systemstringURL 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.

ParamTypeDescription
objectthe object to write the composite key to
keystringthe base key to use to write the value
valuesome 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

ParamTypeDescription
obja fhir resource
targetUrlstringthe extension URL you want to find
[path]stringa 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.

ParamTypeDescription
inputan array of strings, or a identifier value as a string or object
[system]stringthe 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.

ParamDescription
refthe 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.

ParamTypeDescription
typestringThe profile id for the resource variant
propsProperties to apply to the resource

builders.encounter

encounter(type, props)

Create a FHIR Encounter resource.

ParamTypeDescription
typestringThe profile id for the resource variant
propsProperties to apply to the resource

builders.medication

medication(type, props)

Create a FHIR Medication resource.

ParamTypeDescription
typestringThe profile id for the resource variant
propsProperties to apply to the resource

builders.medicationAdministration

medicationAdministration(type, props)

Create a FHIR MedicationAdministration resource.

ParamTypeDescription
typestringThe profile id for the resource variant
propsProperties to apply to the resource

builders.medicationDispense

medicationDispense(type, props)

Create a FHIR MedicationDispense resource.

ParamTypeDescription
typestringThe profile id for the resource variant
propsProperties to apply to the resource

builders.medicationRequest

medicationRequest(type, props)

Create a FHIR MedicationRequest resource.

ParamTypeDescription
typestringThe profile id for the resource variant
propsProperties to apply to the resource

builders.observation

observation(type, props)

Create a FHIR Observation resource.

ParamTypeDescription
typestringThe profile id for the resource variant
propsProperties to apply to the resource

builders.patient

patient(type, props)

Create a FHIR Patient resource.

ParamTypeDescription
typestringThe profile id for the resource variant
propsProperties to apply to the resource

builders.relatedPerson

relatedPerson(type, props)

Create a FHIR RelatedPerson resource.

ParamTypeDescription
typestringThe profile id for the resource variant
propsProperties to apply to the resource