@fhiron/sdk 0.1.0

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.
@@ -0,0 +1,270 @@
1
+ // Fhiron linter — ejemplos válidos por resourceType.
2
+ //
3
+ // Para `fhiron_get_example`: cuando el agente IA necesita "un Patient CL Core
4
+ // válido", llama esta tool y obtiene un recurso completo y conforme. Evita
5
+ // alucinaciones de URLs canónicas, codes, systems y formato de RUN.
6
+ //
7
+ // Cada ejemplo:
8
+ // - Pasa lintResource() sin errores.
9
+ // - Usa systems canónicos CL Core v1.9.4.
10
+ // - Usa códigos reales (LOINC, SNOMED, CIE-10, TFC, DEIS).
11
+ // - Es minimalista — solo los campos necesarios para que valide.
12
+
13
+ "use strict";
14
+
15
+ const { CS } = require("./catalog.js");
16
+
17
+ const EXAMPLES = {
18
+ Patient: {
19
+ resourceType: "Patient",
20
+ identifier: [{
21
+ system: CS("CSTipoIdentificador"),
22
+ value: "12345678-5",
23
+ }],
24
+ name: [{
25
+ family: "Pérez González",
26
+ given: ["María", "Fernanda"],
27
+ }],
28
+ gender: "female",
29
+ birthDate: "1985-03-15",
30
+ address: [{
31
+ line: ["Av. Providencia 1234"],
32
+ city: "Providencia",
33
+ state: "Región Metropolitana",
34
+ country: "CL",
35
+ }],
36
+ },
37
+
38
+ Practitioner: {
39
+ resourceType: "Practitioner",
40
+ identifier: [{
41
+ system: CS("CSTipoIdentificador"),
42
+ value: "11111111-1",
43
+ }],
44
+ name: [{
45
+ family: "Soto Vargas",
46
+ given: ["Carlos"],
47
+ prefix: ["Dr."],
48
+ }],
49
+ qualification: [{
50
+ code: { text: "Médico Cirujano" },
51
+ }],
52
+ },
53
+
54
+ Observation: {
55
+ resourceType: "Observation",
56
+ status: "final",
57
+ category: [{
58
+ coding: [{
59
+ system: "http://terminology.hl7.org/CodeSystem/observation-category",
60
+ code: "vital-signs",
61
+ }],
62
+ }],
63
+ code: {
64
+ coding: [{
65
+ system: "http://loinc.org",
66
+ code: "29463-7",
67
+ display: "Peso corporal",
68
+ }],
69
+ },
70
+ subject: { reference: "Patient/123" },
71
+ effectiveDateTime: "2026-04-29T10:30:00-04:00",
72
+ valueQuantity: {
73
+ value: 72.5,
74
+ unit: "kg",
75
+ system: "http://unitsofmeasure.org",
76
+ code: "kg",
77
+ },
78
+ },
79
+
80
+ Medication: {
81
+ resourceType: "Medication",
82
+ code: {
83
+ coding: [{
84
+ system: "http://www.whocc.no/atc",
85
+ code: "C09AA02",
86
+ display: "Enalapril 10 mg comprimido",
87
+ }],
88
+ },
89
+ form: { text: "Comprimido" },
90
+ },
91
+
92
+ MedicationRequest: {
93
+ resourceType: "MedicationRequest",
94
+ status: "active",
95
+ intent: "order",
96
+ subject: { reference: "Patient/123" },
97
+ authoredOn: "2026-04-29",
98
+ requester: { reference: "Practitioner/456" },
99
+ medicationCodeableConcept: {
100
+ coding: [{
101
+ system: "http://www.whocc.no/atc",
102
+ code: "C09AA02",
103
+ display: "Enalapril 10 mg",
104
+ }],
105
+ },
106
+ dosageInstruction: [{
107
+ text: "1 comprimido cada 24 horas, vía oral",
108
+ timing: { repeat: { frequency: 1, period: 1, periodUnit: "d" } },
109
+ route: { coding: [{ system: "http://snomed.info/sct", code: "26643006", display: "Vía oral" }] },
110
+ }],
111
+ },
112
+
113
+ Encounter: {
114
+ resourceType: "Encounter",
115
+ status: "finished",
116
+ class: {
117
+ system: "http://terminology.hl7.org/CodeSystem/v3-ActCode",
118
+ code: "AMB",
119
+ display: "ambulatorio",
120
+ },
121
+ subject: { reference: "Patient/123" },
122
+ period: {
123
+ start: "2026-04-29T09:00:00-04:00",
124
+ end: "2026-04-29T09:30:00-04:00",
125
+ },
126
+ serviceProvider: { reference: "Organization/hospital" },
127
+ },
128
+
129
+ Condition: {
130
+ resourceType: "Condition",
131
+ clinicalStatus: {
132
+ coding: [{
133
+ system: "http://terminology.hl7.org/CodeSystem/condition-clinical",
134
+ code: "active",
135
+ }],
136
+ },
137
+ code: {
138
+ coding: [{
139
+ system: "http://hl7.org/fhir/sid/icd-10",
140
+ code: "I10",
141
+ display: "Hipertensión esencial (primaria)",
142
+ }],
143
+ },
144
+ subject: { reference: "Patient/123" },
145
+ recordedDate: "2026-04-29",
146
+ },
147
+
148
+ AllergyIntolerance: {
149
+ resourceType: "AllergyIntolerance",
150
+ clinicalStatus: {
151
+ coding: [{
152
+ system: "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical",
153
+ code: "active",
154
+ }],
155
+ },
156
+ code: {
157
+ coding: [{
158
+ system: "http://snomed.info/sct",
159
+ code: "256349002",
160
+ display: "Maní",
161
+ }],
162
+ },
163
+ patient: { reference: "Patient/123" },
164
+ recordedDate: "2026-04-29",
165
+ },
166
+
167
+ Procedure: {
168
+ resourceType: "Procedure",
169
+ status: "completed",
170
+ code: {
171
+ coding: [{
172
+ system: "http://snomed.info/sct",
173
+ code: "80146002",
174
+ display: "Apendicectomía",
175
+ }],
176
+ },
177
+ subject: { reference: "Patient/123" },
178
+ performedDateTime: "2026-04-29T11:00:00-04:00",
179
+ },
180
+
181
+ Coverage: {
182
+ resourceType: "Coverage",
183
+ status: "active",
184
+ beneficiary: { reference: "Patient/123" },
185
+ payor: [{ reference: "Organization/fonasa" }],
186
+ period: { start: "2026-01-01" },
187
+ },
188
+
189
+ Organization: {
190
+ resourceType: "Organization",
191
+ name: "Hospital Clínico Universidad de Chile",
192
+ address: [{
193
+ line: ["Santos Dumont 999"],
194
+ city: "Independencia",
195
+ country: "CL",
196
+ }],
197
+ },
198
+
199
+ Immunization: {
200
+ resourceType: "Immunization",
201
+ status: "completed",
202
+ vaccineCode: {
203
+ coding: [{
204
+ system: "http://hl7.org/fhir/sid/cvx",
205
+ code: "208",
206
+ display: "Vacuna COVID-19 ARNm (LNP-S, PF) 30 mcg/0,3 mL",
207
+ }],
208
+ },
209
+ patient: { reference: "Patient/123" },
210
+ occurrenceDateTime: "2026-04-29",
211
+ performer: [{ actor: { reference: "Practitioner/456" } }],
212
+ },
213
+
214
+ DiagnosticReport: {
215
+ resourceType: "DiagnosticReport",
216
+ status: "final",
217
+ code: {
218
+ coding: [{
219
+ system: "http://loinc.org",
220
+ code: "11502-2",
221
+ display: "Informe de laboratorio",
222
+ }],
223
+ },
224
+ subject: { reference: "Patient/123" },
225
+ effectiveDateTime: "2026-04-29",
226
+ issued: "2026-04-29T15:00:00-04:00",
227
+ },
228
+
229
+ Bundle: {
230
+ resourceType: "Bundle",
231
+ type: "collection",
232
+ entry: [{
233
+ resource: {
234
+ resourceType: "Patient",
235
+ identifier: [{ system: CS("CSTipoIdentificador"), value: "12345678-5" }],
236
+ name: [{ family: "Pérez", given: ["María"] }],
237
+ gender: "female",
238
+ },
239
+ }],
240
+ },
241
+ };
242
+
243
+ /**
244
+ * Devuelve un ejemplo válido CL Core v1.9.4 para el resourceType pedido.
245
+ * Devuelve null si el resourceType no está cubierto.
246
+ *
247
+ * @param {string} resourceType
248
+ * @returns {object|null}
249
+ */
250
+ function getExample(resourceType) {
251
+ if (!resourceType || typeof resourceType !== "string") return null;
252
+ const tpl = EXAMPLES[resourceType];
253
+ if (!tpl) return null;
254
+ // Devolver una copia para que el caller pueda mutar sin contaminar la plantilla.
255
+ return JSON.parse(JSON.stringify(tpl));
256
+ }
257
+
258
+ /**
259
+ * Lista los resourceTypes con ejemplo disponible.
260
+ * @returns {string[]}
261
+ */
262
+ function listExamples() {
263
+ return Object.keys(EXAMPLES);
264
+ }
265
+
266
+ module.exports = {
267
+ EXAMPLES,
268
+ getExample,
269
+ listExamples,
270
+ };