@icure/cardinal-sdk 2.13.1 → 2.13.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.
@@ -1,5 +1,7 @@
1
1
  // auto-generated file
2
- import { expectString, expectStringEnum, extractEntry } from '../../internal/JsonDecodeUtils.mjs';
2
+ import { expectObject, expectString, expectStringEnum, extractEntry } from '../../internal/JsonDecodeUtils.mjs';
3
+ import { randomUuid } from '../../utils/Id.mjs';
4
+ import { Identifier } from '../base/Identifier.mjs';
3
5
  import { AsserterType } from './AsserterType.mjs';
4
6
  /**
5
7
  *
@@ -14,31 +16,65 @@ import { AsserterType } from './AsserterType.mjs';
14
16
  * are asserters, and the
15
17
  * same healthcare element may carry more than one of them.
16
18
  *
17
- * The two fields must agree: [asserterType] declares which kind of entity [asserterId] points at.
18
- * [AsserterTypeDto]
19
- * bounds the vocabulary, but nothing enforces the *pairing* - the field is encrypted, so the
20
- * server never sees the
21
- * values and cannot validate or repair them; that invariant is owned by the SDK.
19
+ * The party is named in exactly one of two ways, and exactly one of the two fields must be set:
20
+ * - [localAsserterIdentifier] names a party stored in this iCure instance: an id, plus the
21
+ * [AsserterTypeDto] saying
22
+ * which kind of record that id points at;
23
+ * - [externalAsserterIdentifier] names a party that has no record here, through a business
24
+ * [IdentifierDto] issued by
25
+ * another system. There is deliberately no [AsserterTypeDto] on this branch: the kind of a
26
+ * record we do not store is
27
+ * not knowable to us.
28
+ *
29
+ * The exactly-one rule is **not** checked on this DTO. It is checked one layer down, in
30
+ * `HealthElementAsserter`'s
31
+ * `init`: mapping this DTO constructs one, so a violation still surfaces as a `400`, and the rule
32
+ * also covers the write
33
+ * paths that never build a DTO at all. This class only checks that [LocalAsserterIdentifier.id] is
34
+ * not blank. Nothing
35
+ * enforces the *pairing* inside [LocalAsserterIdentifier]: [AsserterTypeDto] bounds the
36
+ * vocabulary, not what
37
+ * [LocalAsserterIdentifier.id] actually points at; that invariant is owned by the SDK.
22
38
  *
23
39
  * Note on organisations: an organisation (hospital, practice, care home, ...) is not a distinct
24
40
  * asserter type.
25
41
  * Organisations are stored as healthcare party records, distinguished from individual
26
42
  * practitioners by tags set by the
27
- * client, so an organisation asserter is an entry with `asserterType =
28
- * AsserterTypeDto.healthcareParty` whose
29
- * [asserterId] points to such a record. The association between a practitioner and the
30
- * organisation they were acting
31
- * for at the time of the assertion is deliberately NOT modelled here.
43
+ * client, so an organisation asserter is a [localAsserterIdentifier] with `type =
44
+ * AsserterTypeDto.healthcareParty`
45
+ * whose `id` points to such a record. The association between a practitioner and the organisation
46
+ * they were acting for
47
+ * at the time of the assertion is deliberately NOT modelled here.
32
48
  */
33
49
  export class HealthElementAsserter {
34
50
  constructor(partial) {
35
- this.asserterId = partial.asserterId;
36
- this.asserterType = partial.asserterType;
51
+ /**
52
+ *
53
+ *
54
+ * The asserting party, as a reference to a record stored in this instance. Null when the party is
55
+ * named by
56
+ * [externalAsserterIdentifier].
57
+ */
58
+ this.localAsserterIdentifier = undefined;
59
+ /**
60
+ *
61
+ *
62
+ * The asserting party, as a business identifier from a system that is not this one. Null when the
63
+ * party is named by
64
+ * [localAsserterIdentifier]. Carries no [AsserterTypeDto].
65
+ */
66
+ this.externalAsserterIdentifier = undefined;
67
+ if ('localAsserterIdentifier' in partial)
68
+ this.localAsserterIdentifier = partial.localAsserterIdentifier;
69
+ if ('externalAsserterIdentifier' in partial)
70
+ this.externalAsserterIdentifier = partial.externalAsserterIdentifier;
37
71
  }
38
72
  toJSON() {
39
73
  const res = {};
40
- res['asserterId'] = this.asserterId;
41
- res['asserterType'] = this.asserterType;
74
+ if (this.localAsserterIdentifier != undefined)
75
+ res['localAsserterIdentifier'] = this.localAsserterIdentifier.toJSON();
76
+ if (this.externalAsserterIdentifier != undefined)
77
+ res['externalAsserterIdentifier'] = this.externalAsserterIdentifier.toJSON();
42
78
  return res;
43
79
  }
44
80
  static fromJSON(json, ignoreUnknownKeys = false, path = ['HealthElementAsserter']) {
@@ -46,8 +82,8 @@ export class HealthElementAsserter {
46
82
  throw new Error(`Expected json object at path ${path.join("")}`);
47
83
  const jCpy = Object.assign({}, json);
48
84
  const res = new HealthElementAsserter({
49
- asserterId: expectString(extractEntry(jCpy, 'asserterId', true, path), false, [...path, ".asserterId"]),
50
- asserterType: expectStringEnum(extractEntry(jCpy, 'asserterType', true, path), false, [...path, ".asserterType"], AsserterType, 'AsserterType'),
85
+ localAsserterIdentifier: expectObject(extractEntry(jCpy, 'localAsserterIdentifier', false, path), true, ignoreUnknownKeys, [...path, ".localAsserterIdentifier"], HealthElementAsserter.LocalAsserterIdentifier.fromJSON),
86
+ externalAsserterIdentifier: expectObject(extractEntry(jCpy, 'externalAsserterIdentifier', false, path), true, ignoreUnknownKeys, [...path, ".externalAsserterIdentifier"], HealthElementAsserter.ExternalAsserterIdentifier.fromJSON),
51
87
  });
52
88
  if (!ignoreUnknownKeys) {
53
89
  const unused = Object.keys(jCpy);
@@ -57,3 +93,79 @@ export class HealthElementAsserter {
57
93
  return res;
58
94
  }
59
95
  }
96
+ (function (HealthElementAsserter) {
97
+ /**
98
+ *
99
+ *
100
+ * A reference to the record, stored in iCure.
101
+ */
102
+ class LocalAsserterIdentifier {
103
+ constructor(partial) {
104
+ var _a;
105
+ this.id = (_a = partial.id) !== null && _a !== void 0 ? _a : randomUuid();
106
+ this.type = partial.type;
107
+ }
108
+ toJSON() {
109
+ const res = {};
110
+ res['id'] = this.id;
111
+ res['type'] = this.type;
112
+ return res;
113
+ }
114
+ static fromJSON(json, ignoreUnknownKeys = false, path = ['LocalAsserterIdentifier']) {
115
+ if (typeof json != 'object')
116
+ throw new Error(`Expected json object at path ${path.join("")}`);
117
+ const jCpy = Object.assign({}, json);
118
+ const res = new LocalAsserterIdentifier({
119
+ id: expectString(extractEntry(jCpy, 'id', true, path), false, [...path, ".id"]),
120
+ type: expectStringEnum(extractEntry(jCpy, 'type', true, path), false, [...path, ".type"], AsserterType, 'AsserterType'),
121
+ });
122
+ if (!ignoreUnknownKeys) {
123
+ const unused = Object.keys(jCpy);
124
+ if (unused.length > 0)
125
+ throw new Error(`Unexpected key(s) for json object LocalAsserterIdentifier at path ${path.join("")}: ${unused}`);
126
+ }
127
+ return res;
128
+ }
129
+ }
130
+ HealthElementAsserter.LocalAsserterIdentifier = LocalAsserterIdentifier;
131
+ /**
132
+ *
133
+ *
134
+ * The party making the assertion, when it has no record in this iCure instance.
135
+ *
136
+ * The party is named by a business [identifier] issued by another system: a national registry
137
+ * number, an entry in
138
+ * the sending hospital's directory, and so on. Because the record lives elsewhere there is no
139
+ * [AsserterTypeDto]
140
+ * here - the kind of a record we do not store is not knowable to us. The wrapper around the
141
+ * [IdentifierDto] mirrors
142
+ * [LocalAsserterIdentifier] on the other branch, and is where anything specific to an external
143
+ * asserter would go:
144
+ * [IdentifierDto] itself is shared by every `identifiers` field in the model and cannot carry it.
145
+ */
146
+ class ExternalAsserterIdentifier {
147
+ constructor(partial) {
148
+ this.identifier = partial.identifier;
149
+ }
150
+ toJSON() {
151
+ const res = {};
152
+ res['identifier'] = this.identifier.toJSON();
153
+ return res;
154
+ }
155
+ static fromJSON(json, ignoreUnknownKeys = false, path = ['ExternalAsserterIdentifier']) {
156
+ if (typeof json != 'object')
157
+ throw new Error(`Expected json object at path ${path.join("")}`);
158
+ const jCpy = Object.assign({}, json);
159
+ const res = new ExternalAsserterIdentifier({
160
+ identifier: expectObject(extractEntry(jCpy, 'identifier', true, path), false, ignoreUnknownKeys, [...path, ".identifier"], Identifier.fromJSON),
161
+ });
162
+ if (!ignoreUnknownKeys) {
163
+ const unused = Object.keys(jCpy);
164
+ if (unused.length > 0)
165
+ throw new Error(`Unexpected key(s) for json object ExternalAsserterIdentifier at path ${path.join("")}: ${unused}`);
166
+ }
167
+ return res;
168
+ }
169
+ }
170
+ HealthElementAsserter.ExternalAsserterIdentifier = ExternalAsserterIdentifier;
171
+ })(HealthElementAsserter || (HealthElementAsserter = {}));
@@ -17,4 +17,4 @@ import { TimePicker } from './TimePicker.mjs';
17
17
  * validation rules, and optional codification and tagging.
18
18
  * /
19
19
  */
20
- export type Field = DropdownField | TimePicker | RadioButton | DatePicker | MeasureField | TextField | DateTimePicker | MultipleChoice | CheckBox | NumberField;
20
+ export type Field = DatePicker | MeasureField | DateTimePicker | TextField | CheckBox | DropdownField | NumberField | TimePicker | RadioButton | MultipleChoice;
@@ -6,7 +6,7 @@ import { FieldsGroup } from './FieldsGroup.mjs';
6
6
  * groups.
7
7
  * /
8
8
  */
9
- export type StructureElement = Field | FieldsGroup;
9
+ export type StructureElement = FieldsGroup | Field;
10
10
  export declare namespace StructureElement {
11
11
  function fromJSON(json: any, ignoreUnknownKeys?: boolean, path?: Array<string>): StructureElement;
12
12
  }
@@ -14,17 +14,17 @@ export var StructureElement;
14
14
  (function (StructureElement) {
15
15
  function fromJSON(json, ignoreUnknownKeys = false, path = ['StructureElement']) {
16
16
  switch (json.$ktClass) {
17
- case 'com.icure.cardinal.sdk.model.embed.form.template.DropdownField': return DropdownField.fromJSON(json, ignoreUnknownKeys);
18
- case 'com.icure.cardinal.sdk.model.embed.form.template.TimePicker': return TimePicker.fromJSON(json, ignoreUnknownKeys);
19
- case 'com.icure.cardinal.sdk.model.embed.form.template.RadioButton': return RadioButton.fromJSON(json, ignoreUnknownKeys);
17
+ case 'com.icure.cardinal.sdk.model.embed.form.template.FieldsGroup': return FieldsGroup.fromJSON(json, ignoreUnknownKeys);
20
18
  case 'com.icure.cardinal.sdk.model.embed.form.template.DatePicker': return DatePicker.fromJSON(json, ignoreUnknownKeys);
21
19
  case 'com.icure.cardinal.sdk.model.embed.form.template.MeasureField': return MeasureField.fromJSON(json, ignoreUnknownKeys);
22
- case 'com.icure.cardinal.sdk.model.embed.form.template.TextField': return TextField.fromJSON(json, ignoreUnknownKeys);
23
20
  case 'com.icure.cardinal.sdk.model.embed.form.template.DateTimePicker': return DateTimePicker.fromJSON(json, ignoreUnknownKeys);
24
- case 'com.icure.cardinal.sdk.model.embed.form.template.MultipleChoice': return MultipleChoice.fromJSON(json, ignoreUnknownKeys);
21
+ case 'com.icure.cardinal.sdk.model.embed.form.template.TextField': return TextField.fromJSON(json, ignoreUnknownKeys);
25
22
  case 'com.icure.cardinal.sdk.model.embed.form.template.CheckBox': return CheckBox.fromJSON(json, ignoreUnknownKeys);
23
+ case 'com.icure.cardinal.sdk.model.embed.form.template.DropdownField': return DropdownField.fromJSON(json, ignoreUnknownKeys);
26
24
  case 'com.icure.cardinal.sdk.model.embed.form.template.NumberField': return NumberField.fromJSON(json, ignoreUnknownKeys);
27
- case 'com.icure.cardinal.sdk.model.embed.form.template.FieldsGroup': return FieldsGroup.fromJSON(json, ignoreUnknownKeys);
25
+ case 'com.icure.cardinal.sdk.model.embed.form.template.TimePicker': return TimePicker.fromJSON(json, ignoreUnknownKeys);
26
+ case 'com.icure.cardinal.sdk.model.embed.form.template.RadioButton': return RadioButton.fromJSON(json, ignoreUnknownKeys);
27
+ case 'com.icure.cardinal.sdk.model.embed.form.template.MultipleChoice': return MultipleChoice.fromJSON(json, ignoreUnknownKeys);
28
28
  default: throw new Error('Unexpected discriminator for StructureElement: ' + json.$ktClass);
29
29
  }
30
30
  }
@@ -9,7 +9,7 @@ import { OrPredicate } from './OrPredicate.mjs';
9
9
  * chain.
10
10
  * /
11
11
  */
12
- export type Predicate = KeyValuePredicate | AlwaysPredicate | NotPredicate | AndPredicate | OrPredicate;
12
+ export type Predicate = NotPredicate | AndPredicate | OrPredicate | KeyValuePredicate | AlwaysPredicate;
13
13
  export declare namespace Predicate {
14
14
  function fromJSON(json: any, ignoreUnknownKeys?: boolean, path?: Array<string>): Predicate;
15
15
  }
@@ -8,11 +8,11 @@ export var Predicate;
8
8
  (function (Predicate) {
9
9
  function fromJSON(json, ignoreUnknownKeys = false, path = ['Predicate']) {
10
10
  switch (json.$ktClass) {
11
- case 'com.icure.cardinal.sdk.model.filter.predicate.KeyValuePredicate': return KeyValuePredicate.fromJSON(json, ignoreUnknownKeys);
12
- case 'com.icure.cardinal.sdk.model.filter.predicate.AlwaysPredicate': return AlwaysPredicate.fromJSON(json, ignoreUnknownKeys);
13
11
  case 'com.icure.cardinal.sdk.model.filter.predicate.NotPredicate': return NotPredicate.fromJSON(json, ignoreUnknownKeys);
14
12
  case 'com.icure.cardinal.sdk.model.filter.predicate.AndPredicate': return AndPredicate.fromJSON(json, ignoreUnknownKeys);
15
13
  case 'com.icure.cardinal.sdk.model.filter.predicate.OrPredicate': return OrPredicate.fromJSON(json, ignoreUnknownKeys);
14
+ case 'com.icure.cardinal.sdk.model.filter.predicate.KeyValuePredicate': return KeyValuePredicate.fromJSON(json, ignoreUnknownKeys);
15
+ case 'com.icure.cardinal.sdk.model.filter.predicate.AlwaysPredicate': return AlwaysPredicate.fromJSON(json, ignoreUnknownKeys);
16
16
  default: throw new Error('Unexpected discriminator for Predicate: ' + json.$ktClass);
17
17
  }
18
18
  }