@andes/fhir 1.13.0-beta.8 → 1.13.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.
@@ -8,59 +8,72 @@ exports.encode = encode;
8
8
  * [ASk] Location no se sabe. Solo esta el texto
9
9
  */
10
10
  function encode(patientReference, nomivac) {
11
- return {
11
+ const occurrenceDate = nomivac.fechaAplicacion
12
+ ? new Date(nomivac.fechaAplicacion).toISOString()
13
+ : new Date().toISOString();
14
+ const immunization = {
12
15
  resourceType: 'Immunization',
13
- id: nomivac.idvacuna,
14
- extension: [
15
- {
16
- url: 'http://sisa/fhir/esquema',
17
- valueCoding: {
18
- system: 'http://argentina.gob.ar/salud/NOMIVAC-esquemas',
19
- code: '0', // [TODO] Ver que code ponemos acá
20
- display: nomivac.vacuna
21
- }
22
- },
23
- {
24
- url: 'http://sisa/fhir/condicionAplicacion',
25
- valueCoding: {
26
- system: 'http://argentina.gob.ar/salud/NOMIVAC-condicion',
27
- code: '17',
28
- display: 'Personal de Salud'
29
- }
30
- }
31
- ],
16
+ id: String(nomivac.idvacuna),
17
+ meta: {
18
+ profile: [
19
+ 'http://hl7.org/fhir/uv/ips/StructureDefinition/Immunization-uv-ips'
20
+ ]
21
+ },
22
+ text: {
23
+ status: 'generated',
24
+ div: `<div xmlns="http://www.w3.org/1999/xhtml"><p>${nomivac.vacuna || 'Vacuna'}</p></div>`
25
+ },
32
26
  status: 'completed',
33
- notGiven: false,
34
27
  vaccineCode: {
35
28
  coding: [
36
29
  {
37
30
  system: 'https://snomed.info/sct/11000221109/id/228100022110',
38
- code: nomivac.idvacuna,
31
+ code: String(nomivac.idvacuna),
39
32
  display: nomivac.vacuna
40
33
  }
41
- ]
34
+ ],
35
+ text: nomivac.vacuna
42
36
  },
43
37
  patient: {
44
38
  reference: patientReference
45
39
  },
46
- date: nomivac.fechaAplicacion,
47
- primarySource: false,
48
- location: {
40
+ occurrenceDateTime: occurrenceDate,
41
+ primarySource: false
42
+ };
43
+ if (nomivac.vacuna || nomivac.condicion) {
44
+ immunization.extension = [];
45
+ if (nomivac.vacuna) {
46
+ immunization.extension.push({
47
+ url: 'http://sisa/fhir/esquema',
48
+ valueCoding: {
49
+ system: 'http://argentina.gob.ar/salud/NOMIVAC-esquemas',
50
+ code: '0',
51
+ display: nomivac.vacuna
52
+ }
53
+ });
54
+ }
55
+ if (nomivac.condicion) {
56
+ immunization.extension.push({
57
+ url: 'http://sisa/fhir/condicionAplicacion',
58
+ valueCoding: {
59
+ system: 'http://argentina.gob.ar/salud/NOMIVAC-condicion',
60
+ code: '17',
61
+ display: 'Personal de Salud'
62
+ }
63
+ });
64
+ }
65
+ }
66
+ if (nomivac.location) {
67
+ immunization.location = {
49
68
  reference: 'http://argentina.gob.ar/salud/refes/14999912399913'
50
- },
51
- // lotNumber: null,
52
- vaccinationProtocol: [
69
+ };
70
+ }
71
+ if (nomivac.dosis) {
72
+ immunization.protocolApplied = [
53
73
  {
54
- doseSequence: 1,
55
- doseStatus: {
56
- coding: [
57
- {
58
- system: 'http://hl7.org/fhir/vaccination-protocol-dose-status',
59
- code: nomivac.dosis
60
- }
61
- ]
62
- }
74
+ doseNumberString: String(nomivac.dosis)
63
75
  }
64
- ]
65
- };
76
+ ];
77
+ }
78
+ return immunization;
66
79
  }
@@ -23,7 +23,7 @@ function encode(patientReference, medicationReference, prestacionMedicamento) {
23
23
  },
24
24
  meta: {
25
25
  profile: [
26
- 'http://hl7.org/fhir/uv/ips/StructureDefinition/medication-ips'
26
+ 'http://hl7.org/fhir/uv/ips/StructureDefinition/MedicationStatement-uv-ips'
27
27
  ]
28
28
  },
29
29
  // extension: null,
@@ -63,18 +63,35 @@ function encode(organization) {
63
63
  const direcciones = [];
64
64
  if (data.direccion) {
65
65
  const dir = data.direccion;
66
- direcciones.push({
67
- postalCode: dir.codigoPostal ?? '',
68
- line: [dir.valor],
69
- city: dir.ubicacion?.localidad?.nombre ?? '',
70
- state: dir.ubicacion?.provincia?.nombre ?? '',
71
- country: dir.ubicacion?.pais?.nombre ?? ''
72
- });
66
+ const address = {};
67
+ const city = dir.ubicacion?.localidad?.nombre;
68
+ const state = dir.ubicacion?.provincia?.nombre;
69
+ const country = dir.ubicacion?.pais?.nombre;
70
+ if (dir.valor?.trim()) {
71
+ address.line = [dir.valor.trim()];
72
+ }
73
+ if (dir.codigoPostal && String(dir.codigoPostal).trim()) {
74
+ address.postalCode = String(dir.codigoPostal).trim();
75
+ }
76
+ if (city?.trim()) {
77
+ address.city = city.trim();
78
+ }
79
+ if (state?.trim()) {
80
+ address.state = state.trim();
81
+ }
82
+ if (country?.trim()) {
83
+ address.country = country.trim();
84
+ }
85
+ direcciones.push(address);
73
86
  }
74
87
  // Organización FHIR
75
88
  const organizacionFHIR = {
76
89
  resourceType: 'Organization',
77
90
  id: data._id ?? data.id,
91
+ text: {
92
+ status: 'generated',
93
+ div: `<div xmlns="http://www.w3.org/1999/xhtml"><p>${data.nombre || 'Organización'}</p></div>`
94
+ },
78
95
  identifier: identificadores,
79
96
  active: data.activo ?? undefined,
80
97
  name: data.nombre ?? undefined,
@@ -175,13 +175,23 @@ function encode(patient) {
175
175
  const country = typeof unaDireccion.ubicacion.pais === 'object'
176
176
  ? unaDireccion.ubicacion.pais?.nombre
177
177
  : unaDireccion.ubicacion.pais;
178
- return {
179
- postalCode: unaDireccion.codigoPostal ?? '',
180
- line: [unaDireccion.valor],
181
- city: city ?? '',
182
- state: state ?? '',
183
- country: country ?? ''
184
- };
178
+ const address = {};
179
+ if (unaDireccion.valor?.trim()) {
180
+ address.line = [unaDireccion.valor.trim()];
181
+ }
182
+ if (unaDireccion.codigoPostal && String(unaDireccion.codigoPostal).trim()) {
183
+ address.postalCode = String(unaDireccion.codigoPostal).trim();
184
+ }
185
+ if (city?.trim()) {
186
+ address.city = city.trim();
187
+ }
188
+ if (state?.trim()) {
189
+ address.state = state.trim();
190
+ }
191
+ if (country?.trim()) {
192
+ address.country = country.trim();
193
+ }
194
+ return address;
185
195
  });
186
196
  // Relaciones → contact
187
197
  const relacionesFHIR = (patient.relaciones ?? [])
@@ -207,6 +217,10 @@ function encode(patient) {
207
217
  const pacienteFHIR = {
208
218
  resourceType: 'Patient',
209
219
  id: patient._id ?? patient.id,
220
+ text: {
221
+ status: 'generated',
222
+ div: `<div xmlns="http://www.w3.org/1999/xhtml"><p>${`${patient.nombre || ''} ${patient.apellido || ''}`.trim()}</p></div>`
223
+ },
210
224
  identifier: identificadores,
211
225
  active: patient.activo ?? undefined,
212
226
  name: [{
@@ -52,13 +52,26 @@ function encode(practitioner) {
52
52
  // Direcciones → address
53
53
  // -----------------------------
54
54
  const direcciones = (data.domicilios ?? []).map((unDomicilio) => {
55
- return {
56
- postalCode: unDomicilio.codigoPostal ?? '',
57
- line: [unDomicilio.valor],
58
- city: unDomicilio.ubicacion?.localidad?.nombre ?? '',
59
- state: unDomicilio.ubicacion?.provincia?.nombre ?? '',
60
- country: unDomicilio.ubicacion?.pais?.nombre ?? ''
61
- };
55
+ const address = {};
56
+ const city = unDomicilio.ubicacion?.localidad?.nombre;
57
+ const state = unDomicilio.ubicacion?.provincia?.nombre;
58
+ const country = unDomicilio.ubicacion?.pais?.nombre;
59
+ if (unDomicilio.valor?.trim()) {
60
+ address.line = [unDomicilio.valor.trim()];
61
+ }
62
+ if (unDomicilio.codigoPostal && String(unDomicilio.codigoPostal).trim()) {
63
+ address.postalCode = String(unDomicilio.codigoPostal).trim();
64
+ }
65
+ if (city?.trim()) {
66
+ address.city = city.trim();
67
+ }
68
+ if (state?.trim()) {
69
+ address.state = state.trim();
70
+ }
71
+ if (country?.trim()) {
72
+ address.country = country.trim();
73
+ }
74
+ return address;
62
75
  });
63
76
  // -----------------------------
64
77
  // Relaciones (hoy no se usan en Practitioner)
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@andes/fhir",
3
- "version": "1.13.0-beta.8",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "1.13.0",
4
7
  "engines": {
5
8
  "node": ">=24.0.0"
6
9
  },
@@ -51,4 +54,4 @@
51
54
  }
52
55
  ]
53
56
  }
54
- }
57
+ }