vet-sdk-core-ts 0.4.2 → 0.4.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.
- package/README.md +21 -0
- package/dist/gateway-contract.d.ts +6 -0
- package/dist/gateway-contract.js +30 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -35,3 +35,24 @@ import {
|
|
|
35
35
|
VetChainDomesticAnimalSpecies.DomesticFerret.ncbiTaxonomyId; // "9669"
|
|
36
36
|
findVetChainSpeciesByTaxonomyId("9685")?.key; // "Cat"
|
|
37
37
|
```
|
|
38
|
+
|
|
39
|
+
## Digital-twin search
|
|
40
|
+
|
|
41
|
+
`buildVeterinaryDigitalTwinSearchRequest` accepts only one governed section,
|
|
42
|
+
selected resource families, display text and dates. It returns both the FHIR
|
|
43
|
+
`Parameters` body and the `filters` map for `DigitalTwinSdk.search`; callers do
|
|
44
|
+
not author `Composition.section` or resource claim names.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const request = buildVeterinaryDigitalTwinSearchRequest({
|
|
48
|
+
thid: crypto.randomUUID(),
|
|
49
|
+
search: { section, resourceTypes, text, dateFrom, ...(dateTo ? { dateTo } : {}) },
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
await digitalTwins.search(routeContext, {
|
|
53
|
+
thid: request.payload.thid,
|
|
54
|
+
format: request.format,
|
|
55
|
+
resourceType: request.resourceType,
|
|
56
|
+
filters: request.filters,
|
|
57
|
+
})
|
|
58
|
+
```
|
|
@@ -29,6 +29,7 @@ export type VeterinaryBreakGlassSmartRequest = Readonly<{
|
|
|
29
29
|
export type VeterinaryDigitalTwinSearchRequest = Readonly<{
|
|
30
30
|
format: VeterinaryDigitalTwinFormat;
|
|
31
31
|
resourceType: 'Composition';
|
|
32
|
+
filters: Readonly<Record<string, string | readonly string[]>>;
|
|
32
33
|
payload: Readonly<{
|
|
33
34
|
thid: string;
|
|
34
35
|
body: Readonly<Record<string, unknown>>;
|
|
@@ -47,6 +48,11 @@ export declare function buildVeterinaryBreakGlassSmartRequest(input: Readonly<{
|
|
|
47
48
|
vpToken: string;
|
|
48
49
|
audience: string;
|
|
49
50
|
}>): VeterinaryBreakGlassSmartRequest;
|
|
51
|
+
/**
|
|
52
|
+
* Converts browser-safe search values into both FHIR Parameters and the exact
|
|
53
|
+
* filter map accepted by the Node DigitalTwin SDK. Callers never choose flat
|
|
54
|
+
* claim names.
|
|
55
|
+
*/
|
|
50
56
|
export declare function buildVeterinaryDigitalTwinSearchRequest(input: Readonly<{
|
|
51
57
|
thid: string;
|
|
52
58
|
format?: VeterinaryDigitalTwinFormat;
|
package/dist/gateway-contract.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VeterinaryBreakGlassMaxLifetimeSeconds, VeterinaryDigitalTwinFormats, parseVetChainAnimalCardDid, parseVeterinaryBreakGlassRequestData, parseVeterinaryDigitalTwinSearch, } from 'vet-data-utils-ts';
|
|
1
|
+
import { VeterinaryBreakGlassMaxLifetimeSeconds, VeterinaryDigitalTwinFormats, VeterinaryDigitalTwinSectionSearchProfiles, parseVetChainAnimalCardDid, parseVeterinaryBreakGlassRequestData, parseVeterinaryDigitalTwinSearch, } from 'vet-data-utils-ts';
|
|
2
2
|
export function buildVetGatewayRoutePrefix(context) {
|
|
3
3
|
const tenantId = bounded(context.tenantId, 'tenantId');
|
|
4
4
|
const jurisdiction = bounded(context.jurisdiction, 'jurisdiction').toUpperCase();
|
|
@@ -34,18 +34,42 @@ export function buildVeterinaryBreakGlassSmartRequest(input) {
|
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Converts browser-safe search values into both FHIR Parameters and the exact
|
|
39
|
+
* filter map accepted by the Node DigitalTwin SDK. Callers never choose flat
|
|
40
|
+
* claim names.
|
|
41
|
+
*/
|
|
37
42
|
export function buildVeterinaryDigitalTwinSearchRequest(input) {
|
|
38
43
|
const search = parseVeterinaryDigitalTwinSearch(input.search);
|
|
39
44
|
const format = input.format || VeterinaryDigitalTwinFormats.R4;
|
|
40
45
|
const parameter = [
|
|
41
|
-
{ name: 'section', valueString: search.section },
|
|
42
|
-
{ name: search.claim, valueString: search.value },
|
|
46
|
+
{ name: 'Composition.section', valueString: search.section },
|
|
43
47
|
];
|
|
48
|
+
const profiles = VeterinaryDigitalTwinSectionSearchProfiles[search.section] || [];
|
|
49
|
+
for (const resourceType of search.resourceTypes) {
|
|
50
|
+
const selectedProfile = profiles.find(profile => profile.resourceType === resourceType);
|
|
51
|
+
if (!selectedProfile)
|
|
52
|
+
throw new TypeError('veterinary_digital_twin_resource_invalid');
|
|
53
|
+
parameter.push({ name: selectedProfile.codeDisplayClaim, valueString: search.text }, { name: selectedProfile.dateClaim, valueString: `ge${search.dateFrom}` });
|
|
54
|
+
if (search.dateTo)
|
|
55
|
+
parameter.push({ name: selectedProfile.dateClaim, valueString: `le${search.dateTo}` });
|
|
56
|
+
}
|
|
57
|
+
const filters = {};
|
|
58
|
+
for (const item of parameter) {
|
|
59
|
+
const existing = filters[item.name];
|
|
60
|
+
if (!existing)
|
|
61
|
+
filters[item.name] = item.valueString;
|
|
62
|
+
else if (Array.isArray(existing))
|
|
63
|
+
existing.push(item.valueString);
|
|
64
|
+
else
|
|
65
|
+
filters[item.name] = [existing, item.valueString];
|
|
66
|
+
}
|
|
44
67
|
return Object.freeze({
|
|
45
68
|
format,
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
//
|
|
69
|
+
filters: Object.freeze(filters),
|
|
70
|
+
// GW stores the pseudonymous twin as a Composition. The selected nested
|
|
71
|
+
// resource families become repeated Parameters entries; they never change
|
|
72
|
+
// the asynchronous route resource type.
|
|
49
73
|
resourceType: 'Composition',
|
|
50
74
|
payload: {
|
|
51
75
|
thid: bounded(input.thid, 'thid'),
|
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.3",
|
|
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",
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@noble/hashes": "^2.2.0",
|
|
57
|
-
"vet-data-utils-ts": "0.3.
|
|
57
|
+
"vet-data-utils-ts": "0.3.1"
|
|
58
58
|
}
|
|
59
59
|
}
|