@minvws/mgo-hcim-ui 0.1.1-1
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/LICENSE.md +7 -0
- package/README.md +78 -0
- package/dist/common/index.d.ts +7 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +6 -0
- package/dist/common/organization/organization.d.ts +6 -0
- package/dist/common/organization/organization.d.ts.map +1 -0
- package/dist/common/organization/organization.js +7 -0
- package/dist/common/summaryOptions/summaryOptions.d.ts +8 -0
- package/dist/common/summaryOptions/summaryOptions.d.ts.map +1 -0
- package/dist/common/summaryOptions/summaryOptions.js +12 -0
- package/dist/context/formatLabel.d.ts +14 -0
- package/dist/context/formatLabel.d.ts.map +1 -0
- package/dist/context/formatLabel.js +61 -0
- package/dist/context/index.d.ts +14 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +16 -0
- package/dist/format/date/date.d.ts +4 -0
- package/dist/format/date/date.d.ts.map +1 -0
- package/dist/format/date/date.js +44 -0
- package/dist/format/index.d.ts +6 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +6 -0
- package/dist/format/system/system.d.ts +4 -0
- package/dist/format/system/system.d.ts.map +1 -0
- package/dist/format/system/system.js +21 -0
- package/dist/format/systemCode/systemCode.d.ts +4 -0
- package/dist/format/systemCode/systemCode.d.ts.map +1 -0
- package/dist/format/systemCode/systemCode.js +12 -0
- package/dist/format/systemValue/systemValue.d.ts +4 -0
- package/dist/format/systemValue/systemValue.d.ts.map +1 -0
- package/dist/format/systemValue/systemValue.js +16 -0
- package/dist/format/value/value.d.ts +4 -0
- package/dist/format/value/value.d.ts.map +1 -0
- package/dist/format/value/value.js +18 -0
- package/dist/generator/createGeneratorContext/createGeneratorContext.d.ts +12 -0
- package/dist/generator/createGeneratorContext/createGeneratorContext.d.ts.map +1 -0
- package/dist/generator/createGeneratorContext/createGeneratorContext.js +12 -0
- package/dist/generator/createUiElementHelper/createUiElementHelper.d.ts +6 -0
- package/dist/generator/createUiElementHelper/createUiElementHelper.d.ts.map +1 -0
- package/dist/generator/createUiElementHelper/createUiElementHelper.js +60 -0
- package/dist/generator/generateUiSchema/generateUiSchema.d.ts +5 -0
- package/dist/generator/generateUiSchema/generateUiSchema.d.ts.map +1 -0
- package/dist/generator/generateUiSchema/generateUiSchema.js +40 -0
- package/dist/generator/getProfileKey/getProfileKey.d.ts +3 -0
- package/dist/generator/getProfileKey/getProfileKey.d.ts.map +1 -0
- package/dist/generator/getProfileKey/getProfileKey.js +5 -0
- package/dist/generator/getUiElements/getUiElements.d.ts +3 -0
- package/dist/generator/getUiElements/getUiElements.d.ts.map +1 -0
- package/dist/generator/getUiElements/getUiElements.js +4 -0
- package/dist/generator/index.d.ts +2 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +1 -0
- package/dist/generator/processArray/processArray.d.ts +4 -0
- package/dist/generator/processArray/processArray.d.ts.map +1 -0
- package/dist/generator/processArray/processArray.js +39 -0
- package/dist/generator/processMgoType/processMgoType.d.ts +5 -0
- package/dist/generator/processMgoType/processMgoType.d.ts.map +1 -0
- package/dist/generator/processMgoType/processMgoType.js +52 -0
- package/dist/generator/processObject/processObject.d.ts +4 -0
- package/dist/generator/processObject/processObject.d.ts.map +1 -0
- package/dist/generator/processObject/processObject.js +34 -0
- package/dist/generator/processValue/processValue.d.ts +5 -0
- package/dist/generator/processValue/processValue.d.ts.map +1 -0
- package/dist/generator/processValue/processValue.js +38 -0
- package/dist/helpers/dropEmptyEntries/dropEmptyEntries.d.ts +5 -0
- package/dist/helpers/dropEmptyEntries/dropEmptyEntries.d.ts.map +1 -0
- package/dist/helpers/dropEmptyEntries/dropEmptyEntries.js +28 -0
- package/dist/helpers/getChildren/getChildren.d.ts +4 -0
- package/dist/helpers/getChildren/getChildren.d.ts.map +1 -0
- package/dist/helpers/getChildren/getChildren.js +9 -0
- package/dist/helpers/hasExtensions/hasExtensions.d.ts +4 -0
- package/dist/helpers/hasExtensions/hasExtensions.d.ts.map +1 -0
- package/dist/helpers/hasExtensions/hasExtensions.js +23 -0
- package/dist/helpers/index.d.ts +8 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +7 -0
- package/dist/helpers/isEmptyUiEntry/isEmptyUiEntry.d.ts +3 -0
- package/dist/helpers/isEmptyUiEntry/isEmptyUiEntry.d.ts.map +1 -0
- package/dist/helpers/isEmptyUiEntry/isEmptyUiEntry.js +18 -0
- package/dist/helpers/isUiEntry/isUiEntry.d.ts +5 -0
- package/dist/helpers/isUiEntry/isUiEntry.d.ts.map +1 -0
- package/dist/helpers/isUiEntry/isUiEntry.js +3 -0
- package/dist/helpers/isUiSchemaGroup/isUiSchemaGroup.d.ts +3 -0
- package/dist/helpers/isUiSchemaGroup/isUiSchemaGroup.d.ts.map +1 -0
- package/dist/helpers/isUiSchemaGroup/isUiSchemaGroup.js +3 -0
- package/dist/helpers/numberToString/numberToString.d.ts +3 -0
- package/dist/helpers/numberToString/numberToString.d.ts.map +1 -0
- package/dist/helpers/numberToString/numberToString.js +6 -0
- package/dist/helpers/setEmptyEntries/setEmptyEntries.d.ts +4 -0
- package/dist/helpers/setEmptyEntries/setEmptyEntries.d.ts.map +1 -0
- package/dist/helpers/setEmptyEntries/setEmptyEntries.js +31 -0
- package/dist/helpers/toString/toString.d.ts +3 -0
- package/dist/helpers/toString/toString.d.ts.map +1 -0
- package/dist/helpers/toString/toString.js +6 -0
- package/dist/helpers/valueOf/valueOf.d.ts +4 -0
- package/dist/helpers/valueOf/valueOf.d.ts.map +1 -0
- package/dist/helpers/valueOf/valueOf.js +11 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/special/attachment/attachment.d.ts +4 -0
- package/dist/special/attachment/attachment.d.ts.map +1 -0
- package/dist/special/attachment/attachment.js +18 -0
- package/dist/special/index.d.ts +8 -0
- package/dist/special/index.d.ts.map +1 -0
- package/dist/special/index.js +12 -0
- package/dist/special/oneOfValueX/oneOfValueX.d.ts +6 -0
- package/dist/special/oneOfValueX/oneOfValueX.d.ts.map +1 -0
- package/dist/special/oneOfValueX/oneOfValueX.js +22 -0
- package/dist/special/valueWithMax/valueWithMax.d.ts +3 -0
- package/dist/special/valueWithMax/valueWithMax.d.ts.map +1 -0
- package/dist/special/valueWithMax/valueWithMax.js +8 -0
- package/dist/special/valueWithUnit/valueWithUnit.d.ts +4 -0
- package/dist/special/valueWithUnit/valueWithUnit.d.ts.map +1 -0
- package/dist/special/valueWithUnit/valueWithUnit.js +9 -0
- package/dist/type/annotation/annotation.d.ts +6 -0
- package/dist/type/annotation/annotation.d.ts.map +1 -0
- package/dist/type/annotation/annotation.js +18 -0
- package/dist/type/boolean/boolean.d.ts +4 -0
- package/dist/type/boolean/boolean.d.ts.map +1 -0
- package/dist/type/boolean/boolean.js +11 -0
- package/dist/type/code/code.d.ts +12 -0
- package/dist/type/code/code.d.ts.map +1 -0
- package/dist/type/code/code.js +31 -0
- package/dist/type/codeableConcept/codeableConcept.d.ts +4 -0
- package/dist/type/codeableConcept/codeableConcept.d.ts.map +1 -0
- package/dist/type/codeableConcept/codeableConcept.js +25 -0
- package/dist/type/coding/coding.d.ts +4 -0
- package/dist/type/coding/coding.d.ts.map +1 -0
- package/dist/type/coding/coding.js +18 -0
- package/dist/type/date/date.d.ts +4 -0
- package/dist/type/date/date.d.ts.map +1 -0
- package/dist/type/date/date.js +8 -0
- package/dist/type/dateTime/dateTime.d.ts +4 -0
- package/dist/type/dateTime/dateTime.d.ts.map +1 -0
- package/dist/type/dateTime/dateTime.js +19 -0
- package/dist/type/decimal/decimal.d.ts +4 -0
- package/dist/type/decimal/decimal.d.ts.map +1 -0
- package/dist/type/decimal/decimal.js +8 -0
- package/dist/type/duration/duration.d.ts +4 -0
- package/dist/type/duration/duration.d.ts.map +1 -0
- package/dist/type/duration/duration.js +2 -0
- package/dist/type/identifier/identifier.d.ts +5 -0
- package/dist/type/identifier/identifier.d.ts.map +1 -0
- package/dist/type/identifier/identifier.js +15 -0
- package/dist/type/index.d.ts +32 -0
- package/dist/type/index.d.ts.map +1 -0
- package/dist/type/index.js +54 -0
- package/dist/type/instant/instant.d.ts +4 -0
- package/dist/type/instant/instant.d.ts.map +1 -0
- package/dist/type/instant/instant.js +18 -0
- package/dist/type/integer/integer.d.ts +4 -0
- package/dist/type/integer/integer.d.ts.map +1 -0
- package/dist/type/integer/integer.js +8 -0
- package/dist/type/integer64/integer64.d.ts +4 -0
- package/dist/type/integer64/integer64.d.ts.map +1 -0
- package/dist/type/integer64/integer64.js +8 -0
- package/dist/type/period/period.d.ts +9 -0
- package/dist/type/period/period.d.ts.map +1 -0
- package/dist/type/period/period.js +19 -0
- package/dist/type/positiveInt/positiveInt.d.ts +4 -0
- package/dist/type/positiveInt/positiveInt.d.ts.map +1 -0
- package/dist/type/positiveInt/positiveInt.js +8 -0
- package/dist/type/quantity/quantity.d.ts +4 -0
- package/dist/type/quantity/quantity.d.ts.map +1 -0
- package/dist/type/quantity/quantity.js +9 -0
- package/dist/type/range/range.d.ts +9 -0
- package/dist/type/range/range.d.ts.map +1 -0
- package/dist/type/range/range.js +19 -0
- package/dist/type/ratio/ratio.d.ts +9 -0
- package/dist/type/ratio/ratio.d.ts.map +1 -0
- package/dist/type/ratio/ratio.js +19 -0
- package/dist/type/reference/reference.d.ts +4 -0
- package/dist/type/reference/reference.d.ts.map +1 -0
- package/dist/type/reference/reference.js +23 -0
- package/dist/type/sampledData/sampledData.d.ts +4 -0
- package/dist/type/sampledData/sampledData.d.ts.map +1 -0
- package/dist/type/sampledData/sampledData.js +37 -0
- package/dist/type/simpleQuantity/simpleQuantity.d.ts +4 -0
- package/dist/type/simpleQuantity/simpleQuantity.d.ts.map +1 -0
- package/dist/type/simpleQuantity/simpleQuantity.js +9 -0
- package/dist/type/string/string.d.ts +4 -0
- package/dist/type/string/string.d.ts.map +1 -0
- package/dist/type/string/string.js +16 -0
- package/dist/type/time/time.d.ts +4 -0
- package/dist/type/time/time.d.ts.map +1 -0
- package/dist/type/time/time.js +17 -0
- package/dist/type/timing/timing.d.ts +4 -0
- package/dist/type/timing/timing.d.ts.map +1 -0
- package/dist/type/timing/timing.js +65 -0
- package/dist/type/unsignedInt/unsignedInt.d.ts +4 -0
- package/dist/type/unsignedInt/unsignedInt.d.ts.map +1 -0
- package/dist/type/unsignedInt/unsignedInt.js +9 -0
- package/dist/types/context.d.ts +22 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/schema.d.ts +39 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +1 -0
- package/dist/ui.d.ts +40 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +12 -0
- package/health-ui-schema.png +0 -0
- package/package.json +37 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
The source code is released under the [EUPL license](./LICENSES/EUPL-1.2.txt).
|
|
2
|
+
The documentation is released under the [CC0 license](./LICENSES/CC0-1.0.txt).
|
|
3
|
+
The EUPL 1.2 and the CC0 do not apply to photos, videos, infographics, fonts or other forms of media.
|
|
4
|
+
Specifically the rijkslogo and rijkshuisstijl have specific [terms of use](./LICENSES/LicenseRef-Rijkshuisstijl.txt).
|
|
5
|
+
|
|
6
|
+
This repository follows the [REUSE Specfication v3.3](https://reuse.software/spec/).
|
|
7
|
+
Please see [REUSE.toml](./REUSE.toml) and the individual `*.license` files for copyright and license information.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @minvws/mgo-hcim-ui
|
|
2
|
+
|
|
3
|
+
This package contains functionality for transforming Mgo resources into Health Ui Schemas. It is uses by the [HCIM package][packages-hcim] to provide Health UI Schemas for HCIM FHIR data.
|
|
4
|
+
|
|
5
|
+
For more context on why / how this is used please [visit the about documentation][about-hcim-ui].
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm i --save @minvws/mgo-ui
|
|
11
|
+
|
|
12
|
+
# or
|
|
13
|
+
|
|
14
|
+
pnpm add @minvws/mgo-ui
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Use
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { type MgoCode } from '@minvws/mgo-hcim-parse';
|
|
21
|
+
import { createUiContext, createUiHelpers } from '@minvws/mgo-hcim-ui';
|
|
22
|
+
import { Locale } from '@minvws/mgo-intl';
|
|
23
|
+
|
|
24
|
+
const context = createUiContext({ locale: Locale.NL_NL })
|
|
25
|
+
const ui = createUiHelpers( context )
|
|
26
|
+
|
|
27
|
+
const healthUiSchemaElement = uiHelpers.code('fhir.x.status', {...} /* MgoCode */ );
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Health UI Schema
|
|
31
|
+
|
|
32
|
+
A Health UI Schema is a schema that describes a set of ui elements containing health care data. This ensures all clients render the same content. And makes it very easy to manage the information that is shown for certain medical data across all clients.
|
|
33
|
+
|
|
34
|
+
Here is an example of a Health UI Schema:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
{
|
|
38
|
+
"label": "Quibusdam tempora nobis",
|
|
39
|
+
"children": [
|
|
40
|
+
{
|
|
41
|
+
"label": "Maiores",
|
|
42
|
+
"children": [
|
|
43
|
+
{ "type": "SINGLE_VALUE", "label": "Magni quasi", "display": "Natus nobis" },
|
|
44
|
+
{
|
|
45
|
+
"type": "REFERENCE_VALUE",
|
|
46
|
+
"label": "Magni quasi",
|
|
47
|
+
"display": "Natus nobis",
|
|
48
|
+
"reference": "Repellendus/perferendis-quisquam-est-123"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"label": "Accusantium",
|
|
54
|
+
"children": [
|
|
55
|
+
{
|
|
56
|
+
"type": "SINGLE_VALUE",
|
|
57
|
+
"label": "Consectetur aliquid voluptatibus",
|
|
58
|
+
"display": "Blanditiis"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The Health UI Schema above would render the following content:
|
|
67
|
+
|
|
68
|
+

|
|
69
|
+
|
|
70
|
+
<hr>
|
|
71
|
+
|
|
72
|
+
See the **[package source][source]** for more details
|
|
73
|
+
|
|
74
|
+
_This package and its documentation are still under development._
|
|
75
|
+
|
|
76
|
+
[about-hcim-ui]: https://github.com/minvws/nl-mgo-app-web/blob/main/docs/about.md#from-hcim-to-ui
|
|
77
|
+
[source]: https://github.com/minvws/nl-mgo-app-web/tree/main/packages/hcim-ui
|
|
78
|
+
[packages-hcim]: https://github.com/minvws/nl-mgo-app-web/tree/main/packages/hcim
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { organization } from './organization/organization.js';
|
|
2
|
+
import { summaryOptions } from './summaryOptions/summaryOptions.js';
|
|
3
|
+
export declare const common: {
|
|
4
|
+
organization: typeof organization;
|
|
5
|
+
summaryOptions: typeof summaryOptions;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,eAAO,MAAM,MAAM;;;CAGlB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UiContext } from '../../context/index.js';
|
|
2
|
+
import { type UiElement } from '../../types/index.js';
|
|
3
|
+
export declare function organization({ formatMessage }: UiContext, organization: {
|
|
4
|
+
name?: string;
|
|
5
|
+
} | undefined): UiElement;
|
|
6
|
+
//# sourceMappingURL=organization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../../../src/common/organization/organization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,wBAAgB,YAAY,CACxB,EAAE,aAAa,EAAE,EAAE,SAAS,EAC5B,YAAY,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GAC5C,SAAS,CAMX"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MgoResourceMeta } from '@minvws/mgo-hcim-parse';
|
|
2
|
+
import { type FhirMessagesIds } from '@minvws/mgo-intl';
|
|
3
|
+
import { type UiContext } from '../../context/index.js';
|
|
4
|
+
import { type HealthUiGroup } from '../../types/index.js';
|
|
5
|
+
type ShowDetailsLabel = Extract<FhirMessagesIds, `summary.${string}.show_details`> extends `summary.${infer R}.show_details` ? R : never;
|
|
6
|
+
export declare function summaryOptions({ formatMessage }: UiContext, i18n: ShowDetailsLabel, resource: MgoResourceMeta): HealthUiGroup;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=summaryOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summaryOptions.d.ts","sourceRoot":"","sources":["../../../src/common/summaryOptions/summaryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,KAAK,gBAAgB,GACjB,OAAO,CACH,eAAe,EACf,WAAW,MAAM,eAAe,CACnC,SAAS,WAAW,MAAM,CAAC,eAAe,GACrC,CAAC,GACD,KAAK,CAAC;AAEhB,wBAAgB,cAAc,CAC1B,EAAE,aAAa,EAAE,EAAE,SAAS,EAC5B,IAAI,EAAE,gBAAgB,EACtB,QAAQ,EAAE,eAAe,GAC1B,aAAa,CAWf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function summaryOptions({ formatMessage }, i18n, resource) {
|
|
2
|
+
return {
|
|
3
|
+
label: formatMessage(`summary.options`),
|
|
4
|
+
children: [
|
|
5
|
+
{
|
|
6
|
+
type: 'REFERENCE_LINK',
|
|
7
|
+
label: formatMessage(`summary.${i18n}.show_details`),
|
|
8
|
+
reference: resource.referenceId,
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FhirIntlShape, type FhirMessagesIds } from '@minvws/mgo-intl';
|
|
2
|
+
/**
|
|
3
|
+
* Attempts to translate the label using several fallbacks if the initial label is not available.
|
|
4
|
+
*
|
|
5
|
+
* Given the label: `r3.resource.foo.bar_reference` it will try the following options:
|
|
6
|
+
*
|
|
7
|
+
* - r3.resource.foo.bar_reference // the initial label first
|
|
8
|
+
* - r3.resource.foo.bar // the label without the type extension
|
|
9
|
+
* - (fallback) // a fallback label if provided
|
|
10
|
+
* - fhir.x.bar_reference // a generic "x" property label
|
|
11
|
+
* - fhir.x.bar // a generic "x" property label without the type extension
|
|
12
|
+
*/
|
|
13
|
+
export declare function createLabelFormatter(intl: FhirIntlShape): (label: FhirMessagesIds | string, value: unknown, fallbackLabel?: FhirMessagesIds) => string;
|
|
14
|
+
//# sourceMappingURL=formatLabel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatLabel.d.ts","sourceRoot":"","sources":["../../src/context/formatLabel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA0C5E;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,aAAa,IAIhD,OAAO,eAAe,GAAG,MAAM,EAC/B,OAAO,OAAO,EACd,gBAAgB,eAAe,YA8BtC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isValueType } from '@minvws/mgo-hcim-parse';
|
|
2
|
+
import { snakeCase } from 'lodash-es';
|
|
3
|
+
const fhirXLabelRegexp = /^r[34]\.[\w.]+\./;
|
|
4
|
+
function getFallbackLabels(label, value) {
|
|
5
|
+
let typeExtension = null;
|
|
6
|
+
if (isValueType(value)) {
|
|
7
|
+
typeExtension = `_${snakeCase(value._type)}`;
|
|
8
|
+
}
|
|
9
|
+
else if (Array.isArray(value) && isValueType(value[0])) {
|
|
10
|
+
typeExtension = `_${snakeCase(value[0]._type)}`;
|
|
11
|
+
}
|
|
12
|
+
const labels = {
|
|
13
|
+
labelWithoutType: null,
|
|
14
|
+
fhirXLabel: null,
|
|
15
|
+
fhirXLabelWithoutType: null,
|
|
16
|
+
};
|
|
17
|
+
if (typeExtension && label.endsWith(typeExtension)) {
|
|
18
|
+
labels.labelWithoutType = label.substring(0, label.lastIndexOf(typeExtension));
|
|
19
|
+
}
|
|
20
|
+
if (fhirXLabelRegexp.test(label)) {
|
|
21
|
+
labels.fhirXLabel = label.replace(fhirXLabelRegexp, 'fhir.x.');
|
|
22
|
+
if (typeExtension) {
|
|
23
|
+
labels.fhirXLabelWithoutType = labels.fhirXLabel.substring(0, labels.fhirXLabel.lastIndexOf(typeExtension));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return labels;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Attempts to translate the label using several fallbacks if the initial label is not available.
|
|
30
|
+
*
|
|
31
|
+
* Given the label: `r3.resource.foo.bar_reference` it will try the following options:
|
|
32
|
+
*
|
|
33
|
+
* - r3.resource.foo.bar_reference // the initial label first
|
|
34
|
+
* - r3.resource.foo.bar // the label without the type extension
|
|
35
|
+
* - (fallback) // a fallback label if provided
|
|
36
|
+
* - fhir.x.bar_reference // a generic "x" property label
|
|
37
|
+
* - fhir.x.bar // a generic "x" property label without the type extension
|
|
38
|
+
*/
|
|
39
|
+
export function createLabelFormatter(intl) {
|
|
40
|
+
const hasMessage = (id) => Object.hasOwn(intl.messages, id);
|
|
41
|
+
return function formatLabel(label, value, fallbackLabel) {
|
|
42
|
+
if (hasMessage(label)) {
|
|
43
|
+
return intl.formatMessage({ id: label });
|
|
44
|
+
}
|
|
45
|
+
const { labelWithoutType, fhirXLabel, fhirXLabelWithoutType } = getFallbackLabels(label, value);
|
|
46
|
+
if (labelWithoutType && hasMessage(labelWithoutType)) {
|
|
47
|
+
return intl.formatMessage({ id: labelWithoutType });
|
|
48
|
+
}
|
|
49
|
+
if (fallbackLabel && hasMessage(fallbackLabel)) {
|
|
50
|
+
return intl.formatMessage({ id: fallbackLabel });
|
|
51
|
+
}
|
|
52
|
+
if (fhirXLabel && hasMessage(fhirXLabel)) {
|
|
53
|
+
return intl.formatMessage({ id: fhirXLabel });
|
|
54
|
+
}
|
|
55
|
+
if (fhirXLabelWithoutType && hasMessage(fhirXLabelWithoutType)) {
|
|
56
|
+
return intl.formatMessage({ id: fhirXLabelWithoutType });
|
|
57
|
+
}
|
|
58
|
+
// Let intl handle the missing translation error
|
|
59
|
+
return intl.formatMessage({ id: label });
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FhirMessagesIds, IntlHelpers, type FhirIntlShape, type Locale } from '@minvws/mgo-intl';
|
|
2
|
+
import { createLabelFormatter } from './formatLabel.js';
|
|
3
|
+
export type UiContextOptions = {
|
|
4
|
+
isSummary?: boolean;
|
|
5
|
+
ignoreMissingTranslations?: boolean;
|
|
6
|
+
locale: Locale;
|
|
7
|
+
};
|
|
8
|
+
export type UiContext = {
|
|
9
|
+
isSummary: boolean | undefined;
|
|
10
|
+
intl: FhirIntlShape;
|
|
11
|
+
formatLabel: ReturnType<typeof createLabelFormatter>;
|
|
12
|
+
} & IntlHelpers<string, FhirMessagesIds>;
|
|
13
|
+
export declare function createUiContext(options: UiContextOptions): UiContext;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,eAAe,EAEf,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,MAAM,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAIF,MAAM,MAAM,SAAS,GAAG;IACpB,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;CACxD,GAAG,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEzC,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAiBpE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHelpers, createIntl, createIntlCache, getFhirIntlConfig, } from '@minvws/mgo-intl';
|
|
2
|
+
import { createLabelFormatter } from './formatLabel.js';
|
|
3
|
+
const intlCache = createIntlCache();
|
|
4
|
+
export function createUiContext(options) {
|
|
5
|
+
const { locale, ignoreMissingTranslations, isSummary } = options;
|
|
6
|
+
const intl = createIntl(getFhirIntlConfig({
|
|
7
|
+
locale,
|
|
8
|
+
ignoreMissingTranslations,
|
|
9
|
+
}), intlCache);
|
|
10
|
+
return {
|
|
11
|
+
isSummary,
|
|
12
|
+
intl,
|
|
13
|
+
...createHelpers(intl),
|
|
14
|
+
formatLabel: createLabelFormatter(intl),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type DateString, type DateTimeString, type InstantDateTimeString } from '@minvws/mgo-fhir';
|
|
2
|
+
import { type FormatFunction, type WithUiContext } from '../../types/index.js';
|
|
3
|
+
export declare const date: WithUiContext<FormatFunction<DateString | DateTimeString | InstantDateTimeString>>;
|
|
4
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/format/date/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEpG,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAmC/E,eAAO,MAAM,IAAI,EAAE,aAAa,CAC5B,cAAc,CAAC,UAAU,GAAG,cAAc,GAAG,qBAAqB,CAAC,CAkBlE,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { isNullish } from '@minvws/mgo-utils';
|
|
2
|
+
const milliseconds = /T\d\d:\d\d:\d\d\.\d+/i;
|
|
3
|
+
const seconds = /T\d\d:\d\d:\d\d/i;
|
|
4
|
+
const minutes = /T\d\d:\d\d/i;
|
|
5
|
+
const hours = /T\d\d/i;
|
|
6
|
+
const dateRegexp = /^\d\d\d\d-\d\d-\d\d/;
|
|
7
|
+
const month = /^\d\d\d\d-\d\d/;
|
|
8
|
+
const year = /^\d\d\d\d/;
|
|
9
|
+
const timezone = /(([+-][\d:]+)|Z)$/i;
|
|
10
|
+
function getDateFormatOptions(dateString, isSummary = false) {
|
|
11
|
+
const hasMilliseconds = milliseconds.test(dateString);
|
|
12
|
+
const hasSeconds = hasMilliseconds || seconds.test(dateString);
|
|
13
|
+
const hasMinutes = hasSeconds || minutes.test(dateString);
|
|
14
|
+
const hasHours = hasMinutes || hours.test(dateString);
|
|
15
|
+
const hasDate = dateRegexp.test(dateString);
|
|
16
|
+
const hasMonth = hasDate || month.test(dateString);
|
|
17
|
+
const hasYear = hasMonth || year.test(dateString);
|
|
18
|
+
const hasTimezone = hasHours && timezone.test(dateString);
|
|
19
|
+
return {
|
|
20
|
+
year: hasYear ? 'numeric' : undefined,
|
|
21
|
+
month: hasMonth ? 'long' : undefined,
|
|
22
|
+
day: hasDate ? 'numeric' : undefined,
|
|
23
|
+
hour: hasHours ? 'numeric' : undefined,
|
|
24
|
+
minute: hasMinutes ? 'numeric' : undefined,
|
|
25
|
+
...(!isSummary && {
|
|
26
|
+
second: hasSeconds ? 'numeric' : undefined,
|
|
27
|
+
fractionalSecondDigits: hasMilliseconds ? 3 : undefined,
|
|
28
|
+
timeZoneName: hasTimezone ? 'shortOffset' : undefined,
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export const date = ({ intl: { locale }, isSummary }) => (value) => {
|
|
33
|
+
if (isNullish(value))
|
|
34
|
+
return;
|
|
35
|
+
const date = new Date(value);
|
|
36
|
+
const dateTimeFormat = new Intl.DateTimeFormat(locale, getDateFormatOptions(value, isSummary));
|
|
37
|
+
try {
|
|
38
|
+
return dateTimeFormat.format(date);
|
|
39
|
+
// eslint-disable-next-line sonarjs/no-ignored-exceptions
|
|
40
|
+
}
|
|
41
|
+
catch (_error) {
|
|
42
|
+
return `${value}`;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
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
|
+
valueWithUnit(value: import("@minvws/mgo-utils").Nullable<import("lossless-json").LosslessNumber | number>, unit: import("@minvws/mgo-utils").Nullable<string>): string | undefined;
|
|
4
|
+
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
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/format/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM;;;;CAGlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../src/format/system/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG/E,eAAO,MAAM,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC,CAwBhE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { systemCode } from '../systemCode/systemCode.js';
|
|
2
|
+
export const system = (context) => (value) => {
|
|
3
|
+
const { isSummary, formatMessage } = context;
|
|
4
|
+
const { display, code, system } = value ?? {};
|
|
5
|
+
const systemCodeTranslation = systemCode(context)(value);
|
|
6
|
+
if (isSummary) {
|
|
7
|
+
return systemCodeTranslation;
|
|
8
|
+
}
|
|
9
|
+
let codeInSystemString;
|
|
10
|
+
if (code && system) {
|
|
11
|
+
codeInSystemString = formatMessage('fhir.code_in_system', {
|
|
12
|
+
code,
|
|
13
|
+
system,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
codeInSystemString = system ?? code;
|
|
18
|
+
}
|
|
19
|
+
const systemString = `${display ?? ''} ${codeInSystemString ? '(' + codeInSystemString + ')' : ''}`.trim();
|
|
20
|
+
return systemString === '' ? undefined : systemString;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemCode.d.ts","sourceRoot":"","sources":["../../../src/format/systemCode/systemCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE/E,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC,CAchE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isNullish } from '@minvws/mgo-utils';
|
|
2
|
+
export const systemCode = ({ formatMessage, hasMessage }) => (value) => {
|
|
3
|
+
if (isNullish(value)) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const { display, code, system } = value;
|
|
7
|
+
const systemCodeI18n = `system.code.${system}|${code}`;
|
|
8
|
+
const systemCodeString = hasMessage(systemCodeI18n)
|
|
9
|
+
? formatMessage(systemCodeI18n)
|
|
10
|
+
: display;
|
|
11
|
+
return systemCodeString ?? code;
|
|
12
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type MgoSimpleQuantityProps } from '@minvws/mgo-hcim-parse';
|
|
2
|
+
import { type FormatFunction, type WithUiContext } from '../../types/index.js';
|
|
3
|
+
export declare const systemValue: WithUiContext<FormatFunction<MgoSimpleQuantityProps>>;
|
|
4
|
+
//# sourceMappingURL=systemValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemValue.d.ts","sourceRoot":"","sources":["../../../src/format/systemValue/systemValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGrE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE/E,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAiBzE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isNullish } from '@minvws/mgo-utils';
|
|
2
|
+
import { numberToString } from '../../helpers/index.js';
|
|
3
|
+
export const systemValue = ({ formatMessage, hasMessage }) => (value) => {
|
|
4
|
+
if (isNullish(value))
|
|
5
|
+
return;
|
|
6
|
+
const { system, code, value: quantityValue, unit } = value;
|
|
7
|
+
const countI18nKey = `system.value.${system}|${code}`;
|
|
8
|
+
const numberString = numberToString(quantityValue);
|
|
9
|
+
if (hasMessage(countI18nKey)) {
|
|
10
|
+
return formatMessage(countI18nKey, { value: numberString });
|
|
11
|
+
}
|
|
12
|
+
if (unit) {
|
|
13
|
+
return `${numberString} ${unit}`;
|
|
14
|
+
}
|
|
15
|
+
return numberString;
|
|
16
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type LosslessNumber, type Nullable } from '@minvws/mgo-utils';
|
|
2
|
+
export declare function valueWithUnit(value: Nullable<LosslessNumber | number>, unit: Nullable<string>): string | undefined;
|
|
3
|
+
export declare function valueWithMaxValue(value: Nullable<LosslessNumber | number>, maxValue: Nullable<LosslessNumber | number>): string | undefined;
|
|
4
|
+
//# sourceMappingURL=value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../../src/format/value/value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlF,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,GAAG,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,sBAM7F;AAED,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,QAAQ,CAAC,cAAc,GAAG,MAAM,CAAC,EACxC,QAAQ,EAAE,QAAQ,CAAC,cAAc,GAAG,MAAM,CAAC,sBAO9C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isNullish } from '@minvws/mgo-utils';
|
|
2
|
+
import { numberToString } from '../../helpers/index.js';
|
|
3
|
+
export function valueWithUnit(value, unit) {
|
|
4
|
+
if (isNullish(value))
|
|
5
|
+
return;
|
|
6
|
+
const valueString = numberToString(value);
|
|
7
|
+
if (isNullish(unit))
|
|
8
|
+
return valueString;
|
|
9
|
+
return `${valueString} ${unit}`;
|
|
10
|
+
}
|
|
11
|
+
export function valueWithMaxValue(value, maxValue) {
|
|
12
|
+
if (isNullish(value))
|
|
13
|
+
return;
|
|
14
|
+
const valueString = numberToString(value);
|
|
15
|
+
if (isNullish(maxValue))
|
|
16
|
+
return valueString;
|
|
17
|
+
return `${valueString} / ${numberToString(maxValue)}`;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FhirVersion } from '@minvws/mgo-fhir';
|
|
2
|
+
import { UiContext } from '../../context/index.js';
|
|
3
|
+
import { createUiElementHelper } from '../createUiElementHelper/createUiElementHelper.js';
|
|
4
|
+
export type GeneratorContext = {
|
|
5
|
+
formatMessage: UiContext['formatMessage'];
|
|
6
|
+
formatLabel: UiContext['formatLabel'];
|
|
7
|
+
createUiElement: ReturnType<typeof createUiElementHelper>;
|
|
8
|
+
fhirVersion: `${FhirVersion}`;
|
|
9
|
+
rootPath: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function createGeneratorContext(uiContext: UiContext, rootPath: string, fhirVersion: `${FhirVersion}`): GeneratorContext;
|
|
12
|
+
//# sourceMappingURL=createGeneratorContext.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createUiElementHelper } from '../createUiElementHelper/createUiElementHelper.js';
|
|
2
|
+
export function createGeneratorContext(uiContext, rootPath, fhirVersion) {
|
|
3
|
+
const { formatMessage, formatLabel } = uiContext;
|
|
4
|
+
const createUiElement = createUiElementHelper(uiContext);
|
|
5
|
+
return {
|
|
6
|
+
formatMessage,
|
|
7
|
+
formatLabel,
|
|
8
|
+
createUiElement,
|
|
9
|
+
fhirVersion,
|
|
10
|
+
rootPath,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type MgoType, type MgoTypeId } from '@minvws/mgo-hcim-parse';
|
|
2
|
+
import { type FhirMessagesIds } from '@minvws/mgo-intl';
|
|
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;
|
|
6
|
+
//# sourceMappingURL=createUiElementHelper.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { map } from '@minvws/mgo-utils';
|
|
3
|
+
import { createUiHelpers } from '../../ui.js';
|
|
4
|
+
export function createUiElementHelper(uiContext) {
|
|
5
|
+
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
|
+
};
|
|
46
|
+
return function createUiElement(label, value) {
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
const uiHelper = multipleUiTypeMap[value[0]._type];
|
|
49
|
+
if (uiHelper) {
|
|
50
|
+
return uiHelper(label, value);
|
|
51
|
+
}
|
|
52
|
+
return map(value, (x) => createUiElement(label, x), true);
|
|
53
|
+
}
|
|
54
|
+
const uiHelper = singleUiTypeMap[value._type];
|
|
55
|
+
if (!uiHelper) {
|
|
56
|
+
throw new Error(`No ui helper found for type "${value._type}"`);
|
|
57
|
+
}
|
|
58
|
+
return uiHelper(label, value);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type MgoResourceMeta } from '@minvws/mgo-hcim-parse';
|
|
2
|
+
import { UiContext } from '../../context/index.js';
|
|
3
|
+
import { HealthUiSchemaFunction } from '../../types/index.js';
|
|
4
|
+
export declare const generateUiSchema: HealthUiSchemaFunction<MgoResourceMeta, UiContext>;
|
|
5
|
+
//# sourceMappingURL=generateUiSchema.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isUiSchemaGroup } from '../../helpers/isUiSchemaGroup/isUiSchemaGroup.js';
|
|
2
|
+
import { createGeneratorContext } from '../createGeneratorContext/createGeneratorContext.js';
|
|
3
|
+
import { getProfileKey } from '../getProfileKey/getProfileKey.js';
|
|
4
|
+
import { processValue } from '../processValue/processValue.js';
|
|
5
|
+
const untranslatedLabelRegexp = /^(r3|r4|fhir)\./;
|
|
6
|
+
export const generateUiSchema = (resource, context) => {
|
|
7
|
+
const { formatMessage } = context;
|
|
8
|
+
const { id: _id, referenceId: _referenceId, resourceType: _resourceType, profile, fhirVersion, ...rest } = resource;
|
|
9
|
+
const rootPath = getProfileKey(fhirVersion, profile);
|
|
10
|
+
const generatorContext = createGeneratorContext(context, rootPath, fhirVersion);
|
|
11
|
+
const defaultGroup = {
|
|
12
|
+
children: [],
|
|
13
|
+
};
|
|
14
|
+
const groups = [defaultGroup];
|
|
15
|
+
const elements = processValue(generatorContext, rootPath, rest);
|
|
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
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
defaultGroup.children.push(element);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (const group of groups) {
|
|
34
|
+
group.children.sort((a, b) => a.label.localeCompare(b.label));
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
label: formatMessage(rootPath),
|
|
38
|
+
children: groups,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +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"}
|