@precisa-saude/fhir 0.19.0 → 0.20.0
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/dist/biomarkers.cjs +2 -2
- package/dist/biomarkers.js +1 -1
- package/dist/{chunk-J3QVVVVH.cjs → chunk-2KDLOCD2.cjs} +3 -3
- package/dist/{chunk-J3QVVVVH.cjs.map → chunk-2KDLOCD2.cjs.map} +1 -1
- package/dist/{chunk-MTWOF55H.js → chunk-3KIJIRCI.js} +44 -2
- package/dist/chunk-3KIJIRCI.js.map +1 -0
- package/dist/{chunk-LCXTQE2B.js → chunk-6TQ24JCA.js} +2 -2
- package/dist/{chunk-6HKQY6VO.cjs → chunk-CFKXCL2N.cjs} +4 -4
- package/dist/{chunk-6HKQY6VO.cjs.map → chunk-CFKXCL2N.cjs.map} +1 -1
- package/dist/{chunk-MMO356YH.cjs → chunk-ERALICUK.cjs} +48 -1
- package/dist/chunk-ERALICUK.cjs.map +1 -0
- package/dist/{chunk-Z5VH5QGC.cjs → chunk-NXOTXKVB.cjs} +44 -2
- package/dist/chunk-NXOTXKVB.cjs.map +1 -0
- package/dist/{chunk-EXG2IU2O.js → chunk-OZGOBYLX.js} +2 -2
- package/dist/{chunk-XTEKGGYQ.js → chunk-QULBXISC.js} +48 -1
- package/dist/chunk-QULBXISC.js.map +1 -0
- package/dist/cli.js +91 -2
- package/dist/converter.cjs +3 -3
- package/dist/converter.js +2 -2
- package/dist/importer.cjs +3 -3
- package/dist/importer.js +2 -2
- package/dist/index.cjs +6 -6
- package/dist/index.js +4 -4
- package/dist/reference-ranges.cjs +2 -2
- package/dist/reference-ranges.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-MMO356YH.cjs.map +0 -1
- package/dist/chunk-MTWOF55H.js.map +0 -1
- package/dist/chunk-XTEKGGYQ.js.map +0 -1
- package/dist/chunk-Z5VH5QGC.cjs.map +0 -1
- /package/dist/{chunk-LCXTQE2B.js.map → chunk-6TQ24JCA.js.map} +0 -0
- /package/dist/{chunk-EXG2IU2O.js.map → chunk-OZGOBYLX.js.map} +0 -0
package/dist/biomarkers.cjs
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var _chunkNXOTXKVBcjs = require('./chunk-NXOTXKVB.cjs');
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
@@ -63,5 +63,5 @@ var _chunkZ5VH5QGCcjs = require('./chunk-Z5VH5QGC.cjs');
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
exports.BIOMARKER_DEFINITIONS =
|
|
66
|
+
exports.BIOMARKER_DEFINITIONS = _chunkNXOTXKVBcjs.BIOMARKER_DEFINITIONS; exports.CAC_INDICATOR_CODES = _chunkNXOTXKVBcjs.CAC_INDICATOR_CODES; exports.DEXA_CATEGORIES = _chunkNXOTXKVBcjs.DEXA_CATEGORIES; exports.DEXA_INDICATOR_CODES = _chunkNXOTXKVBcjs.DEXA_INDICATOR_CODES; exports.codeToLoinc = _chunkNXOTXKVBcjs.codeToLoinc; exports.filterVisibleBiomarkers = _chunkNXOTXKVBcjs.filterVisibleBiomarkers; exports.findCodeByName = _chunkNXOTXKVBcjs.findCodeByName; exports.generateCacFullReference = _chunkNXOTXKVBcjs.generateCacFullReference; exports.generateDexaFullReference = _chunkNXOTXKVBcjs.generateDexaFullReference; exports.generateFilteredLLMReference = _chunkNXOTXKVBcjs.generateFilteredLLMReference; exports.generateLLMReference = _chunkNXOTXKVBcjs.generateLLMReference; exports.getAllCodes = _chunkNXOTXKVBcjs.getAllCodes; exports.getAllDefinitions = _chunkNXOTXKVBcjs.getAllDefinitions; exports.getAllLoincCodes = _chunkNXOTXKVBcjs.getAllLoincCodes; exports.getAllSearchPatterns = _chunkNXOTXKVBcjs.getAllSearchPatterns; exports.getBiomarkersByCategory = _chunkNXOTXKVBcjs.getBiomarkersByCategory; exports.getBiomarkersForCategories = _chunkNXOTXKVBcjs.getBiomarkersForCategories; exports.getDefinitionByCode = _chunkNXOTXKVBcjs.getDefinitionByCode; exports.getDefinitionByLoinc = _chunkNXOTXKVBcjs.getDefinitionByLoinc; exports.getDefinitionsBySex = _chunkNXOTXKVBcjs.getDefinitionsBySex; exports.getSexForCode = _chunkNXOTXKVBcjs.getSexForCode; exports.getVisibleDefinitions = _chunkNXOTXKVBcjs.getVisibleDefinitions; exports.isBiomarkerVisible = _chunkNXOTXKVBcjs.isBiomarkerVisible; exports.isCacDocument = _chunkNXOTXKVBcjs.isCacDocument; exports.isDexaDocument = _chunkNXOTXKVBcjs.isDexaDocument; exports.isValidCode = _chunkNXOTXKVBcjs.isValidCode; exports.isValidLoinc = _chunkNXOTXKVBcjs.isValidLoinc; exports.loincToCode = _chunkNXOTXKVBcjs.loincToCode; exports.normalizeCode = _chunkNXOTXKVBcjs.normalizeCode; exports.toBiomarkerTests = _chunkNXOTXKVBcjs.toBiomarkerTests; exports.validateLoincNameMatch = _chunkNXOTXKVBcjs.validateLoincNameMatch;
|
|
67
67
|
//# sourceMappingURL=biomarkers.cjs.map
|
package/dist/biomarkers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNXOTXKVBcjs = require('./chunk-NXOTXKVB.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ function interpretationDisplay(flag) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function labObservationToFHIR(observation, patientId, laboratoryName) {
|
|
33
|
-
const loincCode =
|
|
33
|
+
const loincCode = _chunkNXOTXKVBcjs.codeToLoinc.call(void 0, observation.biomarkerCode) || "99999-9";
|
|
34
34
|
const sourceUnit = observation.unit || _chunkMJ254F5Kcjs.getDefaultUnit.call(void 0, observation.biomarkerCode) || observation.unit;
|
|
35
35
|
const ucumUnit = _chunkMJ254F5Kcjs.unitToUCUM.call(void 0, sourceUnit);
|
|
36
36
|
const isQualitative = observation.isQualitative || typeof observation.value === "string";
|
|
@@ -248,4 +248,4 @@ function labResultToFHIRBundle(report, observations, userProfile) {
|
|
|
248
248
|
|
|
249
249
|
|
|
250
250
|
exports.labObservationToFHIR = labObservationToFHIR; exports.labReportToFHIR = labReportToFHIR; exports.userProfileToFHIR = userProfileToFHIR; exports.labResultToFHIRBundle = labResultToFHIRBundle;
|
|
251
|
-
//# sourceMappingURL=chunk-
|
|
251
|
+
//# sourceMappingURL=chunk-2KDLOCD2.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/chunk-J3QVVVVH.cjs","../src/converter.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACUA,SAAS,kBAAA,CAAmB,IAAA,EAAoB;AAC9C,EAAA,OAAA,CAAQ,IAAA,EAAM;AAAA,IACZ,KAAK,GAAA;AACH,MAAA,OAAO,GAAA;AAAA;AAAA,IACT,KAAK,GAAA;AACH,MAAA,OAAO,GAAA;AAAA;AAAA,IACT,OAAA;AACE,MAAA,OAAO,GAAA;AAAA,EACX;AACF;AAKA,SAAS,qBAAA,CAAsB,IAAA,EAAoB;AACjD,EAAA,OAAA,CAAQ,IAAA,EAAM;AAAA,IACZ,KAAK,GAAA;AACH,MAAA,OAAO,MAAA;AAAA,IACT,KAAK,GAAA;AACH,MAAA,OAAO,KAAA;AAAA,IACT,OAAA;AACE,MAAA,OAAO,QAAA;AAAA,EACX;AACF;AAKO,SAAS,oBAAA,CACd,WAAA,EACA,SAAA,EACA,cAAA,EACiB;AACjB,EAAA,MAAM,UAAA,EAAY,2CAAA,WAAY,CAAY,aAAa,EAAA,GAAK,SAAA;AAE5D,EAAA,MAAM,WAAA,EACJ,WAAA,CAAY,KAAA,G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A;AAEQ,MAAA;AACA,MAAA;AAEN,IAAA;AACR,EAAA;AACF;AAMgB;AAKR,EAAA;AAGA,EAAA;AACJ,IAAA;AACA,IAAA;AACI,MAAA;AACF,MAAA;AACA,MAAA;AACF,IAAA;AACA,EAAA;AAEI,EAAA;AACH,IAAA;AACH,EAAA;AAGM,EAAA;AAGA,EAAA;AAEC,EAAA;AACL,IAAA;AACE,MAAA;AACE,QAAA;AACA,QAAA;AACF,MAAA;AACA,MAAA;AACE,QAAA;AACA,QAAA;AACF,MAAA;AACG,MAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACF,EAAA;AACF;ADxES;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/chunk-J3QVVVVH.cjs","sourcesContent":[null,"/**\n * FHIR Converter\n *\n * Converts lab results to FHIR R4 DiagnosticReport and Observation resources.\n * See: https://hl7.org/fhir/diagnosticreport.html\n */\n\nimport { codeToLoinc } from './biomarkers';\nimport type { FHIRBundle, FHIRDiagnosticReport, FHIRObservation, FHIRPatient } from './fhir-types';\nimport type { Flag, LabObservationData, LabReportData, UserProfileData } from './types';\nimport { getDefaultUnit, unitToUCUM } from './units';\n\n// Re-export all types and functions\nexport * from './fhir-types';\n\n/**\n * Convert Flag to FHIR interpretation code\n */\nfunction interpretationCode(flag: Flag): string {\n switch (flag) {\n case 'H':\n return 'H'; // High\n case 'L':\n return 'L'; // Low\n default:\n return 'N'; // Normal\n }\n}\n\n/**\n * Convert Flag to FHIR interpretation display\n */\nfunction interpretationDisplay(flag: Flag): string {\n switch (flag) {\n case 'H':\n return 'High';\n case 'L':\n return 'Low';\n default:\n return 'Normal';\n }\n}\n\n/**\n * Convert generic lab observation to FHIR Observation\n */\nexport function labObservationToFHIR(\n observation: LabObservationData,\n patientId: string,\n laboratoryName?: string,\n): FHIRObservation {\n const loincCode = codeToLoinc(observation.biomarkerCode) || '99999-9';\n // Use default unit if source unit is empty\n const sourceUnit =\n observation.unit || getDefaultUnit(observation.biomarkerCode) || observation.unit;\n const ucumUnit = unitToUCUM(sourceUnit);\n const isQualitative = observation.isQualitative || typeof observation.value === 'string';\n\n // Base observation structure\n const fhirObs: FHIRObservation = {\n category: [\n {\n coding: [\n {\n code: 'laboratory',\n display: 'Laboratory',\n system: 'http://terminology.hl7.org/CodeSystem/observation-category',\n },\n ],\n },\n ],\n code: {\n coding: [\n {\n code: loincCode,\n display: observation.biomarkerName,\n system: 'http://loinc.org',\n },\n {\n code: observation.biomarkerCode,\n display: observation.biomarkerName,\n system: 'http://fhir-brasil.dev/biomarker-codes',\n },\n ],\n text: observation.biomarkerName,\n },\n effectiveDateTime: observation.collectionDate,\n id: `${observation.reportId}-${observation.biomarkerCode}`,\n interpretation: [\n {\n coding: [\n {\n code: interpretationCode(observation.flag),\n display: interpretationDisplay(observation.flag),\n system: 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation',\n },\n ],\n },\n ],\n performer: laboratoryName ? [{ display: laboratoryName }] : undefined,\n resourceType: 'Observation',\n status: 'final',\n subject: {\n reference: `Patient/${patientId}`,\n },\n };\n\n // Add value based on type (qualitative = string, quantitative = number)\n if (isQualitative) {\n fhirObs.valueString = String(observation.value);\n } else {\n fhirObs.valueQuantity = {\n code: ucumUnit,\n system: 'http://unitsofmeasure.org',\n unit: sourceUnit,\n value: observation.value as number,\n };\n\n // Reference range only applies to quantitative values\n if (observation.referenceMin !== undefined && observation.referenceMax !== undefined) {\n fhirObs.referenceRange = [\n {\n high: {\n code: ucumUnit,\n system: 'http://unitsofmeasure.org',\n unit: sourceUnit,\n value: observation.referenceMax,\n },\n low: {\n code: ucumUnit,\n system: 'http://unitsofmeasure.org',\n unit: sourceUnit,\n value: observation.referenceMin,\n },\n },\n ];\n }\n }\n\n return fhirObs;\n}\n\n/**\n * Convert generic lab report to FHIR DiagnosticReport\n */\nexport function labReportToFHIR(\n report: LabReportData,\n patientId: string,\n observationIds: string[],\n): FHIRDiagnosticReport {\n // Map processing status to FHIR status\n let status: FHIRDiagnosticReport['status'];\n switch (report.processingStatus) {\n case 'complete':\n status = 'final';\n break;\n case 'partial':\n status = 'partial';\n break;\n case 'pending_review':\n status = 'preliminary';\n break;\n default:\n status = 'final';\n }\n\n return {\n category: [\n {\n coding: [\n {\n code: 'LAB',\n display: 'Laboratory',\n system: 'http://terminology.hl7.org/CodeSystem/v2-0074',\n },\n ],\n },\n ],\n code: {\n coding: [\n {\n code: '11502-2', // Laboratory report\n display: 'Laboratory report',\n system: 'http://loinc.org',\n },\n ],\n text: 'Laboratory Results',\n },\n conclusion:\n report.overallStatus === 'NORMAL'\n ? 'All results within normal limits'\n : 'One or more abnormal results detected',\n conclusionCode:\n report.overallStatus === 'ANORMAL'\n ? [\n {\n coding: [\n {\n code: 'A',\n display: 'Abnormal',\n system: 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation',\n },\n ],\n },\n ]\n : undefined,\n effectiveDateTime: report.collectionDate,\n id: report.reportId,\n issued: report.createdAt,\n performer: report.laboratoryName ? [{ display: report.laboratoryName }] : undefined,\n resourceType: 'DiagnosticReport',\n result: observationIds.map((id) => ({ reference: `Observation/${id}` })),\n status,\n subject: {\n reference: `Patient/${patientId}`,\n },\n };\n}\n\n/**\n * Convert user profile to FHIR Patient\n * NOTE: CPF is intentionally excluded for privacy (LGPD compliance)\n */\nexport function userProfileToFHIR(profile: UserProfileData): FHIRPatient {\n const nameParts = profile.name.split(' ');\n const given = nameParts.slice(0, -1);\n const family = nameParts[nameParts.length - 1] || '';\n\n return {\n address: profile.address\n ? [\n {\n city: profile.address.city,\n country: profile.address.country || 'BR',\n line: [\n profile.address.street && profile.address.number\n ? `${profile.address.street}, ${profile.address.number}`\n : profile.address.street,\n profile.address.complement,\n ].filter(Boolean) as string[],\n postalCode: profile.address.postalCode,\n state: profile.address.state,\n },\n ]\n : undefined,\n birthDate: profile.birthDate,\n gender: profile.gender,\n id: profile.userId,\n name: [\n {\n family,\n given: given.length > 0 ? given : undefined,\n text: profile.name,\n },\n ],\n resourceType: 'Patient',\n telecom:\n [\n ...(profile.email ? [{ system: 'email' as const, value: profile.email }] : []),\n ...(profile.phone ? [{ system: 'phone' as const, value: profile.phone }] : []),\n ].length > 0\n ? [\n ...(profile.email ? [{ system: 'email' as const, value: profile.email }] : []),\n ...(profile.phone ? [{ system: 'phone' as const, value: profile.phone }] : []),\n ]\n : undefined,\n };\n}\n\n/**\n * Convert complete lab result to FHIR Bundle\n * This is the main function for exporting lab results to FHIR R4 format\n */\nexport function labResultToFHIRBundle(\n report: LabReportData,\n observations: LabObservationData[],\n userProfile: UserProfileData,\n): FHIRBundle {\n const patientId = userProfile.userId;\n\n // Convert observations\n const fhirObservations = observations.map((obs) => ({\n fullUrl: `urn:uuid:observation-${obs.reportId}-${obs.biomarkerCode}`,\n resource: labObservationToFHIR(\n { ...obs, collectionDate: report.collectionDate },\n patientId,\n report.laboratoryName,\n ),\n }));\n\n const observationIds = observations.map(\n (obs) => `observation-${obs.reportId}-${obs.biomarkerCode}`,\n );\n\n // Convert report\n const diagnosticReport = labReportToFHIR(report, patientId, observationIds);\n\n // Convert patient\n const fhirPatient = userProfileToFHIR(userProfile);\n\n return {\n entry: [\n {\n fullUrl: `urn:uuid:${patientId}`,\n resource: fhirPatient,\n },\n {\n fullUrl: `urn:uuid:diagnostic-report-${report.reportId}`,\n resource: diagnosticReport,\n },\n ...fhirObservations,\n ],\n resourceType: 'Bundle',\n type: 'collection',\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/chunk-2KDLOCD2.cjs","../src/converter.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACUA,SAAS,kBAAA,CAAmB,IAAA,EAAoB;AAC9C,EAAA,OAAA,CAAQ,IAAA,EAAM;AAAA,IACZ,KAAK,GAAA;AACH,MAAA,OAAO,GAAA;AAAA;AAAA,IAC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;AACF,MAAA;AAEF,IAAA;AACN,IAAA;AACI,IAAA;AACJ,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACE,MAAA;AACF,IAAA;AACF,EAAA;AACF;AAMgB;AACR,EAAA;AACA,EAAA;AACA,EAAA;AAEC,EAAA;AACL,IAAA;AAEM,MAAA;AACE,QAAA;AACA,QAAA;AACA,QAAA;AAAM,UAAA;AAGgB,UAAA;AAEtB,QAAA;AACA,QAAA;AACA,QAAA;AACF,MAAA;AAEF,IAAA;AACJ,IAAA;AACA,IAAA;AACI,IAAA;AACJ,IAAA;AACE,MAAA;AACE,QAAA;AACA,QAAA;AACA,QAAA;AACF,MAAA;AACF,IAAA;AACA,IAAA;AACA,IAAA;AAEQ,MAAA;AACA,MAAA;AACJ,IAAA;AAEQ,MAAA;AACA,MAAA;AAEN,IAAA;AACR,EAAA;AACF;AAMgB;AAKR,EAAA;AAGA,EAAA;AACJ,IAAA;AACA,IAAA;AACI,MAAA;AACF,MAAA;AACA,MAAA;AACF,IAAA;AACA,EAAA;AAEI,EAAA;AACH,IAAA;AACH,EAAA;AAGM,EAAA;AAGA,EAAA;AAEC,EAAA;AACL,IAAA;AACE,MAAA;AACE,QAAA;AACA,QAAA;AACF,MAAA;AACA,MAAA;AACE,QAAA;AACA,QAAA;AACF,MAAA;AACG,MAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACF,EAAA;AACF;ADxES;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/chunk-2KDLOCD2.cjs","sourcesContent":[null,"/**\n * FHIR Converter\n *\n * Converts lab results to FHIR R4 DiagnosticReport and Observation resources.\n * See: https://hl7.org/fhir/diagnosticreport.html\n */\n\nimport { codeToLoinc } from './biomarkers';\nimport type { FHIRBundle, FHIRDiagnosticReport, FHIRObservation, FHIRPatient } from './fhir-types';\nimport type { Flag, LabObservationData, LabReportData, UserProfileData } from './types';\nimport { getDefaultUnit, unitToUCUM } from './units';\n\n// Re-export all types and functions\nexport * from './fhir-types';\n\n/**\n * Convert Flag to FHIR interpretation code\n */\nfunction interpretationCode(flag: Flag): string {\n switch (flag) {\n case 'H':\n return 'H'; // High\n case 'L':\n return 'L'; // Low\n default:\n return 'N'; // Normal\n }\n}\n\n/**\n * Convert Flag to FHIR interpretation display\n */\nfunction interpretationDisplay(flag: Flag): string {\n switch (flag) {\n case 'H':\n return 'High';\n case 'L':\n return 'Low';\n default:\n return 'Normal';\n }\n}\n\n/**\n * Convert generic lab observation to FHIR Observation\n */\nexport function labObservationToFHIR(\n observation: LabObservationData,\n patientId: string,\n laboratoryName?: string,\n): FHIRObservation {\n const loincCode = codeToLoinc(observation.biomarkerCode) || '99999-9';\n // Use default unit if source unit is empty\n const sourceUnit =\n observation.unit || getDefaultUnit(observation.biomarkerCode) || observation.unit;\n const ucumUnit = unitToUCUM(sourceUnit);\n const isQualitative = observation.isQualitative || typeof observation.value === 'string';\n\n // Base observation structure\n const fhirObs: FHIRObservation = {\n category: [\n {\n coding: [\n {\n code: 'laboratory',\n display: 'Laboratory',\n system: 'http://terminology.hl7.org/CodeSystem/observation-category',\n },\n ],\n },\n ],\n code: {\n coding: [\n {\n code: loincCode,\n display: observation.biomarkerName,\n system: 'http://loinc.org',\n },\n {\n code: observation.biomarkerCode,\n display: observation.biomarkerName,\n system: 'http://fhir-brasil.dev/biomarker-codes',\n },\n ],\n text: observation.biomarkerName,\n },\n effectiveDateTime: observation.collectionDate,\n id: `${observation.reportId}-${observation.biomarkerCode}`,\n interpretation: [\n {\n coding: [\n {\n code: interpretationCode(observation.flag),\n display: interpretationDisplay(observation.flag),\n system: 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation',\n },\n ],\n },\n ],\n performer: laboratoryName ? [{ display: laboratoryName }] : undefined,\n resourceType: 'Observation',\n status: 'final',\n subject: {\n reference: `Patient/${patientId}`,\n },\n };\n\n // Add value based on type (qualitative = string, quantitative = number)\n if (isQualitative) {\n fhirObs.valueString = String(observation.value);\n } else {\n fhirObs.valueQuantity = {\n code: ucumUnit,\n system: 'http://unitsofmeasure.org',\n unit: sourceUnit,\n value: observation.value as number,\n };\n\n // Reference range only applies to quantitative values\n if (observation.referenceMin !== undefined && observation.referenceMax !== undefined) {\n fhirObs.referenceRange = [\n {\n high: {\n code: ucumUnit,\n system: 'http://unitsofmeasure.org',\n unit: sourceUnit,\n value: observation.referenceMax,\n },\n low: {\n code: ucumUnit,\n system: 'http://unitsofmeasure.org',\n unit: sourceUnit,\n value: observation.referenceMin,\n },\n },\n ];\n }\n }\n\n return fhirObs;\n}\n\n/**\n * Convert generic lab report to FHIR DiagnosticReport\n */\nexport function labReportToFHIR(\n report: LabReportData,\n patientId: string,\n observationIds: string[],\n): FHIRDiagnosticReport {\n // Map processing status to FHIR status\n let status: FHIRDiagnosticReport['status'];\n switch (report.processingStatus) {\n case 'complete':\n status = 'final';\n break;\n case 'partial':\n status = 'partial';\n break;\n case 'pending_review':\n status = 'preliminary';\n break;\n default:\n status = 'final';\n }\n\n return {\n category: [\n {\n coding: [\n {\n code: 'LAB',\n display: 'Laboratory',\n system: 'http://terminology.hl7.org/CodeSystem/v2-0074',\n },\n ],\n },\n ],\n code: {\n coding: [\n {\n code: '11502-2', // Laboratory report\n display: 'Laboratory report',\n system: 'http://loinc.org',\n },\n ],\n text: 'Laboratory Results',\n },\n conclusion:\n report.overallStatus === 'NORMAL'\n ? 'All results within normal limits'\n : 'One or more abnormal results detected',\n conclusionCode:\n report.overallStatus === 'ANORMAL'\n ? [\n {\n coding: [\n {\n code: 'A',\n display: 'Abnormal',\n system: 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation',\n },\n ],\n },\n ]\n : undefined,\n effectiveDateTime: report.collectionDate,\n id: report.reportId,\n issued: report.createdAt,\n performer: report.laboratoryName ? [{ display: report.laboratoryName }] : undefined,\n resourceType: 'DiagnosticReport',\n result: observationIds.map((id) => ({ reference: `Observation/${id}` })),\n status,\n subject: {\n reference: `Patient/${patientId}`,\n },\n };\n}\n\n/**\n * Convert user profile to FHIR Patient\n * NOTE: CPF is intentionally excluded for privacy (LGPD compliance)\n */\nexport function userProfileToFHIR(profile: UserProfileData): FHIRPatient {\n const nameParts = profile.name.split(' ');\n const given = nameParts.slice(0, -1);\n const family = nameParts[nameParts.length - 1] || '';\n\n return {\n address: profile.address\n ? [\n {\n city: profile.address.city,\n country: profile.address.country || 'BR',\n line: [\n profile.address.street && profile.address.number\n ? `${profile.address.street}, ${profile.address.number}`\n : profile.address.street,\n profile.address.complement,\n ].filter(Boolean) as string[],\n postalCode: profile.address.postalCode,\n state: profile.address.state,\n },\n ]\n : undefined,\n birthDate: profile.birthDate,\n gender: profile.gender,\n id: profile.userId,\n name: [\n {\n family,\n given: given.length > 0 ? given : undefined,\n text: profile.name,\n },\n ],\n resourceType: 'Patient',\n telecom:\n [\n ...(profile.email ? [{ system: 'email' as const, value: profile.email }] : []),\n ...(profile.phone ? [{ system: 'phone' as const, value: profile.phone }] : []),\n ].length > 0\n ? [\n ...(profile.email ? [{ system: 'email' as const, value: profile.email }] : []),\n ...(profile.phone ? [{ system: 'phone' as const, value: profile.phone }] : []),\n ]\n : undefined,\n };\n}\n\n/**\n * Convert complete lab result to FHIR Bundle\n * This is the main function for exporting lab results to FHIR R4 format\n */\nexport function labResultToFHIRBundle(\n report: LabReportData,\n observations: LabObservationData[],\n userProfile: UserProfileData,\n): FHIRBundle {\n const patientId = userProfile.userId;\n\n // Convert observations\n const fhirObservations = observations.map((obs) => ({\n fullUrl: `urn:uuid:observation-${obs.reportId}-${obs.biomarkerCode}`,\n resource: labObservationToFHIR(\n { ...obs, collectionDate: report.collectionDate },\n patientId,\n report.laboratoryName,\n ),\n }));\n\n const observationIds = observations.map(\n (obs) => `observation-${obs.reportId}-${obs.biomarkerCode}`,\n );\n\n // Convert report\n const diagnosticReport = labReportToFHIR(report, patientId, observationIds);\n\n // Convert patient\n const fhirPatient = userProfileToFHIR(userProfile);\n\n return {\n entry: [\n {\n fullUrl: `urn:uuid:${patientId}`,\n resource: fhirPatient,\n },\n {\n fullUrl: `urn:uuid:diagnostic-report-${report.reportId}`,\n resource: diagnosticReport,\n },\n ...fhirObservations,\n ],\n resourceType: 'Bundle',\n type: 'collection',\n };\n}\n"]}
|
|
@@ -2198,8 +2198,9 @@ var BIOMARKER_DEFINITIONS = [
|
|
|
2198
2198
|
// múltiplas formulações: "total body water" não devolve nada, "body water"
|
|
2199
2199
|
// devolve os dois códigos abaixo.
|
|
2200
2200
|
//
|
|
2201
|
-
// As
|
|
2201
|
+
// As 13 entradas sem código, e o motivo de cada uma:
|
|
2202
2202
|
//
|
|
2203
|
+
// MuscleMassIndex corte publicado é sobre massa apendicular, não total
|
|
2203
2204
|
// VisceralFatLevel índice de 1 a 20; 73707-2 é área, outra grandeza
|
|
2204
2205
|
// ResidualMass conceito de fracionamento antropométrico, não LOINC
|
|
2205
2206
|
// BasalMetabolicRate candidatos são índice ou RMR medido, ver nota local
|
|
@@ -2249,6 +2250,35 @@ var BIOMARKER_DEFINITIONS = [
|
|
|
2249
2250
|
},
|
|
2250
2251
|
unit: "kg"
|
|
2251
2252
|
},
|
|
2253
|
+
// Derivado, não extraído: `MuscleMass / altura²`, calculado pelo
|
|
2254
|
+
// `calculadoras-clinicas` a partir da altura que o usuário informa no
|
|
2255
|
+
// cadastro. Mesmo ajuste que o IMC faz com o peso, e serve para a medida
|
|
2256
|
+
// ser comparável entre estaturas diferentes e ao longo do tempo.
|
|
2257
|
+
//
|
|
2258
|
+
// Sem `loinc` e sem faixa, e agora com fonte para a decisão em vez de só
|
|
2259
|
+
// cautela. O EWGSOP2 (Age and Ageing, 2019, DOI 10.1093/ageing/afy169)
|
|
2260
|
+
// separa explicitamente "total body Skeletal Muscle Mass (SMM)" de
|
|
2261
|
+
// "Appendicular Skeletal Muscle Mass (ASM)", e os cortes publicados são
|
|
2262
|
+
// sobre ASM. `MuscleMass` aqui é total, então o corte não se aplica.
|
|
2263
|
+
//
|
|
2264
|
+
// O mesmo consenso ainda diz, sobre ajustar por tamanho corporal: "The
|
|
2265
|
+
// authors make no recommendation to adjust for body size, but adjustment
|
|
2266
|
+
// can be made if data are available for a relevant normative population."
|
|
2267
|
+
// Não temos população normativa brasileira para bioimpedância, e o
|
|
2268
|
+
// consenso registra que a equação de Sergi, padrão do método, foi
|
|
2269
|
+
// derivada em europeus idosos.
|
|
2270
|
+
//
|
|
2271
|
+
// Por isso o índice existe para acompanhar a própria evolução, e não para
|
|
2272
|
+
// classificar.
|
|
2273
|
+
{
|
|
2274
|
+
category: "composicao-corporal",
|
|
2275
|
+
code: "MuscleMassIndex",
|
|
2276
|
+
names: {
|
|
2277
|
+
en: ["Muscle Mass Index", "Skeletal Muscle Mass Index", "SMI", "SMMI"],
|
|
2278
|
+
pt: ["\xCDndice de Massa Muscular", "IMM", "\xCDndice de Massa Muscular Esquel\xE9tica"]
|
|
2279
|
+
},
|
|
2280
|
+
unit: "kg/m2"
|
|
2281
|
+
},
|
|
2252
2282
|
{
|
|
2253
2283
|
category: "composicao-corporal",
|
|
2254
2284
|
code: "PhaseAngle",
|
|
@@ -2350,6 +2380,18 @@ var BIOMARKER_DEFINITIONS = [
|
|
|
2350
2380
|
},
|
|
2351
2381
|
unit: "cm"
|
|
2352
2382
|
},
|
|
2383
|
+
// O EWGSOP2 usa a panturrilha como proxy de massa muscular onde não há
|
|
2384
|
+
// outro método disponível, o que a torna útil em consulta sem aparelho.
|
|
2385
|
+
{
|
|
2386
|
+
category: "composicao-corporal",
|
|
2387
|
+
code: "CalfCircumference",
|
|
2388
|
+
loinc: "107112-5",
|
|
2389
|
+
names: {
|
|
2390
|
+
en: ["Calf Circumference", "Calf Girth"],
|
|
2391
|
+
pt: ["Circunfer\xEAncia da Panturrilha", "Per\xEDmetro da Panturrilha", "Panturrilha"]
|
|
2392
|
+
},
|
|
2393
|
+
unit: "cm"
|
|
2394
|
+
},
|
|
2353
2395
|
{
|
|
2354
2396
|
category: "composicao-corporal",
|
|
2355
2397
|
code: "WaistToHeightRatio",
|
|
@@ -3203,4 +3245,4 @@ export {
|
|
|
3203
3245
|
getBiomarkersByCategory,
|
|
3204
3246
|
getBiomarkersForCategories
|
|
3205
3247
|
};
|
|
3206
|
-
//# sourceMappingURL=chunk-
|
|
3248
|
+
//# sourceMappingURL=chunk-3KIJIRCI.js.map
|