@andes/fhir 1.11.1
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.
- package/.circleci/config.yml +69 -0
- package/.editorconfig +14 -0
- package/.gitattributes +1 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/labeler.yml +11 -0
- package/.github/pull_request_template.md +28 -0
- package/.github/workflows/build_test.yml +14 -0
- package/.github/workflows/has_conflicts.yml +13 -0
- package/CHANGELOG.md +306 -0
- package/LICENSE +674 -0
- package/README.md +2 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/src/data/patient.json +185 -0
- package/dist/src/lib/allergyIntolerance.js +40 -0
- package/dist/src/lib/allergyIntolerance.js.map +1 -0
- package/dist/src/lib/bundle.js +23 -0
- package/dist/src/lib/bundle.js.map +1 -0
- package/dist/src/lib/composition.js +151 -0
- package/dist/src/lib/composition.js.map +1 -0
- package/dist/src/lib/condition.js +80 -0
- package/dist/src/lib/condition.js.map +1 -0
- package/dist/src/lib/config.js +23 -0
- package/dist/src/lib/config.js.map +1 -0
- package/dist/src/lib/config.test.js +13 -0
- package/dist/src/lib/config.test.js.map +1 -0
- package/dist/src/lib/device.js +39 -0
- package/dist/src/lib/device.js.map +1 -0
- package/dist/src/lib/device.test.js +10 -0
- package/dist/src/lib/device.test.js.map +1 -0
- package/dist/src/lib/document-reference.js +104 -0
- package/dist/src/lib/document-reference.js.map +1 -0
- package/dist/src/lib/immunization.js +68 -0
- package/dist/src/lib/immunization.js.map +1 -0
- package/dist/src/lib/medication.js +65 -0
- package/dist/src/lib/medication.js.map +1 -0
- package/dist/src/lib/medicationRequest.js +100 -0
- package/dist/src/lib/medicationRequest.js.map +1 -0
- package/dist/src/lib/medicationStatement.js +56 -0
- package/dist/src/lib/medicationStatement.js.map +1 -0
- package/dist/src/lib/organization.js +91 -0
- package/dist/src/lib/organization.js.map +1 -0
- package/dist/src/lib/patient.js +361 -0
- package/dist/src/lib/patient.js.map +1 -0
- package/dist/src/lib/patient.test.js +40 -0
- package/dist/src/lib/patient.test.js.map +1 -0
- package/dist/src/lib/practitioner.js +161 -0
- package/dist/src/lib/practitioner.js.map +1 -0
- package/index.ts +31 -0
- package/jest.config.js +12 -0
- package/package.json +54 -0
- package/src/data/patient.json +185 -0
- package/src/lib/allergyIntolerance.ts +36 -0
- package/src/lib/bundle.ts +19 -0
- package/src/lib/composition.ts +153 -0
- package/src/lib/condition.ts +80 -0
- package/src/lib/config.test.ts +13 -0
- package/src/lib/config.ts +17 -0
- package/src/lib/device.test.ts +9 -0
- package/src/lib/device.ts +36 -0
- package/src/lib/document-reference.ts +102 -0
- package/src/lib/immunization.ts +64 -0
- package/src/lib/medication.ts +61 -0
- package/src/lib/medicationRequest.ts +100 -0
- package/src/lib/medicationStatement.ts +52 -0
- package/src/lib/organization.ts +89 -0
- package/src/lib/patient.test.ts +38 -0
- package/src/lib/patient.ts +374 -0
- package/src/lib/practitioner.ts +157 -0
- package/tsconfig.test.json +18 -0
- package/tslint.json +139 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as moment from 'moment';
|
|
2
|
+
import { makeUrl } from './config';
|
|
3
|
+
|
|
4
|
+
export function encode(ID, author, organization, patient, binaryURL) {
|
|
5
|
+
return {
|
|
6
|
+
resourceType: 'DocumentReference',
|
|
7
|
+
id: ID,
|
|
8
|
+
meta: {
|
|
9
|
+
lastUpdated: moment().format()
|
|
10
|
+
},
|
|
11
|
+
contained: [
|
|
12
|
+
{
|
|
13
|
+
resourceType: 'Practitioner',
|
|
14
|
+
id: author.id,
|
|
15
|
+
identifier: [{
|
|
16
|
+
system: makeUrl('Device'),
|
|
17
|
+
value: author.id
|
|
18
|
+
}]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
resourceType: 'Organization',
|
|
22
|
+
id: organization.id,
|
|
23
|
+
identifier: [{
|
|
24
|
+
system: makeUrl('Organization'),
|
|
25
|
+
value: organization.id
|
|
26
|
+
}]
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
custodian: {
|
|
30
|
+
identifier: {
|
|
31
|
+
system: 'https://federador.msal.gob.ar/uri',
|
|
32
|
+
value: makeUrl('Organization', organization.id)
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
masterIdentifier: {
|
|
36
|
+
system: makeUrl('documentos_versiones'),
|
|
37
|
+
value: ID
|
|
38
|
+
},
|
|
39
|
+
identifier: [{
|
|
40
|
+
system: makeUrl('documentos'),
|
|
41
|
+
value: ID
|
|
42
|
+
}],
|
|
43
|
+
status: 'current',
|
|
44
|
+
type: {
|
|
45
|
+
coding: [
|
|
46
|
+
{
|
|
47
|
+
system: 'http://loinc.org',
|
|
48
|
+
code: '60591-5'
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
subject: {
|
|
53
|
+
reference: makeUrl('Patient', patient.id),
|
|
54
|
+
},
|
|
55
|
+
// author: [
|
|
56
|
+
// {
|
|
57
|
+
// reference: makeUrl('Device', author.id),
|
|
58
|
+
// },
|
|
59
|
+
// {
|
|
60
|
+
// reference: makeUrl('Organization', organization.id),
|
|
61
|
+
// }
|
|
62
|
+
// ],
|
|
63
|
+
securityLabel: [{
|
|
64
|
+
coding: [{
|
|
65
|
+
system: 'https://saludddigital.gob.ar/nivelesconfidencialidad',
|
|
66
|
+
code: 'N'
|
|
67
|
+
}]
|
|
68
|
+
}],
|
|
69
|
+
content: [{
|
|
70
|
+
attachment: {
|
|
71
|
+
id: 'PRINCIPAL',
|
|
72
|
+
url: binaryURL
|
|
73
|
+
}
|
|
74
|
+
}],
|
|
75
|
+
context: {
|
|
76
|
+
event: [{
|
|
77
|
+
coding: [{
|
|
78
|
+
system: 'https://saludddigital.gob.ar/tiposevento',
|
|
79
|
+
code: 'CIR'
|
|
80
|
+
}]
|
|
81
|
+
}],
|
|
82
|
+
// period: {
|
|
83
|
+
// start: '2019-04-03T10:30:00+03:00',
|
|
84
|
+
// end: '2019-04-05T10:30:00+03:00'
|
|
85
|
+
|
|
86
|
+
// },
|
|
87
|
+
facilityType: {
|
|
88
|
+
coding: [{
|
|
89
|
+
system: 'https://saludddigital.gob.ar/tipoprestador',
|
|
90
|
+
code: 'INI'
|
|
91
|
+
}]
|
|
92
|
+
},
|
|
93
|
+
practiceSetting: {
|
|
94
|
+
coding: [{
|
|
95
|
+
system: 'https://saludddigital.gob.ar/especialidades',
|
|
96
|
+
code: 'CLM'
|
|
97
|
+
}]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Encode de Vacunas Nomivac from ANDES to FHIR
|
|
4
|
+
* @param {} nomivac
|
|
5
|
+
* [ASK] El code de extension puede ir en vaccineCode?
|
|
6
|
+
* [ASk] Location no se sabe. Solo esta el texto
|
|
7
|
+
*/
|
|
8
|
+
export function encode(patientReference, nomivac) {
|
|
9
|
+
return {
|
|
10
|
+
resourceType: 'Immunization',
|
|
11
|
+
id: nomivac.idvacuna,
|
|
12
|
+
extension: [
|
|
13
|
+
{
|
|
14
|
+
url: 'http://sisa/fhir/esquema',
|
|
15
|
+
valueCoding: {
|
|
16
|
+
system: 'http://argentina.gob.ar/salud/NOMIVAC-esquemas',
|
|
17
|
+
code: '0', // [TODO] Ver que code ponemos acá
|
|
18
|
+
display: nomivac.vacuna
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
url: 'http://sisa/fhir/condicionAplicacion',
|
|
23
|
+
valueCoding: {
|
|
24
|
+
system: 'http://argentina.gob.ar/salud/NOMIVAC-condicion',
|
|
25
|
+
code: '17',
|
|
26
|
+
display: 'Personal de Salud'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
status: 'completed',
|
|
31
|
+
notGiven: false,
|
|
32
|
+
vaccineCode: {
|
|
33
|
+
coding: [
|
|
34
|
+
{
|
|
35
|
+
system: 'https://snomed.info/sct/11000221109/id/228100022110',
|
|
36
|
+
code: nomivac.idvacuna,
|
|
37
|
+
display: nomivac.vacuna
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
patient: {
|
|
42
|
+
reference: patientReference
|
|
43
|
+
},
|
|
44
|
+
date: nomivac.fechaAplicacion,
|
|
45
|
+
primarySource: false,
|
|
46
|
+
location: {
|
|
47
|
+
reference: 'http://argentina.gob.ar/salud/refes/14999912399913'
|
|
48
|
+
},
|
|
49
|
+
// lotNumber: null,
|
|
50
|
+
vaccinationProtocol: [
|
|
51
|
+
{
|
|
52
|
+
doseSequence: 1,
|
|
53
|
+
doseStatus: {
|
|
54
|
+
coding: [
|
|
55
|
+
{
|
|
56
|
+
system: 'http://hl7.org/fhir/vaccination-protocol-dose-status',
|
|
57
|
+
code: nomivac.dosis
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode de Medicamentos from ANDES to FHIR
|
|
3
|
+
* @param {} medication
|
|
4
|
+
*/
|
|
5
|
+
export function encode(medication) {
|
|
6
|
+
// Falta completar con más detalle
|
|
7
|
+
return {
|
|
8
|
+
resourceType: 'Medication',
|
|
9
|
+
id: medication.conceptId, // Es el id del medicamento, en este caso usamos el código de snomed (ver si sería correcto)
|
|
10
|
+
meta: {
|
|
11
|
+
profile: [
|
|
12
|
+
'http://hl7.org/fhir/uv/ips/StructureDefinition/medication-ips'
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
identifier: medication.moduleId, // Acá va el serial number del medicamento.
|
|
16
|
+
code: {
|
|
17
|
+
coding: [
|
|
18
|
+
{
|
|
19
|
+
system: 'http://snomed.info/sct',
|
|
20
|
+
display: medication.term,
|
|
21
|
+
code: medication.conceptId
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
text: medication.fsn
|
|
25
|
+
},
|
|
26
|
+
status: medication.active === true ? 'active' : 'inactive',
|
|
27
|
+
// manufacturer: null,
|
|
28
|
+
// form: null,
|
|
29
|
+
// amount: null,
|
|
30
|
+
// ingredient: null,
|
|
31
|
+
// ingredient: [ // ejemplo
|
|
32
|
+
// {
|
|
33
|
+
// code: {
|
|
34
|
+
// coding: [
|
|
35
|
+
// {
|
|
36
|
+
// system: "http://snomed.info/sct",
|
|
37
|
+
// display: "salbutamol (sustancia)",
|
|
38
|
+
// code: "372897005"
|
|
39
|
+
// }
|
|
40
|
+
// ]
|
|
41
|
+
// },
|
|
42
|
+
// isActive: true,
|
|
43
|
+
// strength: {
|
|
44
|
+
// numerator: {
|
|
45
|
+
// value: 200,
|
|
46
|
+
// unit: "mcg"
|
|
47
|
+
// },
|
|
48
|
+
// denominator: {
|
|
49
|
+
// value: 1,
|
|
50
|
+
// unit: "disparo"
|
|
51
|
+
// }
|
|
52
|
+
// }
|
|
53
|
+
// }
|
|
54
|
+
// ],
|
|
55
|
+
text: {
|
|
56
|
+
status: 'generated',
|
|
57
|
+
div: `<div xmlns="http://www.w3.org/1999/xhtml"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: Medicacion</p><p><b>meta</b>: </p><p><b>text</b>: ${medication.pt.term}</p></div>`
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode medicationRequest from ANDES to FHIR
|
|
3
|
+
* @param {} medicationRequest
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as moment from 'moment';
|
|
7
|
+
|
|
8
|
+
// Muy incompleto hay que mejorarlo mucho todavía
|
|
9
|
+
|
|
10
|
+
export function encode(patientReference, practitionerReference, medicationFHIR, data) {
|
|
11
|
+
return {
|
|
12
|
+
resourceType: 'MedicationRequest',
|
|
13
|
+
id: data.registro._id, // id de la prescripción completa
|
|
14
|
+
text: {
|
|
15
|
+
status: 'generated',
|
|
16
|
+
// div: `<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: Medicacion </p><p><b>meta</b>: </p><p><b>text</b>: ${'DEFINIR'}</p></div>`
|
|
17
|
+
},
|
|
18
|
+
contained: [
|
|
19
|
+
medicationFHIR
|
|
20
|
+
],
|
|
21
|
+
identifier: [ // Ver bien que sería el array de identifiers
|
|
22
|
+
{
|
|
23
|
+
use: 'official',
|
|
24
|
+
system: 'http://app.andes.gob.ar/prescriptions', // Es el id de la prestación completa
|
|
25
|
+
value: data.registro.id
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
// active | on-hold | cancelled | completed | entered-in-error | stopped | draft | unknown
|
|
29
|
+
status: (data.prestacion.estadoActual.tipo === 'validada') ? 'active' : 'on-hold', // Lo mejor sería enviar el estado de la receta desde la prestación
|
|
30
|
+
// intent: proposal | plan | order | original-order | reflex-order | filler-order | instance-order | option
|
|
31
|
+
intent: 'order', // Ya que no tenemos este dato, ver como sería en caso de recetas prolongadas si puede ir como plan
|
|
32
|
+
// category: {
|
|
33
|
+
// coding: [
|
|
34
|
+
// {
|
|
35
|
+
// system: '',
|
|
36
|
+
// display: '',
|
|
37
|
+
// code: ''
|
|
38
|
+
// }
|
|
39
|
+
// ]
|
|
40
|
+
// },
|
|
41
|
+
// priority: routine | urgent | asap | stat
|
|
42
|
+
priority: 'routine',
|
|
43
|
+
doNotPerform: false,
|
|
44
|
+
// Se puede usar medicationCodeableConcept o medicationReference, vamos a usar esta última.
|
|
45
|
+
medicationReference: {
|
|
46
|
+
reference: medicationFHIR.id,
|
|
47
|
+
display: medicationFHIR.code.text
|
|
48
|
+
},
|
|
49
|
+
subject: {
|
|
50
|
+
reference: patientReference // podría ser una reference a un group también
|
|
51
|
+
},
|
|
52
|
+
// encounter: Por ahora lo dejo pendiente. Podría ponerse una referencia a otra prestación o al informe del encuentro.
|
|
53
|
+
authoredOn: moment(data.registro.createdAt).format('YYYY-MM-DD'),
|
|
54
|
+
// requester & performer: pueden ser Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson|CareTeam)
|
|
55
|
+
// por el momento vamos a tomar al profesional porque no tenemos otra info en la prestación
|
|
56
|
+
requester: {
|
|
57
|
+
reference: practitionerReference
|
|
58
|
+
},
|
|
59
|
+
// performer: {
|
|
60
|
+
// reference: practitionerReference
|
|
61
|
+
// },
|
|
62
|
+
// performerType: Lo dejamos pendiente
|
|
63
|
+
// recorder: {
|
|
64
|
+
// reference: practitionerReference
|
|
65
|
+
// },
|
|
66
|
+
// instantiatesCanonical: null, // ["<canonical>"], // Instantiates FHIR protocol or definition
|
|
67
|
+
// instantiatesUri: null, // ["<uri>"], // Instantiates external protocol or definition
|
|
68
|
+
basedOn: data.prestacion.id, // Vamos a usar el id de la prestación donde esta todo [{ Reference(CarePlan|MedicationRequest|ServiceRequest| ImmunizationRecommendation) }], // What request fulfills
|
|
69
|
+
// groupIdentifier: null, // { Identifier }, // Composite request this is part of
|
|
70
|
+
// courseOfTherapyType: null, // { CodeableConcept }, // Overall pattern of medication administration
|
|
71
|
+
// insurance: null, // [{ Reference(Coverage|ClaimResponse) }], // Associated insurance coverage
|
|
72
|
+
note: null, // De donde sacamos las notas? [{ Annotation }], // Information about the prescription
|
|
73
|
+
dosageInstruction: null, // [{ Dosage }], // How the medication should be taken
|
|
74
|
+
// Medication supply authorization: Hay que ver esta parte
|
|
75
|
+
/*
|
|
76
|
+
dispenseRequest: { // Medication supply authorization
|
|
77
|
+
initialFill: { // First fill details
|
|
78
|
+
quantity: { Quantity(SimpleQuantity) }, // First fill quantity
|
|
79
|
+
duration: { Duration } // First fill duration
|
|
80
|
+
},
|
|
81
|
+
dispenseInterval: { Duration }, // Minimum period of time between dispenses
|
|
82
|
+
validityPeriod: { Period }, // Time period supply is authorized for
|
|
83
|
+
numberOfRepeatsAllowed: "<unsignedInt>", // Number of refills authorized
|
|
84
|
+
quantity: { Quantity(SimpleQuantity) }, // Amount of medication to supply per dispense
|
|
85
|
+
expectedSupplyDuration: { Duration }, // Number of days supply per dispense
|
|
86
|
+
performer: { Reference(Organization) } // Intended dispenser
|
|
87
|
+
},
|
|
88
|
+
*/
|
|
89
|
+
substitution: { // Any restrictions on medication substitution
|
|
90
|
+
// allowed[x]: Whether substitution is allowed or not. One of these 2:
|
|
91
|
+
allowedBoolean: true, // <boolean>,
|
|
92
|
+
// "allowedCodeableConcept" : { CodeableConcept },
|
|
93
|
+
reason: null // { CodeableConcept } // Why should (not) substitution be made
|
|
94
|
+
},
|
|
95
|
+
priorPrescription: null, // { Reference(MedicationRequest) }, // An order/prescription that is being replaced
|
|
96
|
+
detectedIssue: null, // [{ Reference(DetectedIssue) }], // Clinical Issue with action
|
|
97
|
+
eventHistory: null// [{ Reference(Provenance) }]
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode de Medicamentos from ANDES to FHIR
|
|
3
|
+
* @param {} medicationStatement
|
|
4
|
+
*/
|
|
5
|
+
// Muy incompleto hay que mejorarlo mucho todavía
|
|
6
|
+
export function encode(patientReference, medicationReference, prestacionMedicamento) {
|
|
7
|
+
return {
|
|
8
|
+
resourceType: 'MedicationStatement',
|
|
9
|
+
status: (prestacionMedicamento.valor.estado === 'activo') ? 'active' : 'inactive',
|
|
10
|
+
id: prestacionMedicamento._id, // El código de la prestación donde está el registro del contexto de porque está consumiendo el medicamento
|
|
11
|
+
effectiveDateTime: prestacionMedicamento.createdAt,
|
|
12
|
+
medicationCodeableConcept: {
|
|
13
|
+
coding: [
|
|
14
|
+
{
|
|
15
|
+
system: 'http://snomed.info/sct',
|
|
16
|
+
code: prestacionMedicamento.concepto.conceptId,
|
|
17
|
+
display: prestacionMedicamento.concepto.term
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
meta: {
|
|
22
|
+
profile: [
|
|
23
|
+
'http://hl7.org/fhir/uv/ips/StructureDefinition/medication-ips'
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
// extension: null,
|
|
27
|
+
// identifier: '', // Business identifier, not a resource identifier
|
|
28
|
+
subject: {
|
|
29
|
+
reference: patientReference
|
|
30
|
+
},
|
|
31
|
+
medicationReference: {
|
|
32
|
+
reference: medicationReference
|
|
33
|
+
},
|
|
34
|
+
// context: null, // Encounter | Episode of care (podría ser el informe del encuentro o lo que definamos que brinda más información sobre el por qué)
|
|
35
|
+
dosage: [
|
|
36
|
+
{
|
|
37
|
+
text: prestacionMedicamento.valor, // indicación
|
|
38
|
+
route: { coding: [{ system: 'http://standardterms.edqm.eu', code: prestacionMedicamento._id, display: prestacionMedicamento.nombre }] },
|
|
39
|
+
timing: { coding: { system: 'http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation', code: 'QD', display: 'Diario' } }
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
// effectivePeriod: { // Esta parte se podría calcular entre la fecha de la prestación y la cant. de tiempo que se indica, pero hay problemas
|
|
43
|
+
// en este registro ya que no siempre está la unidad de tiempo (dias, mes, etc) hay q ver si no es un bug.
|
|
44
|
+
// start: '2015-03'
|
|
45
|
+
// },
|
|
46
|
+
text: {
|
|
47
|
+
status: 'generated',
|
|
48
|
+
div: `<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: Medicacion </p><p><b>meta</b>: </p><p><b>text</b>: ${prestacionMedicamento.concepto.term}</p></div>`
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { getDominio, makeUrl } from './config';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Encode a organization from ANDES to FHIR
|
|
5
|
+
* @param {} organization
|
|
6
|
+
*/
|
|
7
|
+
export function encode(organization) {
|
|
8
|
+
let data = organization;
|
|
9
|
+
if (data) {
|
|
10
|
+
let identificadores: any[] = data.codigo.sisa ? [{
|
|
11
|
+
assigner: 'sisa',
|
|
12
|
+
value: data.codigo.sisa
|
|
13
|
+
}] : [];
|
|
14
|
+
if (data.codigo.cuie) {
|
|
15
|
+
identificadores.push({
|
|
16
|
+
assigner: 'cuie',
|
|
17
|
+
value: data.codigo.cuie
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (data.codigo.remediar) {
|
|
21
|
+
identificadores.push({
|
|
22
|
+
assigner: 'remediar',
|
|
23
|
+
value: data.codigo.remediar
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (data.codigo.sips) {
|
|
27
|
+
identificadores.push({
|
|
28
|
+
assigner: 'sips',
|
|
29
|
+
value: data.codigo.sips
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
identificadores.push({
|
|
33
|
+
system: makeUrl('Organization'),
|
|
34
|
+
value: data._id
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
let contactos = data.contacto ? data.contacto.map(unContacto => {
|
|
38
|
+
let cont = {
|
|
39
|
+
resourceType: 'ContactPoint',
|
|
40
|
+
value: unContacto.valor,
|
|
41
|
+
rank: unContacto.ranking,
|
|
42
|
+
};
|
|
43
|
+
switch (unContacto.tipo) {
|
|
44
|
+
case 'fijo':
|
|
45
|
+
cont['system'] = 'phone';
|
|
46
|
+
break;
|
|
47
|
+
case 'celular':
|
|
48
|
+
cont['system'] = 'phone';
|
|
49
|
+
break;
|
|
50
|
+
case 'email':
|
|
51
|
+
cont['system'] = 'email';
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
return cont;
|
|
55
|
+
}) : [];
|
|
56
|
+
// Parsea direcciones
|
|
57
|
+
let direcciones = data.direccion ? [{
|
|
58
|
+
resourceType: 'Address',
|
|
59
|
+
postalCode: data.direccion.codigoPostal ? data.direccion.codigoPostal : '',
|
|
60
|
+
line: [data.direccion.valor],
|
|
61
|
+
city: data.direccion.ubicacion.localidad ? data.direccion.ubicacion.localidad.nombre : '',
|
|
62
|
+
state: data.direccion.ubicacion.provincia ? data.direccion.ubicacion.provincia.nombre : '',
|
|
63
|
+
country: data.direccion.ubicacion.pais ? data.direccion.ubicacion.pais.nombre : '',
|
|
64
|
+
}] : [];
|
|
65
|
+
|
|
66
|
+
// Armamos la organizacion FHIR
|
|
67
|
+
let organizacionFHIR = {
|
|
68
|
+
id: data.id,
|
|
69
|
+
resourceType: 'Organization',
|
|
70
|
+
identifier: identificadores,
|
|
71
|
+
active: data.activo ? data.activo : null,
|
|
72
|
+
type: [{
|
|
73
|
+
resourceType: 'CodeableConcept',
|
|
74
|
+
text: data.tipoEstablecimiento ? data.tipoEstablecimiento.nombre : null,
|
|
75
|
+
}],
|
|
76
|
+
name: data.nombre ? data.nombre : null, // Name used for the organization
|
|
77
|
+
};
|
|
78
|
+
if (contactos.length > 0) { // A contact detail for the organization
|
|
79
|
+
organizacionFHIR['telecom'] = contactos;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (direcciones) { // An address for the organization
|
|
83
|
+
organizacionFHIR['address'] = direcciones;
|
|
84
|
+
}
|
|
85
|
+
return organizacionFHIR;
|
|
86
|
+
} else {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as patient from '../data/patient.json';
|
|
2
|
+
import { encode } from './patient';
|
|
3
|
+
describe('encode patient from ANDES to FHIR R4', () => {
|
|
4
|
+
test('Verify basic data', () => {
|
|
5
|
+
expect(encode(patient).resourceType).toBe('Patient');
|
|
6
|
+
expect(encode(patient).identifier[0].value).toBe('42910660');
|
|
7
|
+
expect(encode(patient).identifier[0].system).toBe('http://www.renaper.gob.ar/dni');
|
|
8
|
+
expect(encode(patient).active).toBe(true);
|
|
9
|
+
expect(encode(patient).name[0].use).toBe('official');
|
|
10
|
+
expect(encode(patient).name[0].resourceType).toBe('HumanName');
|
|
11
|
+
expect(encode(patient).name[0].family).toContain('PERINGA');
|
|
12
|
+
expect(encode(patient).name[0].family).toContain('PONCE');
|
|
13
|
+
expect(encode(patient).name[0].given).toContain('AGUSTIN');
|
|
14
|
+
expect(encode(patient).name[0].text).toBe('HUGO AGUSTIN PERINGA PONCE');
|
|
15
|
+
expect(encode(patient).gender).toBe('male');
|
|
16
|
+
expect(encode(patient).birthDate).toBe('1979-11-14');
|
|
17
|
+
});
|
|
18
|
+
test('Verify patient with contact information', () => {
|
|
19
|
+
// Phone;
|
|
20
|
+
expect(encode(patient).telecom[0].resourceType).toBe('ContactPoint');
|
|
21
|
+
expect(encode(patient).telecom[0].value).toBe('4462221');
|
|
22
|
+
expect(encode(patient).telecom[0].system).toBe('phone');
|
|
23
|
+
// Address;
|
|
24
|
+
expect(encode(patient).address[0].resourceType).toBe('Address');
|
|
25
|
+
expect(encode(patient).address[0].postalCode).toBe('8300');
|
|
26
|
+
expect(encode(patient).address[0].line).toContain('Enrique Santos Discepolo 1856');
|
|
27
|
+
expect(encode(patient).address[0].city).toBe('NEUQUEN');
|
|
28
|
+
expect(encode(patient).address[0].state).toBe('Neuquén');
|
|
29
|
+
expect(encode(patient).address[0].country).toBe('Argentina');
|
|
30
|
+
});
|
|
31
|
+
test('Verify patient with relationships', () => {
|
|
32
|
+
expect(encode(patient).contact[0].relationship[0].text).toBe('hijo/a');
|
|
33
|
+
expect(encode(patient).contact[0].name.resourceType).toBe('HumanName');
|
|
34
|
+
expect(encode(patient).contact[0].name.family).toContain('PERINGA');
|
|
35
|
+
expect(encode(patient).contact[0].name.given).toContain('JOSEFINA');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|