Skip to content

Commit

Permalink
feat(fhir): agregamos la feature de medication y medicationStatement (#8
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Sychus authored Aug 5, 2020
1 parent cbce99e commit 65771a2
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 3 deletions.
6 changes: 5 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import * as Composition from './src/lib/composition';
import * as Bundle from './src/lib/bundle';
import * as DocumentReference from './src/lib/document-reference';
import * as Device from './src/lib/device';
import * as Medication from './src/lib/medication';
import * as MedicationStatement from './src/lib/medicationStatement';

export { getDominio, initialize } from './src/lib/config';

Expand All @@ -19,5 +21,7 @@ export {
Composition,
Bundle,
DocumentReference,
Device
Device,
Medication,
MedicationStatement
};
25 changes: 23 additions & 2 deletions src/lib/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ function getReference(url) {
};
}

export function encode(ID, patientReference, custodianReference, deviceReference, ImmunizationReferences, ConditionReferences) {
export function encode(ID, patientReference, custodianReference, deviceReference, medicationStatementReference, ImmunizationReferences, ConditionReferences) {
const now = moment();
let Immunization: any = [];
let conditions: any = [];
let medications: any = [];

if (ImmunizationReferences.length > 0) {
Immunization = [{
Expand All @@ -32,7 +33,26 @@ export function encode(ID, patientReference, custodianReference, deviceReference
entry: ImmunizationReferences.map(getReference)
}];
}

if (medicationStatementReference.length > 0) {
medications = [{
title: 'Medicamentos',
text: null,
// text: {
// 'status': 'additional',
// 'div': '<div xmlns="http:\/\/www.w3.org\/1999\/xhtml"> <table> <thead> <tr> <th>Medicamento<\/th> <th>Strength<\/th> <th>Forma<\/th> <th>Dosis<\/th> <th>Comentario<\/th> <\/tr> <\/thead> <tbody> <tr> <td>salbutamol (sustancia)<\/td> <td>200 mcg<\/td> <td>disparo<\/td> <td>uno por día<\/td> <td>tratamiento de asma<\/td> <\/tr> <\/tbody> <\/table> <\/div>'
// },
code: {
coding: [
{
system: 'http:\/\/loinc.org',
display: 'Medication use',
code: '10160-0'
}
]
},
entry: medicationStatementReference.map(getReference),
}];
}
if (ConditionReferences.length > 0) {
conditions = [{
code: {
Expand Down Expand Up @@ -61,6 +81,7 @@ export function encode(ID, patientReference, custodianReference, deviceReference
},
section: [
...conditions,
...medications,
...Immunization

],
Expand Down
61 changes: 61 additions & 0 deletions src/lib/medication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* Encode de Medicamentos from ANDES to FHIR
* @param {} medication
*/
export function encode(medication) {
// Falta completar con más detalle
return {
resourceType: 'Medication',
id: medication.concepto.conceptId, // Es el id del medicamento, en este caso usamos el código de snomed (ver si sería correcto)
meta: {
profile: [
'http://hl7.org/fhir/uv/ips/StructureDefinition/medication-ips'
]
},
identifier: null, // Acá va el serial number del medicamento.
code: {
coding: [
{
system: 'http://snomed.info/sct',
display: medication.concepto.term,
code: medication.concepto.conceptId
}
],
text: medication.concepto.fsn
},
status: medication.valor.estado,
manufacturer: null,
form: null,
amount: null,
ingredient: null,
// ingredient: [ // ejemplo
// {
// code: {
// coding: [
// {
// system: "http://snomed.info/sct",
// display: "salbutamol (sustancia)",
// code: "372897005"
// }
// ]
// },
// isActive: true,
// strength: {
// numerator: {
// value: 200,
// unit: "mcg"
// },
// denominator: {
// value: 1,
// unit: "disparo"
// }
// }
// }
// ],
// text: {
// status: "generated",
// div: `<div xmlns="http://www.w3.org/1999/xhtml"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: Medicación</p><p><b>meta</b>: </p><p><b>text</b>: </p><p><b>code</b>: ${medication.concepto.fsn}};</span></p></div>`
// }
};
}

75 changes: 75 additions & 0 deletions src/lib/medicationStatement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Encode de Medicamentos from ANDES to FHIR
* @param {} medicationStatement
*/
// Muy incompleto hay que mejorarlo mucho todavía
export function encode(patientReference, medicationReference, prestacionMedicamento) {
return {
resourceType: 'MedicationStatement',
id: prestacionMedicamento._id, // El código de la prestación donde está el registro del contexto de porque está consumiendo el medicamento
meta: {
profile: [
'http://hl7.org/fhir/uv/ips/StructureDefinition/medication-ips'
]
},
extension: null,
identifier: '', // Business identifier, not a resource identifier
status: prestacionMedicamento.valor.estado,
subject: {
reference: patientReference
},
medicationReference: {
reference: medicationReference
},
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é)
dosage: null,
// dosage: [
// {
// route: {
// coding: [
// {
// system: 'http://snomed.info/sct',
// display: prestacionMedicamento.valor.indicacion,
// code: ''
// }
// ]
// },
// timing: {
// repeat: {
// count: 1,
// periodUnit: 'd'
// }
// },
// doseAndRate: [
// {
// type: {
// coding: [
// {
// system: 'http://terminology.hl7.org/CodeSystem/dose-rate-type',
// display: 'Ordered',
// code: 'ordered'
// }
// ]
// },
// doseQuantity: {
// code: '732981002',
// value: 1,
// system: 'http://snomed.info/sct',
// unit: 'disparo (unidad de presentación)'
// }
// }
// ]
// }
// ],
// 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
// en este registro ya que no siempre está la unidad de tiempo (dias, mes, etc) hay q ver si no es un bug.
// start: '2015-03'
// },
text: null
// text: {
// status: 'generated',
// div: `<div xmlns="http://www.w3.org/1999/xhtml"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: IPS-examples-MedicationStatement-01</p><p><b>meta</b>: </p><p><b>text</b>: </p><p><b>identifier</b>: b75f92cb-61d4-469a-9387-df5ef70d25f0</p><p><b>status</b>: ACTIVE</p><p><b>medication</b>: <a href="#medication_IPS-examples-Medication-01">Generated Summary: id: IPS-examples-Medication-01; <span title="Codes: {http://snomed.info/sct 108774000}, {urn:oid:2.16.840.1.113883.2.4.4.1 99872}, {urn:oid:2.16.840.1.113883.2.4.4.7 2076667}">Anastrozole (product)</span></a></p><p><b>subject</b>: <a href="#patient_IPS-examples-Patient-01">Generated Summary: id: IPS-examples-Patient-01; 574687583; active; Martha DeLarosa ; ph: +31788700800(HOME); FEMALE; birthDate: 01/05/1972</a></p><p><b>effective</b>: 01/03/2015 --> (ongoing)</p><p><b>dosage</b>: </p></div>`
// },
};
}

0 comments on commit 65771a2

Please sign in to comment.