/**
* Options to append to the request. Unless otherwise specified, options are appended to the URL as query parameters - see the [OpenMRS Docs](https://rest.openmrs.org/) for all supported parameters.
* @typedef {object} GetOptions
* @property {string} [query] - (OpenFn only) Query string. Maps to `q` in OpenMRS.
* @property {string} [language] - (OpenFn only) Language code. Maps to `Accept-Language` in OpenMRS.
* @property {number} [max=10000] - (OpenFn only) Restrict the maximum number of retrieved records. May be fetched in several pages. Not used if `limit` is set.
* @property {number} [pageSize=1000] - (OpenFn only) Limits the size of each page of data. Not used if limit is set.
* @property {boolean} [singleton] - (OpenFn only) If set to true, only the first result will be returned. Useful for "get by id" APIs.
*/
/**
* Execute a sequence of operations.
* Wraps `language-common/execute`, and prepends initial state for OpenMRS.
* @example
* execute(
* create('foo'),
* delete('bar')
* )(state)
* @private
* @param {Array} operations - Operations to be performed.
* @returns {Operation}
*/
export function execute(...operations: any[]): Operation;
/**
* Fetch resources from OpenMRS. Use this to fetch a single resource,
* or to search a list.
*
* Options will be appended as query parameters to the request URL,
* refer to {@link https://rest.openmrs.org/ OpenMRS Docs} for details.
*
* Pagination is handled automatically by default (maximum 10k items). Set `max`
* to paginate with a higher limit, or pass `limit` to force a single request, as
* per the OpenMRS Rest API.
* @example
List all concepts (up to a maximum of 10k items, with pagination)
* get("concept")
* @example List all concepts (with pagination)
* get("concept", { query: "brian", max: Infinity })
* @example Search up to 100 patients by name (allowing pagination) (see OpenMRS API)
* get("patient", { query: "brian", max: 100 })
* @example Fetch patient by UUID (returns an array of 1 item)
* get("patient/abc")
* @example Fetch patient by UUID (returns an object of patient data)
* get("patient/abc", { singleton: true })
* @example Search up to 10 patients by name (in a single request without pagination) (see OpenMRS API)
* get("patient", { query: "brian", limit: 10 })
* @example List allergy subresources
* get("patient/abc/allergy")
* @example Get allergy subresource by its UUID and parent patient UUID
* get("patient/abc/allergy/xyz")
* @example Get patient by UUID and set the language to French
* get("patient/abc", { language: "fr" })
* @function
* @public
* @param {string} path - Path to resource (excluding `/ws/rest/v1/`)
* @param {GetOptions} [options = {}] Query parameters and other options for the request.
* @state data An array of result objects
* @returns {Operation}
*/
export function get(path: string, options?: GetOptions): Operation;
/**
* Create a resource. For a list of valid resources, see {@link https://rest.openmrs.org/ OpenMRS Docs}
* @public
* @function
* @param {string} path - Path to resource (excluding `/ws/rest/v1/`)
* @param {object} data - Resource definition
* @state data The newly created resource, as returned by OpenMRS
* @returns {Operation}
* @example Create a person (see OpenMRS API)
* create("person", {
* names: [
* {
* givenName: "Mohit",
* familyName: "Kumar",
* },
* ],
* gender: "M",
* birthdate: "1997-09-02",
* addresses: [
* {
* address1: "30, Vivekananda Layout, Munnekolal,Marathahalli",
* cityVillage: "Bengaluru",
* country: "India",
* postalCode: "560037",
* },
* ],
* });
* @example Create an encounter (see OpenMRS API)
* create("encounter", {
* encounterDatetime: '2023-05-25T06:08:25.000+0000',
* patient: '1fdaa696-e759-4a7d-a066-f1ae557c151b',
* encounterType: 'dd528487-82a5-4082-9c72-ed246bd49591',
* location: 'ba685651-ed3b-4e63-9b35-78893060758a',
* encounterProviders: [],
* visit: {
* patient: '1fdaa696-e759-4a7d-a066-f1ae557c151b',
* visitType: '7b0f5697-27e3-40c4-8bae-f4049abfb4ed',
* startDatetime: '2023-05-25T06:08:25.000+0000',
* stopDatetime: '2023-05-25T06:09:25.000+0000',
* },
* })
* @example Create a patient (see OpenMRS API)
* create("patient", {
* identifiers: [
* {
* identifier: '4023287',
* identifierType: '05a29f94-c0ed-11e2-94be-8c13b969e334',
* preferred: true,
* },
* ],
* person: {
* gender: 'M',
* age: 42,
* birthdate: '1970-01-01T00:00:00.000+0100',
* birthdateEstimated: false,
* names: [
* {
* givenName: 'Doe',
* familyName: 'John',
* },
* ],
* },
* })
@example Create a patientIdentifier subresource (see OpenMRS API)
* create("patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3/identifier", {
* "identifier" : "111:CLINIC1",
* "identifierType" : "a5d38e09-efcb-4d91-a526-50ce1ba5011a",
* "location" : "8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
* "preferred" : true
* })
}
*/
export function create(path: string, data: object): Operation;
/**
* Update a resource. Only properties included in the data will be affected.
* For a list of valid resources and for update rules, see the Update sections
* of the {@link https://rest.openmrs.org/ OpenMRS Docs}
* @public
* @function
* @param {string} path - Path to resource (excluding `/ws/rest/v1/`)
* @param {Object} data - Resource properties to update
* @state data The full updated resource, as returned by OpenMRS
* @returns {Operation}
* @example Update a person (see OpenMRS API)
* update('person/3cad37ad-984d-4c65-a019-3eb120c9c373', {
* 'gender': 'M',
* 'birthdate':'1997-01-13'
* })
*/
export function update(path: string, data: any): Operation;
/**
* Update a resource if it already exists, or otherwise create a new one.
*
* Upsert will first make a request for the target item (using the `path` and `params`) to see if it exists, and then issue a second create or update request.
* If the query request returns multiple items, the upsert will throw an error.
*
* Params will be appended as query parameters to the request URL,
* refer to {@link https://rest.openmrs.org/ OpenMRS Docs} for details.
* @public
* @function
* @param {string} path - Path to resource (excluding `/ws/rest/v1/`)
* @param {Object} data - The resource data
* @param {Object} params - Query parameters to append to the initial query
* @state data The created/updated resource, as returned by OpenMRS
* @returns {Operation}
* @example Upsert a patient (see OpenMRS API)
* upsert("patient/a5d38e09-efcb-4d91-a526-50ce1ba5011a", {
* identifiers: [
* {
* identifier: '4023287',
* identifierType: '05a29f94-c0ed-11e2-94be-8c13b969e334',
* preferred: true,
* },
* ],
* person: {
* gender: 'M',
* age: 42,
* birthdate: '1970-01-01T00:00:00.000+0100',
* birthdateEstimated: false,
* names: [
* {
* givenName: 'Doe',
* familyName: 'John',
* },
* ],
* },
* })
* @example Upsert a patient using a query to identify the record
* upsert("patient", $.data, { q: "Lamine Yamal", limit: 1 })
*/
export function upsert(path: string, data: any, params?: any): Operation;
/**
* Delete a resource. Must include a UUID in the path.
* Throws an error if the resource does not exist.
* @example Void a patient
* destroy("patient/12346");
* @example Purge a patient
* destroy("patient/12346", {
* purge: true
* });
* @function
* @public
* @param {string} path - Path to resource (excluding `/ws/rest/v1/`)
* @param {object} [options = {}]
* @param {object} [options.purge=false] The resource will be voided/retired unless true
* @state data The response from OpenMRS
* @returns {Operation}
*/
export function destroy(path: string, options?: {
purge?: object;
}): Operation;
/**
* Options to append to the request. Unless otherwise specified, options are appended to the URL as query parameters - see the [OpenMRS Docs](https://rest.openmrs.org/) for all supported parameters.
*/
export type GetOptions = {
/**
* - (OpenFn only) Query string. Maps to `q` in OpenMRS.
*/
query?: string;
/**
* - (OpenFn only) Language code. Maps to `Accept-Language` in OpenMRS.
*/
language?: string;
/**
* - (OpenFn only) Restrict the maximum number of retrieved records. May be fetched in several pages. Not used if `limit` is set.
*/
max?: number;
/**
* - (OpenFn only) Limits the size of each page of data. Not used if limit is set.
*/
pageSize?: number;
/**
* - (OpenFn only) If set to true, only the first result will be returned. Useful for "get by id" APIs.
*/
singleton?: boolean;
};
export { alterState, arrayToString, as, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, lastReferenceValue, log, map, merge, sourceValue, util } from "@openfn/language-common";