vet-sdk-core-ts 0.4.4 → 0.4.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.
package/README.md CHANGED
@@ -64,14 +64,17 @@ findVetChainSpeciesByTaxonomyId("9685")?.key; // "Cat"
64
64
  ## Digital-twin search
65
65
 
66
66
  `buildVeterinaryDigitalTwinSearchRequest` accepts only one governed section,
67
- selected resource families, display text and dates. It returns both the FHIR
67
+ free text and dates. It returns both the basic FHIR
68
68
  `Parameters` body and the `filters` map for `DigitalTwinSdk.search`; callers do
69
- not author `Composition.section` or resource claim names.
69
+ not author `Composition.section`, resource families or flat claim names. The returned public
70
+ resource is `ResearchSubject`, so the Node SDK sends
71
+ `POST digitaltwin/.../ResearchSubject/_search`; the `Composition.*` fields
72
+ inside GW index the canonical Composition embedded in that ResearchSubject.
70
73
 
71
74
  ```ts
72
75
  const request = buildVeterinaryDigitalTwinSearchRequest({
73
76
  thid: crypto.randomUUID(),
74
- search: { section, resourceTypes, text, dateFrom, ...(dateTo ? { dateTo } : {}) },
77
+ search: { section, text, dateFrom, ...(dateTo ? { dateTo } : {}) },
75
78
  })
76
79
 
77
80
  await digitalTwins.search(routeContext, {
@@ -48,7 +48,7 @@ export type VeterinaryBreakGlassSmartAuthorization = Readonly<{
48
48
  }>;
49
49
  export type VeterinaryDigitalTwinSearchRequest = Readonly<{
50
50
  format: VeterinaryDigitalTwinFormat;
51
- resourceType: 'Composition';
51
+ resourceType: 'ResearchSubject';
52
52
  filters: Readonly<Record<string, string | readonly string[]>>;
53
53
  payload: Readonly<{
54
54
  thid: string;
@@ -86,9 +86,11 @@ export declare function buildVeterinaryBreakGlassSmartRequest(input: Readonly<{
86
86
  audience: string;
87
87
  }>): VeterinaryBreakGlassSmartRequest;
88
88
  /**
89
- * Converts browser-safe search values into both FHIR Parameters and the exact
90
- * filter map accepted by the Node DigitalTwin SDK. Callers never choose flat
91
- * claim names.
89
+ * Converts browser-safe section, text and date values into the basic FHIR
90
+ * Parameters accepted by the Node DigitalTwin SDK. The public resource is a
91
+ * ResearchSubject; GW applies these business filters to its embedded canonical
92
+ * Composition and derived clinical index. Callers never choose claim names or
93
+ * clinical resource families; coded search can be added as a separate profile.
92
94
  */
93
95
  export declare function buildVeterinaryDigitalTwinSearchRequest(input: Readonly<{
94
96
  thid: string;
@@ -60,46 +60,44 @@ export function buildVeterinaryBreakGlassSmartRequest(input) {
60
60
  });
61
61
  }
62
62
  /**
63
- * Converts browser-safe search values into both FHIR Parameters and the exact
64
- * filter map accepted by the Node DigitalTwin SDK. Callers never choose flat
65
- * claim names.
63
+ * Converts browser-safe section, text and date values into the basic FHIR
64
+ * Parameters accepted by the Node DigitalTwin SDK. The public resource is a
65
+ * ResearchSubject; GW applies these business filters to its embedded canonical
66
+ * Composition and derived clinical index. Callers never choose claim names or
67
+ * clinical resource families; coded search can be added as a separate profile.
66
68
  */
67
69
  export function buildVeterinaryDigitalTwinSearchRequest(input) {
68
- const search = parseVeterinaryDigitalTwinSearch(input.search);
70
+ const rawSearch = (input.search || {});
71
+ const requestedSection = String(rawSearch.section || '').trim();
72
+ const defaultProfile = (VeterinaryDigitalTwinSectionSearchProfiles[requestedSection] || [])[0];
73
+ const search = parseVeterinaryDigitalTwinSearch({
74
+ ...rawSearch,
75
+ resourceTypes: defaultProfile ? [defaultProfile.resourceType] : [],
76
+ });
69
77
  const format = input.format || VeterinaryDigitalTwinFormats.R4;
70
78
  const parameter = [
71
- { name: 'Composition.section', valueString: search.section },
79
+ { name: 'section', valueString: search.section },
80
+ { name: 'text', valueString: search.text },
81
+ { name: 'date-from', valueDate: search.dateFrom },
72
82
  ];
73
- const profiles = VeterinaryDigitalTwinSectionSearchProfiles[search.section] || [];
74
- for (const resourceType of search.resourceTypes) {
75
- const selectedProfile = profiles.find(profile => profile.resourceType === resourceType);
76
- if (!selectedProfile)
77
- throw new TypeError('veterinary_digital_twin_resource_invalid');
78
- parameter.push({ name: selectedProfile.codeDisplayClaim, valueString: search.text }, { name: selectedProfile.dateClaim, valueString: `ge${search.dateFrom}` });
79
- if (search.dateTo)
80
- parameter.push({ name: selectedProfile.dateClaim, valueString: `le${search.dateTo}` });
81
- }
82
- const filters = {};
83
- for (const item of parameter) {
84
- const existing = filters[item.name];
85
- if (!existing)
86
- filters[item.name] = item.valueString;
87
- else if (Array.isArray(existing))
88
- existing.push(item.valueString);
89
- else
90
- filters[item.name] = [existing, item.valueString];
91
- }
83
+ if (search.dateTo)
84
+ parameter.push({ name: 'date-to', valueDate: search.dateTo });
85
+ const filters = {
86
+ section: search.section,
87
+ text: search.text,
88
+ 'date-from': search.dateFrom,
89
+ ...(search.dateTo ? { 'date-to': search.dateTo } : {}),
90
+ };
92
91
  return Object.freeze({
93
92
  format,
94
93
  filters: Object.freeze(filters),
95
- // GW stores the pseudonymous twin as a Composition. The selected nested
96
- // resource families become repeated Parameters entries; they never change
97
- // the asynchronous route resource type.
98
- resourceType: 'Composition',
94
+ // ResearchSubject is the public twin. GW searches the embedded canonical
95
+ // Composition and derived clinical index; the route type never changes.
96
+ resourceType: 'ResearchSubject',
99
97
  payload: {
100
98
  thid: bounded(input.thid, 'thid'),
101
99
  body: format === VeterinaryDigitalTwinFormats.Api
102
- ? { data: [{ type: 'Composition-search-request-v1.0', resource: { resourceType: 'Parameters', parameter } }] }
100
+ ? { data: [{ type: 'ResearchSubject-search-request-v1.0', resource: { resourceType: 'Parameters', parameter } }] }
103
101
  : { resourceType: 'Parameters', parameter },
104
102
  },
105
103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vet-sdk-core-ts",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
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",