Skip to main content

fhir@5.0.2

create(resourceType, resource, params, callback)
createTransactionBundle(entries, callback)
get(path, params, options, callback)
getClaim(claimId, params, callback)
post(path, data, options, callback)

This adaptor exports the following from common:

alterState()
dataPath()
dataValue()
dateFns
each()
field()
fields()
fn()
fnIf()
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
resourceTypestringThe resource type to create
resourceobjectThe resource to create
paramsobject(Optional) FHIR parameters to control and configure resource creation
callbackfunction(Optional) callback function

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the FHIR HTTP server (with the body removed)
referencesan array of all the previous data values

Example: Create a new patient

create('Patient', {
name: [
{
use: 'official',
family: 'La Paradisio',
given: ['Josephine', 'Nessa'],
},
],
});

createTransactionBundle

createTransactionBundle(entries, callback) ⇒ Operation

Create a transaction bundle to process multiple requests at once

ParamTypeDescription
entriesarrayarray of transactions
callbackfunction(Optional) callback function

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the FHIR HTTP server (with the body removed)
referencesan array of all the previous data values

Example

createTransactionBundle([
{
fullUrl: "https://hapi.fhir.org/baseR4/Patient/592442",
resource: {
resourceType: "Patient",
id: "592442",
name: [{ given: "Caleb", family: "Cushing" }],
},
request: {
method: "POST",
url: "Patient",
},
},
]);

get

get(path, params, options, callback) ⇒ Operation

Send a HTTP GET request to the baseURL defined in config

ParamTypeDescription
pathstringPath to resource
paramsobject(Optional) Parameters to encode into the URL query
optionsGetOptions(Optional) Options to control the request
callbackfunction(Optional) callback function

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the FHIR HTTP server (with the body removed)
referencesan array of all the previous data values

Example: Get a Patient resource by id

get('Patient/0bd0038b-8aad-4719-8d55-ff94bd3de5d0');

Example: Get a resource with query parameters

get("Claim", { _include: "Claim:patient", _sort: "-_lastUpdated", _count: 200 })

getClaim

getClaim(claimId, params, callback) ⇒ Operation

Get Claim in a FHIR system

ParamTypeDescription
claimIdstringclaim id
paramsobjectquery parameters
callbackfunctioncallback function

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the FHIR HTTP server (with the body removed)
referencesan array of all the previous data values

Example

getClaim('',{ _include: "Claim:patient", _sort: "-_lastUpdated", _count: 200 });

post

post(path, data, options, callback) ⇒ Operation

Send a HTTP POST request to the baseURL defined in config

ParamTypeDescription
pathstringPath to resource
dataobjectJSON data to append to the POST body
optionsRequestOptions(Optional) Additional options for the request
callbackfunction(Optional) callback function

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the FHIR HTTP server (with the body removed)
referencesan array of all the previous data values

Example: Create bundle

post("Bundle",{
"resourceType": "Bundle"
})

Interfaces

GetOptions

Options provided to a GET HTTP request

Properties

NameTypeDescription
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
timeoutnumberRequest timeout in ms. Default: 300 seconds.

RequestOptions

Options provided to a HTTP request

Properties

NameTypeDescription
headersobjectObject of headers to append to the request
bodyobjectJSON payload to attach to the request
queryobjectQuery parameters for the request. Will be encoded into the URL
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
timeoutnumberRequest timeout in ms. Default: 300 seconds.