@andes/fhir 1.13.0-beta.1 → 1.13.0-beta.10

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,13 @@
1
+ export declare const FhirIdentifierSystems: {
2
+ readonly ANDES_ID: "http://andes.gob.ar";
3
+ readonly MATRICULACIONES: "http://andes.gob.ar/matriculaciones";
4
+ readonly DNI: "https://www.renaper.gob.ar/dni";
5
+ readonly CUIL: "https://www.anses.org.ar/cuil";
6
+ readonly PASSPORT: "http://andes.gob.ar/sid/passport";
7
+ readonly FOREIGN_ID: "http://andes.gob.ar/sid/foreign-id";
8
+ readonly PRESCRIPTIONS: "http://app.andes.gob.ar/prescriptions";
9
+ readonly SISA: "https://andes.gob.ar/sisa";
10
+ readonly CUIE: "https://andes.gob.ar/cuie";
11
+ readonly REMEDIAR: "https://andes.gob.ar/remediar";
12
+ readonly SIPS: "https://andes.gob.ar/sips";
13
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FhirIdentifierSystems = void 0;
4
+ exports.FhirIdentifierSystems = {
5
+ ANDES_ID: 'http://andes.gob.ar',
6
+ MATRICULACIONES: 'http://andes.gob.ar/matriculaciones',
7
+ DNI: 'https://www.renaper.gob.ar/dni',
8
+ CUIL: 'https://www.anses.org.ar/cuil',
9
+ PASSPORT: 'http://andes.gob.ar/sid/passport',
10
+ FOREIGN_ID: 'http://andes.gob.ar/sid/foreign-id',
11
+ PRESCRIPTIONS: 'http://app.andes.gob.ar/prescriptions',
12
+ SISA: 'https://andes.gob.ar/sisa',
13
+ CUIE: 'https://andes.gob.ar/cuie',
14
+ REMEDIAR: 'https://andes.gob.ar/remediar',
15
+ SIPS: 'https://andes.gob.ar/sips',
16
+ };
package/dist/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.AllergyIntolerance = exports.MedicationRequest = exports.MedicationStatement = exports.Medication = exports.Device = exports.DocumentReference = exports.Bundle = exports.Composition = exports.Condition = exports.Immunization = exports.Organization = exports.Practitioner = exports.Patient = exports.initialize = exports.getDominio = void 0;
27
37
  const AllergyIntolerance = __importStar(require("./lib/allergyIntolerance"));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encode = void 0;
3
+ exports.encode = encode;
4
4
  /**
5
5
  * Encode de Alergias e Intolerancias from ANDES to FHIR
6
6
  * @param {} AllergyIntolerance
@@ -36,4 +36,3 @@ function encode(patientReference, alergiaIntolerancia) {
36
36
  onsetDateTime: alergiaIntolerancia.valor.fechaInicio
37
37
  };
38
38
  }
39
- exports.encode = encode;
@@ -1,17 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.encode = void 0;
7
- const moment_1 = __importDefault(require("moment"));
3
+ exports.encode = encode;
8
4
  const config_1 = require("./config");
9
5
  function encode(ID, resources) {
10
6
  return {
11
7
  resourceType: 'Bundle',
12
8
  id: ID,
13
9
  meta: {
14
- lastUpdated: (0, moment_1.default)().format()
10
+ lastUpdated: new Date().toISOString()
15
11
  },
16
12
  language: 'es-AR',
17
13
  entry: resources,
@@ -22,4 +18,3 @@ function encode(ID, resources) {
22
18
  }
23
19
  };
24
20
  }
25
- exports.encode = encode;
@@ -1,4 +1,3 @@
1
- import moment from 'moment';
2
1
  export declare function encode(ID: any, patientReference: any, custodianReference: any, deviceReference: any, medicationStatementReference: any, ImmunizationReferences: any, AllergyIntoleranceReferences: any, ConditionReferences: any): {
3
2
  id: any;
4
3
  subject: {
@@ -25,7 +24,7 @@ export declare function encode(ID: any, patientReference: any, custodianReferenc
25
24
  system: string;
26
25
  value: any;
27
26
  };
28
- date: moment.Moment;
27
+ date: string;
29
28
  text: {
30
29
  status: string;
31
30
  div: string;
@@ -38,7 +37,7 @@ export declare function encode(ID: any, patientReference: any, custodianReferenc
38
37
  };
39
38
  attester: {
40
39
  mode: string;
41
- time: moment.Moment;
40
+ time: string;
42
41
  party: {
43
42
  reference: any;
44
43
  };
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
3
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.encode = void 0;
8
- const moment_1 = __importDefault(require("moment"));
4
+ exports.encode = encode;
9
5
  const config_1 = require("./config");
10
6
  function getReference(url) {
11
7
  return {
@@ -13,7 +9,8 @@ function getReference(url) {
13
9
  };
14
10
  }
15
11
  function encode(ID, patientReference, custodianReference, deviceReference, medicationStatementReference, ImmunizationReferences, AllergyIntoleranceReferences, ConditionReferences) {
16
- const now = (0, moment_1.default)();
12
+ const now = new Date();
13
+ const nowIso = now.toISOString();
17
14
  let Immunization = [];
18
15
  let conditions = [];
19
16
  let medications = [];
@@ -116,12 +113,12 @@ function encode(ID, patientReference, custodianReference, deviceReference, medic
116
113
  }
117
114
  ]
118
115
  },
119
- title: 'Resumen del paciente al ' + now.format('DD/MM/YYYY, HH:mm'),
116
+ title: 'Resumen del paciente al ' + now.toLocaleDateString('es-AR') + ', ' + now.toLocaleTimeString('es-AR', { hour: '2-digit', minute: '2-digit' }),
120
117
  identifier: {
121
118
  system: (0, config_1.makeUrl)('Composition'),
122
119
  value: ID
123
120
  },
124
- date: now,
121
+ date: nowIso,
125
122
  // meta: {
126
123
  // profile: [
127
124
  // 'http:\/\/hl7.org\/fhir\/uv\/ips\/StructureDefinition\/composition-uv-ips'
@@ -140,7 +137,7 @@ function encode(ID, patientReference, custodianReference, deviceReference, medic
140
137
  attester: [
141
138
  {
142
139
  mode: 'legal',
143
- time: now,
140
+ time: nowIso,
144
141
  party: {
145
142
  reference: custodianReference
146
143
  }
@@ -149,4 +146,3 @@ function encode(ID, patientReference, custodianReference, deviceReference, medic
149
146
  status: 'final'
150
147
  };
151
148
  }
152
- exports.encode = encode;
@@ -4,7 +4,7 @@
4
4
  * @param registro Registro RUP a transformar a FHIR
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.encode = void 0;
7
+ exports.encode = encode;
8
8
  function encode(patientReference, registro) {
9
9
  return {
10
10
  id: registro._id,
@@ -76,4 +76,3 @@ function encode(patientReference, registro) {
76
76
  }
77
77
  };
78
78
  }
79
- exports.encode = encode;
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.__reset = exports.makeUrl = exports.getDominio = exports.initialize = void 0;
4
- let DOMINIO = 'andes.gob.ar';
3
+ exports.initialize = initialize;
4
+ exports.getDominio = getDominio;
5
+ exports.makeUrl = makeUrl;
6
+ exports.__reset = __reset;
7
+ const identifier_systems_1 = require("../constants/identifier-systems");
8
+ let DOMINIO = identifier_systems_1.FhirIdentifierSystems.ANDES_ID;
5
9
  function initialize(config) {
6
10
  DOMINIO = config.dominio;
7
11
  }
8
- exports.initialize = initialize;
9
12
  function getDominio() {
10
13
  return DOMINIO;
11
14
  }
12
- exports.getDominio = getDominio;
13
15
  function makeUrl(resource, id) {
14
16
  let url = `${DOMINIO}/${resource}`;
15
17
  if (id) {
@@ -17,11 +19,9 @@ function makeUrl(resource, id) {
17
19
  }
18
20
  return url;
19
21
  }
20
- exports.makeUrl = makeUrl;
21
22
  /**
22
23
  * Reseteo explícito para tests
23
24
  */
24
25
  function __reset() {
25
- DOMINIO = 'andes.gob.ar';
26
+ DOMINIO = identifier_systems_1.FhirIdentifierSystems.ANDES_ID;
26
27
  }
27
- exports.__reset = __reset;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encode = void 0;
3
+ exports.encode = encode;
4
4
  const config_1 = require("./config");
5
5
  function encode() {
6
6
  /**
@@ -35,4 +35,3 @@ function encode() {
35
35
  ]
36
36
  };
37
37
  }
38
- exports.encode = encode;
@@ -1,17 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.encode = void 0;
7
- const moment_1 = __importDefault(require("moment"));
3
+ exports.encode = encode;
8
4
  const config_1 = require("./config");
9
5
  function encode(ID, author, organization, patient, binaryURL) {
10
6
  return {
11
7
  resourceType: 'DocumentReference',
12
8
  id: ID,
13
9
  meta: {
14
- lastUpdated: (0, moment_1.default)().format()
10
+ lastUpdated: new Date().toISOString()
15
11
  },
16
12
  contained: [
17
13
  {
@@ -103,4 +99,3 @@ function encode(ID, author, organization, patient, binaryURL) {
103
99
  }
104
100
  };
105
101
  }
106
- exports.encode = encode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encode = void 0;
3
+ exports.encode = encode;
4
4
  /**
5
5
  * Encode de Vacunas Nomivac from ANDES to FHIR
6
6
  * @param {} nomivac
@@ -64,4 +64,3 @@ function encode(patientReference, nomivac) {
64
64
  ]
65
65
  };
66
66
  }
67
- exports.encode = encode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encode = void 0;
3
+ exports.encode = encode;
4
4
  /**
5
5
  * Encode de Medicamentos from ANDES to FHIR
6
6
  * @param {} medication
@@ -61,4 +61,3 @@ function encode(medication) {
61
61
  }
62
62
  };
63
63
  }
64
- exports.encode = encode;
@@ -11,7 +11,7 @@ export declare function encode(patientReference: any, practitionerReference: any
11
11
  contained: any[];
12
12
  identifier: {
13
13
  use: string;
14
- system: string;
14
+ system: "http://app.andes.gob.ar/prescriptions";
15
15
  value: any;
16
16
  }[];
17
17
  status: string;
@@ -25,7 +25,7 @@ export declare function encode(patientReference: any, practitionerReference: any
25
25
  subject: {
26
26
  reference: any;
27
27
  };
28
- authoredOn: string;
28
+ authoredOn: string | undefined;
29
29
  requester: {
30
30
  reference: any;
31
31
  };
@@ -3,12 +3,9 @@
3
3
  * Encode medicationRequest from ANDES to FHIR
4
4
  * @param {} medicationRequest
5
5
  */
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
6
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.encode = void 0;
11
- const moment_1 = __importDefault(require("moment"));
7
+ exports.encode = encode;
8
+ const identifier_systems_1 = require("../constants/identifier-systems");
12
9
  // Muy incompleto hay que mejorarlo mucho todavía
13
10
  function encode(patientReference, practitionerReference, medicationFHIR, data) {
14
11
  return {
@@ -24,7 +21,7 @@ function encode(patientReference, practitionerReference, medicationFHIR, data) {
24
21
  identifier: [
25
22
  {
26
23
  use: 'official',
27
- system: 'http://app.andes.gob.ar/prescriptions', // Es el id de la prestación completa
24
+ system: identifier_systems_1.FhirIdentifierSystems.PRESCRIPTIONS, // Es el id de la prestación completa
28
25
  value: data.registro.id
29
26
  }
30
27
  ],
@@ -53,7 +50,7 @@ function encode(patientReference, practitionerReference, medicationFHIR, data) {
53
50
  reference: patientReference // podría ser una reference a un group también
54
51
  },
55
52
  // encounter: Por ahora lo dejo pendiente. Podría ponerse una referencia a otra prestación o al informe del encuentro.
56
- authoredOn: (0, moment_1.default)(data.registro.createdAt).format('YYYY-MM-DD'),
53
+ authoredOn: data.registro?.createdAt ? new Date(data.registro.createdAt).toISOString().slice(0, 10) : undefined,
57
54
  // requester & performer: pueden ser Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson|CareTeam)
58
55
  // por el momento vamos a tomar al profesional porque no tenemos otra info en la prestación
59
56
  requester: {
@@ -100,4 +97,3 @@ function encode(patientReference, practitionerReference, medicationFHIR, data) {
100
97
  eventHistory: null // [{ Reference(Provenance) }]
101
98
  };
102
99
  }
103
- exports.encode = encode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encode = void 0;
3
+ exports.encode = encode;
4
4
  /**
5
5
  * Encode de Medicamentos from ANDES to FHIR
6
6
  * @param {} medicationStatement
@@ -52,4 +52,3 @@ function encode(patientReference, medicationReference, prestacionMedicamento) {
52
52
  }
53
53
  };
54
54
  }
55
- exports.encode = encode;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encode = void 0;
3
+ exports.encode = encode;
4
4
  const config_1 = require("./config");
5
5
  const rankingMapping_1 = require("../utils/rankingMapping");
6
+ const identifier_systems_1 = require("../constants/identifier-systems");
6
7
  /**
7
8
  * Encode an ANDES Organization to FHIR Organization
8
9
  */
@@ -14,25 +15,25 @@ function encode(organization) {
14
15
  const identificadores = [];
15
16
  if (data.codigo?.sisa) {
16
17
  identificadores.push({
17
- system: 'https://andes.gob.ar/sisa',
18
+ system: identifier_systems_1.FhirIdentifierSystems.SISA,
18
19
  value: data.codigo.sisa
19
20
  });
20
21
  }
21
22
  if (data.codigo?.cuie) {
22
23
  identificadores.push({
23
- system: 'https://andes.gob.ar/cuie',
24
+ system: identifier_systems_1.FhirIdentifierSystems.CUIE,
24
25
  value: data.codigo.cuie
25
26
  });
26
27
  }
27
28
  if (data.codigo?.remediar) {
28
29
  identificadores.push({
29
- system: 'https://andes.gob.ar/remediar',
30
+ system: identifier_systems_1.FhirIdentifierSystems.REMEDIAR,
30
31
  value: data.codigo.remediar
31
32
  });
32
33
  }
33
34
  if (data.codigo?.sips) {
34
35
  identificadores.push({
35
- system: 'https://andes.gob.ar/sips',
36
+ system: identifier_systems_1.FhirIdentifierSystems.SIPS,
36
37
  value: data.codigo.sips
37
38
  });
38
39
  }
@@ -91,4 +92,3 @@ function encode(organization) {
91
92
  }
92
93
  return organizacionFHIR;
93
94
  }
94
- exports.encode = encode;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verify = exports.decode = exports.encode = void 0;
3
+ exports.encode = encode;
4
+ exports.decode = decode;
5
+ exports.verify = verify;
4
6
  const config_1 = require("./config");
5
7
  const rankingMapping_1 = require("../utils/rankingMapping");
8
+ const identifier_systems_1 = require("../constants/identifier-systems");
6
9
  /**
7
10
  * Helpers
8
11
  */
@@ -116,26 +119,26 @@ function encode(patient) {
116
119
  });
117
120
  if (patient.documento) {
118
121
  identificadores.push({
119
- system: 'http://www.renaper.gob.ar/dni',
122
+ system: identifier_systems_1.FhirIdentifierSystems.DNI,
120
123
  value: patient.documento
121
124
  });
122
125
  }
123
126
  if (patient.cuil) {
124
127
  identificadores.push({
125
- system: 'http://www.renaper.gob.ar/cuil',
128
+ system: identifier_systems_1.FhirIdentifierSystems.CUIL,
126
129
  value: patient.cuil
127
130
  });
128
131
  }
129
132
  if (patient.numeroIdentificacion) {
130
133
  if (patient.tipoIdentificacion === 'dni extranjero') {
131
134
  identificadores.push({
132
- system: 'andes.gob.ar/sid/foreign-id',
135
+ system: identifier_systems_1.FhirIdentifierSystems.FOREIGN_ID,
133
136
  value: patient.numeroIdentificacion
134
137
  });
135
138
  }
136
139
  if (patient.tipoIdentificacion === 'pasaporte') {
137
140
  identificadores.push({
138
- system: 'andes.gob.ar/sid/passport',
141
+ system: identifier_systems_1.FhirIdentifierSystems.PASSPORT,
139
142
  value: patient.numeroIdentificacion
140
143
  });
141
144
  }
@@ -248,7 +251,6 @@ function encode(patient) {
248
251
  }
249
252
  return pacienteFHIR;
250
253
  }
251
- exports.encode = encode;
252
254
  /**
253
255
  * Decode a patient from FHIR to ANDES
254
256
  */
@@ -264,7 +266,7 @@ function decode(patient) {
264
266
  const element = items.find(el => el.system === key);
265
267
  return element?.value;
266
268
  }
267
- const tiposIdentificacion = ['andes.gob.ar/sid/foreign-id', 'andes.gob.ar/sid/passport'];
269
+ const tiposIdentificacion = [identifier_systems_1.FhirIdentifierSystems.FOREIGN_ID, identifier_systems_1.FhirIdentifierSystems.PASSPORT];
268
270
  const tipoAndes = ['dni extranjero', 'pasaporte'];
269
271
  let tipoIdentificacion;
270
272
  let numeroIdentificacion;
@@ -286,7 +288,7 @@ function decode(patient) {
286
288
  : '';
287
289
  const pacienteAndes = {
288
290
  id: getValue(patient.identifier, (0, config_1.makeUrl)('Patient')) ?? patient.id,
289
- documento: getValue(patient.identifier, 'http://www.renaper.gob.ar/dni'),
291
+ documento: getValue(patient.identifier, identifier_systems_1.FhirIdentifierSystems.DNI),
290
292
  tipoIdentificacion,
291
293
  numeroIdentificacion,
292
294
  nombre,
@@ -371,7 +373,6 @@ function decode(patient) {
371
373
  }
372
374
  return pacienteAndes;
373
375
  }
374
- exports.decode = decode;
375
376
  /**
376
377
  * Verify if a patient has a FHIR format
377
378
  */
@@ -440,7 +441,6 @@ function verify(patient) {
440
441
  }
441
442
  return respuesta;
442
443
  }
443
- exports.verify = verify;
444
444
  /**
445
445
  * Verify helpers
446
446
  */
@@ -1,6 +1,3 @@
1
1
  import { Practitioner } from 'fhir/r4';
2
2
  import { AndesPractitioner } from '../types/andes/practitioner.types';
3
- /**
4
- * Encode a practitioner from ANDES to FHIR
5
- */
6
3
  export declare function encode(practitioner: AndesPractitioner | null | undefined): Practitioner | null;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encode = void 0;
3
+ exports.encode = encode;
4
4
  const config_1 = require("./config");
5
- /**
6
- * Encode a practitioner from ANDES to FHIR
7
- */
5
+ const fhirDate_1 = require("../utils/fhirDate");
6
+ const rankingMapping_1 = require("../utils/rankingMapping");
8
7
  function encode(practitioner) {
9
8
  const data = practitioner;
10
9
  if (!data) {
@@ -36,7 +35,7 @@ function encode(practitioner) {
36
35
  const contactos = (data.contacto ?? []).map((unContacto) => {
37
36
  const cont = {
38
37
  value: unContacto.valor,
39
- rank: unContacto.ranking
38
+ rank: (0, rankingMapping_1.mapAndesRankingToFhirRank)(unContacto.ranking)
40
39
  };
41
40
  switch (unContacto.tipo) {
42
41
  case 'fijo':
@@ -78,7 +77,7 @@ function encode(practitioner) {
78
77
  identifier: datosGrado.profesion.nombre
79
78
  ? [{
80
79
  system: 'https://www.saludneuquen.gob.ar/matriculacionGrado',
81
- value: datosGrado.profesion.nombre
80
+ value: String(datosGrado.profesion.nombre ?? '')
82
81
  }]
83
82
  : []
84
83
  };
@@ -86,15 +85,22 @@ function encode(practitioner) {
86
85
  unaMatricula.code = {
87
86
  coding: [{
88
87
  system: 'http://www.saludneuquen.gob.ar/fiscalizacion.html',
89
- code: datosGrado.profesion.codigo,
90
- display: datosGrado.profesion.tipoDeFormacion
88
+ code: String(datosGrado.profesion.codigo ?? ''),
89
+ display: String(datosGrado.profesion.tipoDeFormacion ?? '')
91
90
  }],
92
- text: ultima.matriculaNumero
93
- };
94
- unaMatricula.period = {
95
- start: ultima.inicio ?? null,
96
- end: ultima.fin ?? null
91
+ text: String(ultima.matriculaNumero ?? '')
97
92
  };
93
+ const start = (0, fhirDate_1.formatFHIRDateTime)(ultima.inicio);
94
+ const end = (0, fhirDate_1.formatFHIRDateTime)(ultima.fin);
95
+ if (start || end) {
96
+ unaMatricula.period = {};
97
+ if (start) {
98
+ unaMatricula.period.start = start;
99
+ }
100
+ if (end) {
101
+ unaMatricula.period.end = end;
102
+ }
103
+ }
98
104
  }
99
105
  return unaMatricula;
100
106
  });
@@ -110,7 +116,7 @@ function encode(practitioner) {
110
116
  identifier: datosPosgrado.especialidad.nombre
111
117
  ? [{
112
118
  system: 'https://www.saludneuquen.gob.ar/matriculacionEspecialidad/',
113
- value: datosPosgrado.especialidad.nombre
119
+ value: String(datosPosgrado.especialidad.nombre ?? '')
114
120
  }]
115
121
  : []
116
122
  };
@@ -118,15 +124,22 @@ function encode(practitioner) {
118
124
  unaMatricula.code = {
119
125
  coding: [{
120
126
  system: 'http://www.saludneuquen.gob.ar/fiscalizacion.html',
121
- code: datosPosgrado.especialidad.codigo,
122
- display: datosPosgrado.especialidad.tipo
127
+ code: String(datosPosgrado.especialidad.codigo.sisa ?? ''),
128
+ display: String(datosPosgrado.especialidad.nombre ?? '')
123
129
  }],
124
- text: ultima.matriculaNumero
125
- };
126
- unaMatricula.period = {
127
- start: ultima.inicio ?? null,
128
- end: ultima.fin ?? null
130
+ text: String(ultima.matriculaNumero ?? '')
129
131
  };
132
+ const start = (0, fhirDate_1.formatFHIRDateTime)(ultima.inicio);
133
+ const end = (0, fhirDate_1.formatFHIRDateTime)(ultima.fin);
134
+ if (start || end) {
135
+ unaMatricula.period = {};
136
+ if (start) {
137
+ unaMatricula.period.start = start;
138
+ }
139
+ if (end) {
140
+ unaMatricula.period.end = end;
141
+ }
142
+ }
130
143
  }
131
144
  return unaMatricula;
132
145
  });
@@ -155,6 +168,7 @@ function encode(practitioner) {
155
168
  // -----------------------------
156
169
  const profesionalFHIR = {
157
170
  resourceType: 'Practitioner',
171
+ id: data._id,
158
172
  identifier: identificadores,
159
173
  active: data.habilitado ?? undefined,
160
174
  name: [{
@@ -162,7 +176,7 @@ function encode(practitioner) {
162
176
  given: data.nombre?.split(' ') ?? []
163
177
  }],
164
178
  gender: genero,
165
- birthDate: data.fechaNacimiento,
179
+ birthDate: (0, fhirDate_1.formatFHIRDate)(data.fechaNacimiento),
166
180
  };
167
181
  if (contactos.length > 0) {
168
182
  profesionalFHIR.telecom = contactos;
@@ -183,4 +197,3 @@ function encode(practitioner) {
183
197
  }
184
198
  return profesionalFHIR;
185
199
  }
186
- exports.encode = encode;
@@ -43,8 +43,9 @@ export interface AndesProfesion {
43
43
  }
44
44
  export interface AndesEspecialidad {
45
45
  nombre?: string;
46
- codigo?: string;
47
- tipo?: string;
46
+ codigo: {
47
+ sisa: string;
48
+ };
48
49
  }
49
50
  export interface AndesFormacionGrado {
50
51
  profesion: AndesProfesion;
@@ -0,0 +1,3 @@
1
+ export declare function isValidFHIRDateTime(date: any): boolean;
2
+ export declare function formatFHIRDateTime(date: any): string | undefined;
3
+ export declare function formatFHIRDate(date: any): string | undefined;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidFHIRDateTime = isValidFHIRDateTime;
4
+ exports.formatFHIRDateTime = formatFHIRDateTime;
5
+ exports.formatFHIRDate = formatFHIRDate;
6
+ function isValidFHIRDateTime(date) {
7
+ if (date === null || date === undefined || date === 0 || date === '0' || date === '') {
8
+ return false;
9
+ }
10
+ const d = new Date(date);
11
+ return !isNaN(d.getTime());
12
+ }
13
+ function formatFHIRDateTime(date) {
14
+ if (isValidFHIRDateTime(date)) {
15
+ return new Date(date).toISOString();
16
+ }
17
+ return undefined;
18
+ }
19
+ function formatFHIRDate(date) {
20
+ if (isValidFHIRDateTime(date)) {
21
+ return new Date(date).toISOString().split('T')[0];
22
+ }
23
+ return undefined;
24
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapFhirRankToAndesRanking = exports.mapAndesRankingToFhirRank = void 0;
3
+ exports.mapAndesRankingToFhirRank = mapAndesRankingToFhirRank;
4
+ exports.mapFhirRankToAndesRanking = mapFhirRankToAndesRanking;
4
5
  /**
5
6
  * Mapea ANDES ranking base 1 a FHIR rank base 1
6
7
  */
@@ -9,7 +10,6 @@ function mapAndesRankingToFhirRank(andesRanking) {
9
10
  ? andesRanking + 1
10
11
  : 1;
11
12
  }
12
- exports.mapAndesRankingToFhirRank = mapAndesRankingToFhirRank;
13
13
  /**
14
14
  * Mapea FHIR rank base 1 a ANDES ranking base 0
15
15
  */
@@ -18,4 +18,3 @@ function mapFhirRankToAndesRanking(fhirRank) {
18
18
  ? fhirRank - 1
19
19
  : 0;
20
20
  }
21
- exports.mapFhirRankToAndesRanking = mapFhirRankToAndesRanking;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@andes/fhir",
3
- "version": "1.13.0-beta.1",
3
+ "version": "1.13.0-beta.10",
4
4
  "engines": {
5
- "node": ">=18.0.0"
5
+ "node": ">=24.0.0"
6
6
  },
7
7
  "engineStrict": true,
8
8
  "main": "dist/index.js",
@@ -21,22 +21,20 @@
21
21
  "release:prod:dry": "dotenv -e .env -- semantic-release --no-ci --branches master --dry-run"
22
22
  },
23
23
  "devDependencies": {
24
- "@types/jest": "29.5.14",
25
- "@types/node": "^18.19.0",
26
- "@typescript-eslint/eslint-plugin": "^6.21.0",
27
- "@typescript-eslint/parser": "^6.21.0",
24
+ "@types/jest": "^29.5.14",
25
+ "@types/node": "^24.0.0",
26
+ "@typescript-eslint/eslint-plugin": "^8.26.0",
27
+ "@typescript-eslint/parser": "^8.26.0",
28
28
  "dotenv-cli": "^11.0.0",
29
- "eslint": "^8.57.0",
30
- "jest": "29.7.0",
29
+ "eslint": "^9.21.0",
30
+ "jest": "^29.7.0",
31
31
  "rimraf": "^5.0.7",
32
32
  "semantic-release": "^20.1.0",
33
- "ts-jest": "29.2.5",
34
- "ts-node": "^10.9.2",
35
- "typescript": "5.3.3"
33
+ "ts-jest": "^29.2.5",
34
+ "typescript": "^5.8.2"
36
35
  },
37
36
  "dependencies": {
38
- "@types/fhir": "^0.0.41",
39
- "moment": "2.29.4"
37
+ "@types/fhir": "^0.0.41"
40
38
  },
41
39
  "files": [
42
40
  "dist/**/*"
@@ -1,192 +0,0 @@
1
- {
2
- "_id": "58d30d6fgbb1a96b254d9877",
3
- "entidadesValidadoras": [
4
- "RENAPER",
5
- "Sisa"
6
- ],
7
- "documento": "42910660",
8
- "apellido": "PERINGA PONCE",
9
- "nombre": "HUGO AGUSTIN",
10
- "sexo": "masculino",
11
- "fechaNacimiento": "1979-11-14T03:00:00.000-03:00",
12
- "estado": "validado",
13
- "genero": "masculino",
14
- "financiador": [
15
- {
16
- "codigoPuco": 921001,
17
- "nombre": "O.S.P. NEUQUEN",
18
- "financiador": "O.S.P. NEUQUEN"
19
- },
20
- {
21
- "codigoPuco": 921001,
22
- "nombre": "O.S.P. NEUQUEN",
23
- "financiador": "O.S.P. NEUQUEN"
24
- }
25
- ],
26
- "relaciones": [
27
- {
28
- "_id": "5b92dec9646d99436065cbfc",
29
- "relacion": {
30
- "_id": "59247c391ebf0273353b23c0",
31
- "nombre": "hijo/a",
32
- "opuesto": "progenitor/a"
33
- },
34
- "referencia": "5b92de583173b053ae88f2d0",
35
- "nombre": "JOSEFINA",
36
- "apellido": "PERINGA PONCE",
37
- "documento": "333333333",
38
- "fotoId": "5f9072d00254f253d9c7dd54"
39
- },
40
- {
41
- "_id": "5b92dec9646d99436065cbfa",
42
- "relacion": {
43
- "_id": "59247c391ebf0273353b23c0",
44
- "nombre": "hijo/a",
45
- "opuesto": "progenitor/a"
46
- },
47
- "referencia": "5b9287f10394a225c25a150b",
48
- "nombre": "IGNACIO",
49
- "apellido": "PERINGA PONCE",
50
- "documento": "222222222",
51
- "fotoId": "5f9072d00254f253d9c7dd2c"
52
- },
53
- {
54
- "_id": "5f00d31e044ef317c36fd4f8",
55
- "relacion": {
56
- "_id": "59247c391ebf0273353b23c0",
57
- "nombre": "hijo/a",
58
- "opuesto": "progenitor/a"
59
- },
60
- "referencia": "5f00d2f7acfe3a7e46a88227",
61
- "nombre": "JUAN CRUZ",
62
- "apellido": "PERINGA PONCE",
63
- "documento": "11111111",
64
- "fotoId": "5f9078ff0254f253d9dc7212"
65
- },
66
- {
67
- "_id": "5f09f00d5cec191aa5908457",
68
- "relacion": {
69
- "_id": "59247e1c1ebf0273353b23c5",
70
- "nombre": "otro",
71
- "opuesto": "otro"
72
- },
73
- "referencia": "59cb176acd21ce293061b67b",
74
- "nombre": "FLORENCIA INES",
75
- "apellido": "YAMIL",
76
- "documento": "15365478",
77
- "fotoId": "5f9072b40254f253d9c79556"
78
- }
79
- ],
80
- "direccion": [
81
- {
82
- "geoReferencia": [
83
- -38.9305707,
84
- -68.0839758
85
- ],
86
- "activo": true,
87
- "_id": "58d90d6f0bb1a96b254d9878",
88
- "valor": "Enrique Santos Discepolo 1856",
89
- "codigoPostal": "8300",
90
- "ubicacion": {
91
- "_id": "58d90d6f0bb1a96b254d9879",
92
- "pais": {
93
- "_id": "57f3b5c469fe79a598e6281f",
94
- "nombre": "Argentina"
95
- },
96
- "provincia": {
97
- "_id": "57f3f3aacebd681cc2014c53",
98
- "nombre": "Neuquén"
99
- },
100
- "localidad": {
101
- "_id": "57f538a472325875a199a82d",
102
- "nombre": "NEUQUEN"
103
- },
104
- "barrio": null
105
- },
106
- "ranking": 0,
107
- "ultimaActualizacion": "2017-03-27T10:02:16.809-03:00"
108
- },
109
- {
110
- "geoReferencia": null,
111
- "activo": true,
112
- "_id": "6046105ba4e2d85f81ad60f7",
113
- "valor": "NORDENSTROM 1898 0 0",
114
- "codigoPostal": "8300",
115
- "ranking": 1,
116
- "ubicacion": {
117
- "_id": "6046105ba4e2d85f81ad60f8",
118
- "pais": {
119
- "_id": "57f3b5c469fe79a598e6281f",
120
- "nombre": "Argentina"
121
- },
122
- "provincia": {
123
- "_id": "57f3f3aacebd681cc2014c53",
124
- "nombre": "Neuquén"
125
- },
126
- "localidad": {
127
- "_id": "57f538a472325875a199a82d",
128
- "nombre": "Neuquén"
129
- },
130
- "barrio": null
131
- },
132
- "ultimaActualizacion": "2021-03-08T08:54:04.089-03:00"
133
- }
134
- ],
135
- "contacto": [
136
- {
137
- "activo": true,
138
- "_id": "5cabf8cc129519c9cd5bf6f2",
139
- "tipo": "celular",
140
- "valor": "4462221"
141
- },
142
- {
143
- "activo": true,
144
- "_id": "5cabf8cc129519c9cd5bf6f1",
145
- "tipo": "email",
146
- "valor": "hugoperingaponce@gmail.com"
147
- }
148
- ],
149
- "identificadores": [
150
- {
151
- "entidad": "RENAPER",
152
- "valor": "241654536"
153
- }
154
- ],
155
- "estadoCivil": "soltero",
156
- "reportarError": false,
157
- "scan": "27381849",
158
- "carpetaEfectores": [
159
- {
160
- "_id": "5992e06a0e3f6446112e9bd5",
161
- "organizacion": {
162
- "_id": "59650203d03019f919ea31ed",
163
- "nombre": "CENTRO DE SALUD PARQUE INDUSTRIAL"
164
- },
165
- "nroCarpeta": ""
166
- },
167
- {
168
- "_id": "5b57565dc0202168d3d5762d",
169
- "organizacion": {
170
- "_id": "57e9670e52df311059bc8964",
171
- "nombre": "HOSPITAL PROVINCIAL NEUQUEN - DR. EDUARDO CASTRO RENDON"
172
- },
173
- "nroCarpeta": "PDR27381849"
174
- }
175
- ],
176
- "notas": [],
177
- "cuil": "23273818499",
178
- "foto": null,
179
- "activo": true,
180
- "notaError": "",
181
- "tipoIdentificacion": null,
182
- "numeroIdentificacion": null,
183
- "fotoId": "6046105c18944f849e9fe315",
184
- "documentos": [],
185
- "fechaFallecimiento": null,
186
- "createdBy": {
187
- "organizacion": {
188
- "id": "50580352367779",
189
- "nombre": "LABORATORIO RAÑA - SERVICIOS MEDICOS"
190
- }
191
- }
192
- }
@@ -1,26 +0,0 @@
1
- import { AndesPatient } from '../types/andes/patient.types';
2
- export type PartialDeep<T> = {
3
- [K in keyof T]?: T[K] extends object ? PartialDeep<T[K]> : T[K];
4
- };
5
- export declare const createPatient: (overrides?: PartialDeep<AndesPatient>) => {
6
- _id?: string | undefined;
7
- id?: string | undefined;
8
- documento?: string | undefined;
9
- cuil?: string | undefined;
10
- tipoIdentificacion?: string | null | undefined;
11
- numeroIdentificacion?: string | null | undefined;
12
- nombre: string;
13
- apellido: string;
14
- fechaNacimiento?: string | Date | undefined;
15
- fechaFallecimiento?: string | Date | null | undefined;
16
- genero?: string | undefined;
17
- sexo?: string | undefined;
18
- estado?: string | null | undefined;
19
- activo?: boolean | undefined;
20
- estadoCivil?: string | null | undefined;
21
- contacto?: import("../types/andes/patient.types").AndesContacto[] | undefined;
22
- direccion?: import("../types/andes/patient.types").AndesDireccion[] | undefined;
23
- relaciones?: import("../types/andes/patient.types").AndesRelacion[] | undefined;
24
- foto?: string | null | undefined;
25
- createdBy?: import("../types/andes/patient.types").AndesCreatedBy | undefined;
26
- };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.createPatient = void 0;
27
- const basePatient = __importStar(require("../data/patient.json"));
28
- const createPatient = (overrides = {}) => {
29
- const clone = JSON.parse(JSON.stringify(basePatient));
30
- return {
31
- ...clone,
32
- ...overrides,
33
- };
34
- };
35
- exports.createPatient = createPatient;
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config_1 = require("./config");
4
- beforeEach(() => {
5
- (0, config_1.__reset)(); // Resetea el dominio antes de cada test
6
- });
7
- test('Get default domain', () => {
8
- expect((0, config_1.getDominio)()).toBe('andes.gob.ar');
9
- });
10
- test('Get default URL without id', () => {
11
- expect((0, config_1.makeUrl)('patient')).toBe('andes.gob.ar/patient');
12
- });
13
- test('Get default URL with id', () => {
14
- expect((0, config_1.makeUrl)('patient', '123456')).toBe('andes.gob.ar/patient/123456');
15
- });
16
- test('Initialize domain modifies getDominio', () => {
17
- (0, config_1.initialize)({ dominio: 'nuevo-dominio.com' });
18
- expect((0, config_1.getDominio)()).toBe('nuevo-dominio.com');
19
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const device_1 = require("./device");
4
- test('Device type 1', () => {
5
- expect((0, device_1.encode)().id).toBe('device-01');
6
- });
7
- test('Device Name', () => {
8
- expect((0, device_1.encode)().deviceName[0].name).toBe('Sistema de Aplicaciones Neuquinas de Salud (ANDES)');
9
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,132 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const patient = __importStar(require("../data/patient.json"));
27
- const patient_1 = require("./patient");
28
- const patientFactory_1 = require("../helpers/patientFactory");
29
- const pacienteFhir = (0, patient_1.encode)(patient);
30
- describe('encode patient from ANDES to FHIR R4', () => {
31
- test('Verify basic data', () => {
32
- expect(pacienteFhir.resourceType).toBe('Patient');
33
- const ident = pacienteFhir.identifier;
34
- const id = ident?.find(t => t.system === 'http://www.renaper.gob.ar/dni');
35
- expect(id?.value).toBe('42910660');
36
- expect(id?.system).toBe('http://www.renaper.gob.ar/dni');
37
- expect(pacienteFhir.active).toBe(true);
38
- expect(pacienteFhir.name).toBeDefined();
39
- expect(pacienteFhir.name[0].use).toBe('official');
40
- expect(pacienteFhir.name[0].family).toContain('PERINGA');
41
- expect(pacienteFhir.name[0].family).toContain('PONCE');
42
- expect(pacienteFhir.name[0].given).toContain('AGUSTIN');
43
- expect(pacienteFhir.name[0].text).toBe('HUGO AGUSTIN PERINGA PONCE');
44
- expect(pacienteFhir.gender).toBe('male');
45
- expect(pacienteFhir.birthDate).toBe('1979-11-14');
46
- });
47
- test('Verify patient with contact information', () => {
48
- // Phone;
49
- expect(pacienteFhir.telecom).toBeDefined();
50
- expect(pacienteFhir.telecom[0].value).toBe('4462221');
51
- expect(pacienteFhir.telecom[0].system).toBe('phone');
52
- // Address;
53
- expect(pacienteFhir.address).toBeDefined();
54
- expect(pacienteFhir.address[0].postalCode).toBe('8300');
55
- expect(pacienteFhir.address[0].line).toContain('Enrique Santos Discepolo 1856');
56
- expect(pacienteFhir.address[0].city).toBe('NEUQUEN');
57
- expect(pacienteFhir.address[0].state).toBe('Neuquén');
58
- expect(pacienteFhir.address[0].country).toBe('Argentina');
59
- });
60
- test('Verify patient with relationships', () => {
61
- // Validar que exista contact y al menos un elemento
62
- expect(pacienteFhir.contact).toBeDefined();
63
- expect(pacienteFhir.contact.length).toBeGreaterThan(0);
64
- const contacto0 = pacienteFhir.contact[0];
65
- // Validar que tenga relationship y name estructurados
66
- expect(contacto0.relationship).toBeDefined();
67
- expect(contacto0.relationship.length).toBeGreaterThan(0);
68
- expect(contacto0.name).toBeDefined();
69
- // Ahora sí: acceder sin que TS marque error
70
- expect(contacto0.relationship[0].text).toBe('hijo/a');
71
- expect(contacto0.name.family).toContain('PERINGA');
72
- expect(contacto0.name.given).toContain('JOSEFINA');
73
- });
74
- test('Maneja paciente con estado validado', () => {
75
- const paciente = (0, patientFactory_1.createPatient)({ estado: 'validado' });
76
- const fhir = (0, patient_1.encode)(paciente);
77
- expect(fhir).not.toBeNull();
78
- expect(fhir.extension?.some(t => t.valueCode === 'validado')).toBeTruthy();
79
- });
80
- test('Maneja paciente con estado temporal', () => {
81
- const paciente = (0, patientFactory_1.createPatient)({ estado: 'temporal' });
82
- const fhir = (0, patient_1.encode)(paciente);
83
- expect(fhir).not.toBeNull();
84
- expect(fhir.extension?.some(t => t.valueCode === 'temporal')).toBeTruthy();
85
- });
86
- test('Maneja paciente con estado nulo', () => {
87
- const paciente = (0, patientFactory_1.createPatient)({ estado: null });
88
- const fhir = (0, patient_1.encode)(paciente);
89
- expect(fhir).not.toBeNull();
90
- expect(fhir.extension?.some(t => t.valueCode === 'temporal')).toBeTruthy();
91
- });
92
- it('Verifica organización que crea paciente', () => {
93
- const fhir = pacienteFhir;
94
- expect(fhir.managingOrganization).toBeDefined();
95
- expect(fhir.managingOrganization.display).toContain('LABORATORIO');
96
- });
97
- it('Verifica dni extranjero', () => {
98
- const paciente = (0, patientFactory_1.createPatient)({ tipoIdentificacion: 'dni extranjero', numeroIdentificacion: 'ABC123' });
99
- const fhir = (0, patient_1.encode)(paciente);
100
- expect(fhir).not.toBeNull();
101
- const id = fhir.identifier?.find(t => t.system === 'andes.gob.ar/sid/foreign-id');
102
- expect(id?.value).toBe('ABC123');
103
- expect(id?.system).toBe('andes.gob.ar/sid/foreign-id');
104
- });
105
- it('Verifica pasaporte', () => {
106
- const paciente = (0, patientFactory_1.createPatient)({ tipoIdentificacion: 'pasaporte', numeroIdentificacion: 'ABC123CD' });
107
- const fhir = (0, patient_1.encode)(paciente);
108
- expect(fhir).not.toBeNull();
109
- const id = fhir.identifier?.find(t => t.system === 'andes.gob.ar/sid/passport');
110
- expect(id?.value).toBe('ABC123CD');
111
- expect(id?.system).toBe('andes.gob.ar/sid/passport');
112
- });
113
- });
114
- describe('decode patient from FHIR R4 to ANDES', () => {
115
- it('Verifica dni extranjero', () => {
116
- const paciente = (0, patientFactory_1.createPatient)({ tipoIdentificacion: 'dni extranjero', numeroIdentificacion: 'ABC123' });
117
- const fhirEncode = (0, patient_1.encode)(paciente);
118
- expect(fhirEncode).not.toBeNull();
119
- const fhirDecode = (0, patient_1.decode)(fhirEncode);
120
- expect(fhirDecode?.tipoIdentificacion).toBe('dni extranjero');
121
- expect(fhirDecode?.numeroIdentificacion).toBe('ABC123');
122
- });
123
- it('Verifica pasaporte', () => {
124
- const paciente = (0, patientFactory_1.createPatient)({ tipoIdentificacion: 'pasaporte', numeroIdentificacion: 'ABC123CD' });
125
- const fhirEncode = (0, patient_1.encode)(paciente);
126
- expect(fhirEncode).not.toBeNull();
127
- const fhirDecode = (0, patient_1.decode)(fhirEncode);
128
- expect(fhirDecode?.tipoIdentificacion).toBe('pasaporte');
129
- expect(fhirDecode?.numeroIdentificacion).toBe('ABC123CD');
130
- expect(fhirDecode?.estado).toBe('temporal');
131
- });
132
- });