@minvws/mgo-hcim-ui 0.1.1-1 → 0.1.3

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 (199) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +9 -7
  3. package/dist/common/organization/organization.d.ts.map +1 -1
  4. package/dist/common/organization/organization.js +2 -1
  5. package/dist/common/summaryOptions/summaryOptions.d.ts +2 -6
  6. package/dist/common/summaryOptions/summaryOptions.d.ts.map +1 -1
  7. package/dist/common/summaryOptions/summaryOptions.js +7 -4
  8. package/dist/context/baseProps/baseProps.d.ts +7 -0
  9. package/dist/context/baseProps/baseProps.d.ts.map +1 -0
  10. package/dist/context/baseProps/baseProps.js +10 -0
  11. package/dist/context/formatLabel/formatLabel.d.ts +20 -0
  12. package/dist/context/formatLabel/formatLabel.d.ts.map +1 -0
  13. package/dist/context/formatLabel/formatLabel.js +69 -0
  14. package/dist/context/index.d.ts +5 -3
  15. package/dist/context/index.d.ts.map +1 -1
  16. package/dist/context/index.js +3 -1
  17. package/dist/finalize/finalizeSchema/finalizeSchema.d.ts +7 -0
  18. package/dist/finalize/finalizeSchema/finalizeSchema.d.ts.map +1 -0
  19. package/dist/finalize/finalizeSchema/finalizeSchema.js +17 -0
  20. package/dist/finalize/flattenDeepGroups/flattenDeepGroups.d.ts +7 -0
  21. package/dist/finalize/flattenDeepGroups/flattenDeepGroups.d.ts.map +1 -0
  22. package/dist/finalize/flattenDeepGroups/flattenDeepGroups.js +69 -0
  23. package/dist/finalize/flattenSingleSubGroups/flattenSingleSubGroups.d.ts +7 -0
  24. package/dist/finalize/flattenSingleSubGroups/flattenSingleSubGroups.d.ts.map +1 -0
  25. package/dist/finalize/flattenSingleSubGroups/flattenSingleSubGroups.js +29 -0
  26. package/dist/finalize/hoistRootElements/hoistRootElements.d.ts +8 -0
  27. package/dist/finalize/hoistRootElements/hoistRootElements.d.ts.map +1 -0
  28. package/dist/finalize/hoistRootElements/hoistRootElements.js +47 -0
  29. package/dist/finalize/index.d.ts +7 -0
  30. package/dist/finalize/index.d.ts.map +1 -0
  31. package/dist/finalize/index.js +6 -0
  32. package/dist/finalize/setEmptyEntries/setEmptyEntries.d.ts +4 -0
  33. package/dist/finalize/setEmptyEntries/setEmptyEntries.d.ts.map +1 -0
  34. package/dist/finalize/setEmptyEntries/setEmptyEntries.js +27 -0
  35. package/dist/finalize/translateGroupLabels/translateGroupLabels.d.ts +8 -0
  36. package/dist/finalize/translateGroupLabels/translateGroupLabels.d.ts.map +1 -0
  37. package/dist/finalize/translateGroupLabels/translateGroupLabels.js +29 -0
  38. package/dist/format/cardTitle/cardTitle.d.ts +6 -0
  39. package/dist/format/cardTitle/cardTitle.d.ts.map +1 -0
  40. package/dist/format/cardTitle/cardTitle.js +21 -0
  41. package/dist/format/cardTitle/extractDisplayFromUiElement/extractDisplayFromUiElement.d.ts +3 -0
  42. package/dist/format/cardTitle/extractDisplayFromUiElement/extractDisplayFromUiElement.d.ts.map +1 -0
  43. package/dist/format/cardTitle/extractDisplayFromUiElement/extractDisplayFromUiElement.js +17 -0
  44. package/dist/format/index.d.ts +10 -1
  45. package/dist/format/index.d.ts.map +1 -1
  46. package/dist/format/index.js +9 -0
  47. package/dist/generator/createGeneratorContext/createGeneratorContext.d.ts +5 -2
  48. package/dist/generator/createGeneratorContext/createGeneratorContext.d.ts.map +1 -1
  49. package/dist/generator/createGeneratorContext/createGeneratorContext.js +5 -2
  50. package/dist/generator/createUiElementHelper/createUiElementHelper.d.ts +2 -2
  51. package/dist/generator/createUiElementHelper/createUiElementHelper.d.ts.map +1 -1
  52. package/dist/generator/createUiElementHelper/createUiElementHelper.js +11 -43
  53. package/dist/generator/generateUiSchema/generateUiSchema.d.ts.map +1 -1
  54. package/dist/generator/generateUiSchema/generateUiSchema.js +5 -14
  55. package/dist/generator/getProfileKey/getProfileKey.d.ts +1 -1
  56. package/dist/generator/getProfileKey/getProfileKey.d.ts.map +1 -1
  57. package/dist/generator/processArray/processArray.d.ts +2 -2
  58. package/dist/generator/processArray/processArray.d.ts.map +1 -1
  59. package/dist/generator/processArray/processArray.js +2 -2
  60. package/dist/generator/processMgoType/processMgoType.d.ts +2 -2
  61. package/dist/generator/processMgoType/processMgoType.d.ts.map +1 -1
  62. package/dist/generator/processMgoType/processMgoType.js +3 -2
  63. package/dist/generator/processObject/processObject.d.ts +2 -2
  64. package/dist/generator/processObject/processObject.d.ts.map +1 -1
  65. package/dist/generator/processObject/processObject.js +5 -4
  66. package/dist/generator/processValue/processValue.d.ts +2 -2
  67. package/dist/generator/processValue/processValue.d.ts.map +1 -1
  68. package/dist/generator/processValue/processValue.js +4 -3
  69. package/dist/helpers/index.d.ts +3 -3
  70. package/dist/helpers/index.d.ts.map +1 -1
  71. package/dist/helpers/index.js +3 -3
  72. package/dist/helpers/isEmptyNode/isEmptyNode.d.ts +5 -0
  73. package/dist/helpers/isEmptyNode/isEmptyNode.d.ts.map +1 -0
  74. package/dist/helpers/isEmptyNode/isEmptyNode.js +24 -0
  75. package/dist/helpers/isGroupNode/isGroupNode.d.ts +6 -0
  76. package/dist/helpers/isGroupNode/isGroupNode.d.ts.map +1 -0
  77. package/dist/helpers/isGroupNode/isGroupNode.js +3 -0
  78. package/dist/helpers/optional/optional.d.ts +17 -0
  79. package/dist/helpers/optional/optional.d.ts.map +1 -0
  80. package/dist/helpers/optional/optional.js +21 -0
  81. package/dist/index.d.ts +5 -3
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +2 -3
  84. package/dist/schema.d.ts +2 -0
  85. package/dist/schema.d.ts.map +1 -0
  86. package/dist/schema.js +2 -0
  87. package/dist/special/index.d.ts +3 -4
  88. package/dist/special/index.d.ts.map +1 -1
  89. package/dist/special/index.js +0 -2
  90. package/dist/special/oneOfValueX/oneOfValueX.d.ts +2 -2
  91. package/dist/special/oneOfValueX/oneOfValueX.d.ts.map +1 -1
  92. package/dist/special/oneOfValueX/oneOfValueX.js +7 -7
  93. package/dist/special/valueWithMax/valueWithMax.js +3 -3
  94. package/dist/special/valueWithUnit/valueWithUnit.js +3 -3
  95. package/dist/type/annotation/annotation.d.ts +3 -1
  96. package/dist/type/annotation/annotation.d.ts.map +1 -1
  97. package/dist/type/annotation/annotation.js +8 -6
  98. package/dist/type/attachment/attachment.d.ts +4 -0
  99. package/dist/type/attachment/attachment.d.ts.map +1 -0
  100. package/dist/type/attachment/attachment.js +31 -0
  101. package/dist/type/boolean/boolean.js +3 -3
  102. package/dist/type/code/code.js +8 -8
  103. package/dist/type/codeableConcept/codeableConcept.d.ts +2 -2
  104. package/dist/type/codeableConcept/codeableConcept.d.ts.map +1 -1
  105. package/dist/type/codeableConcept/codeableConcept.js +28 -15
  106. package/dist/type/coding/coding.d.ts +5 -2
  107. package/dist/type/coding/coding.d.ts.map +1 -1
  108. package/dist/type/coding/coding.js +14 -6
  109. package/dist/type/date/date.d.ts.map +1 -1
  110. package/dist/type/date/date.js +2 -1
  111. package/dist/type/dateTime/dateTime.d.ts.map +1 -1
  112. package/dist/type/dateTime/dateTime.js +5 -6
  113. package/dist/type/decimal/decimal.js +3 -3
  114. package/dist/type/duration/duration.d.ts +2 -2
  115. package/dist/type/duration/duration.d.ts.map +1 -1
  116. package/dist/type/identifier/identifier.d.ts.map +1 -1
  117. package/dist/type/identifier/identifier.js +5 -6
  118. package/dist/type/index.d.ts +12 -11
  119. package/dist/type/index.d.ts.map +1 -1
  120. package/dist/type/index.js +4 -1
  121. package/dist/type/instant/instant.d.ts.map +1 -1
  122. package/dist/type/instant/instant.js +5 -6
  123. package/dist/type/integer/integer.js +3 -3
  124. package/dist/type/integer64/integer64.js +3 -3
  125. package/dist/type/period/period.d.ts.map +1 -1
  126. package/dist/type/period/period.js +4 -2
  127. package/dist/type/positiveInt/positiveInt.js +3 -3
  128. package/dist/type/quantity/quantity.d.ts +2 -2
  129. package/dist/type/quantity/quantity.d.ts.map +1 -1
  130. package/dist/type/quantity/quantity.js +15 -3
  131. package/dist/type/range/range.d.ts.map +1 -1
  132. package/dist/type/range/range.js +5 -7
  133. package/dist/type/ratio/ratio.d.ts.map +1 -1
  134. package/dist/type/ratio/ratio.js +5 -7
  135. package/dist/type/reference/reference.d.ts.map +1 -1
  136. package/dist/type/reference/reference.js +6 -7
  137. package/dist/type/sampledData/sampledData.d.ts +2 -2
  138. package/dist/type/sampledData/sampledData.d.ts.map +1 -1
  139. package/dist/type/sampledData/sampledData.js +2 -0
  140. package/dist/type/simpleQuantity/simpleQuantity.js +3 -3
  141. package/dist/type/string/string.d.ts.map +1 -1
  142. package/dist/type/string/string.js +5 -6
  143. package/dist/type/time/time.d.ts.map +1 -1
  144. package/dist/type/time/time.js +5 -6
  145. package/dist/type/timing/timing.d.ts +2 -2
  146. package/dist/type/timing/timing.d.ts.map +1 -1
  147. package/dist/type/timing/timing.js +2 -0
  148. package/dist/type/unsignedInt/unsignedInt.js +3 -3
  149. package/dist/typeMaps/complexUiTypeMap.d.ts +8 -0
  150. package/dist/typeMaps/complexUiTypeMap.d.ts.map +1 -0
  151. package/dist/typeMaps/complexUiTypeMap.js +6 -0
  152. package/dist/typeMaps/index.d.ts +4 -0
  153. package/dist/typeMaps/index.d.ts.map +1 -0
  154. package/dist/typeMaps/index.js +3 -0
  155. package/dist/typeMaps/multipleUiTypeMap.d.ts +19 -0
  156. package/dist/typeMaps/multipleUiTypeMap.d.ts.map +1 -0
  157. package/dist/typeMaps/multipleUiTypeMap.js +15 -0
  158. package/dist/typeMaps/singleUiTypeMap.d.ts +32 -0
  159. package/dist/typeMaps/singleUiTypeMap.d.ts.map +1 -0
  160. package/dist/typeMaps/singleUiTypeMap.js +28 -0
  161. package/dist/typeMaps/typeMapTypes.d.ts +12 -0
  162. package/dist/typeMaps/typeMapTypes.d.ts.map +1 -0
  163. package/dist/typeMaps/typeMapTypes.js +2 -0
  164. package/dist/types/context.d.ts +5 -11
  165. package/dist/types/context.d.ts.map +1 -1
  166. package/dist/types/draft.d.ts +10 -0
  167. package/dist/types/draft.d.ts.map +1 -0
  168. package/dist/types/draft.js +1 -0
  169. package/dist/types/index.d.ts +2 -0
  170. package/dist/types/index.d.ts.map +1 -1
  171. package/dist/types/index.js +3 -1
  172. package/dist/types/schema.d.ts +39 -18
  173. package/dist/types/schema.d.ts.map +1 -1
  174. package/dist/types/schemaFunction.d.ts +5 -0
  175. package/dist/types/schemaFunction.d.ts.map +1 -0
  176. package/dist/types/schemaFunction.js +1 -0
  177. package/dist/ui.d.ts +30 -30
  178. package/package.json +26 -11
  179. package/dist/context/formatLabel.d.ts +0 -14
  180. package/dist/context/formatLabel.d.ts.map +0 -1
  181. package/dist/context/formatLabel.js +0 -61
  182. package/dist/generator/getUiElements/getUiElements.d.ts +0 -3
  183. package/dist/generator/getUiElements/getUiElements.d.ts.map +0 -1
  184. package/dist/generator/getUiElements/getUiElements.js +0 -4
  185. package/dist/helpers/dropEmptyEntries/dropEmptyEntries.d.ts +0 -5
  186. package/dist/helpers/dropEmptyEntries/dropEmptyEntries.d.ts.map +0 -1
  187. package/dist/helpers/dropEmptyEntries/dropEmptyEntries.js +0 -28
  188. package/dist/helpers/isEmptyUiEntry/isEmptyUiEntry.d.ts +0 -3
  189. package/dist/helpers/isEmptyUiEntry/isEmptyUiEntry.d.ts.map +0 -1
  190. package/dist/helpers/isEmptyUiEntry/isEmptyUiEntry.js +0 -18
  191. package/dist/helpers/isUiSchemaGroup/isUiSchemaGroup.d.ts +0 -3
  192. package/dist/helpers/isUiSchemaGroup/isUiSchemaGroup.d.ts.map +0 -1
  193. package/dist/helpers/isUiSchemaGroup/isUiSchemaGroup.js +0 -3
  194. package/dist/helpers/setEmptyEntries/setEmptyEntries.d.ts +0 -4
  195. package/dist/helpers/setEmptyEntries/setEmptyEntries.d.ts.map +0 -1
  196. package/dist/helpers/setEmptyEntries/setEmptyEntries.js +0 -31
  197. package/dist/special/attachment/attachment.d.ts +0 -4
  198. package/dist/special/attachment/attachment.d.ts.map +0 -1
  199. package/dist/special/attachment/attachment.js +0 -18
@@ -0,0 +1,29 @@
1
+ import { isNullish } from '@minvws/mgo-utils';
2
+ import { isGroupNode } from '../../helpers/isGroupNode/isGroupNode.js';
3
+ const untranslatedLabelRegexp = /^(r3|r4|fhir)\./;
4
+ /**
5
+ * Translates group and subgroup labels after the schema structure is finalized.
6
+ * Only labels that look like message keys (`r3.*`, `r4.*`, `fhir.*`) are translated.
7
+ */
8
+ export function translateGroupLabels(context) {
9
+ return (schema) => ({
10
+ ...schema,
11
+ children: schema.children.map((child) => isGroupNode(child) ? translateGroup(context, child) : child),
12
+ });
13
+ }
14
+ function translateLabel(context, label) {
15
+ if (label && untranslatedLabelRegexp.test(label)) {
16
+ return context.formatLabel(label, null);
17
+ }
18
+ return label;
19
+ }
20
+ function translateGroup(context, group) {
21
+ const { type, id, label, children, ...rest } = group;
22
+ return {
23
+ type,
24
+ ...(!isNullish(id) ? { id } : {}),
25
+ ...(!isNullish(label) ? { label: translateLabel(context, label) } : {}),
26
+ ...rest,
27
+ children: children.map((child) => isGroupNode(child) ? translateGroup(context, child) : child),
28
+ };
29
+ }
@@ -0,0 +1,6 @@
1
+ import { ValueType } from '@minvws/mgo-hcim-parse';
2
+ import { FhirMessagesIds } from '@minvws/mgo-intl';
3
+ import { type UiContext } from '../../context/index.js';
4
+ import { type SingleTypeUiFunctionMapKeys } from '../../typeMaps/index.js';
5
+ export declare function createCardTitleFormatter(uiContext: UiContext): (value: ValueType<SingleTypeUiFunctionMapKeys> | ValueType<SingleTypeUiFunctionMapKeys>[] | undefined, fallback: FhirMessagesIds) => string;
6
+ //# sourceMappingURL=cardTitle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cardTitle.d.ts","sourceRoot":"","sources":["../../../src/format/cardTitle/cardTitle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAyB,KAAK,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAIlG,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,SAAS,IASrD,OACM,SAAS,CAAC,2BAA2B,CAAC,GACtC,SAAS,CAAC,2BAA2B,CAAC,EAAE,GACxC,SAAS,EACf,UAAU,eAAe,KAC1B,MAAM,CAUZ"}
@@ -0,0 +1,21 @@
1
+ import { createSingleUiTypeMap } from '../../typeMaps/index.js';
2
+ import { createUiHelpers } from '../../ui.js';
3
+ import { extractDisplayFromUiElement } from './extractDisplayFromUiElement/extractDisplayFromUiElement.js';
4
+ export function createCardTitleFormatter(uiContext) {
5
+ const { formatMessage } = uiContext;
6
+ const ui = createUiHelpers(uiContext);
7
+ const singleUiTypeMap = createSingleUiTypeMap(ui);
8
+ /**
9
+ * Attempts to generate the title for a card solely based on the value
10
+ */
11
+ return function cardTitle(value, fallback) {
12
+ const usedValue = Array.isArray(value) ? value[0] : value;
13
+ if (!usedValue) {
14
+ return formatMessage(fallback);
15
+ }
16
+ const helper = singleUiTypeMap[usedValue._type];
17
+ const result = helper(fallback, value); // eslint-disable-line @typescript-eslint/no-explicit-any -- indexed map loses type correlation
18
+ const element = Array.isArray(result) ? result[0] : result;
19
+ return extractDisplayFromUiElement(element) ?? formatMessage(fallback);
20
+ };
21
+ }
@@ -0,0 +1,3 @@
1
+ import { type DicomViewer, type UiElement } from '../../../types/schema.js';
2
+ export declare function extractDisplayFromUiElement(element: UiElement | DicomViewer): string | undefined;
3
+ //# sourceMappingURL=extractDisplayFromUiElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractDisplayFromUiElement.d.ts","sourceRoot":"","sources":["../../../../src/format/cardTitle/extractDisplayFromUiElement/extractDisplayFromUiElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE5E,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAgBhG"}
@@ -0,0 +1,17 @@
1
+ export function extractDisplayFromUiElement(element) {
2
+ switch (element.type) {
3
+ case 'SINGLE_VALUE':
4
+ return element.value?.display;
5
+ case 'MULTIPLE_VALUES':
6
+ return element?.value?.[0]?.display;
7
+ case 'REFERENCE_VALUE':
8
+ case 'EMPTY_VALUE':
9
+ return element.display;
10
+ case 'DOWNLOAD_LINK':
11
+ case 'DOWNLOAD_BINARY':
12
+ case 'DICOM_VIEWER':
13
+ return element.label;
14
+ default:
15
+ return;
16
+ }
17
+ }
@@ -1,6 +1,15 @@
1
+ import { type UiContext } from '../context/index.js';
1
2
  export declare const format: {
2
- date: import("../index.js").WithUiContext<import("../index.js").FormatFunction<import("@minvws/mgo-fhir").DateString | import("@minvws/mgo-fhir").DateTimeString | import("@minvws/mgo-fhir").InstantDateTimeString>>;
3
+ date: import("../types/context.js").WithUiContext<import("../types/context.js").FormatFunction<import("@minvws/mgo-fhir").DateString | import("@minvws/mgo-fhir").DateTimeString | import("@minvws/mgo-fhir").InstantDateTimeString>>;
3
4
  valueWithUnit(value: import("@minvws/mgo-utils").Nullable<import("lossless-json").LosslessNumber | number>, unit: import("@minvws/mgo-utils").Nullable<string>): string | undefined;
4
5
  valueWithMaxValue(value: import("@minvws/mgo-utils").Nullable<import("lossless-json").LosslessNumber | number>, maxValue: import("@minvws/mgo-utils").Nullable<import("lossless-json").LosslessNumber | number>): string | undefined;
5
6
  };
7
+ export declare function createFormatHelpers(context: UiContext): {
8
+ valueWithUnit(value: import("@minvws/mgo-utils").Nullable<import("lossless-json").LosslessNumber | number>, unit: import("@minvws/mgo-utils").Nullable<string>): string | undefined;
9
+ valueWithMaxValue(value: import("@minvws/mgo-utils").Nullable<import("lossless-json").LosslessNumber | number>, maxValue: import("@minvws/mgo-utils").Nullable<import("lossless-json").LosslessNumber | number>): string | undefined;
10
+ date: import("../types/context.js").FormatFunction<`${number}` | `${number}-${number}` | `${number}-${number}-${number}` | `${number}-${number}-${number}T${number}:${number}:${number}${string}`>;
11
+ systemValue: import("../types/context.js").FormatFunction<import("@minvws/mgo-hcim-parse").MgoSimpleQuantityProps>;
12
+ };
13
+ export type FormatHelpers = ReturnType<typeof createFormatHelpers>;
14
+ export { createCardTitleFormatter } from './cardTitle/cardTitle.js';
6
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/format/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM;;;;CAGlB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/format/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD,eAAO,MAAM,MAAM;;;;CAGlB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS;;;;;EAMrD;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,6 +1,15 @@
1
1
  import * as date from './date/date.js';
2
+ import { systemValue } from './systemValue/systemValue.js';
2
3
  import * as value from './value/value.js';
3
4
  export const format = {
4
5
  ...value,
5
6
  ...date,
6
7
  };
8
+ export function createFormatHelpers(context) {
9
+ return {
10
+ date: date.date(context),
11
+ systemValue: systemValue(context),
12
+ ...value,
13
+ };
14
+ }
15
+ export { createCardTitleFormatter } from './cardTitle/cardTitle.js';
@@ -1,12 +1,15 @@
1
1
  import { type FhirVersion } from '@minvws/mgo-fhir';
2
+ import { type Logger } from '@minvws/mgo-logging';
2
3
  import { UiContext } from '../../context/index.js';
3
4
  import { createUiElementHelper } from '../createUiElementHelper/createUiElementHelper.js';
4
5
  export type GeneratorContext = {
5
6
  formatMessage: UiContext['formatMessage'];
6
7
  formatLabel: UiContext['formatLabel'];
7
8
  createUiElement: ReturnType<typeof createUiElementHelper>;
8
- fhirVersion: `${FhirVersion}`;
9
+ fhirVersion: FhirVersion;
9
10
  rootPath: string;
11
+ baseProps: UiContext['baseProps'];
12
+ log: Logger;
10
13
  };
11
- export declare function createGeneratorContext(uiContext: UiContext, rootPath: string, fhirVersion: `${FhirVersion}`): GeneratorContext;
14
+ export declare function createGeneratorContext(uiContext: UiContext, rootPath: string, fhirVersion: FhirVersion, log?: Logger): GeneratorContext;
12
15
  //# sourceMappingURL=createGeneratorContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createGeneratorContext.d.ts","sourceRoot":"","sources":["../../../src/generator/createGeneratorContext/createGeneratorContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAE1F,MAAM,MAAM,gBAAgB,GAAG;IAC3B,aAAa,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;IAC1C,WAAW,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IACtC,eAAe,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;IAC1D,WAAW,EAAE,GAAG,WAAW,EAAE,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,GAAG,WAAW,EAAE,GAC9B,gBAAgB,CAWlB"}
1
+ {"version":3,"file":"createGeneratorContext.d.ts","sourceRoot":"","sources":["../../../src/generator/createGeneratorContext/createGeneratorContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAE1F,MAAM,MAAM,gBAAgB,GAAG;IAC3B,aAAa,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;IAC1C,WAAW,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IACtC,eAAe,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;IAC1D,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAClC,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,EACxB,GAAG,GAAE,MAAsB,GAC5B,gBAAgB,CAalB"}
@@ -1,6 +1,7 @@
1
+ import { consoleLogger } from '@minvws/mgo-logging';
1
2
  import { createUiElementHelper } from '../createUiElementHelper/createUiElementHelper.js';
2
- export function createGeneratorContext(uiContext, rootPath, fhirVersion) {
3
- const { formatMessage, formatLabel } = uiContext;
3
+ export function createGeneratorContext(uiContext, rootPath, fhirVersion, log = consoleLogger) {
4
+ const { formatMessage, formatLabel, baseProps } = uiContext;
4
5
  const createUiElement = createUiElementHelper(uiContext);
5
6
  return {
6
7
  formatMessage,
@@ -8,5 +9,7 @@ export function createGeneratorContext(uiContext, rootPath, fhirVersion) {
8
9
  createUiElement,
9
10
  fhirVersion,
10
11
  rootPath,
12
+ baseProps,
13
+ log,
11
14
  };
12
15
  }
@@ -1,6 +1,6 @@
1
1
  import { type MgoType, type MgoTypeId } from '@minvws/mgo-hcim-parse';
2
2
  import { type FhirMessagesIds } from '@minvws/mgo-intl';
3
3
  import { UiContext } from '../../context/index.js';
4
- import { type HealthUiGroup, type UiElement } from '../../types/index.js';
5
- export declare function createUiElementHelper(uiContext: UiContext): <T extends MgoTypeId>(label: FhirMessagesIds, value: MgoType<T> | MgoType<T>[]) => UiElement | UiElement[] | HealthUiGroup;
4
+ import { DicomViewer, DraftGroup, type UiElement } from '../../types/index.js';
5
+ export declare function createUiElementHelper(uiContext: UiContext): <T extends MgoTypeId>(label: FhirMessagesIds, value: MgoType<T> | MgoType<T>[]) => (UiElement | DicomViewer) | (UiElement | DicomViewer)[] | DraftGroup;
6
6
  //# sourceMappingURL=createUiElementHelper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createUiElementHelper.d.ts","sourceRoot":"","sources":["../../../src/generator/createUiElementHelper/createUiElementHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAmB,MAAM,sBAAsB,CAAC;AAU3F,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,IA6CtB,CAAC,SAAS,SAAS,EAC/C,OAAO,eAAe,EACtB,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,KACjC,SAAS,GAAG,SAAS,EAAE,GAAG,aAAa,CAe7C"}
1
+ {"version":3,"file":"createUiElementHelper.d.ts","sourceRoot":"","sources":["../../../src/generator/createUiElementHelper/createUiElementHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AASnD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAG/E,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,IAMtB,CAAC,SAAS,SAAS,EAC/C,OAAO,eAAe,EACtB,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,KACjC,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,GAAG,WAAW,CAAC,EAAE,GAAG,UAAU,CAqB1E"}
@@ -1,48 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { map } from '@minvws/mgo-utils';
3
+ import { createComplexUiTypeMap, createMultipleUiTypeMap, createSingleUiTypeMap, } from '../../typeMaps/index.js';
3
4
  import { createUiHelpers } from '../../ui.js';
4
5
  export function createUiElementHelper(uiContext) {
5
6
  const ui = createUiHelpers(uiContext);
6
- const singleUiTypeMap = {
7
- annotation: ui.annotation,
8
- attachment: (_label, value) => ui.attachment(value),
9
- boolean: ui.boolean,
10
- code: ui.code,
11
- codeableConcept: ui.codeableConcept,
12
- coding: ui.coding,
13
- date: ui.date,
14
- dateTime: ui.dateTime,
15
- decimal: ui.decimal,
16
- duration: ui.duration,
17
- identifier: ui.identifier,
18
- instant: ui.instant,
19
- integer: ui.integer,
20
- integer64: ui.integer64,
21
- period: ui.period,
22
- positiveInt: ui.positiveInt,
23
- quantity: ui.quantity,
24
- range: ui.range,
25
- ratio: ui.ratio,
26
- reference: ui.reference,
27
- simpleQuantity: ui.simpleQuantity,
28
- string: ui.string,
29
- time: ui.time,
30
- unsignedInt: ui.unsignedInt,
31
- // complex types
32
- timing: ui.timing,
33
- sampledData: ui.sampledData,
34
- };
35
- const multipleUiTypeMap = {
36
- annotation: ui.annotation,
37
- code: ui.code,
38
- codeableConcept: ui.codeableConcept,
39
- coding: ui.coding,
40
- dateTime: ui.dateTime,
41
- identifier: ui.identifier,
42
- instant: ui.instant,
43
- reference: ui.reference,
44
- string: ui.string,
45
- };
7
+ const singleUiTypeMap = createSingleUiTypeMap(ui);
8
+ const complexUiTypeMap = createComplexUiTypeMap(ui);
9
+ const multipleUiTypeMap = createMultipleUiTypeMap(ui);
46
10
  return function createUiElement(label, value) {
47
11
  if (Array.isArray(value)) {
48
12
  const uiHelper = multipleUiTypeMap[value[0]._type];
@@ -51,10 +15,14 @@ export function createUiElementHelper(uiContext) {
51
15
  }
52
16
  return map(value, (x) => createUiElement(label, x), true);
53
17
  }
18
+ const complexHelper = complexUiTypeMap[value._type];
19
+ if (complexHelper) {
20
+ return complexHelper(label, value);
21
+ }
54
22
  const uiHelper = singleUiTypeMap[value._type];
55
- if (!uiHelper) {
56
- throw new Error(`No ui helper found for type "${value._type}"`);
23
+ if (uiHelper) {
24
+ return uiHelper(label, value);
57
25
  }
58
- return uiHelper(label, value);
26
+ throw new Error(`No ui helper found for type "${value._type}"`);
59
27
  };
60
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generateUiSchema.d.ts","sourceRoot":"","sources":["../../../src/generator/generateUiSchema/generateUiSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAsB,MAAM,sBAAsB,CAAC;AAOlF,eAAO,MAAM,gBAAgB,EAAE,sBAAsB,CAAC,eAAe,EAAE,SAAS,CAgD/E,CAAC"}
1
+ {"version":3,"file":"generateUiSchema.d.ts","sourceRoot":"","sources":["../../../src/generator/generateUiSchema/generateUiSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAc,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAK1E,eAAO,MAAM,gBAAgB,EAAE,sBAAsB,CAAC,eAAe,EAAE,SAAS,CAwC/E,CAAC"}
@@ -1,37 +1,28 @@
1
- import { isUiSchemaGroup } from '../../helpers/isUiSchemaGroup/isUiSchemaGroup.js';
1
+ import { isGroupNode } from '../../helpers/isGroupNode/isGroupNode.js';
2
2
  import { createGeneratorContext } from '../createGeneratorContext/createGeneratorContext.js';
3
3
  import { getProfileKey } from '../getProfileKey/getProfileKey.js';
4
4
  import { processValue } from '../processValue/processValue.js';
5
- const untranslatedLabelRegexp = /^(r3|r4|fhir)\./;
6
5
  export const generateUiSchema = (resource, context) => {
7
6
  const { formatMessage } = context;
8
7
  const { id: _id, referenceId: _referenceId, resourceType: _resourceType, profile, fhirVersion, ...rest } = resource;
9
8
  const rootPath = getProfileKey(fhirVersion, profile);
10
9
  const generatorContext = createGeneratorContext(context, rootPath, fhirVersion);
11
10
  const defaultGroup = {
11
+ type: 'HEALTH_UI_GROUP',
12
12
  children: [],
13
13
  };
14
14
  const groups = [defaultGroup];
15
15
  const elements = processValue(generatorContext, rootPath, rest);
16
16
  for (const element of elements) {
17
- if (isUiSchemaGroup(element)) {
18
- groups.push({
19
- ...element,
20
- // We only translate the group labels at the last moment.
21
- // Otherwise groups within other groups might be missing translations for their label
22
- // even though that label is never actually used as their contents will be merged
23
- // into their parent group.
24
- label: untranslatedLabelRegexp.test(element.label)
25
- ? context.formatLabel(element.label, null)
26
- : element.label,
27
- });
17
+ if (isGroupNode(element)) {
18
+ groups.push(element);
28
19
  }
29
20
  else {
30
21
  defaultGroup.children.push(element);
31
22
  }
32
23
  }
33
24
  for (const group of groups) {
34
- group.children.sort((a, b) => a.label.localeCompare(b.label));
25
+ group.children.sort((a, b) => (a.label ?? '').localeCompare(b.label ?? ''));
35
26
  }
36
27
  return {
37
28
  label: formatMessage(rootPath),
@@ -1,3 +1,3 @@
1
1
  import { type FhirVersion, type NictizNlProfile } from '@minvws/mgo-fhir';
2
- export declare function getProfileKey(fhirVersion: `${FhirVersion}`, profile: NictizNlProfile): string;
2
+ export declare function getProfileKey(fhirVersion: FhirVersion, profile: NictizNlProfile): string;
3
3
  //# sourceMappingURL=getProfileKey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getProfileKey.d.ts","sourceRoot":"","sources":["../../../src/generator/getProfileKey/getProfileKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG1E,wBAAgB,aAAa,CAAC,WAAW,EAAE,GAAG,WAAW,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAG7F"}
1
+ {"version":3,"file":"getProfileKey.d.ts","sourceRoot":"","sources":["../../../src/generator/getProfileKey/getProfileKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG1E,wBAAgB,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAGxF"}
@@ -1,4 +1,4 @@
1
- import { type HealthUiGroup, type UiElement } from '../../types/index.js';
1
+ import { DraftNode } from '../../types/index.js';
2
2
  import { type GeneratorContext } from '../createGeneratorContext/createGeneratorContext.js';
3
- export declare function processArray(context: GeneratorContext, path: string, value: unknown[]): (UiElement | HealthUiGroup)[];
3
+ export declare function processArray(context: GeneratorContext, path: string, value: unknown[]): DraftNode[];
4
4
  //# sourceMappingURL=processArray.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"processArray.d.ts","sourceRoot":"","sources":["../../../src/generator/processArray/processArray.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAsB5F,wBAAgB,YAAY,CACxB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EAAE,GACjB,CAAC,SAAS,GAAG,aAAa,CAAC,EAAE,CAoB/B"}
1
+ {"version":3,"file":"processArray.d.ts","sourceRoot":"","sources":["../../../src/generator/processArray/processArray.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAsB5F,wBAAgB,YAAY,CACxB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EAAE,GACjB,SAAS,EAAE,CAoBb"}
@@ -31,9 +31,9 @@ export function processArray(context, path, value) {
31
31
  }
32
32
  return [
33
33
  {
34
- label: context.formatLabel(path, null),
34
+ ...context.baseProps(path, null),
35
35
  type: 'SINGLE_VALUE',
36
- display: undefined,
36
+ value: undefined,
37
37
  },
38
38
  ];
39
39
  }
@@ -1,5 +1,5 @@
1
1
  import { type PrimitiveValueType, type ValueType } from '@minvws/mgo-hcim-parse';
2
- import { type HealthUiGroup, type UiElement } from '../../types/index.js';
2
+ import { DraftNode } from '../../types/index.js';
3
3
  import { type GeneratorContext } from '../createGeneratorContext/createGeneratorContext.js';
4
- export declare function processMgoType(context: GeneratorContext, path: string, value: ValueType | PrimitiveValueType): (UiElement | HealthUiGroup)[];
4
+ export declare function processMgoType(context: GeneratorContext, path: string, value: ValueType | PrimitiveValueType): DraftNode[];
5
5
  //# sourceMappingURL=processMgoType.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"processMgoType.d.ts","sourceRoot":"","sources":["../../../src/generator/processMgoType/processMgoType.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACjB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAyC5F,wBAAgB,cAAc,CAC1B,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,GAAG,kBAAkB,iCA0BxC"}
1
+ {"version":3,"file":"processMgoType.d.ts","sourceRoot":"","sources":["../../../src/generator/processMgoType/processMgoType.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACjB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAc,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAgC5F,wBAAgB,cAAc,CAC1B,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,GAAG,kBAAkB,eA4BxC"}
@@ -1,7 +1,6 @@
1
1
  import { isExtensionValue, isValueType, } from '@minvws/mgo-hcim-parse';
2
2
  import { isNullish } from '@minvws/mgo-utils';
3
3
  import { snakeCase } from 'lodash-es';
4
- import { getUiElements } from '../getUiElements/getUiElements.js';
5
4
  function processNestedArray(context, path, value) {
6
5
  return value.map((item) => processNestedValue(context, path, item).flat()).flat();
7
6
  }
@@ -43,8 +42,10 @@ export function processMgoType(context, path, value) {
43
42
  if (extraUiElements.length) {
44
43
  return [
45
44
  {
45
+ type: 'HEALTH_UI_GROUP',
46
+ id: path,
46
47
  label: path,
47
- children: getUiElements(elements),
48
+ children: elements,
48
49
  },
49
50
  ];
50
51
  }
@@ -1,4 +1,4 @@
1
- import { type HealthUiGroup, type UiElement } from '../../types/index.js';
1
+ import { DraftNode } from '../../types/index.js';
2
2
  import { type GeneratorContext } from '../createGeneratorContext/createGeneratorContext.js';
3
- export declare function processObject(context: GeneratorContext, path: string, value: object): (UiElement | HealthUiGroup)[];
3
+ export declare function processObject(context: GeneratorContext, path: string, value: object): DraftNode[];
4
4
  //# sourceMappingURL=processObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"processObject.d.ts","sourceRoot":"","sources":["../../../src/generator/processObject/processObject.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAI5F,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iCAgCnF"}
1
+ {"version":3,"file":"processObject.d.ts","sourceRoot":"","sources":["../../../src/generator/processObject/processObject.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAG5F,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAkCnF"}
@@ -1,6 +1,5 @@
1
1
  import { isNullish } from '@minvws/mgo-utils';
2
2
  import { snakeCase } from 'lodash-es';
3
- import { getUiElements } from '../getUiElements/getUiElements.js';
4
3
  import { processValue } from '../processValue/processValue.js';
5
4
  export function processObject(context, path, value) {
6
5
  const elements = [];
@@ -13,9 +12,9 @@ export function processObject(context, path, value) {
13
12
  const valuePath = `${path}.${snakeCase(key)}`;
14
13
  if (isNullish(value)) {
15
14
  elements.push({
16
- label: context.formatLabel(valuePath, null),
15
+ ...context.baseProps(valuePath, null),
17
16
  type: 'SINGLE_VALUE',
18
- display: undefined,
17
+ value: undefined,
19
18
  });
20
19
  }
21
20
  else {
@@ -25,8 +24,10 @@ export function processObject(context, path, value) {
25
24
  if (path !== context.rootPath && elements.length > 1) {
26
25
  return [
27
26
  {
27
+ type: 'HEALTH_UI_GROUP',
28
+ id: path,
28
29
  label: path,
29
- children: getUiElements(elements),
30
+ children: elements,
30
31
  },
31
32
  ];
32
33
  }
@@ -1,5 +1,5 @@
1
1
  import { type Nullable } from '@minvws/mgo-utils';
2
- import { type HealthUiGroup, type UiElement } from '../../types/index.js';
2
+ import { DraftNode } from '../../types/index.js';
3
3
  import { type GeneratorContext } from '../createGeneratorContext/createGeneratorContext.js';
4
- export declare function processValue(context: GeneratorContext, path: string, value: Nullable<unknown[] | object>): (UiElement | HealthUiGroup)[];
4
+ export declare function processValue(context: GeneratorContext, path: string, value: Nullable<unknown[] | object>): DraftNode[];
5
5
  //# sourceMappingURL=processValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"processValue.d.ts","sourceRoot":"","sources":["../../../src/generator/processValue/processValue.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAO5F,wBAAgB,YAAY,CACxB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GACpC,CAAC,SAAS,GAAG,aAAa,CAAC,EAAE,CA8B/B"}
1
+ {"version":3,"file":"processValue.d.ts","sourceRoot":"","sources":["../../../src/generator/processValue/processValue.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAc,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAM5F,wBAAgB,YAAY,CACxB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GACpC,SAAS,EAAE,CAgCb"}
@@ -1,7 +1,6 @@
1
1
  import { isMgoElement, isValueType } from '@minvws/mgo-hcim-parse';
2
2
  import { isNullish } from '@minvws/mgo-utils';
3
3
  import { getProfileKey } from '../getProfileKey/getProfileKey.js';
4
- import { getUiElements } from '../getUiElements/getUiElements.js';
5
4
  import { processArray } from '../processArray/processArray.js';
6
5
  import { processMgoType } from '../processMgoType/processMgoType.js';
7
6
  import { processObject } from '../processObject/processObject.js';
@@ -11,6 +10,8 @@ export function processValue(context, path, value) {
11
10
  if (isMgoElement(value)) {
12
11
  path = getProfileKey(context.fhirVersion, value._profile);
13
12
  group = {
13
+ type: 'HEALTH_UI_GROUP',
14
+ id: path,
14
15
  label: getProfileKey(context.fhirVersion, value._profile),
15
16
  children: [],
16
17
  };
@@ -28,10 +29,10 @@ export function processValue(context, path, value) {
28
29
  elements = processObject(context, path, value);
29
30
  }
30
31
  else {
31
- console.error(`Failed to process path: ${path} with value:`, value);
32
+ context.log.error(`Failed to process path: ${path} with value:`, value);
32
33
  }
33
34
  if (group) {
34
- group.children = getUiElements(elements);
35
+ group.children = elements;
35
36
  return [group];
36
37
  }
37
38
  return elements;
@@ -1,8 +1,8 @@
1
- export * from './dropEmptyEntries/dropEmptyEntries.js';
2
1
  export * from './getChildren/getChildren.js';
3
- export * from './isEmptyUiEntry/isEmptyUiEntry.js';
2
+ export * from './isEmptyNode/isEmptyNode.js';
4
3
  export * from './isUiEntry/isUiEntry.js';
4
+ export * from './isGroupNode/isGroupNode.js';
5
5
  export * from './numberToString/numberToString.js';
6
- export * from './setEmptyEntries/setEmptyEntries.js';
6
+ export * from './optional/optional.js';
7
7
  export * from './toString/toString.js';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
@@ -1,7 +1,7 @@
1
- export * from './dropEmptyEntries/dropEmptyEntries.js';
2
1
  export * from './getChildren/getChildren.js';
3
- export * from './isEmptyUiEntry/isEmptyUiEntry.js';
2
+ export * from './isEmptyNode/isEmptyNode.js';
4
3
  export * from './isUiEntry/isUiEntry.js';
4
+ export * from './isGroupNode/isGroupNode.js';
5
5
  export * from './numberToString/numberToString.js';
6
- export * from './setEmptyEntries/setEmptyEntries.js';
6
+ export * from './optional/optional.js';
7
7
  export * from './toString/toString.js';
@@ -0,0 +1,5 @@
1
+ import { type DicomViewer, type DraftGroup, type HealthUiGroup, type HealthUiSubGroup, type UiElement } from '../../types/index.js';
2
+ type SchemaNode = UiElement | DicomViewer | DraftGroup | HealthUiGroup | HealthUiSubGroup;
3
+ export declare function isEmptyNode(node: SchemaNode): boolean;
4
+ export {};
5
+ //# sourceMappingURL=isEmptyNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEmptyNode.d.ts","sourceRoot":"","sources":["../../../src/helpers/isEmptyNode/isEmptyNode.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACjB,MAAM,sBAAsB,CAAC;AAG9B,KAAK,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,aAAa,GAAG,gBAAgB,CAAC;AAE1F,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAsBrD"}
@@ -0,0 +1,24 @@
1
+ import { isNullish } from '@minvws/mgo-utils';
2
+ import { isGroupNode } from '../isGroupNode/isGroupNode.js';
3
+ export function isEmptyNode(node) {
4
+ if (isGroupNode(node)) {
5
+ return node.children.every(isEmptyNode);
6
+ }
7
+ switch (node.type) {
8
+ case 'REFERENCE_VALUE':
9
+ return isNullish(node.reference) && isNullish(node.display);
10
+ case 'DETAILS_LINK':
11
+ return false;
12
+ case 'DOWNLOAD_BINARY':
13
+ return isNullish(node.reference);
14
+ case 'SINGLE_VALUE':
15
+ return isNullish(node.value?.display);
16
+ case 'MULTIPLE_VALUES':
17
+ return isNullish(node.value) || !node.value.flat().length;
18
+ case 'DOWNLOAD_LINK':
19
+ case 'DICOM_VIEWER':
20
+ return isNullish(node.url);
21
+ default:
22
+ throw new Error(`Unknown UI entry type: ${JSON.stringify(node)}`);
23
+ }
24
+ }
@@ -0,0 +1,6 @@
1
+ type GroupNodeType = 'HEALTH_UI_GROUP' | 'HEALTH_UI_SUB_GROUP';
2
+ export declare function isGroupNode<T extends object>(node: T): node is Extract<T, {
3
+ type: GroupNodeType;
4
+ }>;
5
+ export {};
6
+ //# sourceMappingURL=isGroupNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isGroupNode.d.ts","sourceRoot":"","sources":["../../../src/helpers/isGroupNode/isGroupNode.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG,iBAAiB,GAAG,qBAAqB,CAAC;AAE/D,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EACxC,IAAI,EAAE,CAAC,GACR,IAAI,IAAI,OAAO,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAI7C"}
@@ -0,0 +1,3 @@
1
+ export function isGroupNode(node) {
2
+ return ('type' in node && (node.type === 'HEALTH_UI_GROUP' || node.type === 'HEALTH_UI_SUB_GROUP'));
3
+ }
@@ -0,0 +1,17 @@
1
+ import { type DicomViewer, type DraftGroup, type HealthUiGroup, type HealthUiSubGroup, type UiElement } from '../../types/index.js';
2
+ /**
3
+ * A helper function to filter out empty elements in a health ui schema.
4
+ * It works for single elements, groups, and arrays of either.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * // example usage in a ui schema group
9
+ * children: [
10
+ * ...optional(ui.codeableConcept('r3.foo.code', resource.code)),
11
+ * ...optional(ui.period('r3.foo.period', resource.period)),
12
+ * ...optional(ui.timing('r3.foo.timing', resource.timing)),
13
+ * ]
14
+ * ```
15
+ */
16
+ export declare function optional<T extends UiElement | DicomViewer | DraftGroup | HealthUiGroup | HealthUiSubGroup>(elements: T | T[]): T[];
17
+ //# sourceMappingURL=optional.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional.d.ts","sourceRoot":"","sources":["../../../src/helpers/optional/optional.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACjB,MAAM,sBAAsB,CAAC;AAG9B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CACpB,CAAC,SAAS,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,aAAa,GAAG,gBAAgB,EACnF,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAMxB"}
@@ -0,0 +1,21 @@
1
+ import { isEmptyNode } from '../isEmptyNode/isEmptyNode.js';
2
+ /**
3
+ * A helper function to filter out empty elements in a health ui schema.
4
+ * It works for single elements, groups, and arrays of either.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * // example usage in a ui schema group
9
+ * children: [
10
+ * ...optional(ui.codeableConcept('r3.foo.code', resource.code)),
11
+ * ...optional(ui.period('r3.foo.period', resource.period)),
12
+ * ...optional(ui.timing('r3.foo.timing', resource.timing)),
13
+ * ]
14
+ * ```
15
+ */
16
+ export function optional(elements) {
17
+ if (Array.isArray(elements)) {
18
+ return elements.filter((x) => !isEmptyNode(x));
19
+ }
20
+ return isEmptyNode(elements) ? [] : [elements];
21
+ }