@haste-health/fhir-types 0.12.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.
@@ -0,0 +1,58 @@
1
+ import * as r4 from "./generated/r4/types.js";
2
+ import * as r4b from "./generated/r4b/types.js";
3
+
4
+ export type R4 = "4.0";
5
+ export type R4B = "4.3";
6
+
7
+ export const R4: R4 = "4.0";
8
+ export const R4B: R4B = "4.3";
9
+
10
+ export const FHIR_VERSIONS_SUPPORTED: [R4, R4B] = [R4, R4B];
11
+ export type FHIR_VERSION = (typeof FHIR_VERSIONS_SUPPORTED)[number];
12
+
13
+ type ResourceTypeMap = {
14
+ [R4]: r4.ResourceType;
15
+ [R4B]: r4b.ResourceType;
16
+ };
17
+
18
+ export type ResourceType<
19
+ Version extends (typeof FHIR_VERSIONS_SUPPORTED)[number],
20
+ > = ResourceTypeMap[Version];
21
+
22
+ export type AllResourceTypes = ResourceType<FHIR_VERSION>;
23
+
24
+ export type Resource<
25
+ Version extends (typeof FHIR_VERSIONS_SUPPORTED)[number],
26
+ Type extends AllResourceTypes,
27
+ > = Version extends R4
28
+ ? Type extends r4.ResourceType
29
+ ? r4.AResource<Type>
30
+ : never
31
+ : Version extends R4B
32
+ ? Type extends r4b.ResourceType
33
+ ? r4b.AResource<Type>
34
+ : never
35
+ : never;
36
+
37
+ // [DATA TYPES]
38
+ // ------------------------------------------------------------------------------------------------
39
+
40
+ export type DataType<Version extends (typeof FHIR_VERSIONS_SUPPORTED)[number]> =
41
+ Version extends R4 ? r4.DataType : Version extends R4B ? r4b.DataType : never;
42
+
43
+ export type AllDataTypes = r4.DataType | r4b.DataType;
44
+
45
+ export type Data<
46
+ Version extends (typeof FHIR_VERSIONS_SUPPORTED)[number],
47
+ Type extends AllDataTypes,
48
+ > = Version extends R4
49
+ ? Type extends r4.DataType
50
+ ? r4.AData<Type>
51
+ : never
52
+ : Version extends R4B
53
+ ? Type extends r4b.DataType
54
+ ? r4b.AData<Type>
55
+ : never
56
+ : never;
57
+
58
+ // ------------------------------------------------------------------------------------------------