dataconv-client-sdk-ts 0.3.0 → 0.3.1
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 +40 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,23 +50,35 @@ const client = new DataConvClient({
|
|
|
50
50
|
client.setIdToken('<id_token>');
|
|
51
51
|
client.setVpToken('<vp_token>');
|
|
52
52
|
|
|
53
|
-
// 1.
|
|
53
|
+
// 1. Discover frontend field descriptors from the API.
|
|
54
|
+
const apiConfig = await client.getWellKnownApiConfig();
|
|
55
|
+
|
|
56
|
+
// Example UI options:
|
|
57
|
+
const fieldOptions = apiConfig.fields;
|
|
58
|
+
// [
|
|
59
|
+
// { code: 'section', display: 'Departamento o sección: ...' },
|
|
60
|
+
// { code: 'family', display: 'Categoría de este registro...' },
|
|
61
|
+
// ...
|
|
62
|
+
// ]
|
|
63
|
+
|
|
64
|
+
// 2. Create the tenant/software configuration using the current API field keys.
|
|
54
65
|
const createResult = await client.createConfig({
|
|
55
66
|
entries: [
|
|
56
67
|
{
|
|
57
|
-
softwareId: '
|
|
68
|
+
softwareId: 'api-config',
|
|
58
69
|
config: {
|
|
59
70
|
mappingConfig: {
|
|
60
|
-
headerRowIndex:
|
|
71
|
+
headerRowIndex: 3,
|
|
61
72
|
fieldMap: {
|
|
62
|
-
section: '
|
|
63
|
-
family: '
|
|
64
|
-
subfamily: '
|
|
65
|
-
concept: '
|
|
66
|
-
|
|
67
|
-
species: 'ESPECIE',
|
|
73
|
+
section: 'DEPARTAMENTO',
|
|
74
|
+
family: 'CATEGORIA',
|
|
75
|
+
subfamily: 'SUBCATEGORIA',
|
|
76
|
+
concept: 'DESCRIPCION',
|
|
77
|
+
subject_id: 'ID_INTERNO',
|
|
78
|
+
subject_animal-species: 'ESPECIE',
|
|
68
79
|
date: 'FECHA',
|
|
69
|
-
|
|
80
|
+
observation_weight: 'PESO',
|
|
81
|
+
coverage_insurer: 'ASEGURADORA'
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
84
|
}
|
|
@@ -74,42 +86,43 @@ const createResult = await client.createConfig({
|
|
|
74
86
|
]
|
|
75
87
|
});
|
|
76
88
|
|
|
77
|
-
//
|
|
89
|
+
// 3. Wait until the configuration job completes.
|
|
78
90
|
const configResponse = await client.pollConfig({
|
|
79
|
-
thid: createResult.thid
|
|
91
|
+
thid: createResult.thid,
|
|
92
|
+
softwareId: 'api-config'
|
|
80
93
|
});
|
|
81
94
|
|
|
82
|
-
//
|
|
95
|
+
// 4. Upload the Excel or XLSX file for pre-conversion.
|
|
83
96
|
const uploadResult = await client.uploadWithLink(
|
|
84
97
|
'https://example.com/exampleQvetES.xlsx?dl=1',
|
|
85
98
|
{
|
|
86
|
-
softwareId: '
|
|
99
|
+
softwareId: 'api-config',
|
|
87
100
|
fileName: 'exampleQvetES.xlsx'
|
|
88
101
|
}
|
|
89
102
|
);
|
|
90
103
|
|
|
91
|
-
//
|
|
104
|
+
// 5. Wait for the pre-conversion result.
|
|
92
105
|
const conversionResponse = await client.pollUploadResponse({
|
|
93
106
|
thid: uploadResult.thid,
|
|
94
|
-
softwareId: '
|
|
107
|
+
softwareId: 'api-config'
|
|
95
108
|
});
|
|
96
109
|
|
|
97
110
|
const convertedBundle = client.getConvertedBundle(conversionResponse);
|
|
98
111
|
const storedConfigs = client.getSuccessfulTenantConfigs(configResponse);
|
|
99
112
|
|
|
100
|
-
//
|
|
113
|
+
// 6. Confirm promotion of the reviewed thread.
|
|
101
114
|
const patchResponse = await client.patchConversion({
|
|
102
115
|
thid: uploadResult.thid,
|
|
103
|
-
softwareId: '
|
|
116
|
+
softwareId: 'api-config'
|
|
104
117
|
});
|
|
105
118
|
|
|
106
|
-
//
|
|
119
|
+
// 7. Publish aggregated resources in batch if your flow needs it.
|
|
107
120
|
const publicationResponse = await client.batchPromotion({
|
|
108
121
|
thid: uploadResult.thid,
|
|
109
|
-
softwareId: '
|
|
122
|
+
softwareId: 'api-config'
|
|
110
123
|
});
|
|
111
124
|
|
|
112
|
-
//
|
|
125
|
+
// 8. Search promoted resources using lowercase FHIR parameters.
|
|
113
126
|
const searchResponse = await client.searchResources({
|
|
114
127
|
resourceType: 'DocumentReference',
|
|
115
128
|
searchParams: {
|
|
@@ -153,6 +166,12 @@ The returned object includes:
|
|
|
153
166
|
- `fields` as `{ code, display }[]`
|
|
154
167
|
- `endpoints` for `create`, `createResponse`, `upload`, and `uploadResponse`
|
|
155
168
|
|
|
169
|
+
The recommended frontend flow is:
|
|
170
|
+
|
|
171
|
+
1. Read `fields` from `/.well-known/api-config.json`.
|
|
172
|
+
2. Let the user map spreadsheet columns to those field codes.
|
|
173
|
+
3. Submit `mappingConfig.fieldMap` using those same codes.
|
|
174
|
+
|
|
156
175
|
## Backend initialization
|
|
157
176
|
|
|
158
177
|
If the backend instantiates the SDK after `Organization/_activate`, it can inject `axios` or `fetch` just like `ica-client-sdk-ts`.
|
package/package.json
CHANGED