primero@2.11.10
Functions
- cleanupState(state)
- createCase(params, callback)
- createReferrals(params, callback)
- generateAuthString(state)
- getCases(query, options, callback)
- getForms(query, callback)
- getLocations(query, callback)
- getLookups(query, callback)
- getReferrals(params, callback)
- login(state)
- queryHandler(state, params, callback)
- updateCase(id, params, callback)
- updateReferral(params, callback)
- upsertCase(params, callback)
The following functions are exported from the common adaptor:
- alterState()
- beta()
- combine()
- dataPath()
- dataValue()
- dateFns()
- each()
- field()
- fields()
- fn()
- http()
- lastReferenceValue()
- merge()
- sourceValue()
cleanupState
cleanupState(state) ⇒ State
Removes unserializable keys from the state.
Param | Type |
---|---|
state | State |
Example
cleanupState(state)
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.
Param | Type | Description |
---|---|---|
params | object | an object with some case data. |
callback | function | (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
Param | Type | Description |
---|---|---|
params | object | an object with referral data. |
callback | function | (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",
},
});
generateAuthString
generateAuthString(state) ⇒ string
Generate an auth string to support multiple types of auth credentials.
Param | Type |
---|---|
state | State |
Example
generateAuthString(state)
getCases
getCases(query, options, callback) ⇒ Operation
Get cases from Primero
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.
You can specify a case_id
value to fetch a unique case and a query string to filter result.
Param | Type | Description |
---|---|---|
query | object | an object with a query param at minimum, option to getReferrals |
options | object | (Optional) an object with a getReferrals key to fetch referrals |
callback | function | (Optional) Callback function |
Example ( Get cases from Primero with query parameters)
getCases({
remote: true,
query: "sex=male",
});
Example (Get case from Primero for a specific case id)
getCases({
remote: true,
case_id: "6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz",
});
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.
Param | Type | Description |
---|---|---|
query | object | an object with a query param at minimum |
callback | function | (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)
Param | Type | Description |
---|---|---|
query | object | an object with a query param at minimum |
callback | function | (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)
Param | Type | Description |
---|---|---|
query | object | an object with a query param at minimum |
callback | function | (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
.
Param | Type | Description |
---|---|---|
params | object | an object with an externalId field to select the attribute to use for matching on case and an externalId value for that case. |
callback | function | (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",
});
login
login(state) ⇒ State
Logs in to Primero.
Param | Type | Description |
---|---|---|
state | State | Runtime state. |
Example
login(state)
queryHandler
queryHandler(state, params, callback) ⇒ State
Execute custom query
Param | Type |
---|---|
state | State |
params | object |
callback | function |
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
Param | Type | Description |
---|---|---|
id | string | A case ID to use for the update. |
params | object | an object with some case data. |
callback | function | (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
Param | Type | Description |
---|---|---|
params | object | an object with an caseExternalId value to use, the id and the referral id to update. |
callback | function | (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.
Param | Type | Description |
---|---|---|
params | object | an object with an externalIds and some case data. |
callback | function | (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",
}),
});