@openfn/language-fhir-fr 1.0.1 → 1.0.2

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/dist/index.cjs CHANGED
@@ -1,9 +1,13 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
6
  var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
7
11
  var __commonJS = (cb, mod) => function __require() {
8
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
13
  };
@@ -27,7 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
27
31
 
28
32
  // ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js
29
33
  var require_lodash = __commonJS({
30
- "../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js"(exports, module2) {
34
+ "../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js"(exports2, module2) {
31
35
  (function() {
32
36
  var undefined2;
33
37
  var VERSION = "4.17.21";
@@ -353,7 +357,7 @@ var require_lodash = __commonJS({
353
357
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
354
358
  var freeSelf = typeof self == "object" && self && self.Object === Object && self;
355
359
  var root = freeGlobal || freeSelf || Function("return this")();
356
- var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
360
+ var freeExports = typeof exports2 == "object" && exports2 && !exports2.nodeType && exports2;
357
361
  var freeModule = freeExports && typeof module2 == "object" && module2 && !module2.nodeType && module2;
358
362
  var moduleExports = freeModule && freeModule.exports === freeExports;
359
363
  var freeProcess = moduleExports && freeGlobal.process;
@@ -2157,8 +2161,8 @@ var require_lodash = __commonJS({
2157
2161
  function createBind(func, bitmask, thisArg) {
2158
2162
  var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
2159
2163
  function wrapper() {
2160
- var fn2 = this && this !== root && this instanceof wrapper ? Ctor : func;
2161
- return fn2.apply(isBind ? thisArg : this, arguments);
2164
+ var fn = this && this !== root && this instanceof wrapper ? Ctor : func;
2165
+ return fn.apply(isBind ? thisArg : this, arguments);
2162
2166
  }
2163
2167
  return wrapper;
2164
2168
  }
@@ -2224,8 +2228,8 @@ var require_lodash = __commonJS({
2224
2228
  arity - length
2225
2229
  );
2226
2230
  }
2227
- var fn2 = this && this !== root && this instanceof wrapper ? Ctor : func;
2228
- return apply(fn2, this, args);
2231
+ var fn = this && this !== root && this instanceof wrapper ? Ctor : func;
2232
+ return apply(fn, this, args);
2229
2233
  }
2230
2234
  return wrapper;
2231
2235
  }
@@ -2313,7 +2317,7 @@ var require_lodash = __commonJS({
2313
2317
  arity - length
2314
2318
  );
2315
2319
  }
2316
- var thisBinding = isBind ? thisArg : this, fn2 = isBindKey ? thisBinding[func] : func;
2320
+ var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func;
2317
2321
  length = args.length;
2318
2322
  if (argPos) {
2319
2323
  args = reorder(args, argPos);
@@ -2324,9 +2328,9 @@ var require_lodash = __commonJS({
2324
2328
  args.length = ary2;
2325
2329
  }
2326
2330
  if (this && this !== root && this instanceof wrapper) {
2327
- fn2 = Ctor || createCtor(fn2);
2331
+ fn = Ctor || createCtor(fn);
2328
2332
  }
2329
- return fn2.apply(thisBinding, args);
2333
+ return fn.apply(thisBinding, args);
2330
2334
  }
2331
2335
  return wrapper;
2332
2336
  }
@@ -2383,14 +2387,14 @@ var require_lodash = __commonJS({
2383
2387
  function createPartial(func, bitmask, thisArg, partials) {
2384
2388
  var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
2385
2389
  function wrapper() {
2386
- var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array2(leftLength + argsLength), fn2 = this && this !== root && this instanceof wrapper ? Ctor : func;
2390
+ var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array2(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
2387
2391
  while (++leftIndex < leftLength) {
2388
2392
  args[leftIndex] = partials[leftIndex];
2389
2393
  }
2390
2394
  while (argsLength--) {
2391
2395
  args[leftIndex++] = arguments[++argsIndex];
2392
2396
  }
2393
- return apply(fn2, isBind ? thisArg : this, args);
2397
+ return apply(fn, isBind ? thisArg : this, args);
2394
2398
  }
2395
2399
  return wrapper;
2396
2400
  }
@@ -4349,7 +4353,7 @@ var require_lodash = __commonJS({
4349
4353
  });
4350
4354
  return result2;
4351
4355
  }
4352
- var merge2 = createAssigner(function(object, source, srcIndex) {
4356
+ var merge = createAssigner(function(object, source, srcIndex) {
4353
4357
  baseMerge(object, source, srcIndex);
4354
4358
  });
4355
4359
  var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
@@ -5039,7 +5043,7 @@ var require_lodash = __commonJS({
5039
5043
  lodash.matches = matches;
5040
5044
  lodash.matchesProperty = matchesProperty;
5041
5045
  lodash.memoize = memoize;
5042
- lodash.merge = merge2;
5046
+ lodash.merge = merge;
5043
5047
  lodash.mergeWith = mergeWith;
5044
5048
  lodash.method = method;
5045
5049
  lodash.methodOf = methodOf;
@@ -5459,48 +5463,10 @@ var require_lodash = __commonJS({
5459
5463
  } else {
5460
5464
  root._ = _3;
5461
5465
  }
5462
- }).call(exports);
5466
+ }).call(exports2);
5463
5467
  }
5464
5468
  });
5465
5469
 
5466
- // src/index.js
5467
- var src_exports = {};
5468
- __export(src_exports, {
5469
- b: () => builders_exports,
5470
- builders: () => builders_exports,
5471
- cursor: () => import_language_common.cursor,
5472
- dataPath: () => import_language_common.dataPath,
5473
- dataValue: () => import_language_common.dataValue,
5474
- dateFns: () => import_language_common.dateFns,
5475
- default: () => src_default,
5476
- each: () => import_language_common.each,
5477
- field: () => import_language_common.field,
5478
- fields: () => import_language_common.fields,
5479
- fn: () => import_language_common.fn,
5480
- lastReferenceValue: () => import_language_common.lastReferenceValue,
5481
- merge: () => import_language_common.merge,
5482
- sourceValue: () => import_language_common.sourceValue,
5483
- util: () => utils_exports
5484
- });
5485
- module.exports = __toCommonJS(src_exports);
5486
-
5487
- // src/Adaptor.js
5488
- var Adaptor_exports = {};
5489
- __export(Adaptor_exports, {
5490
- cursor: () => import_language_common.cursor,
5491
- dataPath: () => import_language_common.dataPath,
5492
- dataValue: () => import_language_common.dataValue,
5493
- dateFns: () => import_language_common.dateFns,
5494
- each: () => import_language_common.each,
5495
- field: () => import_language_common.field,
5496
- fields: () => import_language_common.fields,
5497
- fn: () => import_language_common.fn,
5498
- lastReferenceValue: () => import_language_common.lastReferenceValue,
5499
- merge: () => import_language_common.merge,
5500
- sourceValue: () => import_language_common.sourceValue
5501
- });
5502
- var import_util = require("@openfn/language-common/util");
5503
-
5504
5470
  // src/utils.js
5505
5471
  var utils_exports = {};
5506
5472
  __export(utils_exports, {
@@ -5517,142 +5483,144 @@ __export(utils_exports, {
5517
5483
  reference: () => reference,
5518
5484
  setSystemMap: () => setSystemMap
5519
5485
  });
5520
- var import_lodash = __toESM(require_lodash(), 1);
5521
- var systemMap = {
5522
- SmartCareID: "http://moh.gov.et/fhir/hiv/identifier/SmartCareID",
5523
- MRN: "http://moh.gov.et/fhir/hiv/identifier/MRN",
5524
- UAN: "http://moh.gov.et/fhir/hiv/identifier/UAN"
5525
- };
5526
- 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)))?)?)?/;
5527
- var mapSystems = (obj) => {
5528
- if (Array.isArray(obj)) {
5529
- return obj.map(mapSystems);
5530
- }
5531
- if (obj.system in systemMap) {
5532
- return {
5533
- ...obj,
5534
- system: systemMap[obj.system]
5486
+ var import_lodash, systemMap, datetimeregex, mapSystems, setSystemMap, identifier, id, addExtension, findExtension, coding, concept, cc, reference, ref, composite;
5487
+ var init_utils = __esm({
5488
+ "src/utils.js"() {
5489
+ import_lodash = __toESM(require_lodash(), 1);
5490
+ systemMap = {
5491
+ SmartCareID: "http://moh.gov.et/fhir/hiv/identifier/SmartCareID",
5492
+ MRN: "http://moh.gov.et/fhir/hiv/identifier/MRN",
5493
+ UAN: "http://moh.gov.et/fhir/hiv/identifier/UAN"
5494
+ };
5495
+ 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)))?)?)?/;
5496
+ mapSystems = (obj) => {
5497
+ if (Array.isArray(obj)) {
5498
+ return obj.map(mapSystems);
5499
+ }
5500
+ if (obj.system in systemMap) {
5501
+ return {
5502
+ ...obj,
5503
+ system: systemMap[obj.system]
5504
+ };
5505
+ }
5506
+ return obj;
5507
+ };
5508
+ setSystemMap = (newMappings) => {
5509
+ Object.assign(systemMap, newMappings);
5510
+ };
5511
+ identifier = (input, system) => {
5512
+ if (Array.isArray(input)) {
5513
+ return input.map((i) => identifier(i, system));
5514
+ }
5515
+ if (input) {
5516
+ if (typeof input === "string") {
5517
+ return mapSystems({
5518
+ value: input,
5519
+ system
5520
+ });
5521
+ } else if (system) {
5522
+ return mapSystems({
5523
+ system,
5524
+ ...input
5525
+ });
5526
+ } else {
5527
+ return mapSystems(input);
5528
+ }
5529
+ }
5530
+ };
5531
+ id = identifier;
5532
+ addExtension = (resource, url, value) => {
5533
+ const obj = {
5534
+ url
5535
+ };
5536
+ composite(obj, "value", value);
5537
+ resource.extension ?? (resource.extension = []);
5538
+ resource.extension.push(obj);
5539
+ };
5540
+ findExtension = (obj, targetUrl, path) => {
5541
+ var _a;
5542
+ const result = (_a = obj.extension) == null ? void 0 : _a.find((ext) => ext.url === targetUrl);
5543
+ if (result && path) {
5544
+ return import_lodash.default.get(result, path);
5545
+ }
5546
+ return result;
5547
+ };
5548
+ coding = (code, system) => ({ code, system: mapSystems(system) });
5549
+ concept = (text, ...codings) => {
5550
+ const result = {};
5551
+ let incomingCodings = codings;
5552
+ if (typeof text === "string") {
5553
+ result.text = text;
5554
+ } else {
5555
+ incomingCodings = [text].concat(codings);
5556
+ }
5557
+ const c = [];
5558
+ for (const item of incomingCodings) {
5559
+ if (Array.isArray(item)) {
5560
+ c.push(coding(item[0], item[1]));
5561
+ } else {
5562
+ c.push(item);
5563
+ }
5564
+ }
5565
+ result.coding = c;
5566
+ return result;
5567
+ };
5568
+ cc = concept;
5569
+ reference = (ref2, opts) => {
5570
+ if (Array.isArray(ref2)) {
5571
+ return ref2.map(reference, opts);
5572
+ }
5573
+ if (ref2.resourceType && ref2.id) {
5574
+ return { reference: `${ref2.resourceType}/${ref2.id}` };
5575
+ }
5576
+ if (ref2.reference) {
5577
+ return ref2;
5578
+ }
5579
+ const result = {};
5580
+ if (typeof ref2 === "string") {
5581
+ result.reference = ref2;
5582
+ }
5583
+ if (opts) {
5584
+ Object.assign(result, opts);
5585
+ }
5586
+ return result;
5587
+ };
5588
+ ref = reference;
5589
+ composite = (object, key, value) => {
5590
+ const k = [key];
5591
+ if (value.coding) {
5592
+ k.push("CodeableConcept");
5593
+ } else if (value.reference) {
5594
+ k.push("Reference");
5595
+ } else if (value.id && value.meta && value.resourceType) {
5596
+ k.push("Reference");
5597
+ value = reference(value);
5598
+ } else if (value.start || value.end) {
5599
+ k.push("Period");
5600
+ } else if (value.dateTime) {
5601
+ k.push("DateTime");
5602
+ } else if (typeof value === "string") {
5603
+ if (datetimeregex.test(value)) {
5604
+ k.push("DateTime");
5605
+ } else {
5606
+ k.push("String");
5607
+ }
5608
+ } else if (typeof value === "boolean") {
5609
+ k.push("Boolean");
5610
+ } else if (typeof value === "number") {
5611
+ k.push("Integer");
5612
+ }
5613
+ if (k.length === 2) {
5614
+ const finalKey = k.join("");
5615
+ object[finalKey] = value;
5616
+ } else {
5617
+ console.warn(
5618
+ `WARNING: Failed to map ${key}: unrecognised data type (see utils.composite)`
5619
+ );
5620
+ }
5535
5621
  };
5536
5622
  }
5537
- return obj;
5538
- };
5539
- var setSystemMap = (newMappings) => {
5540
- Object.assign(systemMap, newMappings);
5541
- };
5542
- var identifier = (input, system) => {
5543
- if (Array.isArray(input)) {
5544
- return input.map((i) => identifier(i, system));
5545
- }
5546
- if (input) {
5547
- if (typeof input === "string") {
5548
- return mapSystems({
5549
- value: input,
5550
- system
5551
- });
5552
- } else if (system) {
5553
- return mapSystems({
5554
- system,
5555
- ...input
5556
- });
5557
- } else {
5558
- return mapSystems(input);
5559
- }
5560
- }
5561
- };
5562
- var id = identifier;
5563
- var addExtension = (resource, url, value) => {
5564
- const obj = {
5565
- url
5566
- };
5567
- composite(obj, "value", value);
5568
- resource.extension ?? (resource.extension = []);
5569
- resource.extension.push(obj);
5570
- };
5571
- var findExtension = (obj, targetUrl, path) => {
5572
- var _a;
5573
- const result = (_a = obj.extension) == null ? void 0 : _a.find((ext) => ext.url === targetUrl);
5574
- if (result && path) {
5575
- return import_lodash.default.get(result, path);
5576
- }
5577
- return result;
5578
- };
5579
- var coding = (code, system) => ({ code, system: mapSystems(system) });
5580
- var concept = (text, ...codings) => {
5581
- const result = {};
5582
- let incomingCodings = codings;
5583
- if (typeof text === "string") {
5584
- result.text = text;
5585
- } else {
5586
- incomingCodings = [text].concat(codings);
5587
- }
5588
- const c = [];
5589
- for (const item of incomingCodings) {
5590
- if (Array.isArray(item)) {
5591
- c.push(coding(item[0], item[1]));
5592
- } else {
5593
- c.push(item);
5594
- }
5595
- }
5596
- result.coding = c;
5597
- return result;
5598
- };
5599
- var cc = concept;
5600
- var reference = (ref2, opts) => {
5601
- if (Array.isArray(ref2)) {
5602
- return ref2.map(reference, opts);
5603
- }
5604
- if (ref2.resourceType && ref2.id) {
5605
- return { reference: `${ref2.resourceType}/${ref2.id}` };
5606
- }
5607
- if (ref2.reference) {
5608
- return ref2;
5609
- }
5610
- const result = {};
5611
- if (typeof ref2 === "string") {
5612
- result.reference = ref2;
5613
- }
5614
- if (opts) {
5615
- Object.assign(result, opts);
5616
- }
5617
- return result;
5618
- };
5619
- var ref = reference;
5620
- var composite = (object, key, value) => {
5621
- const k = [key];
5622
- if (value.coding) {
5623
- k.push("CodeableConcept");
5624
- } else if (value.reference) {
5625
- k.push("Reference");
5626
- } else if (value.id && value.meta && value.resourceType) {
5627
- k.push("Reference");
5628
- value = reference(value);
5629
- } else if (value.start || value.end) {
5630
- k.push("Period");
5631
- } else if (value.dateTime) {
5632
- k.push("DateTime");
5633
- } else if (typeof value === "string") {
5634
- if (datetimeregex.test(value)) {
5635
- k.push("DateTime");
5636
- } else {
5637
- k.push("String");
5638
- }
5639
- } else if (typeof value === "boolean") {
5640
- k.push("Boolean");
5641
- } else if (typeof value === "number") {
5642
- k.push("Integer");
5643
- }
5644
- if (k.length === 2) {
5645
- const finalKey = k.join("");
5646
- object[finalKey] = value;
5647
- } else {
5648
- console.warn(
5649
- `WARNING: Failed to map ${key}: unrecognised data type (see utils.composite)`
5650
- );
5651
- }
5652
- };
5653
-
5654
- // src/Adaptor.js
5655
- var import_language_common = require("@openfn/language-common");
5623
+ });
5656
5624
 
5657
5625
  // src/builders.js
5658
5626
  var builders_exports = {};
@@ -5675,7 +5643,6 @@ __export(builders_exports, {
5675
5643
  schedule: () => schedule,
5676
5644
  slot: () => slot
5677
5645
  });
5678
- var import_lodash2 = __toESM(require_lodash(), 1);
5679
5646
  function address(type, props) {
5680
5647
  const mappings = {
5681
5648
  "fr-core-address": address_fr_core_address
@@ -11767,26 +11734,21 @@ function slot_fr_core_slot(props) {
11767
11734
  };
11768
11735
  return resource;
11769
11736
  }
11737
+ var import_lodash2;
11738
+ var init_builders = __esm({
11739
+ "src/builders.js"() {
11740
+ init_utils();
11741
+ import_lodash2 = __toESM(require_lodash(), 1);
11742
+ }
11743
+ });
11770
11744
 
11771
11745
  // src/index.js
11772
- var src_default = Adaptor_exports;
11773
- // Annotate the CommonJS export names for ESM import in node:
11774
- 0 && (module.exports = {
11775
- b,
11776
- builders,
11777
- cursor,
11778
- dataPath,
11779
- dataValue,
11780
- dateFns,
11781
- each,
11782
- field,
11783
- fields,
11784
- fn,
11785
- lastReferenceValue,
11786
- merge,
11787
- sourceValue,
11788
- util
11789
- });
11746
+ exports.__esModule = true;
11747
+ exports.b = exports.builders = exports.util = void 0;
11748
+ init_builders();
11749
+ exports.util = (init_utils(), __toCommonJS(utils_exports));
11750
+ exports.builders = (init_builders(), __toCommonJS(builders_exports));
11751
+ exports.b = (init_builders(), __toCommonJS(builders_exports));
11790
11752
  /**
11791
11753
  * @license
11792
11754
  * Lodash <https://lodash.com/>