@medplum/core 2.1.4 → 2.1.6

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.
@@ -1,30 +1,36 @@
1
- import { Bundle, Resource, StructureDefinition } from '@medplum/fhirtypes';
1
+ import { Bundle, ElementDefinitionBinding, Resource, StructureDefinition } from '@medplum/fhirtypes';
2
2
  import { TypedValue } from '../types';
3
3
  /**
4
4
  * Internal representation of a non-primitive FHIR type, suitable for use in resource validation
5
5
  */
6
6
  export interface InternalTypeSchema {
7
7
  name: string;
8
- fields: Record<string, ElementValidator>;
9
- constraints: Constraint[];
8
+ url?: string;
9
+ kind?: string;
10
+ description?: string;
11
+ elements: Record<string, InternalSchemaElement>;
12
+ constraints?: Constraint[];
13
+ parentType?: InternalTypeSchema;
10
14
  innerTypes: InternalTypeSchema[];
11
15
  summaryProperties?: Set<string>;
12
16
  mandatoryProperties?: Set<string>;
13
17
  }
14
- export interface ElementValidator {
18
+ export interface InternalSchemaElement {
19
+ description: string;
20
+ path: string;
15
21
  min: number;
16
22
  max: number;
17
- isArray: boolean;
18
- constraints: Constraint[];
23
+ isArray?: boolean;
24
+ constraints?: Constraint[];
19
25
  type: ElementType[];
20
26
  slicing?: SlicingRules;
21
27
  fixed?: TypedValue;
22
28
  pattern?: TypedValue;
23
- binding?: string;
29
+ binding?: ElementDefinitionBinding;
24
30
  }
25
31
  export interface ElementType {
26
32
  code: string;
27
- targetProfile: string[];
33
+ targetProfile?: string[];
28
34
  }
29
35
  export interface Constraint {
30
36
  key: string;
@@ -41,7 +47,7 @@ export interface SlicingRules {
41
47
  export interface SliceDefinition {
42
48
  name: string;
43
49
  type?: ElementType[];
44
- fields: Record<string, ElementValidator>;
50
+ elements: Record<string, InternalSchemaElement>;
45
51
  min: number;
46
52
  max: number;
47
53
  }
@@ -57,8 +63,24 @@ export interface SliceDiscriminator {
57
63
  * @experimental
58
64
  */
59
65
  export declare function parseStructureDefinition(sd: StructureDefinition): InternalTypeSchema;
60
- export declare function loadDataTypes(bundle: Bundle<StructureDefinition>): void;
66
+ export declare function indexStructureDefinitionBundle(bundle: StructureDefinition[] | Bundle): void;
67
+ export declare function loadDataType(sd: StructureDefinition): void;
68
+ export declare function getAllDataTypes(): Record<string, InternalTypeSchema>;
69
+ export declare function isDataTypeLoaded(type: string): boolean;
70
+ export declare function tryGetDataType(type: string): InternalTypeSchema | undefined;
61
71
  export declare function getDataType(type: string): InternalTypeSchema;
72
+ /**
73
+ * Returns true if the given string is a valid FHIR resource type.
74
+ *
75
+ * ```ts
76
+ * isResourceType('Patient'); // true
77
+ * isResourceType('XYZ'); // false
78
+ * ```
79
+ *
80
+ * @param resourceType The candidate resource type string.
81
+ * @returns True if the resource type is a valid FHIR resource type.
82
+ */
83
+ export declare function isResourceType(resourceType: string): boolean;
62
84
  /**
63
85
  * Construct the subset of a resource containing a minimum set of fields. The returned resource is not guaranteed
64
86
  * to contain only the provided properties, and may contain others (e.g. `resourceType` and `id`)
@@ -22,4 +22,4 @@ export declare const fhirTypeToJsType: {
22
22
  readonly xhtml: "string";
23
23
  readonly 'http://hl7.org/fhirpath/System.String': "string";
24
24
  };
25
- export declare function validate(resource: Resource, profile?: StructureDefinition): void;
25
+ export declare function validateResource(resource: Resource, profile?: StructureDefinition): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",
@@ -20,7 +20,8 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@medplum/definitions": "*",
23
- "@medplum/fhirtypes": "*"
23
+ "@medplum/fhirtypes": "*",
24
+ "jest-websocket-mock": "2.5.0"
24
25
  },
25
26
  "peerDependencies": {
26
27
  "pdfmake": "^0.2.5"
@@ -1,2 +0,0 @@
1
- export * from './parse';
2
- export * from './tokenize';
@@ -1 +0,0 @@
1
- export * from './parse';
@@ -1,4 +0,0 @@
1
- export * from './atoms';
2
- export * from './parse';
3
- export * from './tokenize';
4
- export * from './utils';
@@ -1,2 +0,0 @@
1
- export * from './parse';
2
- export * from './types';