@openfn/language-fhir-ndr-et 0.1.3 → 0.1.5
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.
- package/README.md +8 -3
- package/dist/index.cjs +26666 -0
- package/dist/index.js +26637 -0
- package/dist/utils.cjs +187 -0
- package/dist/utils.js +146 -0
- package/package.json +2 -2
- package/types/Adaptor.d.ts +3 -0
- package/types/index.d.ts +4 -0
- package/types/utils.d.ts +21 -0
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
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/utils.js
|
|
26
|
+
var utils_exports = {};
|
|
27
|
+
__export(utils_exports, {
|
|
28
|
+
addExtension: () => addExtension,
|
|
29
|
+
cc: () => cc,
|
|
30
|
+
coding: () => coding,
|
|
31
|
+
composite: () => composite,
|
|
32
|
+
concept: () => concept,
|
|
33
|
+
findExtension: () => findExtension,
|
|
34
|
+
id: () => id,
|
|
35
|
+
identifier: () => identifier,
|
|
36
|
+
mapSystems: () => mapSystems,
|
|
37
|
+
ref: () => ref,
|
|
38
|
+
reference: () => reference,
|
|
39
|
+
setSystemMap: () => setSystemMap
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(utils_exports);
|
|
42
|
+
var import_lodash = __toESM(require("lodash"), 1);
|
|
43
|
+
var systemMap = {
|
|
44
|
+
SmartCareID: "http://moh.gov.et/fhir/hiv/identifier/SmartCareID",
|
|
45
|
+
MRN: "http://moh.gov.et/fhir/hiv/identifier/MRN",
|
|
46
|
+
UAN: "http://moh.gov.et/fhir/hiv/identifier/UAN"
|
|
47
|
+
};
|
|
48
|
+
var datetimeregex = /([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?/;
|
|
49
|
+
var mapSystems = (obj) => {
|
|
50
|
+
if (Array.isArray(obj)) {
|
|
51
|
+
return obj.map(mapSystems);
|
|
52
|
+
}
|
|
53
|
+
if (obj.system in systemMap) {
|
|
54
|
+
return {
|
|
55
|
+
...obj,
|
|
56
|
+
system: systemMap[obj.system]
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return obj;
|
|
60
|
+
};
|
|
61
|
+
var setSystemMap = (newMappings) => {
|
|
62
|
+
Object.assign(systemMap, newMappings);
|
|
63
|
+
};
|
|
64
|
+
var identifier = (input, system) => {
|
|
65
|
+
if (Array.isArray(input)) {
|
|
66
|
+
return input.map((i) => identifier(i, system));
|
|
67
|
+
}
|
|
68
|
+
if (input) {
|
|
69
|
+
if (typeof input === "string") {
|
|
70
|
+
return mapSystems({
|
|
71
|
+
value: input,
|
|
72
|
+
system
|
|
73
|
+
});
|
|
74
|
+
} else if (system) {
|
|
75
|
+
return mapSystems({
|
|
76
|
+
system,
|
|
77
|
+
...input
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
return mapSystems(input);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var id = identifier;
|
|
85
|
+
var addExtension = (resource, url, value) => {
|
|
86
|
+
const obj = {
|
|
87
|
+
url
|
|
88
|
+
};
|
|
89
|
+
composite(obj, "value", value);
|
|
90
|
+
resource.extension ?? (resource.extension = []);
|
|
91
|
+
resource.extension.push(obj);
|
|
92
|
+
};
|
|
93
|
+
var findExtension = (obj, targetUrl, path) => {
|
|
94
|
+
var _a;
|
|
95
|
+
const result = (_a = obj.extension) == null ? void 0 : _a.find((ext) => ext.url === targetUrl);
|
|
96
|
+
if (result && path) {
|
|
97
|
+
return import_lodash.default.get(result, path);
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
};
|
|
101
|
+
var coding = (code, system) => ({ code, system: mapSystems(system) });
|
|
102
|
+
var concept = (text, ...codings) => {
|
|
103
|
+
const result = {};
|
|
104
|
+
let incomingCodings = codings;
|
|
105
|
+
if (typeof text === "string") {
|
|
106
|
+
result.text = text;
|
|
107
|
+
} else {
|
|
108
|
+
incomingCodings = [text].concat(codings);
|
|
109
|
+
}
|
|
110
|
+
const c = [];
|
|
111
|
+
for (const item of incomingCodings) {
|
|
112
|
+
if (Array.isArray(item)) {
|
|
113
|
+
c.push(coding(item[0], item[1]));
|
|
114
|
+
} else {
|
|
115
|
+
c.push(item);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
result.coding = c;
|
|
119
|
+
return result;
|
|
120
|
+
};
|
|
121
|
+
var cc = concept;
|
|
122
|
+
var reference = (ref2, opts) => {
|
|
123
|
+
if (Array.isArray(ref2)) {
|
|
124
|
+
return ref2.map(reference, opts);
|
|
125
|
+
}
|
|
126
|
+
if (ref2.resourceType && ref2.id) {
|
|
127
|
+
return { reference: `${ref2.resourceType}/${ref2.id}` };
|
|
128
|
+
}
|
|
129
|
+
if (ref2.reference) {
|
|
130
|
+
return ref2;
|
|
131
|
+
}
|
|
132
|
+
const result = {};
|
|
133
|
+
if (typeof ref2 === "string") {
|
|
134
|
+
result.reference = ref2;
|
|
135
|
+
}
|
|
136
|
+
if (opts) {
|
|
137
|
+
Object.assign(result, opts);
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
};
|
|
141
|
+
var ref = reference;
|
|
142
|
+
var composite = (object, key, value) => {
|
|
143
|
+
const k = [key];
|
|
144
|
+
if (value.coding) {
|
|
145
|
+
k.push("CodeableConcept");
|
|
146
|
+
} else if (value.reference) {
|
|
147
|
+
k.push("Reference");
|
|
148
|
+
} else if (value.id && value.meta && value.resourceType) {
|
|
149
|
+
k.push("Reference");
|
|
150
|
+
value = reference(value);
|
|
151
|
+
} else if (value.start || value.end) {
|
|
152
|
+
k.push("Period");
|
|
153
|
+
} else if (value.dateTime) {
|
|
154
|
+
k.push("DateTime");
|
|
155
|
+
} else if (typeof value === "string") {
|
|
156
|
+
if (datetimeregex.test(value)) {
|
|
157
|
+
k.push("DateTime");
|
|
158
|
+
} else {
|
|
159
|
+
k.push("String");
|
|
160
|
+
}
|
|
161
|
+
} else if (typeof value === "boolean") {
|
|
162
|
+
k.push("Boolean");
|
|
163
|
+
} else if (typeof value === "number") {
|
|
164
|
+
k.push("Integer");
|
|
165
|
+
}
|
|
166
|
+
if (k.length === 2) {
|
|
167
|
+
const finalKey = k.join("");
|
|
168
|
+
object[finalKey] = value;
|
|
169
|
+
} else {
|
|
170
|
+
console.warn(`WARNING: Failed to map ${key}: unrecognised data type (see utils.composite)`);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
174
|
+
0 && (module.exports = {
|
|
175
|
+
addExtension,
|
|
176
|
+
cc,
|
|
177
|
+
coding,
|
|
178
|
+
composite,
|
|
179
|
+
concept,
|
|
180
|
+
findExtension,
|
|
181
|
+
id,
|
|
182
|
+
identifier,
|
|
183
|
+
mapSystems,
|
|
184
|
+
ref,
|
|
185
|
+
reference,
|
|
186
|
+
setSystemMap
|
|
187
|
+
});
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// src/utils.js
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
var systemMap = {
|
|
4
|
+
SmartCareID: "http://moh.gov.et/fhir/hiv/identifier/SmartCareID",
|
|
5
|
+
MRN: "http://moh.gov.et/fhir/hiv/identifier/MRN",
|
|
6
|
+
UAN: "http://moh.gov.et/fhir/hiv/identifier/UAN"
|
|
7
|
+
};
|
|
8
|
+
var datetimeregex = /([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?/;
|
|
9
|
+
var mapSystems = (obj) => {
|
|
10
|
+
if (Array.isArray(obj)) {
|
|
11
|
+
return obj.map(mapSystems);
|
|
12
|
+
}
|
|
13
|
+
if (obj.system in systemMap) {
|
|
14
|
+
return {
|
|
15
|
+
...obj,
|
|
16
|
+
system: systemMap[obj.system]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return obj;
|
|
20
|
+
};
|
|
21
|
+
var setSystemMap = (newMappings) => {
|
|
22
|
+
Object.assign(systemMap, newMappings);
|
|
23
|
+
};
|
|
24
|
+
var identifier = (input, system) => {
|
|
25
|
+
if (Array.isArray(input)) {
|
|
26
|
+
return input.map((i) => identifier(i, system));
|
|
27
|
+
}
|
|
28
|
+
if (input) {
|
|
29
|
+
if (typeof input === "string") {
|
|
30
|
+
return mapSystems({
|
|
31
|
+
value: input,
|
|
32
|
+
system
|
|
33
|
+
});
|
|
34
|
+
} else if (system) {
|
|
35
|
+
return mapSystems({
|
|
36
|
+
system,
|
|
37
|
+
...input
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
return mapSystems(input);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var id = identifier;
|
|
45
|
+
var addExtension = (resource, url, value) => {
|
|
46
|
+
const obj = {
|
|
47
|
+
url
|
|
48
|
+
};
|
|
49
|
+
composite(obj, "value", value);
|
|
50
|
+
resource.extension ?? (resource.extension = []);
|
|
51
|
+
resource.extension.push(obj);
|
|
52
|
+
};
|
|
53
|
+
var findExtension = (obj, targetUrl, path) => {
|
|
54
|
+
var _a;
|
|
55
|
+
const result = (_a = obj.extension) == null ? void 0 : _a.find((ext) => ext.url === targetUrl);
|
|
56
|
+
if (result && path) {
|
|
57
|
+
return _.get(result, path);
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
61
|
+
var coding = (code, system) => ({ code, system: mapSystems(system) });
|
|
62
|
+
var concept = (text, ...codings) => {
|
|
63
|
+
const result = {};
|
|
64
|
+
let incomingCodings = codings;
|
|
65
|
+
if (typeof text === "string") {
|
|
66
|
+
result.text = text;
|
|
67
|
+
} else {
|
|
68
|
+
incomingCodings = [text].concat(codings);
|
|
69
|
+
}
|
|
70
|
+
const c = [];
|
|
71
|
+
for (const item of incomingCodings) {
|
|
72
|
+
if (Array.isArray(item)) {
|
|
73
|
+
c.push(coding(item[0], item[1]));
|
|
74
|
+
} else {
|
|
75
|
+
c.push(item);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
result.coding = c;
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
var cc = concept;
|
|
82
|
+
var reference = (ref2, opts) => {
|
|
83
|
+
if (Array.isArray(ref2)) {
|
|
84
|
+
return ref2.map(reference, opts);
|
|
85
|
+
}
|
|
86
|
+
if (ref2.resourceType && ref2.id) {
|
|
87
|
+
return { reference: `${ref2.resourceType}/${ref2.id}` };
|
|
88
|
+
}
|
|
89
|
+
if (ref2.reference) {
|
|
90
|
+
return ref2;
|
|
91
|
+
}
|
|
92
|
+
const result = {};
|
|
93
|
+
if (typeof ref2 === "string") {
|
|
94
|
+
result.reference = ref2;
|
|
95
|
+
}
|
|
96
|
+
if (opts) {
|
|
97
|
+
Object.assign(result, opts);
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
};
|
|
101
|
+
var ref = reference;
|
|
102
|
+
var composite = (object, key, value) => {
|
|
103
|
+
const k = [key];
|
|
104
|
+
if (value.coding) {
|
|
105
|
+
k.push("CodeableConcept");
|
|
106
|
+
} else if (value.reference) {
|
|
107
|
+
k.push("Reference");
|
|
108
|
+
} else if (value.id && value.meta && value.resourceType) {
|
|
109
|
+
k.push("Reference");
|
|
110
|
+
value = reference(value);
|
|
111
|
+
} else if (value.start || value.end) {
|
|
112
|
+
k.push("Period");
|
|
113
|
+
} else if (value.dateTime) {
|
|
114
|
+
k.push("DateTime");
|
|
115
|
+
} else if (typeof value === "string") {
|
|
116
|
+
if (datetimeregex.test(value)) {
|
|
117
|
+
k.push("DateTime");
|
|
118
|
+
} else {
|
|
119
|
+
k.push("String");
|
|
120
|
+
}
|
|
121
|
+
} else if (typeof value === "boolean") {
|
|
122
|
+
k.push("Boolean");
|
|
123
|
+
} else if (typeof value === "number") {
|
|
124
|
+
k.push("Integer");
|
|
125
|
+
}
|
|
126
|
+
if (k.length === 2) {
|
|
127
|
+
const finalKey = k.join("");
|
|
128
|
+
object[finalKey] = value;
|
|
129
|
+
} else {
|
|
130
|
+
console.warn(`WARNING: Failed to map ${key}: unrecognised data type (see utils.composite)`);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
export {
|
|
134
|
+
addExtension,
|
|
135
|
+
cc,
|
|
136
|
+
coding,
|
|
137
|
+
composite,
|
|
138
|
+
concept,
|
|
139
|
+
findExtension,
|
|
140
|
+
id,
|
|
141
|
+
identifier,
|
|
142
|
+
mapSystems,
|
|
143
|
+
ref,
|
|
144
|
+
reference,
|
|
145
|
+
setSystemMap
|
|
146
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-fhir-ndr-et",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "OpenFn fhir adaptor for NDR HIV in Ehtiopia",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"types": "types/index.d.ts",
|
|
53
53
|
"main": "dist/index.cjs",
|
|
54
54
|
"scripts": {
|
|
55
|
-
"
|
|
55
|
+
"build": "pnpm clean && pnpm build-adaptor fhir-ndr-et",
|
|
56
56
|
"build:src": "esno build/build.ts",
|
|
57
57
|
"build:adaptor": "pnpm build-adaptor fhir-ndr-et",
|
|
58
58
|
"build:schema": "esno build/generate-schema.ts",
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export function getBuilderName(resourceName: any): any;
|
|
2
|
+
export function create(resourceType: FhirResourceTypes, resource: FhirResource, params: object, callback?: Function): Operation;
|
|
3
|
+
export { dataPath, dataValue, cursor, each, field, fields, fn, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
|
package/types/index.d.ts
ADDED
package/types/utils.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function mapSystems(obj: any): any;
|
|
2
|
+
export function setSystemMap(newMappings: any): void;
|
|
3
|
+
export function identifier(input: any, system?: string): any;
|
|
4
|
+
export function id(input: any, system?: string): any;
|
|
5
|
+
export function addExtension(resource: any, url: string, value: any): void;
|
|
6
|
+
export function findExtension(obj: any, targetUrl: string, path?: string): any;
|
|
7
|
+
export function coding(code: string, system: string): {
|
|
8
|
+
code: string;
|
|
9
|
+
system: any;
|
|
10
|
+
};
|
|
11
|
+
export function concept(text: any, ...codings: any[]): {
|
|
12
|
+
text: string;
|
|
13
|
+
coding: any[];
|
|
14
|
+
};
|
|
15
|
+
export function cc(text: any, ...codings: any[]): {
|
|
16
|
+
text: string;
|
|
17
|
+
coding: any[];
|
|
18
|
+
};
|
|
19
|
+
export function reference(ref: any, opts: any): any;
|
|
20
|
+
export function ref(ref: any, opts: any): any;
|
|
21
|
+
export function composite(object: any, key: string, value: any): void;
|