Skip to main content

fhir@4.0.0

Functions

create(path, data, callback)
createTransactionBundle(params, callback)
get(path, query, callback)
getClaim(claimId, query, callback)
post(path, data, params, callback)

The following functions are exported from the common adaptor:

alterState()
dataPath()
dataValue()
dateFns()
each()
field()
fields()
fn()
fnIf()
lastReferenceValue()
merge()
sourceValue()

create

create(path, data, callback) ⇒ Operation

Creates a resource in a destination system

ParamTypeDescription
pathstringPath to resource
dataobjectdata to create the new resource
callbackfunction(Optional) callback function

Example

create("Bundle", {
entry: [
{
fullUrl: "", // Eg: Patient URL
resource: {}, // Resource data
search: {
mode: "match",
},
},
],
type: "collection",
});

createTransactionBundle

createTransactionBundle(params, callback) ⇒ Operation

Creates a transactionBundle for HAPI FHIR

ParamTypeDescription
paramsobjectdata to create the new transaction
callbackfunction(Optional) callback function

Example

createTransactionBundle({
resourceType: "Bundle",
type: "transaction",
entry: [
{
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, query, callback) ⇒ Operation

Get a resource in a FHIR system

ParamTypeDescription
pathstringPath to resource
queryobjectdata to get the new resource
callbackfunction(Optional) callback function

Example (Get Claim from FHIR with optional query)

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

Example (Get Patient from FHIR)

get('Patient');

getClaim

getClaim(claimId, query, callback) ⇒ Operation

Get Claim in a FHIR system

ParamTypeDescription
claimIdstring(optional) claim id
queryobject(optinal) query parameters
callbackfunction(Optional) callback function

Example

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

post

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

Sends a HTTP POST request to the destination system

ParamTypeDescription
pathstringPath to resource
dataobjectObject or JSON which defines data that will be used to create a given resource
paramsRequestParamsContains optional headers, parseAs, and throwOnError
callbackfunction(Optional) callback function

Example

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

request

request ⇒ Object

This is an asynchronous function that sends a request to a specified URL with optional parameters and headers, and returns the response data in JSON format. If there is an error in the response, the function will throw an error unless params.throwOnError is false.

Returns: Object - The request function returns a object, where the parsed JSON body is written to data, and the raw http response to response.

ParamTypeDefaultDescription
urlstringThe URL of the API endpoint that the request is being made to.
[params]objectAn object containing any additional parameters to be sent with the request, such as query parameters or request body data. It is an optional parameter and defaults to an empty object if not provided.
[method]string"GET"The HTTP method to be used for the request. It defaults to 'GET' if not specified.

RequestParams

RequestParams : Object

Options provided to a HTTP request

Properties

NameTypeDefaultDescription
[throwOnError]booleantrueOptional boolean value to throw if the error is status code 400.
headersobjectAn optional object of headers to append to the request.
parseAsstringAn optional field of the data response format.