Skip to main content

primero@2.10.2

Functions

execute(operations)Operation

Execute a sequence of operations. Wraps language-common/execute, and prepends initial state for http.

generateAuthString(state)string

Generate an auth string to support multiple types of auth credentials.

queryHandler(state, params, callback)State

Execute custom query

login(state)State

Logs in to Primero.

cleanupState(state)State

Removes unserializable keys from the state.

getCases(query, options, callback)Operation

Get cases from Primero

createCase(params, callback)Operation

Create case in Primero

updateCase(id, params, callback)Operation

Update case in Primero

upsertCase(params, callback)Operation

Upsert case to Primero

getReferrals(params, callback)Operation

Get referrals for a specific case in Primero

createReferrals(params, callback)Operation

Create referrals in Primero

updateReferral(params, callback)Operation

Update a single referral for a specific case in Primero

getForms(query, callback)Operation

Get forms from Primero

getLookups(query, callback)Operation

Get lookups from Primero

getLocations(query, callback)Operation

Get locations from Primero

execute(operations) ⇒ Operation

Execute a sequence of operations. Wraps language-common/execute, and prepends initial state for http.

Kind: global function

ParamTypeDescription
operationsOperationsOperations to be performed.

Example

execute(
create('foo'),
delete('bar')
)(state)

generateAuthString(state) ⇒ string

Generate an auth string to support multiple types of auth credentials.

Kind: global function

ParamType
stateState

Example

generateAuthString(state)

queryHandler(state, params, callback) ⇒ State

Execute custom query

Kind: global function

ParamType
stateState
paramsobject
callbackfunction

login(state) ⇒ State

Logs in to Primero.

Kind: global function

ParamTypeDescription
stateStateRuntime state.

Example

login(state)

cleanupState(state) ⇒ State

Removes unserializable keys from the state.

Kind: global function

ParamType
stateState

Example

cleanupState(state)

getCases(query, options, callback) ⇒ Operation

Get cases from Primero

Kind: global function
Access: public

ParamTypeDescription
queryobjectan object with a query param at minimum, option to getReferrals
optionsobject(Optional) an object with a getReferrals key to fetch referrals
callbackfunction(Optional) Callback function

Example

getCases({
remote: true,
case_id: '6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz'
query: 'sex=male' // optional
}, { withReferrals: true }, callback)

createCase(params, callback) ⇒ Operation

Create case in Primero

Kind: global function
Access: public

ParamTypeDescription
paramsobjectan object with some case data.
callbackfunction(Optional) Callback function

Example

createCase({
data: state => data {
"enabled": true,
"age": 15,
"sex": "male",
"name": "Alex",
"status": "open",
"case_id": "6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz",
"owned_by": "primero_cp"
}}, callback)

updateCase(id, params, callback) ⇒ Operation

Update case in Primero

Kind: global function
Access: public

ParamTypeDescription
idstringan ID to use for the update.
paramsobjectan object with some case data.
callbackfunction(Optional) Callback function

Example

updateCase("7ed1d49f-14c7-4181-8d83-dc8ed1699f08", {
data: state => data {
"age": 20,
"sex": "male",
"name": "Alex",
"status": "open",
"case_id": "6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz",
}}, callback)

upsertCase(params, callback) ⇒ Operation

Upsert case to Primero

Kind: global function
Access: public

ParamTypeDescription
paramsobjectan object with an externalId and some case data.
callbackfunction(Optional) Callback function

Example

upsertCase({
externalIds: ['case_id'],
data: state => ({
"age": 20,
"sex": "male",
"name": "Alex",
"status": "open",
"case_id": "6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz",
})
});

getReferrals(params, callback) ⇒ Operation

Get referrals for a specific case in Primero

Kind: global function
Access: public

ParamTypeDescription
paramsobjectan object with an externalId field to select the attribute to use for matching on case and an externalId value for that case.
callbackfunction(Optional) Callback function

Example

getReferrals({
externalId: "record_id",
id: "7ed1d49f-14c7-4181-8d83-dc8ed1699f08",
}, callback)

createReferrals(params, callback) ⇒ Operation

Create referrals in Primero

Kind: global function
Access: public

ParamTypeDescription
paramsobjectan object with referral data.
callbackfunction(Optional) Callback function

Example

createReferrals({
data: {
"ids": ['case_id'],
"transitioned_to": "primero_cp",
"notes": "Creating a referral"
}
}, callback)

updateReferral(params, callback) ⇒ Operation

Update a single referral for a specific case in Primero

Kind: global function
Access: public

ParamTypeDescription
paramsobjectan object with an externalId value to use, the id and the referral id to update.
callbackfunction(Optional) Callback function

Example

updateReferral({
caseExternalId: "record_id",
caseId: "7ed1d49f-14c7-4181-8d83-dc8ed1699f08"
id: "37612f65-3bda-48eb-b526-d31383f94166",
data: state => state.data
}, callback)

getForms(query, callback) ⇒ Operation

Get forms from Primero

Kind: global function
Access: public

ParamTypeDescription
queryobjectan object with a query param at minimum
callbackfunction(Optional) Callback function

Example

getForms({
record_type: '' // Optional. Filters by the record type of the form,
module_id: 'id' //Optional. Filter forms by module,
}, callback)

getLookups(query, callback) ⇒ Operation

Get lookups from Primero

Kind: global function
Access: public

ParamTypeDescription
queryobjectan object with a query param at minimum
callbackfunction(Optional) Callback function

Example

getLookups({
page: 1 // Optional. Pagination. Defaults to 1,
per: 20 // Optional. Records per page. Defaults to 20,
}, callback)

getLocations(query, callback) ⇒ Operation

Get locations from Primero

Kind: global function
Access: public

ParamTypeDescription
queryobjectan object with a query param at minimum
callbackfunction(Optional) Callback function

Example

getLocations({
page: 1 // Optional.
per: 20 // Optional. Records per page,
hierarchy: // Defaults to false,
}, callback)