/**
* Execute a sequence of operations.
* Wraps `language-common/execute`, and prepends initial state for http.
* @example
* execute(
* create('foo'),
* delete('bar')
* )(state)
* @private
* @param {Operations} operations - Operations to be performed.
* @returns {Operation}
*/
export function execute(...operations: Operations): 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.
* @public
* @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 }
* );
* @param {object} query - Query parameters to send to primero, which will be built into URL parameters. See {@link https://github.com/primeroIMS/primero/blob/master/doc/api/cases/get.md Primero Docs} for a list of valid parameters.
* @param {object} options - (Optional) Additional options
* @param {boolean} options.withReferrals - Set to true to include referrals with each case. This will generate an extra request for each case and may take some time to process.
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function getCases(query: object, options: {
withReferrals: boolean;
}, callback: Function): Operation;
/**
* Create a new case in Primero
*
* Use this function to create a new case in Primero based on a set of Data.
* @public
* @example Create a new case in Primero based on a set of Data
* createCase({
* data: {
* age: 16,
* sex: "female",
* name: "Edwine Edgemont",
* },
* });
* @function
* @param {object} params - an object with some case data.
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function createCase(params: object, callback: Function): 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
* @public
* @example Update case for a specific case id
* updateCase("6aeaa66a-5a92-4ff5-bf7a-e59cde07eaaz", {
* data: {
* age: 16,
* sex: "female",
* name: "Fiona Edgemont",
* },
* });
* @function
* @param {string} id - A case ID to use for the update.
* @param {object} params - an object with some case data.
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function updateCase(id: string, params: object, callback: Function): 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.
* @public
* @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",
* }),
* });
* @function
* @param {object} params - an object with an externalIds and some case data.
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function upsertCase(params: object, callback: Function): 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`.
* @public
* @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",
* });
* @function
* @param {object} params - an object with an externalId field to select the attribute to use for matching on case and an externalId value for that case.
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function getReferrals(params: object, callback: Function): Operation;
/**
* Create referrals in Primero
*
* Use this function to bulk refer to one or multiple cases from Primero to a single user
* @public
* @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",
* },
* });
* @function
* @param {object} params - an object with referral data.
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function createReferrals(params: object, callback: Function): Operation;
export function updateReferrals(params: any, callback: any): Operation;
/**
* Update a single referral for a specific case in Primero
* @public
* @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,
* });
* @function
* @param {object} params - an object with an caseExternalId value to use, the id and the referral id to update.
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function updateReferral(params: object, callback: Function): 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.
* @public
* @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",
* });
* @function
* @param {object} query - an object with a query param at minimum
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function getForms(query: object, callback: Function): 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)
* @public
* @example Get lookups from Primero with query parameters
* getLookups({
* per: 10000,
* page: 5
* });
* @function
* @param {object} query - an object with a query param at minimum
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function getLookups(query: object, callback: Function): 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)
* @public
* @example Get loocations from Primero with query parameters
* getLocations({
* page: 1,
* per: 20
* })
* @function
* @param {object} query - an object with a query param at minimum
* @param {function} callback - (Optional) Callback function
* @returns {Operation}
*/
export function getLocations(query: object, callback: Function): Operation;
export function composeNextState(state: any, data: any, meta: any): any;
export { alterState, beta, combine, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, lastReferenceValue, merge, sourceValue, as } from "@openfn/language-common";