Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/lib/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
AndesContactoOrg,
AndesDireccionOrg
} from '../types/andes/organization.types';
import { mapAndesRankingToFhirRank } from '../utils/rankingMapping';

/**
* Encode an ANDES Organization to FHIR Organization
Expand All @@ -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
});
}
Expand All @@ -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':
Expand Down
14 changes: 1 addition & 13 deletions src/lib/patient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
AndesDireccion,
AndesRelacion
} from '../types/andes/patient.types';
import { mapAndesRankingToFhirRank, mapFhirRankToAndesRanking } from '../utils/rankingMapping';

/**
* Helpers
Expand Down Expand Up @@ -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
*/
Expand Down
17 changes: 17 additions & 0 deletions src/utils/rankingMapping.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Loading