Skip to main content

opencrvs@1.0.0

createBirthNotification(body)
queryEvents(variables, options)

This adaptor exports the following namespaced functions:

http.post(path, body, options)
http.request(method, path, body, options)

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

ParamTypeDescription
bodyArrayAn array of Birth Notification bundle entries.

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan 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
},
},
]);

queryEvents

queryEvents(variables, options) ⇒ Operation

Make an events search query against the OpenCRVS GraphQL API.

ParamTypeDescription
variablesObjectGraphQL search parameters. For a full list of options, see variables.advancedSearchParameters in OpenCRVS Docs
optionsObjectOptions to control the request, such as count and skip. Count defaults to 10.

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: Search for events with specific parameters

query(
{
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

query(
{
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

ParamTypeDescription
pathstringPath to resource
bodyobjectObject which will be attached to the POST body
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan 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

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource
bodyobjectObject which will be attached to the POST body
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan 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

NameDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

OpenCRVSState

State object

Properties

NameDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

RequestOptions

Options provided to the HTTP request

Properties

NameTypeDescription
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
queryobjectAn object of query parameters to be encoded into the URL.