Skip to main content

primero@3.0.6

createCase(params, callback)
createReferrals(params, callback)
getCases(query, options, callback)
getForms(query, callback)
getLocations(query, callback)
getLookups(query, callback)
getReferrals(params, callback)
updateCase(id, params, callback)
updateReferral(params, callback)
upsertCase(params, callback)

This adaptor exports the following from common:

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

Functions

createCase

createCase(params, callback) ⇒ Operation

Create a new case in Primero

Use this function to create a new case in Primero based on a set of Data.

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

Example: Create a new case in Primero based on a set of Data

createCase({
data: {
age: 16,
sex: "female",
name: "Edwine Edgemont",
},
});

createReferrals

createReferrals(params, callback) ⇒ Operation

Create referrals in Primero

Use this function to bulk refer to one or multiple cases from Primero to a single user

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

Example: Create referrals for multiple cases in Primero

createReferrals({
data: {
ids: [
"749e9c6e-60db-45ec-8f5a-69da7c223a79",
"dcea6052-07d9-4cfa-9abf-9a36987cdd25",
],
transitioned_to: "primero_cp",
notes: "This is a bulk referral",
},
});

getCases

getCases(query, options, callback) ⇒ Operation

Use this function to get cases from Primero based on a set of query parameters. Note that in many implementations, the remote attribute should be set to true to ensure that only cases marked for remote access will be retrieved. Set case_id on the query object to fetch a specific case.

ParamTypeDescription
queryobjectQuery parameters to send to primero, which will be built into URL parameters. See Primero Docs for a list of valid parameters.
optionsobject(Optional) Additional options
options.withReferralsbooleanSet to true to include referrals with each case. This will generate an extra request for each case and may take some time to process.
callbackfunction(Optional) Callback function

Example: Fetch all cases

getCases();

Example: Fetch all cases which match query criteria

getCases({
remote: true,
sex: "male",
age: "10..15",
protection_concerns :"unaccompanied,separated",
});

Example: Fetch a specific case by id

getCases({
case_id: "6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz",
});

Example: Get all remote cases and their referrals

getCases(
{ remote: true },
{ withReferrals: true }
);

getForms

getForms(query, callback) ⇒ Operation

Get forms from Primero

Use this function to get forms from Primero that are accessible to this user based on a set of query parameters. The user can filter the form list by record type and module.

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

Example: Get the list of all forms

getForms();

Example: Get the list of all forms for a specific module

getForms({
module_id: "6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz",
});

getLocations

getLocations(query, callback) ⇒ Operation

Get locations from Primero

Use this function to get a paginated list of all locations that are accessible to this user from Primero. Note: You can specify a per value to fetch records per page(Defaults to 20). Also you can specify page value to fetch pagination (Defaults to 1). Another parameter is hierarchy: true (Defaults to false)

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

Example: Get loocations from Primero with query parameters

getLocations({
page: 1,
per: 20
})

getLookups

getLookups(query, callback) ⇒ Operation

Get lookups from Primero

Use this function to get a paginated list of all lookups that are accessible to this user from Primero. Note: You can specify a per value to fetch records per page(Defaults to 20). Also you can specify page value to fetch pagination (Defaults to 1)

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

Example: Get lookups from Primero with query parameters

getLookups({
per: 10000,
page: 5
});

getReferrals

getReferrals(params, callback) ⇒ Operation

Get referrals for a specific case in Primero

Use this function to get the list of referrals of one case from Primero. The search can be done using either record id or case id.

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: Get referrals for a case in Primero by record id

getReferrals({
externalId: "record_id",
id: "6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz",
});

Example: Get referrals for a case in Primero by case id

 getReferrals({
id: "6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz",
});

updateCase

updateCase(id, params, callback) ⇒ Operation

Update an existing case in Primero

Use this function to update an existing case from Primero. In this implementation, the function uses a case ID to check for the case to update, Then merge the values submitted in this call into an existing case. Fields not specified in this request will not be modified. For nested subform fields, the subform arrays will be recursively merged, keeping both the existing values and appending the new

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

Example: Update case for a specific case id

updateCase("6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz", {
data: {
age: 16,
sex: "female",
name: "Fiona Edgemont",
},
});

updateReferral

updateReferral(params, callback) ⇒ Operation

Update a single referral for a specific case in Primero

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

Example: Update referral by record id

updateReferral({
caseExternalId: "record_id",
id: "749e9c6e-60db-45ec-8f5a-69da7c223a79",
caseId: "dcea6052-07d9-4cfa-9abf-9a36987cdd25",
data: (state) => state.data,
});

upsertCase

upsertCase(params, callback) ⇒ Operation

Upsert case to Primero

Use this function to update an existing case from Primero or to create it otherwise. In this implementation, we first fetch the list of cases, then we check if the case exist before choosing the right operation to do.

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

Example: Upsert case for a specific case id

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