opencrvs@1.0.9
- createBirthNotification(body)
- createDocumentEntry(resource, [fullUrl])
- queryEvents(variables, options)
This adaptor exports the following namespaced functions:
This adaptor exports the following from common:
- combine()
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- fnIf()
- group()
- lastReferenceValue()
- merge()
- scrubEmojis()
- sourceValue()
- util
Functions
createBirthNotification
createBirthNotification(body) ⇒ Operation
Create a Birth Notification. Pass an array of FHIR resources wrapped in entry
objects like { fullUrl, resource }. References must use the full URL
of the corresponding resources. See OpenCRVS Event Notification Postman documentation
| Param | Type | Description |
|---|---|---|
| body | Array | An array of Birth Notification bundle entries. |
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 birth notification
createBirthNotification($.bundleData)
Example: Cross-reference two bundle resources
createBirthNotification([
{
fullUrl: 'urn:uuid:abcde',
resource: {
resourceType: 'Composition',
section:[
{
title: "Mother's details",
code: {
coding: [
{
system: 'http://opencrvs.org/specs/sections',
code: 'mother-details',
},
],
text: "Mother's details",
},
entry: [
{
reference: 'urn:uuid:wxyz',
},
],
}
// ... other section details
]
// ... other resource details
},
},
{
fullUrl: 'urn:uuid:wxyz',
resource: {
resourceType: 'Patient',
// ... other resource details
},
},
]);
createDocumentEntry
createDocumentEntry(resource, [fullUrl]) ⇒ Object
Create a document bundle entry with automatic UUID generation
Returns: Object - Bundle entry with fullUrl and resource
| Param | Type | Description |
|---|---|---|
| resource | Object | A FHIR resource using builders from fhir-4 |
| [fullUrl] | string | Custom fullUrl. Auto-generated if not provided |
Example
createDocumentEntry(builders.patient({ name: [{ given: ['John'] }] }))
queryEvents
queryEvents(variables, options) ⇒ Operation
Make an events search query against the OpenCRVS GraphQL API.
| Param | Type | Description |
|---|---|---|
| variables | Object | GraphQL search parameters. For a full list of options, see variables.advancedSearchParameters in OpenCRVS Docs |
| options | Object | Options to control the request, such as count and skip. Count defaults to 10. |
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 for events with specific parameters
queryEvents(
{
event: 'birth',
registrationStatuses: ['REGISTERED'],
childGender: 'male',
dateOfRegistrationEnd: '2022-12-31T23:59:59.999Z',
dateOfRegistrationStart: '2021-11-01T00:00:00.000Z',
declarationJurisdictionId: '',
eventLocationId: '704b9706-d729-4834-8656-05b562065deb',
fatherFirstNames: 'Dad',
motherFirstNames: 'Mom',
},
);
Example: Search for events with options
queryEvents(
{
event: 'birth',
registrationStatuses: ['REGISTERED'],
childGender: 'male',
dateOfRegistrationEnd: '2022-12-31T23:59:59.999Z',
dateOfRegistrationStart: '2021-11-01T00:00:00.000Z',
declarationJurisdictionId: '',
eventLocationId: '704b9706-d729-4834-8656-05b562065deb',
fatherFirstNames: 'Dad',
motherFirstNames: 'Mom',
},
{ count: 10, skip: 0 }
);
http
These functions belong to the http namespace.
http.post
post(path, body, options) ⇒ Operation
Make a POST request
| 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
http.post("/location", {
"statisticalID": "TEST_LOCATION",
"name": "My name",
"alias": "My alias",
"partOf": "Location/0",
"code": "ADMIN_STRUCTURE",
"jurisdictionType": "STATE",
"statistics": [
{
"year": 0,
"male_population": 0,
"female_population": 0,
"population": 0,
"crude_birth_rate": 0
}
]
});
http.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: Create a new administrative location
http.request("POST", "/location", {
"statisticalID": "TEST_LOCATION",
"name": "My name",
"alias": "My alias",
"partOf": "Location/0",
"code": "ADMIN_STRUCTURE",
"jurisdictionType": "STATE",
"statistics": [
{
"year": 0,
"male_population": 0,
"female_population": 0,
"population": 0,
"crude_birth_rate": 0
}
]
});
Interfaces
OpenCRVSHTTPState
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 |
OpenCRVSState
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 the HTTP request
Properties
| Name | Type | Description |
|---|---|---|
| errors | object | Map of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code. |
| query | object | An object of query parameters to be encoded into the URL. |