File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,6 +118,19 @@ function mapEstadoCivilFHIRToAndes(estadoCivil?: string): string {
118118 }
119119}
120120
121+ function mapAndesRankingToFhirRank ( andesRanking ?: number ) : number {
122+ return typeof andesRanking === 'number' && Number . isInteger ( andesRanking ) && andesRanking >= 0
123+ ? andesRanking + 1
124+ : 1 ;
125+ }
126+
127+ function mapFhirRankToAndesRanking ( fhirRank ?: number ) : number {
128+ return typeof fhirRank === 'number' && Number . isInteger ( fhirRank ) && fhirRank > 0
129+ ? fhirRank - 1
130+ : 0 ;
131+ }
132+
133+
121134/**
122135 * Encode a patient from ANDES to FHIR
123136 */
@@ -170,7 +183,7 @@ export function encode(patient: AndesPatient | null | undefined): Patient | null
170183 . map ( ( unContacto : AndesContacto ) : ContactPoint => {
171184 const cont : ContactPoint = {
172185 value : unContacto . valor ,
173- rank : unContacto . ranking
186+ rank : mapAndesRankingToFhirRank ( unContacto . ranking )
174187 } ;
175188
176189 switch ( unContacto . tipo ) {
@@ -357,7 +370,7 @@ export function decode(patient: Patient): AndesPatient {
357370 ? patient . telecom . map ( ( unContacto : ContactPoint ) => {
358371 const cont : any = {
359372 valor : unContacto . value ,
360- ranking : unContacto . rank
373+ ranking : mapFhirRankToAndesRanking ( unContacto . rank )
361374 } ;
362375 switch ( unContacto . system ) {
363376 case 'phone' :
You can’t perform that action at this time.
0 commit comments