@openfn/language-openelis 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "properties": {
4
+ "baseUrl": {
5
+ "title": "Base URL",
6
+ "description": "The base URL for the OpenELIS instance",
7
+ "format": "uri",
8
+ "minLength": 1,
9
+ "examples": ["https://demo.openelis-global.org"]
10
+ },
11
+ "username": {
12
+ "title": "Username",
13
+ "type": "string",
14
+ "description": "Username",
15
+ "examples": ["admin"]
16
+ },
17
+ "password": {
18
+ "title": "Password",
19
+ "type": "string",
20
+ "description": "Password",
21
+ "writeOnly": true,
22
+ "examples": ["@some(!)Str0ngp4ss0w0rd"]
23
+ }
24
+ },
25
+ "type": "object",
26
+ "additionalProperties": true,
27
+ "required": ["password", "username", "baseUrl"]
28
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,193 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+
25
+ // src/index.js
26
+ var src_exports = {};
27
+ __export(src_exports, {
28
+ as: () => import_language_common.as,
29
+ combine: () => import_language_common.combine,
30
+ cursor: () => import_language_common.cursor,
31
+ dataPath: () => import_language_common.dataPath,
32
+ dataValue: () => import_language_common.dataValue,
33
+ dateFns: () => import_language_common.dateFns,
34
+ default: () => src_default,
35
+ each: () => import_language_common.each,
36
+ field: () => import_language_common.field,
37
+ fields: () => import_language_common.fields,
38
+ fn: () => import_language_common.fn,
39
+ fnIf: () => import_language_common.fnIf,
40
+ group: () => import_language_common.group,
41
+ http: () => http_exports,
42
+ lastReferenceValue: () => import_language_common.lastReferenceValue,
43
+ map: () => import_language_common.map,
44
+ merge: () => import_language_common.merge,
45
+ scrubEmojis: () => import_language_common.scrubEmojis,
46
+ sourceValue: () => import_language_common.sourceValue,
47
+ util: () => import_language_common.util
48
+ });
49
+ module.exports = __toCommonJS(src_exports);
50
+
51
+ // src/Adaptor.js
52
+ var Adaptor_exports = {};
53
+ __export(Adaptor_exports, {
54
+ as: () => import_language_common.as,
55
+ combine: () => import_language_common.combine,
56
+ cursor: () => import_language_common.cursor,
57
+ dataPath: () => import_language_common.dataPath,
58
+ dataValue: () => import_language_common.dataValue,
59
+ dateFns: () => import_language_common.dateFns,
60
+ each: () => import_language_common.each,
61
+ field: () => import_language_common.field,
62
+ fields: () => import_language_common.fields,
63
+ fn: () => import_language_common.fn,
64
+ fnIf: () => import_language_common.fnIf,
65
+ group: () => import_language_common.group,
66
+ lastReferenceValue: () => import_language_common.lastReferenceValue,
67
+ map: () => import_language_common.map,
68
+ merge: () => import_language_common.merge,
69
+ scrubEmojis: () => import_language_common.scrubEmojis,
70
+ sourceValue: () => import_language_common.sourceValue,
71
+ util: () => import_language_common.util
72
+ });
73
+ var import_language_common = require("@openfn/language-common");
74
+
75
+ // src/http.js
76
+ var http_exports = {};
77
+ __export(http_exports, {
78
+ get: () => get,
79
+ post: () => post,
80
+ request: () => request2
81
+ });
82
+ var import_util2 = require("@openfn/language-common/util");
83
+
84
+ // src/Utils.js
85
+ var import_language_common2 = require("@openfn/language-common");
86
+ var import_util = require("@openfn/language-common/util");
87
+ var import_node_path = __toESM(require("path"), 1);
88
+ var prepareNextState = (state, response) => {
89
+ const { body, ...responseWithoutBody } = response;
90
+ if (!state.references) {
91
+ state.references = [];
92
+ }
93
+ return {
94
+ ...(0, import_language_common2.composeNextState)(state, response.body),
95
+ response: responseWithoutBody
96
+ };
97
+ };
98
+ var request = (configuration = {}, method, path, options) => {
99
+ const { baseUrl, username, password } = configuration;
100
+ let { body = {}, query = {}, headers = {}, parseAs = "json" } = options;
101
+ if (username && password) {
102
+ headers = (0, import_util.makeBasicAuthHeader)(username, password);
103
+ }
104
+ const opts = {
105
+ parseAs,
106
+ baseUrl,
107
+ body,
108
+ query,
109
+ headers: {
110
+ "content-type": "application/json",
111
+ ...headers
112
+ }
113
+ };
114
+ const safePath = import_node_path.default.join(`/api/OpenELIS-Global/rest/${path}`);
115
+ return (0, import_util.request)(method, safePath, opts).then(import_util.logResponse);
116
+ };
117
+
118
+ // src/http.js
119
+ function get(path, options) {
120
+ return async (state) => {
121
+ const [resolvedPath, resolvedOptions] = (0, import_util2.expandReferences)(state, path, options);
122
+ const response = await request(
123
+ state.configuration,
124
+ "GET",
125
+ resolvedPath,
126
+ {
127
+ ...resolvedOptions,
128
+ body: {}
129
+ }
130
+ );
131
+ return prepareNextState(state, response);
132
+ };
133
+ }
134
+ function post(path, body, options) {
135
+ return async (state) => {
136
+ const [resolvedPath, resolvedBody, resolvedOptions] = (0, import_util2.expandReferences)(
137
+ state,
138
+ path,
139
+ body,
140
+ options
141
+ );
142
+ const response = await request(
143
+ state.configuration,
144
+ "POST",
145
+ resolvedPath,
146
+ {
147
+ body: resolvedBody,
148
+ ...resolvedOptions
149
+ }
150
+ );
151
+ return prepareNextState(state, response);
152
+ };
153
+ }
154
+ function request2(method, path, body, options = {}) {
155
+ return async (state) => {
156
+ const [resolvedMethod, resolvedPath, resolvedBody, resolvedoptions] = (0, import_util2.expandReferences)(state, method, path, body, options);
157
+ const response = await request(
158
+ state.configuration,
159
+ resolvedMethod,
160
+ resolvedPath,
161
+ {
162
+ body: resolvedBody,
163
+ ...resolvedoptions
164
+ }
165
+ );
166
+ return prepareNextState(state, response);
167
+ };
168
+ }
169
+
170
+ // src/index.js
171
+ var src_default = Adaptor_exports;
172
+ // Annotate the CommonJS export names for ESM import in node:
173
+ 0 && (module.exports = {
174
+ as,
175
+ combine,
176
+ cursor,
177
+ dataPath,
178
+ dataValue,
179
+ dateFns,
180
+ each,
181
+ field,
182
+ fields,
183
+ fn,
184
+ fnIf,
185
+ group,
186
+ http,
187
+ lastReferenceValue,
188
+ map,
189
+ merge,
190
+ scrubEmojis,
191
+ sourceValue,
192
+ util
193
+ });
package/dist/index.js ADDED
@@ -0,0 +1,172 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/Adaptor.js
8
+ var Adaptor_exports = {};
9
+ __export(Adaptor_exports, {
10
+ as: () => as,
11
+ combine: () => combine,
12
+ cursor: () => cursor,
13
+ dataPath: () => dataPath,
14
+ dataValue: () => dataValue,
15
+ dateFns: () => dateFns,
16
+ each: () => each,
17
+ field: () => field,
18
+ fields: () => fields,
19
+ fn: () => fn,
20
+ fnIf: () => fnIf,
21
+ group: () => group,
22
+ lastReferenceValue: () => lastReferenceValue,
23
+ map: () => map,
24
+ merge: () => merge,
25
+ scrubEmojis: () => scrubEmojis,
26
+ sourceValue: () => sourceValue,
27
+ util: () => util
28
+ });
29
+ import {
30
+ as,
31
+ combine,
32
+ cursor,
33
+ dataPath,
34
+ dataValue,
35
+ dateFns,
36
+ each,
37
+ field,
38
+ fields,
39
+ fn,
40
+ fnIf,
41
+ group,
42
+ lastReferenceValue,
43
+ map,
44
+ merge,
45
+ scrubEmojis,
46
+ sourceValue,
47
+ util
48
+ } from "@openfn/language-common";
49
+
50
+ // src/http.js
51
+ var http_exports = {};
52
+ __export(http_exports, {
53
+ get: () => get,
54
+ post: () => post,
55
+ request: () => request2
56
+ });
57
+ import { expandReferences } from "@openfn/language-common/util";
58
+
59
+ // src/Utils.js
60
+ import { composeNextState } from "@openfn/language-common";
61
+ import {
62
+ request as commonRequest,
63
+ makeBasicAuthHeader,
64
+ logResponse
65
+ } from "@openfn/language-common/util";
66
+ import nodepath from "path";
67
+ var prepareNextState = (state, response) => {
68
+ const { body, ...responseWithoutBody } = response;
69
+ if (!state.references) {
70
+ state.references = [];
71
+ }
72
+ return {
73
+ ...composeNextState(state, response.body),
74
+ response: responseWithoutBody
75
+ };
76
+ };
77
+ var request = (configuration = {}, method, path, options) => {
78
+ const { baseUrl, username, password } = configuration;
79
+ let { body = {}, query = {}, headers = {}, parseAs = "json" } = options;
80
+ if (username && password) {
81
+ headers = makeBasicAuthHeader(username, password);
82
+ }
83
+ const opts = {
84
+ parseAs,
85
+ baseUrl,
86
+ body,
87
+ query,
88
+ headers: {
89
+ "content-type": "application/json",
90
+ ...headers
91
+ }
92
+ };
93
+ const safePath = nodepath.join(`/api/OpenELIS-Global/rest/${path}`);
94
+ return commonRequest(method, safePath, opts).then(logResponse);
95
+ };
96
+
97
+ // src/http.js
98
+ function get(path, options) {
99
+ return async (state) => {
100
+ const [resolvedPath, resolvedOptions] = expandReferences(state, path, options);
101
+ const response = await request(
102
+ state.configuration,
103
+ "GET",
104
+ resolvedPath,
105
+ {
106
+ ...resolvedOptions,
107
+ body: {}
108
+ }
109
+ );
110
+ return prepareNextState(state, response);
111
+ };
112
+ }
113
+ function post(path, body, options) {
114
+ return async (state) => {
115
+ const [resolvedPath, resolvedBody, resolvedOptions] = expandReferences(
116
+ state,
117
+ path,
118
+ body,
119
+ options
120
+ );
121
+ const response = await request(
122
+ state.configuration,
123
+ "POST",
124
+ resolvedPath,
125
+ {
126
+ body: resolvedBody,
127
+ ...resolvedOptions
128
+ }
129
+ );
130
+ return prepareNextState(state, response);
131
+ };
132
+ }
133
+ function request2(method, path, body, options = {}) {
134
+ return async (state) => {
135
+ const [resolvedMethod, resolvedPath, resolvedBody, resolvedoptions] = expandReferences(state, method, path, body, options);
136
+ const response = await request(
137
+ state.configuration,
138
+ resolvedMethod,
139
+ resolvedPath,
140
+ {
141
+ body: resolvedBody,
142
+ ...resolvedoptions
143
+ }
144
+ );
145
+ return prepareNextState(state, response);
146
+ };
147
+ }
148
+
149
+ // src/index.js
150
+ var src_default = Adaptor_exports;
151
+ export {
152
+ as,
153
+ combine,
154
+ cursor,
155
+ dataPath,
156
+ dataValue,
157
+ dateFns,
158
+ src_default as default,
159
+ each,
160
+ field,
161
+ fields,
162
+ fn,
163
+ fnIf,
164
+ group,
165
+ http_exports as http,
166
+ lastReferenceValue,
167
+ map,
168
+ merge,
169
+ scrubEmojis,
170
+ sourceValue,
171
+ util
172
+ };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@openfn/language-openelis",
3
+ "version": "1.0.0",
4
+ "description": "OpenFn openelis adaptor",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "types": "./types/index.d.ts",
10
+ "require": "./dist/index.cjs"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "author": "Open Function Group",
15
+ "license": "LGPLv3",
16
+ "files": [
17
+ "dist/",
18
+ "types/",
19
+ "ast.json",
20
+ "configuration-schema.json"
21
+ ],
22
+ "dependencies": {
23
+ "@openfn/language-common": "3.2.2"
24
+ },
25
+ "devDependencies": {
26
+ "assertion-error": "2.0.0",
27
+ "chai": "4.3.6",
28
+ "deep-eql": "4.1.1",
29
+ "mocha": "^10.7.3",
30
+ "rimraf": "3.0.2",
31
+ "undici": "^5.22.1"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/openfn/adaptors.git"
36
+ },
37
+ "types": "types/index.d.ts",
38
+ "main": "dist/index.cjs",
39
+ "scripts": {
40
+ "build": "pnpm clean && build-adaptor openelis",
41
+ "test": "mocha --experimental-specifier-resolution=node --no-warnings",
42
+ "test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
43
+ "clean": "rimraf dist types docs",
44
+ "pack": "pnpm pack --pack-destination ../../dist",
45
+ "lint": "eslint src"
46
+ }
47
+ }
@@ -0,0 +1 @@
1
+ export { as, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, lastReferenceValue, map, merge, scrubEmojis, sourceValue, util } from "@openfn/language-common";
@@ -0,0 +1,2 @@
1
+ export function prepareNextState(state: any, response: any): any;
2
+ export function request(configuration: {}, method: any, path: any, options: any): any;
@@ -0,0 +1,200 @@
1
+ /**
2
+ * State object
3
+ * @typedef {Object} HttpState
4
+ * @property data - the parsed response body
5
+ * @property response - the response from the HTTP server, including headers, statusCode, body, etc
6
+ * @property references - an array of all previous data objects used in the Job
7
+ **/
8
+ /**
9
+ * Options provided to the HTTP request
10
+ * @typedef {Object} RequestOptions
11
+ * @public
12
+ * @property {object|string} body - body data to append to the request. JSON will be converted to a string (but a content-type header will not be attached to the request).
13
+ * @property {object} query - An object of query parameters to be encoded into the URL.
14
+ * @property {object} headers - An object of headers to append to the request.
15
+ * @property {string} parseAs - Parse the response body as json, text or stream. By default will use the response headers.
16
+ */
17
+ /**
18
+ * Make a GET request to an OpenELIS instance
19
+ * @example <caption>Get all orders in progress</caption>
20
+ * http.get('home-dashboard/ORDERS_IN_PROGRESS');
21
+ * @example <caption>Get all orders ready for validation</caption>
22
+ * http.get('home-dashboard/ORDERS_READY_FOR_VALIDATION');
23
+ * @example <caption>Get all the reasons why a lab order could be referred</caption>
24
+ * http.get('referral-reasons');
25
+ * @function
26
+ * @public
27
+ * @param {string} path - Path to resource
28
+ * @param {RequestOptions} options - Optional request options
29
+ * @returns {Operation}
30
+ * @state {HttpState}
31
+ */
32
+ export function get(path: string, options: RequestOptions): Operation;
33
+ /**
34
+ * Make a POST request to an OpenELIS instance
35
+ * @example <caption>Validate results for a lab order</caption>
36
+ * http.post('AccessionValidation', {
37
+ "formName": "ResultValidationForm",
38
+ "formMethod": "POST",
39
+ "cancelAction": "Home",
40
+ "submitOnCancel": false,
41
+ "cancelMethod": "POST",
42
+ "searchFinished": true,
43
+ "paging": {
44
+ "totalPages": "1",
45
+ "currentPage": "1",
46
+ "searchTermToPage": [
47
+ {
48
+ "id": "25RSH00005L",
49
+ "value": "1"
50
+ }
51
+ ]
52
+ },
53
+ "currentDate": "",
54
+ "resultList": [
55
+ {
56
+ "id": 4,
57
+ <more details>
58
+ }
59
+ ],
60
+ "testSection": "",
61
+ "accessionNumber": "25RSH00005L",
62
+ "testDate": "",
63
+ "testName": "",
64
+ "testSections": [
65
+ {
66
+ "id": "56",
67
+ "value": "Biochemistry"
68
+ }
69
+ ],
70
+ "testSectionsByName": [
71
+ {
72
+ "id": "56",
73
+ "value": "Biochemistry"
74
+ }
75
+ ],
76
+ "displayTestSections": true
77
+ });
78
+ * @example <caption>Add results to an order</caption>
79
+ * http.post('LogbookResults', {
80
+ "formName": "LogbookResultsForm",
81
+ "formMethod": "POST",
82
+ "cancelAction": "Home",
83
+ "submitOnCancel": false,
84
+ "cancelMethod": "POST",
85
+ "paging": {
86
+ "totalPages": "1",
87
+ "currentPage": "1",
88
+ "searchTermToPage": [
89
+ {
90
+ "id": "DEV01260000000000003",
91
+ "value": "1"
92
+ }
93
+ ]
94
+ },
95
+ "accessionNumber": "DEV01260000000000003",
96
+ "singlePatient": false,
97
+ "currentDate": "09/02/2026",
98
+ "displayTestMethod": true,
99
+ "displayTestKit": false,
100
+ "testResult": [
101
+ {
102
+ "id": "0",
103
+ <more details>
104
+ }
105
+ ],
106
+ "inventoryItems": [],
107
+ "hivKits": [],
108
+ "syphilisKits": [],
109
+ "type": "",
110
+ "displayMethods": true,
111
+ "testSectionId": "",
112
+ "displayTestSections": true,
113
+ "searchByRange": false,
114
+ "searchFinished": true
115
+ });
116
+ * @function
117
+ * @public
118
+ * @param {string} path - Path to resource
119
+ * @param {object} body - Object which will be attached to the POST body
120
+ * @param {RequestOptions} options - Optional request options
121
+ * @returns {Operation}
122
+ * @state {HttpState}
123
+ */
124
+ export function post(path: string, body: object, options: RequestOptions): Operation;
125
+ /**
126
+ * Make a general HTTP request
127
+ * @example <caption>Edit an existing patient's information</caption>
128
+ * http.request('POST', 'PatientManagement', {
129
+ "patientUpdateStatus": "UPDATE",
130
+ "nationalId": "1234567892",
131
+ "subjectNumber": "1234567892",
132
+ "lastName": "Lazic",
133
+ "firstName": "Aleksa",
134
+ "streetAddress": "",
135
+ "city": "",
136
+ "primaryPhone": "+255-45-89-63-21",
137
+ "gender": "F",
138
+ "birthDateForDisplay": "13/08/2000",
139
+ "commune": "",
140
+ "education": "",
141
+ "maritialStatus": "",
142
+ "nationality": "",
143
+ "healthDistrict": "",
144
+ "healthRegion": "",
145
+ "otherNationality": "",
146
+ "patientContact": {
147
+ "person": {
148
+ "firstName": "",
149
+ "lastName": "",
150
+ "primaryPhone": "",
151
+ "email": "",
152
+ "lastupdated": 1764586121386,
153
+ "id": "409"
154
+ },
155
+ "lastupdated": 1764536400000,
156
+ "id": "200",
157
+ "patientId": "202"
158
+ },
159
+ "patientPK": "202",
160
+ "guid": "c7e48932-2ed8-440a-9312-b68112e3873f",
161
+ "aka": "",
162
+ "mothersName": "",
163
+ "mothersInitial": "",
164
+ "addressDepartment": "",
165
+ "insuranceNumber": "",
166
+ "occupation": "",
167
+ "readOnly": false,
168
+ "stnumber": ""
169
+ });
170
+ * @function
171
+ * @public
172
+ * @param {string} method - HTTP method to use
173
+ * @param {string} path - Path to resource
174
+ * @param {object} body - Object which will be attached to the POST body
175
+ * @param {RequestOptions} options - Optional request options
176
+ * @returns {Operation}
177
+ * @state {HttpState}
178
+ */
179
+ export function request(method: string, path: string, body: object, options?: RequestOptions): Operation;
180
+ /**
181
+ * State object
182
+ */
183
+ export type HttpState = {
184
+ /**
185
+ * - the parsed response body
186
+ */
187
+ data: any;
188
+ /**
189
+ * - the response from the HTTP server, including headers, statusCode, body, etc
190
+ */
191
+ response: any;
192
+ /**
193
+ * - an array of all previous data objects used in the Job
194
+ */
195
+ references: any;
196
+ };
197
+ /**
198
+ * Options provided to the HTTP request
199
+ */
200
+ export type RequestOptions = any;
@@ -0,0 +1,4 @@
1
+ export default Adaptor;
2
+ export * from "./Adaptor.js";
3
+ export * as http from "./http.js";
4
+ import * as Adaptor from "./Adaptor.js";