@medplum/core 2.0.20 → 2.0.22

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.
Files changed (47) hide show
  1. package/dist/cjs/index.cjs +448 -289
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.min.cjs +1 -1
  4. package/dist/esm/client.mjs +199 -101
  5. package/dist/esm/client.mjs.map +1 -1
  6. package/dist/esm/crypto.mjs +3 -1
  7. package/dist/esm/crypto.mjs.map +1 -1
  8. package/dist/esm/fhirpath/functions.mjs +179 -129
  9. package/dist/esm/fhirpath/functions.mjs.map +1 -1
  10. package/dist/esm/format.mjs +6 -4
  11. package/dist/esm/format.mjs.map +1 -1
  12. package/dist/esm/hl7.mjs +1 -1
  13. package/dist/esm/hl7.mjs.map +1 -1
  14. package/dist/esm/index.min.mjs +1 -1
  15. package/dist/esm/index.mjs +1 -0
  16. package/dist/esm/index.mjs.map +1 -1
  17. package/dist/esm/jwt.mjs +4 -2
  18. package/dist/esm/jwt.mjs.map +1 -1
  19. package/dist/esm/schema.mjs +4 -10
  20. package/dist/esm/schema.mjs.map +1 -1
  21. package/dist/esm/search/details.mjs +0 -1
  22. package/dist/esm/search/details.mjs.map +1 -1
  23. package/dist/esm/search/match.mjs +1 -0
  24. package/dist/esm/search/match.mjs.map +1 -1
  25. package/dist/esm/search/search.mjs +2 -2
  26. package/dist/esm/search/search.mjs.map +1 -1
  27. package/dist/esm/sftp.mjs +0 -1
  28. package/dist/esm/sftp.mjs.map +1 -1
  29. package/dist/esm/storage.mjs +8 -0
  30. package/dist/esm/storage.mjs.map +1 -1
  31. package/dist/esm/types.mjs +1 -0
  32. package/dist/esm/types.mjs.map +1 -1
  33. package/dist/esm/utils.mjs +8 -7
  34. package/dist/esm/utils.mjs.map +1 -1
  35. package/dist/types/client.d.ts +89 -65
  36. package/dist/types/config.d.ts +7 -3
  37. package/dist/types/crypto.d.ts +3 -1
  38. package/dist/types/hl7.d.ts +1 -1
  39. package/dist/types/index.d.ts +1 -0
  40. package/dist/types/jwt.d.ts +2 -1
  41. package/dist/types/schema.d.ts +4 -10
  42. package/dist/types/search/details.d.ts +0 -1
  43. package/dist/types/search/search.d.ts +1 -1
  44. package/dist/types/storage.d.ts +8 -0
  45. package/dist/types/typeschema/types.d.ts +55 -0
  46. package/dist/types/utils.d.ts +4 -4
  47. package/package.json +1 -1
@@ -6,6 +6,7 @@ import { booleanToTypedValue, toJsBoolean, removeDuplicates, isQuantity, fhirPat
6
6
 
7
7
  /**
8
8
  * Temporary placholder for unimplemented methods.
9
+ * @returns Empty array.
9
10
  */
10
11
  const stub = () => [];
11
12
  const functions = {
@@ -17,7 +18,6 @@ const functions = {
17
18
  * Returns true if the input collection is empty ({ }) and false otherwise.
18
19
  *
19
20
  * See: https://hl7.org/fhirpath/#empty-boolean
20
- *
21
21
  * @param input The input collection.
22
22
  * @returns True if the input collection is empty ({ }) and false otherwise.
23
23
  */
@@ -34,9 +34,8 @@ const functions = {
34
34
  * for where(criteria).exists().
35
35
  *
36
36
  * See: https://hl7.org/fhirpath/#existscriteria-expression-boolean
37
- *
38
- * @param input
39
- * @param criteria
37
+ * @param input The input collection.
38
+ * @param criteria Optional criteria applied to the collection.
40
39
  * @returns True if the collection has unknown elements, and false otherwise.
41
40
  */
42
41
  exists: (input, criteria) => {
@@ -54,7 +53,6 @@ const functions = {
54
53
  * If the input collection is empty ({ }), the result is true.
55
54
  *
56
55
  * See: https://hl7.org/fhirpath/#allcriteria-expression-boolean
57
- *
58
56
  * @param input The input collection.
59
57
  * @param criteria The evaluation criteria.
60
58
  * @returns True if for every element in the input collection, criteria evaluates to true.
@@ -68,9 +66,7 @@ const functions = {
68
66
  * If the input is empty ({ }), the result is true.
69
67
  *
70
68
  * See: https://hl7.org/fhirpath/#alltrue-boolean
71
- *
72
69
  * @param input The input collection.
73
- * @param criteria The evaluation criteria.
74
70
  * @returns True if all the items are true.
75
71
  */
76
72
  allTrue: (input) => {
@@ -86,9 +82,7 @@ const functions = {
86
82
  * If all the items are false, or if the input is empty ({ }), the result is false.
87
83
  *
88
84
  * See: https://hl7.org/fhirpath/#anytrue-boolean
89
- *
90
85
  * @param input The input collection.
91
- * @param criteria The evaluation criteria.
92
86
  * @returns True if unknown of the items are true.
93
87
  */
94
88
  anyTrue: (input) => {
@@ -105,9 +99,7 @@ const functions = {
105
99
  * If the input is empty ({ }), the result is true.
106
100
  *
107
101
  * See: https://hl7.org/fhirpath/#allfalse-boolean
108
- *
109
102
  * @param input The input collection.
110
- * @param criteria The evaluation criteria.
111
103
  * @returns True if all the items are false.
112
104
  */
113
105
  allFalse: (input) => {
@@ -123,9 +115,7 @@ const functions = {
123
115
  * If all the items are true, or if the input is empty ({ }), the result is false.
124
116
  *
125
117
  * See: https://hl7.org/fhirpath/#anyfalse-boolean
126
- *
127
118
  * @param input The input collection.
128
- * @param criteria The evaluation criteria.
129
119
  * @returns True if for every element in the input collection, criteria evaluates to true.
130
120
  */
131
121
  anyFalse: (input) => {
@@ -165,7 +155,6 @@ const functions = {
165
155
  * Returns 0 when the input collection is empty.
166
156
  *
167
157
  * See: https://hl7.org/fhirpath/#count-integer
168
- *
169
158
  * @param input The input collection.
170
159
  * @returns The integer count of the number of items in the input collection.
171
160
  */
@@ -183,7 +172,6 @@ const functions = {
183
172
  * preserved in the result.
184
173
  *
185
174
  * See: https://hl7.org/fhirpath/#distinct-collection
186
- *
187
175
  * @param input The input collection.
188
176
  * @returns The integer count of the number of items in the input collection.
189
177
  */
@@ -202,7 +190,6 @@ const functions = {
202
190
  * as defined below.
203
191
  *
204
192
  * See: https://hl7.org/fhirpath/#isdistinct-boolean
205
- *
206
193
  * @param input The input collection.
207
194
  * @returns The integer count of the number of items in the input collection.
208
195
  */
@@ -225,9 +212,8 @@ const functions = {
225
212
  * consistent with singleton evaluation of collections behavior.
226
213
  *
227
214
  * See: https://hl7.org/fhirpath/#wherecriteria-expression-collection
228
- *
229
215
  * @param input The input collection.
230
- * @param condition The condition atom.
216
+ * @param criteria The condition atom.
231
217
  * @returns A collection containing only those elements in the input collection for which the stated criteria expression evaluates to true.
232
218
  */
233
219
  where: (input, criteria) => {
@@ -243,6 +229,9 @@ const functions = {
243
229
  * the input collection is empty ({ }), the result is empty as well.
244
230
  *
245
231
  * See: http://hl7.org/fhirpath/#selectprojection-expression-collection
232
+ * @param input The input collection.
233
+ * @param criteria The condition atom.
234
+ * @returns A collection containing only those elements in the input collection for which the stated criteria expression evaluates to true.
246
235
  */
247
236
  select: (input, criteria) => {
248
237
  return input.map((e) => criteria.eval([e])).flat();
@@ -262,6 +251,9 @@ const functions = {
262
251
  * must resolve to the name of a type in a model
263
252
  *
264
253
  * See: http://hl7.org/fhirpath/#oftypetype-type-specifier-collection
254
+ * @param input The input collection.
255
+ * @param criteria The condition atom.
256
+ * @returns A collection containing only those elements in the input collection that are of the given type or a subclass thereof.
265
257
  */
266
258
  ofType: (input, criteria) => {
267
259
  return input.filter((e) => e.type === criteria.name);
@@ -277,7 +269,6 @@ const functions = {
277
269
  * about cardinality is violated at run-time.
278
270
  *
279
271
  * See: https://hl7.org/fhirpath/#single-collection
280
- *
281
272
  * @param input The input collection.
282
273
  * @returns The single item in the input if there is just one item.
283
274
  */
@@ -292,7 +283,6 @@ const functions = {
292
283
  * This function is equivalent to item[0], so it will return an empty collection if the input collection has no items.
293
284
  *
294
285
  * See: https://hl7.org/fhirpath/#first-collection
295
- *
296
286
  * @param input The input collection.
297
287
  * @returns A collection containing only the first item in the input collection.
298
288
  */
@@ -304,7 +294,6 @@ const functions = {
304
294
  * Will return an empty collection if the input collection has no items.
305
295
  *
306
296
  * See: https://hl7.org/fhirpath/#last-collection
307
- *
308
297
  * @param input The input collection.
309
298
  * @returns A collection containing only the last item in the input collection.
310
299
  */
@@ -316,7 +305,6 @@ const functions = {
316
305
  * Will return an empty collection if the input collection has no items, or only one item.
317
306
  *
318
307
  * See: https://hl7.org/fhirpath/#tail-collection
319
- *
320
308
  * @param input The input collection.
321
309
  * @returns A collection containing all but the first item in the input collection.
322
310
  */
@@ -330,8 +318,8 @@ const functions = {
330
318
  * If num is less than or equal to zero, the input collection is simply returned.
331
319
  *
332
320
  * See: https://hl7.org/fhirpath/#skipnum-integer-collection
333
- *
334
321
  * @param input The input collection.
322
+ * @param num The atom representing the number of elements to skip.
335
323
  * @returns A collection containing all but the first item in the input collection.
336
324
  */
337
325
  skip: (input, num) => {
@@ -354,8 +342,8 @@ const functions = {
354
342
  * take returns an empty collection.
355
343
  *
356
344
  * See: https://hl7.org/fhirpath/#takenum-integer-collection
357
- *
358
345
  * @param input The input collection.
346
+ * @param num The atom representing the number of elements to take.
359
347
  * @returns A collection containing the first num items in the input collection.
360
348
  */
361
349
  take: (input, num) => {
@@ -377,6 +365,9 @@ const functions = {
377
365
  * Order of items is not guaranteed to be preserved in the result of this function.
378
366
  *
379
367
  * See: http://hl7.org/fhirpath/#intersectother-collection-collection
368
+ * @param input The input collection.
369
+ * @param other The atom representing the collection of elements to intersect.
370
+ * @returns A collection containing the elements that are in both collections.
380
371
  */
381
372
  intersect: (input, other) => {
382
373
  if (!other) {
@@ -398,6 +389,9 @@ const functions = {
398
389
  * e.g. (1 | 2 | 3).exclude(2) returns (1 | 3).
399
390
  *
400
391
  * See: http://hl7.org/fhirpath/#excludeother-collection-collection
392
+ * @param input The input collection.
393
+ * @param other The atom representing the collection of elements to exclude.
394
+ * @returns A collection containing the elements that are in the input collection but not the other collection.
401
395
  */
402
396
  exclude: (input, other) => {
403
397
  if (!other) {
@@ -425,6 +419,9 @@ const functions = {
425
419
  * In other words, this function returns the distinct list of elements from both inputs.
426
420
  *
427
421
  * See: http://hl7.org/fhirpath/#unionother-collection
422
+ * @param input The input collection.
423
+ * @param other The atom representing the collection of elements to merge.
424
+ * @returns A collection containing the elements that represent the union of both collections.
428
425
  */
429
426
  union: (input, other) => {
430
427
  if (!other) {
@@ -441,6 +438,9 @@ const functions = {
441
438
  * There is no expectation of order in the resulting collection.
442
439
  *
443
440
  * See: http://hl7.org/fhirpath/#combineother-collection-collection
441
+ * @param input The input collection.
442
+ * @param other The atom representing the collection of elements to merge.
443
+ * @returns A collection containing the elements that represent the combination of both collections including duplicates.
444
444
  */
445
445
  combine: (input, other) => {
446
446
  if (!other) {
@@ -469,12 +469,11 @@ const functions = {
469
469
  * true-result should only be evaluated if the criterion evaluates to true,
470
470
  * and otherwise-result should only be evaluated otherwise. For implementations,
471
471
  * this means delaying evaluation of the arguments.
472
- *
473
- * @param input
474
- * @param criterion
475
- * @param trueResult
476
- * @param otherwiseResult
477
- * @returns
472
+ * @param input The input collection.
473
+ * @param criterion The atom representing the conditional.
474
+ * @param trueResult The atom to be used if the conditional evaluates to true.
475
+ * @param otherwiseResult Optional atom to be used if the conditional evaluates to false.
476
+ * @returns The result of the iif function.
478
477
  */
479
478
  iif: (input, criterion, trueResult, otherwiseResult) => {
480
479
  const evalResult = criterion.eval(input);
@@ -501,9 +500,8 @@ const functions = {
501
500
  * If the item is not one the above types, or the item is a String, Integer, or Decimal, but is not equal to one of the possible values convertible to a Boolean, the result is empty.
502
501
  *
503
502
  * See: https://hl7.org/fhirpath/#toboolean-boolean
504
- *
505
- * @param input
506
- * @returns
503
+ * @param input The input collection.
504
+ * @returns The input converted to boolean value.
507
505
  */
508
506
  toBoolean: (input) => {
509
507
  if (input.length === 0) {
@@ -545,9 +543,8 @@ const functions = {
545
543
  * If the input collection is empty, the result is empty.
546
544
  *
547
545
  * See: http://hl7.org/fhirpath/#convertstoboolean-boolean
548
- *
549
- * @param input
550
- * @returns
546
+ * @param input The input collection.
547
+ * @returns True if the input can be converted to boolean.
551
548
  */
552
549
  convertsToBoolean: (input) => {
553
550
  if (input.length === 0) {
@@ -572,7 +569,6 @@ const functions = {
572
569
  * If the input collection is empty, the result is empty.
573
570
  *
574
571
  * See: https://hl7.org/fhirpath/#tointeger-integer
575
- *
576
572
  * @param input The input collection.
577
573
  * @returns The string representation of the input.
578
574
  */
@@ -606,9 +602,8 @@ const functions = {
606
602
  * If the input collection is empty, the result is empty.
607
603
  *
608
604
  * See: https://hl7.org/fhirpath/#convertstointeger-boolean
609
- *
610
605
  * @param input The input collection.
611
- * @returns
606
+ * @returns True if the input can be converted to an integer.
612
607
  */
613
608
  convertsToInteger: (input) => {
614
609
  if (input.length === 0) {
@@ -631,6 +626,8 @@ const functions = {
631
626
  * If the input collection is empty, the result is empty.
632
627
  *
633
628
  * See: https://hl7.org/fhirpath/#todate-date
629
+ * @param input The input collection.
630
+ * @returns The value converted to a date if possible; otherwise empty array.
634
631
  */
635
632
  toDate: (input) => {
636
633
  if (input.length === 0) {
@@ -657,6 +654,8 @@ const functions = {
657
654
  * If the input collection is empty, the result is empty.
658
655
  *
659
656
  * See: https://hl7.org/fhirpath/#convertstodate-boolean
657
+ * @param input The input collection.
658
+ * @returns True if the item can be converted to a date.
660
659
  */
661
660
  convertsToDate: (input) => {
662
661
  if (input.length === 0) {
@@ -665,26 +664,25 @@ const functions = {
665
664
  return booleanToTypedValue(functions.toDate(input).length === 1);
666
665
  },
667
666
  /**
668
- * If the input collection contains a single item, this function will return a single datetime if:
669
- * 1) the item is a DateTime
670
- * 2) the item is a Date, in which case the result is a DateTime with the year, month, and day of the Date, and the time components empty (not set to zero)
671
- * 3) the item is a String and is convertible to a DateTime
672
- *
673
- * If the item is not one of the above types, the result is empty.
674
- *
675
- * If the item is a String, but the string is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is empty.
676
- *
677
- * If the item contains a partial datetime (e.g. '2012-01-01T10:00'), the result is a partial datetime.
678
- *
679
- * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
680
- *
681
- * If the input collection is empty, the result is empty.
682
-
683
- * See: https://hl7.org/fhirpath/#todatetime-datetime
684
- *
685
- * @param input
686
- * @returns
687
- */
667
+ * If the input collection contains a single item, this function will return a single datetime if:
668
+ * 1) the item is a DateTime
669
+ * 2) the item is a Date, in which case the result is a DateTime with the year, month, and day of the Date, and the time components empty (not set to zero)
670
+ * 3) the item is a String and is convertible to a DateTime
671
+ *
672
+ * If the item is not one of the above types, the result is empty.
673
+ *
674
+ * If the item is a String, but the string is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is empty.
675
+ *
676
+ * If the item contains a partial datetime (e.g. '2012-01-01T10:00'), the result is a partial datetime.
677
+ *
678
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
679
+ *
680
+ * If the input collection is empty, the result is empty.
681
+ *
682
+ * See: https://hl7.org/fhirpath/#todatetime-datetime
683
+ * @param input The input collection.
684
+ * @returns The value converted to a dateTime if possible; otherwise empty array.
685
+ */
688
686
  toDateTime: (input) => {
689
687
  if (input.length === 0) {
690
688
  return [];
@@ -708,9 +706,8 @@ const functions = {
708
706
  * If the input collection is empty, the result is empty.
709
707
  *
710
708
  * See: https://hl7.org/fhirpath/#convertstodatetime-boolean
711
- *
712
- * @param input
713
- * @returns
709
+ * @param input The input collection.
710
+ * @returns True if the item can be converted to a dateTime.
714
711
  */
715
712
  convertsToDateTime: (input) => {
716
713
  if (input.length === 0) {
@@ -732,9 +729,8 @@ const functions = {
732
729
  * If the input collection is empty, the result is empty.
733
730
  *
734
731
  * See: https://hl7.org/fhirpath/#decimal-conversion-functions
735
- *
736
732
  * @param input The input collection.
737
- * @returns
733
+ * @returns The value converted to a decimal if possible; otherwise empty array.
738
734
  */
739
735
  toDecimal: (input) => {
740
736
  if (input.length === 0) {
@@ -753,22 +749,21 @@ const functions = {
753
749
  return [];
754
750
  },
755
751
  /**
756
- * If the input collection contains a single item, this function will true if:
757
- * 1) the item is an Integer or Decimal
758
- * 2) the item is a String and is convertible to a Decimal
759
- * 3) the item is a Boolean
760
- *
761
- * If the item is not one of the above types, or is not convertible to a Decimal (using the regex format (\\+|-)?\d+(\.\d+)?), the result is false.
762
- *
763
- * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
764
- *
765
- * If the input collection is empty, the result is empty.
766
-
767
- * See: https://hl7.org/fhirpath/#convertstodecimal-boolean
768
- *
769
- * @param input The input collection.
770
- * @returns
771
- */
752
+ * If the input collection contains a single item, this function will true if:
753
+ * 1) the item is an Integer or Decimal
754
+ * 2) the item is a String and is convertible to a Decimal
755
+ * 3) the item is a Boolean
756
+ *
757
+ * If the item is not one of the above types, or is not convertible to a Decimal (using the regex format (\\+|-)?\d+(\.\d+)?), the result is false.
758
+ *
759
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
760
+ *
761
+ * If the input collection is empty, the result is empty.
762
+ *
763
+ * See: https://hl7.org/fhirpath/#convertstodecimal-boolean
764
+ * @param input The input collection.
765
+ * @returns True if the item can be converted to a decimal.
766
+ */
772
767
  convertsToDecimal: (input) => {
773
768
  if (input.length === 0) {
774
769
  return [];
@@ -785,9 +780,8 @@ const functions = {
785
780
  * If the item is not one of the above types, the result is empty.
786
781
  *
787
782
  * See: https://hl7.org/fhirpath/#quantity-conversion-functions
788
- *
789
783
  * @param input The input collection.
790
- * @returns
784
+ * @returns The value converted to a quantity if possible; otherwise empty array.
791
785
  */
792
786
  toQuantity: (input) => {
793
787
  if (input.length === 0) {
@@ -827,9 +821,8 @@ const functions = {
827
821
  * If the unit argument is provided, it must be the string representation of a UCUM code (or a FHIRPath calendar duration keyword), and is used to determine whether the input quantity can be converted to the given unit, according to the unit conversion rules specified by UCUM. If the input quantity can be converted, the result is true, otherwise, the result is false.
828
822
  *
829
823
  * See: https://hl7.org/fhirpath/#convertstoquantityunit-string-boolean
830
- *
831
824
  * @param input The input collection.
832
- * @returns
825
+ * @returns True if the item can be converted to a quantity.
833
826
  */
834
827
  convertsToQuantity: (input) => {
835
828
  if (input.length === 0) {
@@ -849,7 +842,6 @@ const functions = {
849
842
  * If the item is not one of the above types, the result is false.
850
843
  *
851
844
  * See: https://hl7.org/fhirpath/#tostring-string
852
- *
853
845
  * @param input The input collection.
854
846
  * @returns The string representation of the input.
855
847
  */
@@ -882,9 +874,8 @@ const functions = {
882
874
  * If the input collection is empty, the result is empty.
883
875
  *
884
876
  * See: https://hl7.org/fhirpath/#tostring-string
885
- *
886
877
  * @param input The input collection.
887
- * @returns
878
+ * @returns True if the item can be converted to a string
888
879
  */
889
880
  convertsToString: (input) => {
890
881
  if (input.length === 0) {
@@ -908,9 +899,8 @@ const functions = {
908
899
  * If the input collection is empty, the result is empty.
909
900
  *
910
901
  * See: https://hl7.org/fhirpath/#totime-time
911
- *
912
- * @param input
913
- * @returns
902
+ * @param input The input collection.
903
+ * @returns The value converted to a time if possible; otherwise empty array.
914
904
  */
915
905
  toTime: (input) => {
916
906
  if (input.length === 0) {
@@ -937,9 +927,8 @@ const functions = {
937
927
  * If the input collection is empty, the result is empty.
938
928
  *
939
929
  * See: https://hl7.org/fhirpath/#convertstotime-boolean
940
- *
941
- * @param input
942
- * @returns
930
+ * @param input The input collection.
931
+ * @returns True if the item can be converted to a time.
943
932
  */
944
933
  convertsToTime: (input) => {
945
934
  if (input.length === 0) {
@@ -962,12 +951,12 @@ const functions = {
962
951
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
963
952
  *
964
953
  * See: https://hl7.org/fhirpath/#indexofsubstring-string-integer
965
- *
966
954
  * @param input The input collection.
955
+ * @param searchStringAtom The substring to search for.
967
956
  * @returns The index of the substring.
968
957
  */
969
- indexOf: (input, substringAtom) => {
970
- return applyStringFunc((str, substring) => str.indexOf(substring), input, substringAtom);
958
+ indexOf: (input, searchStringAtom) => {
959
+ return applyStringFunc((str, substring) => str.indexOf(substring), input, searchStringAtom);
971
960
  },
972
961
  /**
973
962
  * Returns the part of the string starting at position start (zero-based). If length is given, will return at most length number of characters from the input string.
@@ -979,9 +968,10 @@ const functions = {
979
968
  * If an empty length is provided, the behavior is the same as if length had not been provided.
980
969
  *
981
970
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
982
- *
983
971
  * @param input The input collection.
984
- * @returns The index of the substring.
972
+ * @param startAtom The start index atom.
973
+ * @param lengthAtom Optional length atom.
974
+ * @returns The substring.
985
975
  */
986
976
  substring: (input, startAtom, lengthAtom) => {
987
977
  return applyStringFunc((str, start, length) => {
@@ -991,71 +981,134 @@ const functions = {
991
981
  }, input, startAtom, lengthAtom);
992
982
  },
993
983
  /**
984
+ * Returns true when the input string starts with the given prefix.
994
985
  *
986
+ * If prefix is the empty string (''), the result is true.
987
+ *
988
+ * If the input collection is empty, the result is empty.
989
+ *
990
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
991
+ *
992
+ * See: https://hl7.org/fhirpath/#startswithprefix-string-boolean
995
993
  * @param input The input collection.
996
- * @returns The index of the substring.
994
+ * @param prefixAtom The prefix substring to test.
995
+ * @returns True if the input string starts with the given prefix string.
997
996
  */
998
997
  startsWith: (input, prefixAtom) => {
999
998
  return applyStringFunc((str, prefix) => str.startsWith(prefix), input, prefixAtom);
1000
999
  },
1001
1000
  /**
1001
+ * Returns true when the input string ends with the given suffix.
1002
+ *
1003
+ * If suffix is the empty string (''), the result is true.
1004
+ *
1005
+ * If the input collection is empty, the result is empty.
1006
+ *
1007
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1002
1008
  *
1009
+ * See: https://hl7.org/fhirpath/#endswithsuffix-string-boolean
1003
1010
  * @param input The input collection.
1004
- * @returns The index of the substring.
1011
+ * @param suffixAtom The suffix substring to test.
1012
+ * @returns True if the input string ends with the given suffix string.
1005
1013
  */
1006
1014
  endsWith: (input, suffixAtom) => {
1007
1015
  return applyStringFunc((str, suffix) => str.endsWith(suffix), input, suffixAtom);
1008
1016
  },
1009
1017
  /**
1018
+ * Returns true when the given substring is a substring of the input string.
1019
+ *
1020
+ * If substring is the empty string (''), the result is true.
1021
+ *
1022
+ * If the input collection is empty, the result is empty.
1023
+ *
1024
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1010
1025
  *
1026
+ * See: https://hl7.org/fhirpath/#containssubstring-string-boolean
1011
1027
  * @param input The input collection.
1012
- * @returns The index of the substring.
1028
+ * @param substringAtom The substring to test.
1029
+ * @returns True if the input string contains the given substring.
1013
1030
  */
1014
1031
  contains: (input, substringAtom) => {
1015
1032
  return applyStringFunc((str, substring) => str.includes(substring), input, substringAtom);
1016
1033
  },
1017
1034
  /**
1035
+ * Returns the input string with all characters converted to upper case.
1036
+ *
1037
+ * If the input collection is empty, the result is empty.
1038
+ *
1039
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1018
1040
  *
1041
+ * See: https://hl7.org/fhirpath/#upper-string
1019
1042
  * @param input The input collection.
1020
- * @returns The index of the substring.
1043
+ * @returns The string converted to upper case.
1021
1044
  */
1022
1045
  upper: (input) => {
1023
1046
  return applyStringFunc((str) => str.toUpperCase(), input);
1024
1047
  },
1025
1048
  /**
1049
+ * Returns the input string with all characters converted to lower case.
1050
+ *
1051
+ * If the input collection is empty, the result is empty.
1026
1052
  *
1053
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1054
+ *
1055
+ * See: https://hl7.org/fhirpath/#lower-string
1027
1056
  * @param input The input collection.
1028
- * @returns The index of the substring.
1057
+ * @returns The string converted to lower case.
1029
1058
  */
1030
1059
  lower: (input) => {
1031
1060
  return applyStringFunc((str) => str.toLowerCase(), input);
1032
1061
  },
1033
1062
  /**
1063
+ * Returns the input string with all instances of pattern replaced with substitution. If the substitution is the empty string (''),
1064
+ * instances of pattern are removed from the result. If pattern is the empty string (''), every character in the input string is
1065
+ * surrounded by the substitution, e.g. 'abc'.replace('','x') becomes 'xaxbxcx'.
1034
1066
  *
1067
+ * If the input collection, pattern, or substitution are empty, the result is empty ({ }).
1068
+ *
1069
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1070
+ *
1071
+ * See: https://hl7.org/fhirpath/#replacepattern-string-substitution-string-string
1035
1072
  * @param input The input collection.
1036
- * @returns The index of the substring.
1073
+ * @param patternAtom The pattern to search for.
1074
+ * @param substitionAtom The substition to replace with.
1075
+ * @returns The string with all instances of the search pattern replaced with the substitution string.
1037
1076
  */
1038
1077
  replace: (input, patternAtom, substitionAtom) => {
1039
1078
  return applyStringFunc((str, pattern, substition) => str.replaceAll(pattern, substition), input, patternAtom, substitionAtom);
1040
1079
  },
1041
1080
  /**
1081
+ * Returns true when the value matches the given regular expression. Regular expressions should function consistently, regardless of any culture- and locale-specific settings in the environment, should be case-sensitive, use 'single line' mode and allow Unicode characters.
1042
1082
  *
1083
+ * If the input collection or regex are empty, the result is empty ({ }).
1084
+ *
1085
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1086
+ *
1087
+ * See: https://hl7.org/fhirpath/#matchesregex-string-boolean
1043
1088
  * @param input The input collection.
1044
- * @returns The index of the substring.
1089
+ * @param regexAtom The regular expression atom.
1090
+ * @returns True if the input string matches the given regular expression.
1045
1091
  */
1046
1092
  matches: (input, regexAtom) => {
1047
1093
  return applyStringFunc((str, regex) => !!str.match(regex), input, regexAtom);
1048
1094
  },
1049
1095
  /**
1096
+ * Matches the input using the regular expression in regex and replaces each match with the substitution string. The substitution may refer to identified match groups in the regular expression.
1097
+ *
1098
+ * If the input collection, regex, or substitution are empty, the result is empty ({ }).
1099
+ *
1100
+ * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1050
1101
  *
1102
+ * See: https://hl7.org/fhirpath/#replacematchesregex-string-substitution-string-string
1051
1103
  * @param input The input collection.
1052
- * @returns The index of the substring.
1104
+ * @param regexAtom The regular expression atom.
1105
+ * @param substitionAtom The substition to replace with.
1106
+ * @returns The string with all instances of the search pattern replaced with the substitution string.
1053
1107
  */
1054
1108
  replaceMatches: (input, regexAtom, substitionAtom) => {
1055
1109
  return applyStringFunc((str, pattern, substition) => str.replaceAll(pattern, substition), input, regexAtom, substitionAtom);
1056
1110
  },
1057
1111
  /**
1058
- *
1059
1112
  * @param input The input collection.
1060
1113
  * @returns The index of the substring.
1061
1114
  */
@@ -1066,8 +1119,8 @@ const functions = {
1066
1119
  * Returns the list of characters in the input string. If the input collection is empty ({ }), the result is empty.
1067
1120
  *
1068
1121
  * See: https://hl7.org/fhirpath/#tochars-collection
1069
- *
1070
1122
  * @param input The input collection.
1123
+ * @returns Array of characters.
1071
1124
  */
1072
1125
  toChars: (input) => {
1073
1126
  return applyStringFunc((str) => (str ? str.split('') : undefined), input);
@@ -1083,7 +1136,6 @@ const functions = {
1083
1136
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1084
1137
  *
1085
1138
  * See: https://hl7.org/fhirpath/#abs-integer-decimal-quantity
1086
- *
1087
1139
  * @param input The input collection.
1088
1140
  * @returns A collection containing the result.
1089
1141
  */
@@ -1098,7 +1150,6 @@ const functions = {
1098
1150
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1099
1151
  *
1100
1152
  * See: https://hl7.org/fhirpath/#ceiling-integer
1101
- *
1102
1153
  * @param input The input collection.
1103
1154
  * @returns A collection containing the result.
1104
1155
  */
@@ -1115,7 +1166,6 @@ const functions = {
1115
1166
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1116
1167
  *
1117
1168
  * See: https://hl7.org/fhirpath/#exp-decimal
1118
- *
1119
1169
  * @param input The input collection.
1120
1170
  * @returns A collection containing the result.
1121
1171
  */
@@ -1130,7 +1180,6 @@ const functions = {
1130
1180
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1131
1181
  *
1132
1182
  * See: https://hl7.org/fhirpath/#floor-integer
1133
- *
1134
1183
  * @param input The input collection.
1135
1184
  * @returns A collection containing the result.
1136
1185
  */
@@ -1147,7 +1196,6 @@ const functions = {
1147
1196
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1148
1197
  *
1149
1198
  * See: https://hl7.org/fhirpath/#ln-decimal
1150
- *
1151
1199
  * @param input The input collection.
1152
1200
  * @returns A collection containing the result.
1153
1201
  */
@@ -1166,8 +1214,8 @@ const functions = {
1166
1214
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1167
1215
  *
1168
1216
  * See: https://hl7.org/fhirpath/#logbase-decimal-decimal
1169
- *
1170
1217
  * @param input The input collection.
1218
+ * @param baseAtom The logarithm base.
1171
1219
  * @returns A collection containing the result.
1172
1220
  */
1173
1221
  log: (input, baseAtom) => {
@@ -1183,8 +1231,8 @@ const functions = {
1183
1231
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1184
1232
  *
1185
1233
  * See: https://hl7.org/fhirpath/#powerexponent-integer-decimal-integer-decimal
1186
- *
1187
1234
  * @param input The input collection.
1235
+ * @param expAtom The exponent power.
1188
1236
  * @returns A collection containing the result.
1189
1237
  */
1190
1238
  power: (input, expAtom) => {
@@ -1202,7 +1250,6 @@ const functions = {
1202
1250
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1203
1251
  *
1204
1252
  * See: https://hl7.org/fhirpath/#roundprecision-integer-decimal
1205
- *
1206
1253
  * @param input The input collection.
1207
1254
  * @returns A collection containing the result.
1208
1255
  */
@@ -1221,7 +1268,6 @@ const functions = {
1221
1268
  * Note that this function is equivalent to raising a number of the power of 0.5 using the power() function.
1222
1269
  *
1223
1270
  * See: https://hl7.org/fhirpath/#sqrt-decimal
1224
- *
1225
1271
  * @param input The input collection.
1226
1272
  * @returns A collection containing the result.
1227
1273
  */
@@ -1236,7 +1282,6 @@ const functions = {
1236
1282
  * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
1237
1283
  *
1238
1284
  * See: https://hl7.org/fhirpath/#truncate-integer
1239
- *
1240
1285
  * @param input The input collection.
1241
1286
  * @returns A collection containing the result.
1242
1287
  */
@@ -1262,9 +1307,9 @@ const functions = {
1262
1307
  * function unchanged.
1263
1308
  *
1264
1309
  * See: https://hl7.org/fhirpath/#tracename-string-projection-expression-collection
1265
- *
1266
1310
  * @param input The input collection.
1267
1311
  * @param nameAtom The log name.
1312
+ * @returns The input collection.
1268
1313
  */
1269
1314
  trace: (input, nameAtom) => {
1270
1315
  console.log('trace', input, nameAtom);
@@ -1274,6 +1319,7 @@ const functions = {
1274
1319
  * Returns the current date and time, including timezone offset.
1275
1320
  *
1276
1321
  * See: https://hl7.org/fhirpath/#now-datetime
1322
+ * @returns The current dateTime.
1277
1323
  */
1278
1324
  now: () => {
1279
1325
  return [{ type: PropertyType.dateTime, value: new Date().toISOString() }];
@@ -1282,6 +1328,7 @@ const functions = {
1282
1328
  * Returns the current time.
1283
1329
  *
1284
1330
  * See: https://hl7.org/fhirpath/#timeofday-time
1331
+ * @returns The current time string.
1285
1332
  */
1286
1333
  timeOfDay: () => {
1287
1334
  return [{ type: PropertyType.time, value: new Date().toISOString().substring(11) }];
@@ -1290,6 +1337,7 @@ const functions = {
1290
1337
  * Returns the current date.
1291
1338
  *
1292
1339
  * See: https://hl7.org/fhirpath/#today-date
1340
+ * @returns The current date string.
1293
1341
  */
1294
1342
  today: () => {
1295
1343
  return [{ type: PropertyType.date, value: new Date().toISOString().substring(0, 10) }];
@@ -1301,6 +1349,11 @@ const functions = {
1301
1349
  *
1302
1350
  * IBM FHIR issue: https://github.com/IBM/FHIR/issues/1014
1303
1351
  * IBM FHIR PR: https://github.com/IBM/FHIR/pull/1023
1352
+ * @param input The input collection.
1353
+ * @param startAtom The start date/time.
1354
+ * @param endAtom The end date/time.
1355
+ * @param unitsAtom Which units to return ("years", "months", or "days").
1356
+ * @returns The Quantity of time between the two dates.
1304
1357
  */
1305
1358
  between: (input, startAtom, endAtom, unitsAtom) => {
1306
1359
  const startDate = functions.toDateTime(startAtom.eval(input));
@@ -1329,10 +1382,9 @@ const functions = {
1329
1382
  * For implementations with compile-time typing, this requires special-case
1330
1383
  * handling when processing the argument to treat it as a type specifier rather
1331
1384
  * than an identifier expression:
1332
- *
1333
- * @param input
1334
- * @param typeAtom
1335
- * @returns
1385
+ * @param input The input collection.
1386
+ * @param typeAtom The desired type.
1387
+ * @returns True if the input element is of the desired type.
1336
1388
  */
1337
1389
  is: (input, typeAtom) => {
1338
1390
  let typeName = '';
@@ -1354,9 +1406,8 @@ const functions = {
1354
1406
  * 6.5.3. not() : Boolean
1355
1407
  *
1356
1408
  * Returns true if the input collection evaluates to false, and false if it evaluates to true. Otherwise, the result is empty ({ }):
1357
- *
1358
- * @param input
1359
- * @returns
1409
+ * @param input The input collection.
1410
+ * @returns True if the input evaluates to false.
1360
1411
  */
1361
1412
  not: (input) => {
1362
1413
  return functions.toBoolean(input).map((value) => ({ type: PropertyType.boolean, value: !value.value }));
@@ -1369,7 +1420,7 @@ const functions = {
1369
1420
  * For each item in the collection, if it is a string that is a uri (or canonical or url), locate the target of the reference, and add it to the resulting collection. If the item does not resolve to a resource, the item is ignored and nothing is added to the output collection.
1370
1421
  * The items in the collection may also represent a Reference, in which case the Reference.reference is resolved.
1371
1422
  * @param input The input collection.
1372
- * @returns
1423
+ * @returns The resolved resource.
1373
1424
  */
1374
1425
  resolve: (input) => {
1375
1426
  return input
@@ -1424,9 +1475,8 @@ const functions = {
1424
1475
  * https://hl7.org/fhirpath/modelinfo.xsd
1425
1476
  *
1426
1477
  * See: https://hl7.org/fhirpath/#model-information
1427
- *
1428
1478
  * @param input The input collection.
1429
- * @returns
1479
+ * @returns The type of the input value.
1430
1480
  */
1431
1481
  type: (input) => {
1432
1482
  return input.map(({ value }) => {