vet-sdk-core-ts 0.4.23 → 0.4.24
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/dist/scheduling.d.ts +26 -0
- package/dist/scheduling.js +24 -0
- package/package.json +2 -2
package/dist/scheduling.d.ts
CHANGED
|
@@ -27,6 +27,32 @@ export declare function buildVeterinarySchedulingSearch(resourceType: Veterinary
|
|
|
27
27
|
}>;
|
|
28
28
|
}>[];
|
|
29
29
|
}>;
|
|
30
|
+
/** Builds the clinic-wide `_search` envelope for responses recorded inside an inclusive time period. */
|
|
31
|
+
export declare function buildVeterinaryAppointmentResponseSearchPeriod(input: Readonly<{
|
|
32
|
+
from: string;
|
|
33
|
+
to: string;
|
|
34
|
+
}>): Readonly<{
|
|
35
|
+
data: readonly Readonly<{
|
|
36
|
+
resource: Readonly<{
|
|
37
|
+
resourceType: VeterinarySchedulingResourceType;
|
|
38
|
+
id: string;
|
|
39
|
+
meta: Readonly<{
|
|
40
|
+
claims: Readonly<Record<string, readonly string[]>>;
|
|
41
|
+
}>;
|
|
42
|
+
}>;
|
|
43
|
+
}>[];
|
|
44
|
+
}>;
|
|
45
|
+
export type VeterinaryAppointmentResponseEmailPayload = Readonly<{
|
|
46
|
+
to: string;
|
|
47
|
+
subject: string;
|
|
48
|
+
text: string;
|
|
49
|
+
metadata: Readonly<Record<string, string>>;
|
|
50
|
+
}>;
|
|
51
|
+
/** Converts the governed English AppointmentResponse Communication projection into an email-adapter payload. */
|
|
52
|
+
export declare function convertVeterinaryAppointmentResponseCommunicationToEnglishEmail(input: Readonly<{
|
|
53
|
+
recipientEmail: string;
|
|
54
|
+
communication: unknown;
|
|
55
|
+
}>): VeterinaryAppointmentResponseEmailPayload;
|
|
30
56
|
/** Reads canonical GW search matches from `body.data[].resource`. */
|
|
31
57
|
export declare function readVeterinarySchedulingSearch(body: unknown, expectedResourceType: VeterinarySchedulingResourceType): readonly VeterinarySchedulingFlatClaimsResource[];
|
|
32
58
|
export type VeterinaryScheduleReconciliation = Readonly<{
|
package/dist/scheduling.js
CHANGED
|
@@ -28,6 +28,30 @@ export function buildVeterinarySchedulingSearch(resourceType, claims) {
|
|
|
28
28
|
});
|
|
29
29
|
return Object.freeze({ data: Object.freeze([Object.freeze({ resource })]) });
|
|
30
30
|
}
|
|
31
|
+
/** Builds the clinic-wide `_search` envelope for responses recorded inside an inclusive time period. */
|
|
32
|
+
export function buildVeterinaryAppointmentResponseSearchPeriod(input) {
|
|
33
|
+
const from = Date.parse(input.from);
|
|
34
|
+
const to = Date.parse(input.to);
|
|
35
|
+
if (!Number.isFinite(from) || !Number.isFinite(to) || from > to)
|
|
36
|
+
throw new Error('appointment_response_search_period_invalid');
|
|
37
|
+
return buildVeterinarySchedulingSearch('AppointmentResponse', {
|
|
38
|
+
'VeterinaryAppointmentResponse.respondedAt': [`ge${new Date(from).toISOString()}`, `le${new Date(to).toISOString()}`],
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** Converts the governed English AppointmentResponse Communication projection into an email-adapter payload. */
|
|
42
|
+
export function convertVeterinaryAppointmentResponseCommunicationToEnglishEmail(input) {
|
|
43
|
+
const email = String(input.recipientEmail || '').trim().toLowerCase();
|
|
44
|
+
const resource = input.communication;
|
|
45
|
+
const claims = resource?.resourceType === 'Communication' ? resource?.meta?.claims : undefined;
|
|
46
|
+
const references = Array.isArray(claims?.['Communication.content-reference']) ? claims['Communication.content-reference'].map(String) : [];
|
|
47
|
+
const appointmentResponse = references.find((value) => value.startsWith('AppointmentResponse/'));
|
|
48
|
+
const appointment = references.find((value) => value.startsWith('Appointment/'));
|
|
49
|
+
const text = String(claims?.['Communication.text'] || '').trim();
|
|
50
|
+
const recipient = String(claims?.['Communication.recipient'] || '').trim();
|
|
51
|
+
if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email) || !appointmentResponse || !appointment || !text || !recipient)
|
|
52
|
+
throw new Error('appointment_response_email_invalid');
|
|
53
|
+
return Object.freeze({ to: email, subject: 'Appointment response', text, metadata: Object.freeze({ appointmentResponse, appointment, recipient, language: 'en' }) });
|
|
54
|
+
}
|
|
31
55
|
/** Reads canonical GW search matches from `body.data[].resource`. */
|
|
32
56
|
export function readVeterinarySchedulingSearch(body, expectedResourceType) {
|
|
33
57
|
if (!body || typeof body !== 'object' || !Array.isArray(body.data)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vet-sdk-core-ts",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.24",
|
|
4
4
|
"description": "Browser-safe VetChain core contracts and governed animal species identifiers",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Connecting Solution & Applications Ltd",
|
|
@@ -76,6 +76,6 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@noble/hashes": "^2.2.0",
|
|
78
78
|
"gdc-common-utils-ts": "2.9.10",
|
|
79
|
-
"vet-data-utils-ts": "0.5.
|
|
79
|
+
"vet-data-utils-ts": "0.5.13"
|
|
80
80
|
}
|
|
81
81
|
}
|