@andes/fhir 1.12.1-beta.4 → 1.12.1-beta.7

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.
@@ -49,15 +49,25 @@ function buildGenderIdentityExtension(genero) {
49
49
  if (!genero) {
50
50
  return [];
51
51
  }
52
- return [{
53
- url: 'http://hl7.org/fhir/StructureDefinition/individual-genderIdentity',
54
- valueCode: genero
55
- }];
52
+ return [
53
+ {
54
+ "url": "https://andes.gob.ar/fhir/StructureDefinition/patient-genderIdentity",
55
+ "valueCodeableConcept": {
56
+ "coding": [
57
+ {
58
+ "system": "https://andes.gob.ar/fhir/CodeSystem/gender-identity",
59
+ "code": genero,
60
+ "display": genero
61
+ }
62
+ ]
63
+ }
64
+ }
65
+ ];
56
66
  }
57
67
  function buildStatusExtension(estado) {
58
68
  const value = estado ?? 'temporal';
59
69
  return [{
60
- url: 'andes.gob.ar/fhir/StructureDefinition/patient-status',
70
+ url: 'https://andes.gob.ar/fhir/StructureDefinition/patient-status',
61
71
  valueCode: value
62
72
  }];
63
73
  }
@@ -89,6 +99,16 @@ function mapEstadoCivilFHIRToAndes(estadoCivil) {
89
99
  return 'otro';
90
100
  }
91
101
  }
102
+ function mapAndesRankingToFhirRank(andesRanking) {
103
+ return typeof andesRanking === 'number' && Number.isInteger(andesRanking) && andesRanking >= 0
104
+ ? andesRanking + 1
105
+ : 1;
106
+ }
107
+ function mapFhirRankToAndesRanking(fhirRank) {
108
+ return typeof fhirRank === 'number' && Number.isInteger(fhirRank) && fhirRank > 0
109
+ ? fhirRank - 1
110
+ : 0;
111
+ }
92
112
  /**
93
113
  * Encode a patient from ANDES to FHIR
94
114
  */
@@ -135,7 +155,7 @@ function encode(patient) {
135
155
  .map((unContacto) => {
136
156
  const cont = {
137
157
  value: unContacto.valor,
138
- rank: unContacto.ranking
158
+ rank: mapAndesRankingToFhirRank(unContacto.ranking)
139
159
  };
140
160
  switch (unContacto.tipo) {
141
161
  case 'fijo':
@@ -230,7 +250,7 @@ function encode(patient) {
230
250
  }
231
251
  if (patient.createdBy?.organizacion) {
232
252
  const managingOrganization = {
233
- reference: patient.createdBy.organizacion.id,
253
+ reference: `Organization/${patient.createdBy.organizacion.id}`,
234
254
  display: patient.createdBy.organizacion.nombre
235
255
  };
236
256
  pacienteFHIR.managingOrganization = managingOrganization;
@@ -289,7 +309,7 @@ function decode(patient) {
289
309
  ? patient.telecom.map((unContacto) => {
290
310
  const cont = {
291
311
  valor: unContacto.value,
292
- ranking: unContacto.rank
312
+ ranking: mapFhirRankToAndesRanking(unContacto.rank)
293
313
  };
294
314
  switch (unContacto.system) {
295
315
  case 'phone':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andes/fhir",
3
- "version": "1.12.1-beta.4",
3
+ "version": "1.12.1-beta.7",
4
4
  "engines": {
5
5
  "node": ">=18.0.0"
6
6
  },