fhir-opensrp@1.0.0
- create(path, body, options)
- delete(path, options)
- read(path, options)
- request(method, path, body, options)
- update(path, body, options)
This adaptor exports the following from common:
- as()
- combine()
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- fnIf()
- group()
- lastReferenceValue()
- map()
- merge()
- scrubEmojis()
- sourceValue()
- util
Functions
create
create(path, body, options) ⇒ Operation
Create a resource
| Param | Type | Description |
|---|---|---|
| path | string | Path to resource |
| body | object | Object which will be attached to the POST body |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
Example: Create a Patient using builders (see fhir-4 docs)
create('Patient', builders.patient({
identifier: [
builders.identifier({
use: 'official',
system: 'http://ohie.org/National_Id',
value: 'NIN-TEST-001',
}),
],
name: [{ use: 'official', family: 'Nakamura', given: ['Aiko'], text: 'Aiko Nakamura' }],
gender: 'female',
birthDate: '1992-04-10',
active: true,
telecom: [{ system: 'phone', value: '0712345678' }],
}));
Example: Create a Patient without builders
create('Patient', {
resourceType: 'Patient',
active: true,
identifier: [
{ use: 'official', system: 'http://ohie.org/National_Id', value: 'NIN-TEST-001' },
],
name: [{ use: 'official', family: 'Nakamura', given: ['Aiko'] }],
gender: 'female',
birthDate: '1992-04-10',
telecom: [{ system: 'phone', value: '0712345678' }],
});
delete
delete(path, options) ⇒ Operation
Delete a resource
| Param | Type | Description |
|---|---|---|
| path | string | Path to resource |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
Example: Delete a Patient by ID
delete('Patient/97597');
read
read(path, options) ⇒ Operation
Read a resource
| Param | Type | Description |
|---|---|---|
| path | string | Path to resource |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
Example: Read server metadata
read('metadata');
Example: Search for recently updated Patients
read('Patient', {
query: {
'_lastUpdated': 'gt2026-07-01T00:00:00Z',
'_sort': '_lastUpdated',
'_count': 200
}
});
request
request(method, path, body, options) ⇒ Operation
Make a general HTTP request
| Param | Type | Description |
|---|---|---|
| method | string | HTTP method to use |
| path | string | Path to resource |
| body | object | Object which will be attached to the POST body |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
Example: Search Observations for a specific patient
request('GET', 'Observation', null, {
query: { 'subject': 'Patient/0181038e-682b-4c7c-a946-e3757d2fa2f7' }
});
Example: Update a Patient resource
request('PUT', 'Patient/0181038e-682b-4c7c-a946-e3757d2fa2f7', {
resourceType: 'Patient',
id: '0181038e-682b-4c7c-a946-e3757d2fa2f7',
active: false,
name: [{ use: 'official', family: 'Mathenge', given: ['Monica'] }],
gender: 'female',
birthDate: '1990-07-07',
});
update
update(path, body, options) ⇒ Operation
Update a resource
| Param | Type | Description |
|---|---|---|
| path | string | Path to resource |
| body | object | Object which will be attached to the POST body |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
Example: Update a Patient by ID
update('Patient/0181038e-682b-4c7c-a946-e3757d2fa2f7', {
resourceType: 'Patient',
id: '0181038e-682b-4c7c-a946-e3757d2fa2f7',
active: true,
name: [{ use: 'official', family: 'Mathenge', given: ['Monica'] }],
gender: 'female',
birthDate: '1990-07-07',
telecom: [{ system: 'phone', value: '0712010203' }],
managingOrganization: { reference: 'Organization/eb4963c3-3d6e-4ea9-bde8-6a5b638bc4f8' },
});
Interfaces
OnaFHIRState
State object
Properties
| Name | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
RequestOptions
Options provided to Ona fhir request
Properties
| Name | Type | Description |
|---|---|---|
| query | object | An object of query parameters to be encoded into the URL. |
| headers | object | An object of headers to append to the request. |