diff --git a/src/lib/organization.ts b/src/lib/organization.ts index 2bb7624..b380803 100644 --- a/src/lib/organization.ts +++ b/src/lib/organization.ts @@ -10,6 +10,7 @@ import { AndesContactoOrg, AndesDireccionOrg } from '../types/andes/organization.types'; +import { mapAndesRankingToFhirRank } from '../utils/rankingMapping'; /** * Encode an ANDES Organization to FHIR Organization @@ -23,25 +24,25 @@ export function encode(organization: AndesOrganization | null | undefined): Orga if (data.codigo?.sisa) { identificadores.push({ - system: 'andes.gob.ar/sisa', + system: 'https://andes.gob.ar/sisa', value: data.codigo.sisa }); } if (data.codigo?.cuie) { identificadores.push({ - system: 'andes.gob.ar/cuie', + system: 'https://andes.gob.ar/cuie', value: data.codigo.cuie }); } if (data.codigo?.remediar) { identificadores.push({ - system: 'andes.gob.ar/remediar', + system: 'https://andes.gob.ar/remediar', value: data.codigo.remediar }); } if (data.codigo?.sips) { identificadores.push({ - system: 'andes.gob.ar/sips', + system: 'https://andes.gob.ar/sips', value: data.codigo.sips }); } @@ -56,7 +57,7 @@ export function encode(organization: AndesOrganization | null | undefined): Orga .map((item: AndesContactoOrg): ContactPoint => { const cp: ContactPoint = { value: item.valor, - rank: item.ranking + rank: mapAndesRankingToFhirRank(item.ranking) }; switch (item.tipo) { case 'fijo': diff --git a/src/lib/patient.ts b/src/lib/patient.ts index d8e4207..52da60f 100644 --- a/src/lib/patient.ts +++ b/src/lib/patient.ts @@ -13,6 +13,7 @@ import { AndesDireccion, AndesRelacion } from '../types/andes/patient.types'; +import { mapAndesRankingToFhirRank, mapFhirRankToAndesRanking } from '../utils/rankingMapping'; /** * Helpers @@ -118,19 +119,6 @@ function mapEstadoCivilFHIRToAndes(estadoCivil?: string): string { } } -function mapAndesRankingToFhirRank(andesRanking?: number): number { - return typeof andesRanking === 'number' && Number.isInteger(andesRanking) && andesRanking >= 0 - ? andesRanking + 1 - : 1; -} - -function mapFhirRankToAndesRanking(fhirRank?: number): number { - return typeof fhirRank === 'number' && Number.isInteger(fhirRank) && fhirRank > 0 - ? fhirRank - 1 - : 0; -} - - /** * Encode a patient from ANDES to FHIR */ diff --git a/src/utils/rankingMapping.ts b/src/utils/rankingMapping.ts new file mode 100644 index 0000000..ec7289c --- /dev/null +++ b/src/utils/rankingMapping.ts @@ -0,0 +1,17 @@ +/** + * Mapea ANDES ranking base 1 a FHIR rank base 1 + */ +export function mapAndesRankingToFhirRank(andesRanking?: number): number { + return typeof andesRanking === 'number' && Number.isInteger(andesRanking) && andesRanking >= 0 + ? andesRanking + 1 + : 1; +} + +/** + * Mapea FHIR rank base 1 a ANDES ranking base 0 + */ +export function mapFhirRankToAndesRanking(fhirRank?: number): number { + return typeof fhirRank === 'number' && Number.isInteger(fhirRank) && fhirRank > 0 + ? fhirRank - 1 + : 0; +}