@medplum/core 0.9.3 → 0.9.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,139 +1,139 @@
1
- import { ElementDefinition, SearchParameter, StructureDefinition } from '@medplum/fhirtypes';
2
- /**
3
- * List of property types.
4
- * http://www.hl7.org/fhir/valueset-defined-types.html
5
- * The list here includes additions found from StructureDefinition resources.
6
- */
7
- export declare enum PropertyType {
8
- Address = "Address",
9
- Age = "Age",
10
- Annotation = "Annotation",
11
- Attachment = "Attachment",
12
- BackboneElement = "BackboneElement",
13
- CodeableConcept = "CodeableConcept",
14
- Coding = "Coding",
15
- ContactDetail = "ContactDetail",
16
- ContactPoint = "ContactPoint",
17
- Contributor = "Contributor",
18
- Count = "Count",
19
- DataRequirement = "DataRequirement",
20
- Distance = "Distance",
21
- Dosage = "Dosage",
22
- Duration = "Duration",
23
- Expression = "Expression",
24
- Extension = "Extension",
25
- HumanName = "HumanName",
26
- Identifier = "Identifier",
27
- MarketingStatus = "MarketingStatus",
28
- Meta = "Meta",
29
- Money = "Money",
30
- Narrative = "Narrative",
31
- ParameterDefinition = "ParameterDefinition",
32
- Period = "Period",
33
- Population = "Population",
34
- ProdCharacteristic = "ProdCharacteristic",
35
- ProductShelfLife = "ProductShelfLife",
36
- Quantity = "Quantity",
37
- Range = "Range",
38
- Ratio = "Ratio",
39
- Reference = "Reference",
40
- RelatedArtifact = "RelatedArtifact",
41
- Resource = "Resource",
42
- SampledData = "SampledData",
43
- Signature = "Signature",
44
- SubstanceAmount = "SubstanceAmount",
45
- SystemString = "http://hl7.org/fhirpath/System.String",
46
- Timing = "Timing",
47
- TriggerDefinition = "TriggerDefinition",
48
- UsageContext = "UsageContext",
49
- base64Binary = "base64Binary",
50
- boolean = "boolean",
51
- canonical = "canonical",
52
- code = "code",
53
- date = "date",
54
- dateTime = "dateTime",
55
- decimal = "decimal",
56
- id = "id",
57
- instant = "instant",
58
- integer = "integer",
59
- markdown = "markdown",
60
- oid = "oid",
61
- positiveInt = "positiveInt",
62
- string = "string",
63
- time = "time",
64
- unsignedInt = "unsignedInt",
65
- uri = "uri",
66
- url = "url",
67
- uuid = "uuid"
68
- }
69
- /**
70
- * An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.
71
- *
72
- * StructureDefinition resources contain schema information for other resource types.
73
- * These schemas can be used to automatically generate user interface elements for
74
- * resources.
75
- *
76
- * However, a StructureDefinition resource is not optimized for realtime lookups. All
77
- * resource types, sub types, and property definitions are stored in a flat array of
78
- * ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., "Patient.name")
79
- * requires a linear scan of all ElementDefinition objects
80
- *
81
- * A StructureDefinition resource contains information about one or more types.
82
- * For example, the "Patient" StructureDefinition includes "Patient", "Patient_Contact",
83
- * "Patient_Communication", and "Patient_Link". This is inefficient.
84
- *
85
- * Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition.
86
- * In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.
87
- *
88
- * The hierarchy is:
89
- * IndexedStructureDefinition - top level for one resource type
90
- * TypeSchema - one per resource type and all contained BackboneElements
91
- * PropertySchema - one per property/field
92
- */
93
- export interface IndexedStructureDefinition {
94
- types: {
95
- [resourceType: string]: TypeSchema;
96
- };
97
- }
98
- /**
99
- * An indexed TypeSchema.
100
- *
101
- * Example: The IndexedStructureDefinition for "Patient" would include the following TypeSchemas:
102
- * 1) Patient
103
- * 2) Patient_Contact
104
- * 3) Patient_Communication
105
- * 4) Patient_Link
106
- */
107
- export interface TypeSchema {
108
- display: string;
109
- properties: {
110
- [name: string]: ElementDefinition;
111
- };
112
- searchParams?: {
113
- [code: string]: SearchParameter;
114
- };
115
- description?: string;
116
- parentType?: string;
117
- }
118
- /**
119
- * Creates a new empty IndexedStructureDefinition.
120
- * @returns The empty IndexedStructureDefinition.
121
- */
122
- export declare function createSchema(): IndexedStructureDefinition;
123
- export declare function createTypeSchema(typeName: string, description: string | undefined): TypeSchema;
124
- /**
125
- * Indexes a StructureDefinition for fast lookup.
126
- * See comments on IndexedStructureDefinition for more details.
127
- * @param schema The output IndexedStructureDefinition.
128
- * @param structureDefinition The original StructureDefinition.
129
- */
130
- export declare function indexStructureDefinition(schema: IndexedStructureDefinition, structureDefinition: StructureDefinition): void;
131
- /**
132
- * Indexes a SearchParameter resource for fast lookup.
133
- * Indexes by SearchParameter.code, which is the query string parameter name.
134
- * @param schema The output IndexedStructureDefinition.
135
- * @param searchParam The SearchParameter resource.
136
- */
137
- export declare function indexSearchParameter(schema: IndexedStructureDefinition, searchParam: SearchParameter): void;
138
- export declare function buildTypeName(components: string[]): string;
139
- export declare function getPropertyDisplayName(property: ElementDefinition): string;
1
+ import { ElementDefinition, SearchParameter, StructureDefinition } from '@medplum/fhirtypes';
2
+ /**
3
+ * List of property types.
4
+ * http://www.hl7.org/fhir/valueset-defined-types.html
5
+ * The list here includes additions found from StructureDefinition resources.
6
+ */
7
+ export declare enum PropertyType {
8
+ Address = "Address",
9
+ Age = "Age",
10
+ Annotation = "Annotation",
11
+ Attachment = "Attachment",
12
+ BackboneElement = "BackboneElement",
13
+ CodeableConcept = "CodeableConcept",
14
+ Coding = "Coding",
15
+ ContactDetail = "ContactDetail",
16
+ ContactPoint = "ContactPoint",
17
+ Contributor = "Contributor",
18
+ Count = "Count",
19
+ DataRequirement = "DataRequirement",
20
+ Distance = "Distance",
21
+ Dosage = "Dosage",
22
+ Duration = "Duration",
23
+ Expression = "Expression",
24
+ Extension = "Extension",
25
+ HumanName = "HumanName",
26
+ Identifier = "Identifier",
27
+ MarketingStatus = "MarketingStatus",
28
+ Meta = "Meta",
29
+ Money = "Money",
30
+ Narrative = "Narrative",
31
+ ParameterDefinition = "ParameterDefinition",
32
+ Period = "Period",
33
+ Population = "Population",
34
+ ProdCharacteristic = "ProdCharacteristic",
35
+ ProductShelfLife = "ProductShelfLife",
36
+ Quantity = "Quantity",
37
+ Range = "Range",
38
+ Ratio = "Ratio",
39
+ Reference = "Reference",
40
+ RelatedArtifact = "RelatedArtifact",
41
+ Resource = "Resource",
42
+ SampledData = "SampledData",
43
+ Signature = "Signature",
44
+ SubstanceAmount = "SubstanceAmount",
45
+ SystemString = "http://hl7.org/fhirpath/System.String",
46
+ Timing = "Timing",
47
+ TriggerDefinition = "TriggerDefinition",
48
+ UsageContext = "UsageContext",
49
+ base64Binary = "base64Binary",
50
+ boolean = "boolean",
51
+ canonical = "canonical",
52
+ code = "code",
53
+ date = "date",
54
+ dateTime = "dateTime",
55
+ decimal = "decimal",
56
+ id = "id",
57
+ instant = "instant",
58
+ integer = "integer",
59
+ markdown = "markdown",
60
+ oid = "oid",
61
+ positiveInt = "positiveInt",
62
+ string = "string",
63
+ time = "time",
64
+ unsignedInt = "unsignedInt",
65
+ uri = "uri",
66
+ url = "url",
67
+ uuid = "uuid"
68
+ }
69
+ /**
70
+ * An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.
71
+ *
72
+ * StructureDefinition resources contain schema information for other resource types.
73
+ * These schemas can be used to automatically generate user interface elements for
74
+ * resources.
75
+ *
76
+ * However, a StructureDefinition resource is not optimized for realtime lookups. All
77
+ * resource types, sub types, and property definitions are stored in a flat array of
78
+ * ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., "Patient.name")
79
+ * requires a linear scan of all ElementDefinition objects
80
+ *
81
+ * A StructureDefinition resource contains information about one or more types.
82
+ * For example, the "Patient" StructureDefinition includes "Patient", "Patient_Contact",
83
+ * "Patient_Communication", and "Patient_Link". This is inefficient.
84
+ *
85
+ * Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition.
86
+ * In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.
87
+ *
88
+ * The hierarchy is:
89
+ * IndexedStructureDefinition - top level for one resource type
90
+ * TypeSchema - one per resource type and all contained BackboneElements
91
+ * PropertySchema - one per property/field
92
+ */
93
+ export interface IndexedStructureDefinition {
94
+ types: {
95
+ [resourceType: string]: TypeSchema;
96
+ };
97
+ }
98
+ /**
99
+ * An indexed TypeSchema.
100
+ *
101
+ * Example: The IndexedStructureDefinition for "Patient" would include the following TypeSchemas:
102
+ * 1) Patient
103
+ * 2) Patient_Contact
104
+ * 3) Patient_Communication
105
+ * 4) Patient_Link
106
+ */
107
+ export interface TypeSchema {
108
+ display: string;
109
+ properties: {
110
+ [name: string]: ElementDefinition;
111
+ };
112
+ searchParams?: {
113
+ [code: string]: SearchParameter;
114
+ };
115
+ description?: string;
116
+ parentType?: string;
117
+ }
118
+ /**
119
+ * Creates a new empty IndexedStructureDefinition.
120
+ * @returns The empty IndexedStructureDefinition.
121
+ */
122
+ export declare function createSchema(): IndexedStructureDefinition;
123
+ export declare function createTypeSchema(typeName: string, description: string | undefined): TypeSchema;
124
+ /**
125
+ * Indexes a StructureDefinition for fast lookup.
126
+ * See comments on IndexedStructureDefinition for more details.
127
+ * @param schema The output IndexedStructureDefinition.
128
+ * @param structureDefinition The original StructureDefinition.
129
+ */
130
+ export declare function indexStructureDefinition(schema: IndexedStructureDefinition, structureDefinition: StructureDefinition): void;
131
+ /**
132
+ * Indexes a SearchParameter resource for fast lookup.
133
+ * Indexes by SearchParameter.code, which is the query string parameter name.
134
+ * @param schema The output IndexedStructureDefinition.
135
+ * @param searchParam The SearchParameter resource.
136
+ */
137
+ export declare function indexSearchParameter(schema: IndexedStructureDefinition, searchParam: SearchParameter): void;
138
+ export declare function buildTypeName(components: string[]): string;
139
+ export declare function getPropertyDisplayName(property: ElementDefinition): string;
@@ -1,131 +1,131 @@
1
- import { Patient, Practitioner, QuestionnaireResponse, QuestionnaireResponseItemAnswer, Reference, RelatedPerson, Resource } from '@medplum/fhirtypes';
2
- export declare type ProfileResource = Patient | Practitioner | RelatedPerson;
3
- /**
4
- * Creates a reference resource.
5
- * @param resource The FHIR reesource.
6
- * @returns A reference resource.
7
- */
8
- export declare function createReference<T extends Resource>(resource: T): Reference<T>;
9
- /**
10
- * Returns a reference string for a resource.
11
- * @param resource The FHIR resource.
12
- * @returns A reference string of the form resourceType/id.
13
- */
14
- export declare function getReferenceString(resource: Resource): string;
15
- /**
16
- * Returns the ID portion of a reference.
17
- * @param reference A FHIR reference.
18
- * @returns The ID portion of a reference.
19
- */
20
- export declare function resolveId(reference: Reference | undefined): string | undefined;
21
- /**
22
- * Returns true if the resource is a "ProfileResource".
23
- * @param resource The FHIR resource.
24
- * @returns True if the resource is a "ProfileResource".
25
- */
26
- export declare function isProfileResource(resource: Resource): boolean;
27
- /**
28
- * Returns a display string for the resource.
29
- * @param resource The input resource.
30
- * @return Human friendly display string.
31
- */
32
- export declare function getDisplayString(resource: Resource): string;
33
- /**
34
- * Returns an image URL for the resource, if one is available.
35
- * @param resource The input resource.
36
- * @returns The image URL for the resource or undefined.
37
- */
38
- export declare function getImageSrc(resource: Resource): string | undefined;
39
- /**
40
- * Returns a Date property as a Date.
41
- * When working with JSON objects, Dates are often serialized as ISO-8601 strings.
42
- * When that happens, we need to safely convert to a proper Date object.
43
- * @param date The date property value, which could be a string or a Date object.
44
- * @returns A Date object.
45
- */
46
- export declare function getDateProperty(date: string | undefined): Date | undefined;
47
- /**
48
- * Calculates the age in years from the birth date.
49
- * @param birthDateStr The birth date or start date in ISO-8601 format YYYY-MM-DD.
50
- * @param endDateStr Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today.
51
- * @returns The age in years, months, and days.
52
- */
53
- export declare function calculateAge(birthDateStr: string, endDateStr?: string): {
54
- years: number;
55
- months: number;
56
- days: number;
57
- };
58
- /**
59
- * Calculates the age string for display using the age appropriate units.
60
- * If the age is greater than or equal to 2 years, then the age is displayed in years.
61
- * If the age is greater than or equal to 1 month, then the age is displayed in months.
62
- * Otherwise, the age is displayed in days.
63
- * @param birthDateStr The birth date or start date in ISO-8601 format YYYY-MM-DD.
64
- * @param endDateStr Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today.
65
- * @returns The age string.
66
- */
67
- export declare function calculateAgeString(birthDateStr: string, endDateStr?: string): string | undefined;
68
- /**
69
- * Returns all questionnaire answers as a map by link ID.
70
- * @param response The questionnaire response resource.
71
- * @returns Questionnaire answers mapped by link ID.
72
- */
73
- export declare function getQuestionnaireAnswers(response: QuestionnaireResponse): Record<string, QuestionnaireResponseItemAnswer>;
74
- /**
75
- * Returns an extension value by extension URLs.
76
- * @param resource The base resource.
77
- * @param urls Array of extension URLs. Each entry represents a nested extension.
78
- * @returns The extension value if found; undefined otherwise.
79
- */
80
- export declare function getExtensionValue(resource: Resource, ...urls: string[]): string | undefined;
81
- /**
82
- * FHIR JSON stringify.
83
- * Removes properties with empty string values.
84
- * Removes objects with zero properties.
85
- * See: https://www.hl7.org/fhir/json.html
86
- * @param value The input value.
87
- * @param pretty Optional flag to pretty-print the JSON.
88
- * @returns The resulting JSON string.
89
- */
90
- export declare function stringify(value: any, pretty?: boolean): string;
91
- /**
92
- * Resource equality.
93
- * Ignores meta.versionId and meta.lastUpdated.
94
- * @param object1 The first object.
95
- * @param object2 The second object.
96
- * @returns True if the objects are equal.
97
- */
98
- export declare function deepEquals(object1: unknown, object2: unknown, path?: string): boolean;
99
- /**
100
- * Returns true if the input string is a UUID.
101
- * @param input The input string.
102
- * @returns True if the input string matches the UUID format.
103
- */
104
- export declare function isUUID(input: string): boolean;
105
- /**
106
- * Returns true if the input is an object.
107
- * @param object The candidate object.
108
- * @returns True if the input is a non-null non-undefined object.
109
- */
110
- export declare function isObject(obj: unknown): obj is Record<string, unknown>;
111
- /**
112
- * Returns true if the input array is an array of strings.
113
- * @param arr Input array.
114
- * @returns True if the input array is an array of strings.
115
- */
116
- export declare function isStringArray(arr: any[]): arr is string[];
117
- /**
118
- * Converts an ArrayBuffer to hex string.
119
- * See: https://stackoverflow.com/a/55200387
120
- * @param arrayBuffer The input array buffer.
121
- * @returns The resulting hex string.
122
- */
123
- export declare function arrayBufferToHex(arrayBuffer: ArrayBuffer): string;
124
- /**
125
- * Converts an ArrayBuffer to a base-64 encoded string.
126
- * @param arrayBuffer The input array buffer.
127
- * @returns The base-64 encoded string.
128
- */
129
- export declare function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string;
130
- export declare function capitalize(word: string): string;
131
- export declare function isLowerCase(c: string): boolean;
1
+ import { Patient, Practitioner, QuestionnaireResponse, QuestionnaireResponseItemAnswer, Reference, RelatedPerson, Resource } from '@medplum/fhirtypes';
2
+ export declare type ProfileResource = Patient | Practitioner | RelatedPerson;
3
+ /**
4
+ * Creates a reference resource.
5
+ * @param resource The FHIR reesource.
6
+ * @returns A reference resource.
7
+ */
8
+ export declare function createReference<T extends Resource>(resource: T): Reference<T>;
9
+ /**
10
+ * Returns a reference string for a resource.
11
+ * @param resource The FHIR resource.
12
+ * @returns A reference string of the form resourceType/id.
13
+ */
14
+ export declare function getReferenceString(resource: Resource): string;
15
+ /**
16
+ * Returns the ID portion of a reference.
17
+ * @param reference A FHIR reference.
18
+ * @returns The ID portion of a reference.
19
+ */
20
+ export declare function resolveId(reference: Reference | undefined): string | undefined;
21
+ /**
22
+ * Returns true if the resource is a "ProfileResource".
23
+ * @param resource The FHIR resource.
24
+ * @returns True if the resource is a "ProfileResource".
25
+ */
26
+ export declare function isProfileResource(resource: Resource): boolean;
27
+ /**
28
+ * Returns a display string for the resource.
29
+ * @param resource The input resource.
30
+ * @return Human friendly display string.
31
+ */
32
+ export declare function getDisplayString(resource: Resource): string;
33
+ /**
34
+ * Returns an image URL for the resource, if one is available.
35
+ * @param resource The input resource.
36
+ * @returns The image URL for the resource or undefined.
37
+ */
38
+ export declare function getImageSrc(resource: Resource): string | undefined;
39
+ /**
40
+ * Returns a Date property as a Date.
41
+ * When working with JSON objects, Dates are often serialized as ISO-8601 strings.
42
+ * When that happens, we need to safely convert to a proper Date object.
43
+ * @param date The date property value, which could be a string or a Date object.
44
+ * @returns A Date object.
45
+ */
46
+ export declare function getDateProperty(date: string | undefined): Date | undefined;
47
+ /**
48
+ * Calculates the age in years from the birth date.
49
+ * @param birthDateStr The birth date or start date in ISO-8601 format YYYY-MM-DD.
50
+ * @param endDateStr Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today.
51
+ * @returns The age in years, months, and days.
52
+ */
53
+ export declare function calculateAge(birthDateStr: string, endDateStr?: string): {
54
+ years: number;
55
+ months: number;
56
+ days: number;
57
+ };
58
+ /**
59
+ * Calculates the age string for display using the age appropriate units.
60
+ * If the age is greater than or equal to 2 years, then the age is displayed in years.
61
+ * If the age is greater than or equal to 1 month, then the age is displayed in months.
62
+ * Otherwise, the age is displayed in days.
63
+ * @param birthDateStr The birth date or start date in ISO-8601 format YYYY-MM-DD.
64
+ * @param endDateStr Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today.
65
+ * @returns The age string.
66
+ */
67
+ export declare function calculateAgeString(birthDateStr: string, endDateStr?: string): string | undefined;
68
+ /**
69
+ * Returns all questionnaire answers as a map by link ID.
70
+ * @param response The questionnaire response resource.
71
+ * @returns Questionnaire answers mapped by link ID.
72
+ */
73
+ export declare function getQuestionnaireAnswers(response: QuestionnaireResponse): Record<string, QuestionnaireResponseItemAnswer>;
74
+ /**
75
+ * Returns an extension value by extension URLs.
76
+ * @param resource The base resource.
77
+ * @param urls Array of extension URLs. Each entry represents a nested extension.
78
+ * @returns The extension value if found; undefined otherwise.
79
+ */
80
+ export declare function getExtensionValue(resource: Resource, ...urls: string[]): string | undefined;
81
+ /**
82
+ * FHIR JSON stringify.
83
+ * Removes properties with empty string values.
84
+ * Removes objects with zero properties.
85
+ * See: https://www.hl7.org/fhir/json.html
86
+ * @param value The input value.
87
+ * @param pretty Optional flag to pretty-print the JSON.
88
+ * @returns The resulting JSON string.
89
+ */
90
+ export declare function stringify(value: any, pretty?: boolean): string;
91
+ /**
92
+ * Resource equality.
93
+ * Ignores meta.versionId and meta.lastUpdated.
94
+ * @param object1 The first object.
95
+ * @param object2 The second object.
96
+ * @returns True if the objects are equal.
97
+ */
98
+ export declare function deepEquals(object1: unknown, object2: unknown, path?: string): boolean;
99
+ /**
100
+ * Returns true if the input string is a UUID.
101
+ * @param input The input string.
102
+ * @returns True if the input string matches the UUID format.
103
+ */
104
+ export declare function isUUID(input: string): boolean;
105
+ /**
106
+ * Returns true if the input is an object.
107
+ * @param object The candidate object.
108
+ * @returns True if the input is a non-null non-undefined object.
109
+ */
110
+ export declare function isObject(obj: unknown): obj is Record<string, unknown>;
111
+ /**
112
+ * Returns true if the input array is an array of strings.
113
+ * @param arr Input array.
114
+ * @returns True if the input array is an array of strings.
115
+ */
116
+ export declare function isStringArray(arr: any[]): arr is string[];
117
+ /**
118
+ * Converts an ArrayBuffer to hex string.
119
+ * See: https://stackoverflow.com/a/55200387
120
+ * @param arrayBuffer The input array buffer.
121
+ * @returns The resulting hex string.
122
+ */
123
+ export declare function arrayBufferToHex(arrayBuffer: ArrayBuffer): string;
124
+ /**
125
+ * Converts an ArrayBuffer to a base-64 encoded string.
126
+ * @param arrayBuffer The input array buffer.
127
+ * @returns The base-64 encoded string.
128
+ */
129
+ export declare function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string;
130
+ export declare function capitalize(word: string): string;
131
+ export declare function isLowerCase(c: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "0.9.3",
3
+ "version": "0.9.6",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",
@@ -17,7 +17,8 @@
17
17
  "test": "jest"
18
18
  },
19
19
  "devDependencies": {
20
- "@medplum/fhirtypes": "0.9.3",
20
+ "@medplum/fhirtypes": "0.9.6",
21
+ "@types/nodemailer": "6.4.4",
21
22
  "fast-json-patch": "3.1.1"
22
23
  },
23
24
  "main": "dist/cjs/index.js",