vet-sdk-core-ts 0.4.5 → 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,17 +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. The returned public
69
+ not author `Composition.section`, resource families or flat claim names. The returned public
70
70
  resource is `ResearchSubject`, so the Node SDK sends
71
71
  `POST digitaltwin/.../ResearchSubject/_search`; the `Composition.*` fields
72
- filter the canonical Composition embedded in that ResearchSubject.
72
+ inside GW index the canonical Composition embedded in that ResearchSubject.
73
73
 
74
74
  ```ts
75
75
  const request = buildVeterinaryDigitalTwinSearchRequest({
76
76
  thid: crypto.randomUUID(),
77
- search: { section, resourceTypes, text, dateFrom, ...(dateTo ? { dateTo } : {}) },
77
+ search: { section, text, dateFrom, ...(dateTo ? { dateTo } : {}) },
78
78
  })
79
79
 
80
80
  await digitalTwins.search(routeContext, {
@@ -86,10 +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. The public twin resource is
91
- * ResearchSubject; Composition.* filters address its embedded canonical
92
- * Composition index. Callers never choose flat 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.
93
94
  */
94
95
  export declare function buildVeterinaryDigitalTwinSearchRequest(input: Readonly<{
95
96
  thid: string;
@@ -60,42 +60,39 @@ 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. The public twin resource is
65
- * ResearchSubject; Composition.* filters address its embedded canonical
66
- * Composition index. Callers never choose flat 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.
67
68
  */
68
69
  export function buildVeterinaryDigitalTwinSearchRequest(input) {
69
- 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
+ });
70
77
  const format = input.format || VeterinaryDigitalTwinFormats.R4;
71
78
  const parameter = [
72
- { 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 },
73
82
  ];
74
- const profiles = VeterinaryDigitalTwinSectionSearchProfiles[search.section] || [];
75
- for (const resourceType of search.resourceTypes) {
76
- const selectedProfile = profiles.find(profile => profile.resourceType === resourceType);
77
- if (!selectedProfile)
78
- throw new TypeError('veterinary_digital_twin_resource_invalid');
79
- parameter.push({ name: selectedProfile.codeDisplayClaim, valueString: search.text }, { name: selectedProfile.dateClaim, valueString: `ge${search.dateFrom}` });
80
- if (search.dateTo)
81
- parameter.push({ name: selectedProfile.dateClaim, valueString: `le${search.dateTo}` });
82
- }
83
- const filters = {};
84
- for (const item of parameter) {
85
- const existing = filters[item.name];
86
- if (!existing)
87
- filters[item.name] = item.valueString;
88
- else if (Array.isArray(existing))
89
- existing.push(item.valueString);
90
- else
91
- filters[item.name] = [existing, item.valueString];
92
- }
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
+ };
93
91
  return Object.freeze({
94
92
  format,
95
93
  filters: Object.freeze(filters),
96
- // ResearchSubject is the public twin. Its embedded canonical Composition
97
- // indexes the selected nested resource families as repeated Parameters;
98
- // those filters never change the asynchronous route resource type.
94
+ // ResearchSubject is the public twin. GW searches the embedded canonical
95
+ // Composition and derived clinical index; the route type never changes.
99
96
  resourceType: 'ResearchSubject',
100
97
  payload: {
101
98
  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.5",
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",