@precisa-saude/fhir 0.20.0 → 0.20.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/dist/cli.js CHANGED
@@ -3026,6 +3026,12 @@ function loincToCode(loinc) {
3026
3026
  function codeToLoinc(code) {
3027
3027
  return codeToLoincMap.get(code);
3028
3028
  }
3029
+ function isValidCode(code) {
3030
+ return validCodeSet.has(code);
3031
+ }
3032
+ function normalizeCode(code) {
3033
+ return codeAliasToCanonicalMap.get(code) ?? code;
3034
+ }
3029
3035
  function getDefinitionByCode(code) {
3030
3036
  return codeToDefinitionMap.get(code);
3031
3037
  }
@@ -3090,6 +3096,10 @@ async function categories(_args, json) {
3090
3096
  outputText(lines.join("\n"));
3091
3097
  }
3092
3098
 
3099
+ // src/code-systems.ts
3100
+ var LOINC_SYSTEM = "http://loinc.org";
3101
+ var BIOMARKER_CODE_SYSTEM = "http://fhir-brasil.dev/biomarker-codes";
3102
+
3093
3103
  // src/units.ts
3094
3104
  var UNIT_TO_UCUM = {
3095
3105
  // Dimensionless / special measurements
@@ -3960,7 +3970,7 @@ function interpretationDisplay(flag) {
3960
3970
  }
3961
3971
  }
3962
3972
  function labObservationToFHIR(observation, patientId, laboratoryName) {
3963
- const loincCode = codeToLoinc(observation.biomarkerCode) || "99999-9";
3973
+ const loincCode = codeToLoinc(observation.biomarkerCode);
3964
3974
  const sourceUnit = observation.unit || getDefaultUnit(observation.biomarkerCode) || observation.unit;
3965
3975
  const ucumUnit = unitToUCUM(sourceUnit);
3966
3976
  const isQualitative = observation.isQualitative || typeof observation.value === "string";
@@ -3977,16 +3987,23 @@ function labObservationToFHIR(observation, patientId, laboratoryName) {
3977
3987
  }
3978
3988
  ],
3979
3989
  code: {
3990
+ // Sem LOINC, o coding LOINC simplesmente não sai. Antes ia `99999-9`,
3991
+ // que não é código LOINC nenhum: publicava sob `http://loinc.org` uma
3992
+ // afirmação falsa, e quem consumisse o bundle confiando no system
3993
+ // trataria aquilo como código de verdade. Composição corporal, densidade
3994
+ // óssea e escore de cálcio não têm LOINC, e o certo é a lacuna explícita.
3980
3995
  coding: [
3981
- {
3982
- code: loincCode,
3983
- display: observation.biomarkerName,
3984
- system: "http://loinc.org"
3985
- },
3996
+ ...loincCode ? [
3997
+ {
3998
+ code: loincCode,
3999
+ display: observation.biomarkerName,
4000
+ system: LOINC_SYSTEM
4001
+ }
4002
+ ] : [],
3986
4003
  {
3987
4004
  code: observation.biomarkerCode,
3988
4005
  display: observation.biomarkerName,
3989
- system: "http://fhir-brasil.dev/biomarker-codes"
4006
+ system: BIOMARKER_CODE_SYSTEM
3990
4007
  }
3991
4008
  ],
3992
4009
  text: observation.biomarkerName
@@ -4217,10 +4234,30 @@ function validateFHIRImportBundle(data) {
4217
4234
  // src/importer.ts
4218
4235
  var MAX_OBSERVATIONS = 5e3;
4219
4236
  var MAX_FILE_SIZE = 15 * 1024 * 1024;
4220
- function extractLoincCode(observation) {
4221
- if (!observation.code?.coding) return void 0;
4222
- const loincCoding = observation.code.coding.find((c) => c.system === "http://loinc.org");
4223
- return loincCoding?.code;
4237
+ function resolveBiomarkerCode(observation) {
4238
+ const coding = observation.code?.coding ?? [];
4239
+ const loincCode = coding.find((c) => c.system === LOINC_SYSTEM)?.code;
4240
+ const declaredCode = coding.find((c) => c.system === BIOMARKER_CODE_SYSTEM)?.code;
4241
+ const seenCodes = [
4242
+ ...loincCode ? [`LOINC ${loincCode}`] : [],
4243
+ ...declaredCode ? [`biomarker code ${declaredCode}`] : []
4244
+ ];
4245
+ let reason;
4246
+ if (seenCodes.length > 0) {
4247
+ reason = `Unknown code: ${seenCodes.join(", ")}`;
4248
+ } else if (coding.length > 0) {
4249
+ const systems = [...new Set(coding.map((c) => c.system ?? "(sem system)"))];
4250
+ reason = `No code in a supported system (found: ${systems.join(", ")})`;
4251
+ } else {
4252
+ reason = "No code found in observation coding";
4253
+ }
4254
+ const fromLoinc = loincCode ? loincToCode(loincCode) : void 0;
4255
+ if (fromLoinc) return { internalCode: fromLoinc, loincCode, reason };
4256
+ if (declaredCode && isValidCode(declaredCode)) {
4257
+ const canonical = normalizeCode(declaredCode);
4258
+ return { internalCode: canonical, loincCode: codeToLoinc(canonical), reason };
4259
+ }
4260
+ return { loincCode, reason };
4224
4261
  }
4225
4262
  function extractFlag(observation) {
4226
4263
  const code = observation.interpretation?.[0]?.coding?.[0]?.code;
@@ -4249,28 +4286,13 @@ function extractObservationsFromBundle(bundle) {
4249
4286
  return { observations, skipped };
4250
4287
  }
4251
4288
  function mapFHIRObservationToInternal(observation, index) {
4252
- const loincCode = extractLoincCode(observation);
4253
- if (!loincCode) {
4254
- return {
4255
- skipped: {
4256
- index,
4257
- reason: "No LOINC code found in observation coding",
4258
- resourceType: "Observation"
4259
- }
4260
- };
4261
- }
4262
- const internalCode = loincToCode(loincCode);
4289
+ const { internalCode, loincCode, reason } = resolveBiomarkerCode(observation);
4263
4290
  if (!internalCode) {
4264
4291
  return {
4265
- skipped: {
4266
- index,
4267
- loincCode,
4268
- reason: `Unknown LOINC code: ${loincCode}`,
4269
- resourceType: "Observation"
4270
- }
4292
+ skipped: { index, loincCode, reason, resourceType: "Observation" }
4271
4293
  };
4272
4294
  }
4273
- const definition = getDefinitionByLoinc(loincCode);
4295
+ const definition = getDefinitionByCode(internalCode);
4274
4296
  let value;
4275
4297
  let unit = "";
4276
4298
  let isQualitative = false;
@@ -6578,7 +6600,7 @@ async function main() {
6578
6600
  strict: false
6579
6601
  });
6580
6602
  if (values.version) {
6581
- process.stdout.write(`${"0.20.0"}
6603
+ process.stdout.write(`${"0.20.1"}
6582
6604
  `);
6583
6605
  return;
6584
6606
  }
@@ -3,7 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- var _chunk2KDLOCD2cjs = require('./chunk-2KDLOCD2.cjs');
6
+ var _chunkQJF5BZ3Jcjs = require('./chunk-QJF5BZ3J.cjs');
7
+ require('./chunk-OR67NJDZ.cjs');
7
8
  require('./chunk-NXOTXKVB.cjs');
8
9
  require('./chunk-MJ254F5K.cjs');
9
10
 
@@ -11,5 +12,5 @@ require('./chunk-MJ254F5K.cjs');
11
12
 
12
13
 
13
14
 
14
- exports.labObservationToFHIR = _chunk2KDLOCD2cjs.labObservationToFHIR; exports.labReportToFHIR = _chunk2KDLOCD2cjs.labReportToFHIR; exports.labResultToFHIRBundle = _chunk2KDLOCD2cjs.labResultToFHIRBundle; exports.userProfileToFHIR = _chunk2KDLOCD2cjs.userProfileToFHIR;
15
+ exports.labObservationToFHIR = _chunkQJF5BZ3Jcjs.labObservationToFHIR; exports.labReportToFHIR = _chunkQJF5BZ3Jcjs.labReportToFHIR; exports.labResultToFHIRBundle = _chunkQJF5BZ3Jcjs.labResultToFHIRBundle; exports.userProfileToFHIR = _chunkQJF5BZ3Jcjs.userProfileToFHIR;
15
16
  //# sourceMappingURL=converter.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/converter.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,6QAAC","file":"/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/converter.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/converter.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,6QAAC","file":"/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/converter.cjs"}
package/dist/converter.js CHANGED
@@ -3,7 +3,8 @@ import {
3
3
  labReportToFHIR,
4
4
  labResultToFHIRBundle,
5
5
  userProfileToFHIR
6
- } from "./chunk-6TQ24JCA.js";
6
+ } from "./chunk-SN5ZJHWS.js";
7
+ import "./chunk-A6HR4XDK.js";
7
8
  import "./chunk-3KIJIRCI.js";
8
9
  import "./chunk-R4MUCMO3.js";
9
10
  export {
package/dist/importer.cjs CHANGED
@@ -4,7 +4,8 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkCFKXCL2Ncjs = require('./chunk-CFKXCL2N.cjs');
7
+ var _chunkETZXOGABcjs = require('./chunk-ETZXOGAB.cjs');
8
+ require('./chunk-OR67NJDZ.cjs');
8
9
  require('./chunk-NXOTXKVB.cjs');
9
10
  require('./chunk-3ILBFLVQ.cjs');
10
11
 
@@ -13,5 +14,5 @@ require('./chunk-3ILBFLVQ.cjs');
13
14
 
14
15
 
15
16
 
16
- exports.MAX_FILE_SIZE = _chunkCFKXCL2Ncjs.MAX_FILE_SIZE; exports.MAX_OBSERVATIONS = _chunkCFKXCL2Ncjs.MAX_OBSERVATIONS; exports.extractObservationsFromBundle = _chunkCFKXCL2Ncjs.extractObservationsFromBundle; exports.mapFHIRObservationToInternal = _chunkCFKXCL2Ncjs.mapFHIRObservationToInternal; exports.processImportBundle = _chunkCFKXCL2Ncjs.processImportBundle;
17
+ exports.MAX_FILE_SIZE = _chunkETZXOGABcjs.MAX_FILE_SIZE; exports.MAX_OBSERVATIONS = _chunkETZXOGABcjs.MAX_OBSERVATIONS; exports.extractObservationsFromBundle = _chunkETZXOGABcjs.extractObservationsFromBundle; exports.mapFHIRObservationToInternal = _chunkETZXOGABcjs.mapFHIRObservationToInternal; exports.processImportBundle = _chunkETZXOGABcjs.processImportBundle;
17
18
  //# sourceMappingURL=importer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/importer.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,4WAAC","file":"/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/importer.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/importer.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,4WAAC","file":"/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/importer.cjs"}
@@ -13,7 +13,8 @@ interface ImportedObservation {
13
13
  collectionDate: string;
14
14
  flag: 'H' | 'L' | '';
15
15
  isQualitative: boolean;
16
- loincCode: string;
16
+ /** Ausente nos biomarcadores sem LOINC publicado, como composição corporal. */
17
+ loincCode?: string;
17
18
  referenceMax?: number;
18
19
  referenceMin?: number;
19
20
  unit: string;
@@ -13,7 +13,8 @@ interface ImportedObservation {
13
13
  collectionDate: string;
14
14
  flag: 'H' | 'L' | '';
15
15
  isQualitative: boolean;
16
- loincCode: string;
16
+ /** Ausente nos biomarcadores sem LOINC publicado, como composição corporal. */
17
+ loincCode?: string;
17
18
  referenceMax?: number;
18
19
  referenceMin?: number;
19
20
  unit: string;
package/dist/importer.js CHANGED
@@ -4,7 +4,8 @@ import {
4
4
  extractObservationsFromBundle,
5
5
  mapFHIRObservationToInternal,
6
6
  processImportBundle
7
- } from "./chunk-OZGOBYLX.js";
7
+ } from "./chunk-YYANW65U.js";
8
+ import "./chunk-A6HR4XDK.js";
8
9
  import "./chunk-3KIJIRCI.js";
9
10
  import "./chunk-N3ZCOLG2.js";
10
11
  export {
package/dist/index.cjs CHANGED
@@ -3,14 +3,18 @@
3
3
 
4
4
 
5
5
 
6
- var _chunk2KDLOCD2cjs = require('./chunk-2KDLOCD2.cjs');
6
+ var _chunkQJF5BZ3Jcjs = require('./chunk-QJF5BZ3J.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
12
 
13
- var _chunkCFKXCL2Ncjs = require('./chunk-CFKXCL2N.cjs');
13
+ var _chunkETZXOGABcjs = require('./chunk-ETZXOGAB.cjs');
14
+
15
+
16
+
17
+ var _chunkOR67NJDZcjs = require('./chunk-OR67NJDZ.cjs');
14
18
 
15
19
 
16
20
 
@@ -228,7 +232,7 @@ function interventionToFHIRObservation(intervention, patientId) {
228
232
  }
229
233
  function interventionsToFHIRBundle(interventions, userProfile) {
230
234
  const patientId = userProfile.userId;
231
- const fhirPatient = _chunk2KDLOCD2cjs.userProfileToFHIR.call(void 0, userProfile);
235
+ const fhirPatient = _chunkQJF5BZ3Jcjs.userProfileToFHIR.call(void 0, userProfile);
232
236
  const entries = interventions.map((intervention) => {
233
237
  const isMedication = intervention.type === "medication" || intervention.type === "supplement";
234
238
  const resource = isMedication ? interventionToFHIRMedicationStatement(intervention, patientId) : interventionToFHIRObservation(intervention, patientId);
@@ -691,5 +695,7 @@ function cnsToFHIRIdentifier(cns) {
691
695
 
692
696
 
693
697
 
694
- exports.AGE_BRACKETS = AGE_BRACKETS; exports.BIOMARKER_DEFAULT_UNIT = _chunkMJ254F5Kcjs.BIOMARKER_DEFAULT_UNIT; exports.BIOMARKER_DEFINITIONS = _chunkNXOTXKVBcjs.BIOMARKER_DEFINITIONS; exports.BIOMARKER_UNITS = _chunkMJ254F5Kcjs.BIOMARKER_UNITS; exports.BODY_FAT_ZONES = BODY_FAT_ZONES; exports.CAC_INDICATOR_CODES = _chunkNXOTXKVBcjs.CAC_INDICATOR_CODES; exports.CATEGORY_GROUPS = CATEGORY_GROUPS; exports.CATEGORY_SCREENING_INTERVALS = CATEGORY_SCREENING_INTERVALS; exports.DEXA_CATEGORIES = _chunkNXOTXKVBcjs.DEXA_CATEGORIES; exports.DEXA_INDICATOR_CODES = _chunkNXOTXKVBcjs.DEXA_INDICATOR_CODES; exports.MAX_FILE_SIZE = _chunkCFKXCL2Ncjs.MAX_FILE_SIZE; exports.MAX_OBSERVATIONS = _chunkCFKXCL2Ncjs.MAX_OBSERVATIONS; exports.T_SCORE_ZONES = T_SCORE_ZONES; exports.UNIT_TO_UCUM = _chunkMJ254F5Kcjs.UNIT_TO_UCUM; exports.ZONE_DEFS = ZONE_DEFS; exports.applyFallbackReferenceRanges = _chunkERALICUKcjs.applyFallbackReferenceRanges; exports.biomarkerRangeDefinitions = _chunkERALICUKcjs.biomarkerRangeDefinitions; exports.calculateNextScreeningDate = calculateNextScreeningDate; exports.cnsToFHIRIdentifier = cnsToFHIRIdentifier; exports.codeToLoinc = _chunkNXOTXKVBcjs.codeToLoinc; exports.convertUnit = _chunkMJ254F5Kcjs.convertUnit; exports.cpfToFHIRIdentifier = cpfToFHIRIdentifier; exports.defaultReferenceRanges = _chunkERALICUKcjs.defaultReferenceRanges; exports.extractObservationsFromBundle = _chunkCFKXCL2Ncjs.extractObservationsFromBundle; exports.filterVisibleBiomarkers = _chunkNXOTXKVBcjs.filterVisibleBiomarkers; exports.findCodeByName = _chunkNXOTXKVBcjs.findCodeByName; exports.formatCNS = formatCNS; exports.formatCPF = formatCPF; 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.getCanonicalUnit = _chunkMJ254F5Kcjs.getCanonicalUnit; exports.getCategoriesByInterval = getCategoriesByInterval; exports.getCategoryGroup = getCategoryGroup; exports.getDaysUntilScreening = getDaysUntilScreening; exports.getDefaultUnit = _chunkMJ254F5Kcjs.getDefaultUnit; exports.getDefinitionByCode = _chunkNXOTXKVBcjs.getDefinitionByCode; exports.getDefinitionByLoinc = _chunkNXOTXKVBcjs.getDefinitionByLoinc; exports.getDefinitionsBySex = _chunkNXOTXKVBcjs.getDefinitionsBySex; exports.getDueCategories = getDueCategories; exports.getFallbackReferenceRange = _chunkERALICUKcjs.getFallbackReferenceRange; exports.getRangeDirection = _chunkERALICUKcjs.getRangeDirection; exports.getReferenceRange = _chunkERALICUKcjs.getReferenceRange; exports.getSIUnit = _chunkMJ254F5Kcjs.getSIUnit; exports.getScreeningInterval = getScreeningInterval; exports.getSexForCode = _chunkNXOTXKVBcjs.getSexForCode; exports.getVisibleDefinitions = _chunkNXOTXKVBcjs.getVisibleDefinitions; exports.interventionToFHIRMedicationStatement = interventionToFHIRMedicationStatement; exports.interventionToFHIRObservation = interventionToFHIRObservation; exports.interventionsToFHIRBundle = interventionsToFHIRBundle; exports.isBiomarkerVisible = _chunkNXOTXKVBcjs.isBiomarkerVisible; exports.isCacDocument = _chunkNXOTXKVBcjs.isCacDocument; exports.isDexaDocument = _chunkNXOTXKVBcjs.isDexaDocument; exports.isScreeningDue = isScreeningDue; exports.isValidCode = _chunkNXOTXKVBcjs.isValidCode; exports.isValidLoinc = _chunkNXOTXKVBcjs.isValidLoinc; exports.labObservationToFHIR = _chunk2KDLOCD2cjs.labObservationToFHIR; exports.labReportToFHIR = _chunk2KDLOCD2cjs.labReportToFHIR; exports.labResultToFHIRBundle = _chunk2KDLOCD2cjs.labResultToFHIRBundle; exports.listMappedSubcategories = listMappedSubcategories; exports.loincToCode = _chunkNXOTXKVBcjs.loincToCode; exports.mapFHIRObservationToInternal = _chunkCFKXCL2Ncjs.mapFHIRObservationToInternal; exports.normalizeCode = _chunkNXOTXKVBcjs.normalizeCode; exports.plural = plural; exports.pluralCount = pluralCount; exports.pluralPhrase = pluralPhrase; exports.pluralPhraseCount = pluralPhraseCount; exports.processImportBundle = _chunkCFKXCL2Ncjs.processImportBundle; exports.toBiomarkerTests = _chunkNXOTXKVBcjs.toBiomarkerTests; exports.unitToUCUM = _chunkMJ254F5Kcjs.unitToUCUM; exports.userProfileToFHIR = _chunk2KDLOCD2cjs.userProfileToFHIR; exports.validateCNS = validateCNS; exports.validateCPF = validateCPF; exports.validateFHIRDiagnosticReport = _chunk3ILBFLVQcjs.validateFHIRDiagnosticReport; exports.validateFHIRImportBundle = _chunk3ILBFLVQcjs.validateFHIRImportBundle; exports.validateFHIRObservation = _chunk3ILBFLVQcjs.validateFHIRObservation; exports.validateLoincNameMatch = _chunkNXOTXKVBcjs.validateLoincNameMatch;
698
+
699
+
700
+ exports.AGE_BRACKETS = AGE_BRACKETS; exports.BIOMARKER_CODE_SYSTEM = _chunkOR67NJDZcjs.BIOMARKER_CODE_SYSTEM; exports.BIOMARKER_DEFAULT_UNIT = _chunkMJ254F5Kcjs.BIOMARKER_DEFAULT_UNIT; exports.BIOMARKER_DEFINITIONS = _chunkNXOTXKVBcjs.BIOMARKER_DEFINITIONS; exports.BIOMARKER_UNITS = _chunkMJ254F5Kcjs.BIOMARKER_UNITS; exports.BODY_FAT_ZONES = BODY_FAT_ZONES; exports.CAC_INDICATOR_CODES = _chunkNXOTXKVBcjs.CAC_INDICATOR_CODES; exports.CATEGORY_GROUPS = CATEGORY_GROUPS; exports.CATEGORY_SCREENING_INTERVALS = CATEGORY_SCREENING_INTERVALS; exports.DEXA_CATEGORIES = _chunkNXOTXKVBcjs.DEXA_CATEGORIES; exports.DEXA_INDICATOR_CODES = _chunkNXOTXKVBcjs.DEXA_INDICATOR_CODES; exports.LOINC_SYSTEM = _chunkOR67NJDZcjs.LOINC_SYSTEM; exports.MAX_FILE_SIZE = _chunkETZXOGABcjs.MAX_FILE_SIZE; exports.MAX_OBSERVATIONS = _chunkETZXOGABcjs.MAX_OBSERVATIONS; exports.T_SCORE_ZONES = T_SCORE_ZONES; exports.UNIT_TO_UCUM = _chunkMJ254F5Kcjs.UNIT_TO_UCUM; exports.ZONE_DEFS = ZONE_DEFS; exports.applyFallbackReferenceRanges = _chunkERALICUKcjs.applyFallbackReferenceRanges; exports.biomarkerRangeDefinitions = _chunkERALICUKcjs.biomarkerRangeDefinitions; exports.calculateNextScreeningDate = calculateNextScreeningDate; exports.cnsToFHIRIdentifier = cnsToFHIRIdentifier; exports.codeToLoinc = _chunkNXOTXKVBcjs.codeToLoinc; exports.convertUnit = _chunkMJ254F5Kcjs.convertUnit; exports.cpfToFHIRIdentifier = cpfToFHIRIdentifier; exports.defaultReferenceRanges = _chunkERALICUKcjs.defaultReferenceRanges; exports.extractObservationsFromBundle = _chunkETZXOGABcjs.extractObservationsFromBundle; exports.filterVisibleBiomarkers = _chunkNXOTXKVBcjs.filterVisibleBiomarkers; exports.findCodeByName = _chunkNXOTXKVBcjs.findCodeByName; exports.formatCNS = formatCNS; exports.formatCPF = formatCPF; 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.getCanonicalUnit = _chunkMJ254F5Kcjs.getCanonicalUnit; exports.getCategoriesByInterval = getCategoriesByInterval; exports.getCategoryGroup = getCategoryGroup; exports.getDaysUntilScreening = getDaysUntilScreening; exports.getDefaultUnit = _chunkMJ254F5Kcjs.getDefaultUnit; exports.getDefinitionByCode = _chunkNXOTXKVBcjs.getDefinitionByCode; exports.getDefinitionByLoinc = _chunkNXOTXKVBcjs.getDefinitionByLoinc; exports.getDefinitionsBySex = _chunkNXOTXKVBcjs.getDefinitionsBySex; exports.getDueCategories = getDueCategories; exports.getFallbackReferenceRange = _chunkERALICUKcjs.getFallbackReferenceRange; exports.getRangeDirection = _chunkERALICUKcjs.getRangeDirection; exports.getReferenceRange = _chunkERALICUKcjs.getReferenceRange; exports.getSIUnit = _chunkMJ254F5Kcjs.getSIUnit; exports.getScreeningInterval = getScreeningInterval; exports.getSexForCode = _chunkNXOTXKVBcjs.getSexForCode; exports.getVisibleDefinitions = _chunkNXOTXKVBcjs.getVisibleDefinitions; exports.interventionToFHIRMedicationStatement = interventionToFHIRMedicationStatement; exports.interventionToFHIRObservation = interventionToFHIRObservation; exports.interventionsToFHIRBundle = interventionsToFHIRBundle; exports.isBiomarkerVisible = _chunkNXOTXKVBcjs.isBiomarkerVisible; exports.isCacDocument = _chunkNXOTXKVBcjs.isCacDocument; exports.isDexaDocument = _chunkNXOTXKVBcjs.isDexaDocument; exports.isScreeningDue = isScreeningDue; exports.isValidCode = _chunkNXOTXKVBcjs.isValidCode; exports.isValidLoinc = _chunkNXOTXKVBcjs.isValidLoinc; exports.labObservationToFHIR = _chunkQJF5BZ3Jcjs.labObservationToFHIR; exports.labReportToFHIR = _chunkQJF5BZ3Jcjs.labReportToFHIR; exports.labResultToFHIRBundle = _chunkQJF5BZ3Jcjs.labResultToFHIRBundle; exports.listMappedSubcategories = listMappedSubcategories; exports.loincToCode = _chunkNXOTXKVBcjs.loincToCode; exports.mapFHIRObservationToInternal = _chunkETZXOGABcjs.mapFHIRObservationToInternal; exports.normalizeCode = _chunkNXOTXKVBcjs.normalizeCode; exports.plural = plural; exports.pluralCount = pluralCount; exports.pluralPhrase = pluralPhrase; exports.pluralPhraseCount = pluralPhraseCount; exports.processImportBundle = _chunkETZXOGABcjs.processImportBundle; exports.toBiomarkerTests = _chunkNXOTXKVBcjs.toBiomarkerTests; exports.unitToUCUM = _chunkMJ254F5Kcjs.unitToUCUM; exports.userProfileToFHIR = _chunkQJF5BZ3Jcjs.userProfileToFHIR; exports.validateCNS = validateCNS; exports.validateCPF = validateCPF; exports.validateFHIRDiagnosticReport = _chunk3ILBFLVQcjs.validateFHIRDiagnosticReport; exports.validateFHIRImportBundle = _chunk3ILBFLVQcjs.validateFHIRImportBundle; exports.validateFHIRObservation = _chunk3ILBFLVQcjs.validateFHIRObservation; exports.validateLoincNameMatch = _chunkNXOTXKVBcjs.validateLoincNameMatch;
695
701
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/index.cjs","../src/category-groups.ts","../src/intervention-converter.ts","../src/dexa-zone-data.ts","../src/screening-intervals.ts","../src/i18n.ts","../src/identifiers.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACnCO,IAAM,gBAAA,EAA4D;AAAA,EACvE,cAAA,EAAgB;AAAA,IACd,EAAA,EAAI,gBAAA;AAAA,IACJ,EAAA,EAAI,gBAAA;AAAA,IACJ,IAAA,EAAM,gBAAA;AAAA,IACN,aAAA,EAAe,CAAC,SAAS;AAAA,EAC3B,CAAA;AAAA,EACA,2BAAA,EAA6B;AAAA,IAC3B,EAAA,EAAI,0BAAA;AAAA,IACJ,EAAA,EAAI,4CAAA;AAAA,IACJ,IAAA,EAAM,2BAAA;AAAA,IACN,aAAA,E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AACR,IAAA;AACA,IAAA;AACV,EAAA;AAAA;AAGA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AAAA;AAGA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACF;AAKiG;AAC7C,EAAA;AACpD;AAOkC;AACkB,EAAA;AACpD;AAK+D;AACf,EAAA;AACxB,EAAA;AAEgB,EAAA;AACW,EAAA;AAC1C,EAAA;AACT;AAQE;AAE4C,EAA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,IAAA;AAChC,EAAA;AACO,EAAA;AACG,IAAA;AACH,IAAA;AACgB,IAAA;AACvB,EAAA;AACF;AASiE;AACxC,EAAA;AACS,IAAA;AAChC,EAAA;AACO,EAAA;AACG,IAAA;AACH,IAAA;AACgB,IAAA;AACvB,EAAA;AACF;ANmdoD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/index.cjs","sourcesContent":[null,"/**\n * Agrupamento de categorias clínicas em 10 grupos de alto nível.\n *\n * `BiomarkerDefinition.category` armazena 20 sub-categorias (granularidade\n * fina, ex: `tireoide`, `pancreas`). Este módulo agrupa essas\n * sub-categorias em 10 buckets clínicos amplos para apresentação no\n * site, na API pública e em material de divulgação.\n *\n * As sub-categorias permanecem como fonte da verdade nos dados; este\n * agrupamento é uma camada derivada.\n */\n\nexport type CategoryGroup =\n | 'cardiovascular'\n | 'metabolico-endocrino'\n | 'renal-eletrolitico'\n | 'hepatico-biliar'\n | 'hematologico'\n | 'imunologico'\n | 'oncologico'\n | 'nutricional-ambiental'\n | 'saude-reprodutiva'\n | 'composicao-envelhecimento';\n\nexport interface CategoryGroupInfo {\n /** Rótulo em inglês */\n en: string;\n /** Rótulo em português */\n pt: string;\n /** Slug (kebab-case, sem acento) */\n slug: CategoryGroup;\n /** Sub-categorias da fonte agrupadas neste bucket */\n subcategories: readonly string[];\n}\n\nexport const CATEGORY_GROUPS: Record<CategoryGroup, CategoryGroupInfo> = {\n cardiovascular: {\n en: 'Cardiovascular',\n pt: 'Cardiovascular',\n slug: 'cardiovascular',\n subcategories: ['coracao'],\n },\n 'composicao-envelhecimento': {\n en: 'Body Composition & Aging',\n pt: 'Composição Corporal e Envelhecimento',\n slug: 'composicao-envelhecimento',\n subcategories: ['composicao-corporal', 'densidade-ossea', 'estresse-envelhecimento'],\n },\n hematologico: {\n en: 'Hematology',\n pt: 'Hematológico',\n slug: 'hematologico',\n subcategories: ['sangue'],\n },\n 'hepatico-biliar': {\n en: 'Hepatic & Biliary',\n pt: 'Hepático e Biliar',\n slug: 'hepatico-biliar',\n subcategories: ['figado'],\n },\n imunologico: {\n en: 'Immunology',\n pt: 'Imunológico',\n slug: 'imunologico',\n subcategories: ['autoimunidade', 'regulacao-imunologica'],\n },\n 'metabolico-endocrino': {\n en: 'Metabolic & Endocrine',\n pt: 'Metabólico e Endócrino',\n slug: 'metabolico-endocrino',\n subcategories: ['metabolico', 'pancreas', 'hormonios', 'tireoide'],\n },\n 'nutricional-ambiental': {\n en: 'Nutrition & Environmental Exposure',\n pt: 'Nutricional e Exposição Ambiental',\n slug: 'nutricional-ambiental',\n subcategories: ['nutrientes', 'toxinas-ambientais'],\n },\n oncologico: {\n en: 'Oncology',\n pt: 'Oncológico',\n slug: 'oncologico',\n subcategories: ['marcadores-tumorais'],\n },\n 'renal-eletrolitico': {\n en: 'Renal & Electrolytes',\n pt: 'Renal e Eletrolítico',\n slug: 'renal-eletrolitico',\n subcategories: ['rins', 'urina', 'eletrolitos'],\n },\n 'saude-reprodutiva': {\n en: 'Reproductive Health',\n pt: 'Saúde Reprodutiva',\n slug: 'saude-reprodutiva',\n subcategories: ['saude-feminina', 'saude-masculina'],\n },\n};\n\nconst SUBCATEGORY_TO_GROUP = new Map<string, CategoryGroup>();\nfor (const group of Object.values(CATEGORY_GROUPS)) {\n for (const sub of group.subcategories) {\n SUBCATEGORY_TO_GROUP.set(sub, group.slug);\n }\n}\n\n/**\n * Resolve a sub-categoria (granular) para o grupo de alto nível (10 buckets).\n */\nexport function getCategoryGroup(subcategory: string): CategoryGroup | undefined {\n return SUBCATEGORY_TO_GROUP.get(subcategory);\n}\n\n/**\n * Lista todas as sub-categorias mapeadas em algum grupo.\n */\nexport function listMappedSubcategories(): readonly string[] {\n return [...SUBCATEGORY_TO_GROUP.keys()];\n}\n","/**\n * FHIR Intervention Converter\n *\n * Converts interventions (medication, supplement, diet, exercise, sleep)\n * to FHIR R4 MedicationStatement and Observation resources.\n */\n\nimport { userProfileToFHIR } from './converter';\nimport type { FHIRBundle, FHIRMedicationStatement, FHIRObservation } from './fhir-types';\nimport type { InterventionData, UserProfileData } from './types';\n\n/**\n * Determine MedicationStatement/Observation status based on end date\n */\nfunction interventionStatus(endDate?: string): 'active' | 'completed' {\n if (!endDate) return 'active';\n return new Date(endDate) < new Date() ? 'completed' : 'active';\n}\n\n/**\n * LOINC-like codes for lifestyle observation types\n */\nconst LIFESTYLE_CODES: Record<string, { code: string; display: string }> = {\n diet: { code: '81259-4', display: 'Diet' },\n exercise: { code: '73985-4', display: 'Exercise activity' },\n sleep: { code: '93832-4', display: 'Sleep duration' },\n};\n\n/**\n * Convert medication/supplement intervention to FHIR MedicationStatement\n */\nexport function interventionToFHIRMedicationStatement(\n intervention: InterventionData,\n patientId: string,\n): FHIRMedicationStatement {\n const statement: FHIRMedicationStatement = {\n category: {\n coding: [\n {\n code: 'patientspecified',\n display: 'Patient Specified',\n system: 'http://terminology.hl7.org/CodeSystem/medication-statement-category',\n },\n ],\n },\n dateAsserted: intervention.startDate,\n effectivePeriod: {\n end: intervention.endDate,\n start: intervention.startDate,\n },\n id: `intervention-${intervention.interventionId}`,\n medicationCodeableConcept: {\n text: intervention.name,\n },\n resourceType: 'MedicationStatement',\n status: interventionStatus(intervention.endDate),\n subject: {\n reference: `Patient/${patientId}`,\n },\n };\n\n if (intervention.notes) {\n statement.note = [{ text: intervention.notes }];\n }\n\n return statement;\n}\n\n/**\n * Convert diet/exercise/sleep intervention to FHIR Observation (social-history)\n */\nexport function interventionToFHIRObservation(\n intervention: InterventionData,\n patientId: string,\n): FHIRObservation {\n const lifestyleCode = LIFESTYLE_CODES[intervention.type];\n\n const observation: FHIRObservation = {\n category: [\n {\n coding: [\n {\n code: 'social-history',\n display: 'Social History',\n system: 'http://terminology.hl7.org/CodeSystem/observation-category',\n },\n ],\n },\n ],\n code: {\n coding: lifestyleCode\n ? [\n {\n code: lifestyleCode.code,\n display: lifestyleCode.display,\n system: 'http://loinc.org',\n },\n ]\n : [],\n text: intervention.name,\n },\n effectivePeriod: {\n end: intervention.endDate,\n start: intervention.startDate,\n },\n id: `intervention-${intervention.interventionId}`,\n resourceType: 'Observation',\n status: 'final',\n subject: {\n reference: `Patient/${patientId}`,\n },\n valueString: intervention.name,\n };\n\n if (intervention.notes) {\n observation.note = [{ text: intervention.notes }];\n }\n\n return observation;\n}\n\n/**\n * Convert all interventions to a FHIR Bundle\n */\nexport function interventionsToFHIRBundle(\n interventions: InterventionData[],\n userProfile: UserProfileData,\n): FHIRBundle {\n const patientId = userProfile.userId;\n const fhirPatient = userProfileToFHIR(userProfile);\n\n const entries = interventions.map((intervention) => {\n const isMedication = intervention.type === 'medication' || intervention.type === 'supplement';\n const resource = isMedication\n ? interventionToFHIRMedicationStatement(intervention, patientId)\n : interventionToFHIRObservation(intervention, patientId);\n\n return {\n fullUrl: `urn:uuid:intervention-${intervention.interventionId}`,\n resource,\n };\n });\n\n return {\n entry: [\n {\n fullUrl: `urn:uuid:${patientId}`,\n resource: fhirPatient,\n },\n ...entries,\n ],\n resourceType: 'Bundle',\n type: 'collection',\n };\n}\n","/**\n * Structured zone data for DEXA body composition and bone density charts.\n *\n * Body fat zones derived from Gallagher et al. Am J Clin Nutr 2000;72:694-701 (PMID: 10966886)\n * and ACSM Guidelines for Exercise Testing, 11th Ed (2021).\n *\n * T-Score zones from WHO criteria (Kanis JA, Osteoporos Int, PMID: 7696835).\n */\n\nexport interface BodyFatZone {\n ageMax: number;\n ageMin: number;\n color: string;\n fatPctMax: number;\n fatPctMin: number;\n label: string;\n sex: 'F' | 'M';\n}\n\ninterface AgeBracket {\n ageMax: number;\n ageMin: number;\n label: string;\n}\n\nconst AGE_BRACKETS: AgeBracket[] = [\n { ageMax: 25, ageMin: 18, label: '18-25' },\n { ageMax: 35, ageMin: 26, label: '26-35' },\n { ageMax: 45, ageMin: 36, label: '36-45' },\n { ageMax: 55, ageMin: 46, label: '46-55' },\n { ageMax: 99, ageMin: 56, label: '56+' },\n];\n\n// Zone boundaries per age bracket for men: [essential, athletic, fitness, average, obese]\n// Each value is the upper bound of the zone\nconst MALE_ZONES: number[][] = [\n [5, 10, 20, 25, 40],\n [5, 11, 21, 26, 40],\n [5, 12, 22, 27, 40],\n [5, 13, 23, 28, 40],\n [5, 14, 24, 29, 40],\n];\n\nconst FEMALE_ZONES: number[][] = [\n [13, 18, 28, 32, 45],\n [13, 18, 29, 33, 45],\n [13, 19, 30, 34, 45],\n [13, 20, 31, 35, 45],\n [13, 20, 32, 36, 45],\n];\n\ninterface ZoneDefinition {\n color: string;\n label: string;\n}\n\nconst ZONE_DEFS: ZoneDefinition[] = [\n { color: '#3b82f6', label: 'Essencial' },\n { color: '#06b6d4', label: 'Atlético' },\n { color: '#22c55e', label: 'Fitness' },\n { color: '#eab308', label: 'Média' },\n { color: '#ef4444', label: 'Obeso' },\n];\n\nfunction buildZones(sex: 'F' | 'M', zoneData: number[][]): BodyFatZone[] {\n const zones: BodyFatZone[] = [];\n for (let i = 0; i < AGE_BRACKETS.length; i++) {\n const bracket = AGE_BRACKETS[i]!;\n const b = zoneData[i]!;\n zones.push({\n ...bracket,\n color: ZONE_DEFS[0]!.color,\n fatPctMax: b[0]!,\n fatPctMin: 0,\n label: ZONE_DEFS[0]!.label,\n sex,\n });\n zones.push({\n ...bracket,\n color: ZONE_DEFS[1]!.color,\n fatPctMax: b[1]!,\n fatPctMin: b[0]!,\n label: ZONE_DEFS[1]!.label,\n sex,\n });\n zones.push({\n ...bracket,\n color: ZONE_DEFS[2]!.color,\n fatPctMax: b[2]!,\n fatPctMin: b[1]!,\n label: ZONE_DEFS[2]!.label,\n sex,\n });\n zones.push({\n ...bracket,\n color: ZONE_DEFS[3]!.color,\n fatPctMax: b[3]!,\n fatPctMin: b[2]!,\n label: ZONE_DEFS[3]!.label,\n sex,\n });\n zones.push({\n ...bracket,\n color: ZONE_DEFS[4]!.color,\n fatPctMax: b[4]!,\n fatPctMin: b[3]!,\n label: ZONE_DEFS[4]!.label,\n sex,\n });\n }\n return zones;\n}\n\nexport const BODY_FAT_ZONES: BodyFatZone[] = [\n ...buildZones('M', MALE_ZONES),\n ...buildZones('F', FEMALE_ZONES),\n];\n\nexport { AGE_BRACKETS, ZONE_DEFS };\n\nexport interface TScoreZone {\n color: string;\n label: string;\n max: number;\n min: number;\n}\n\nexport const T_SCORE_ZONES: TScoreZone[] = [\n { color: '#22c55e', label: 'Normal', max: 4, min: -1.0 },\n { color: '#eab308', label: 'Osteopenia', max: -1.0, min: -2.5 },\n { color: '#ef4444', label: 'Osteoporose', max: -2.5, min: -5 },\n];\n","/**\n * Screening Intervals Configuration\n *\n * Defines recommended screening intervals for different biomarker categories\n * based on clinical guidelines and best practices.\n */\n\n/**\n * Screening interval in months\n */\nexport type ScreeningIntervalMonths = 3 | 6 | 12;\n\n/**\n * Biomarker category with its recommended screening interval\n */\nexport interface CategoryScreeningInterval {\n category: string;\n intervalMonths: ScreeningIntervalMonths;\n nameEn: string;\n namePt: string;\n}\n\n/**\n * Screening interval configuration for each category\n *\n * Categories are grouped by their recommended screening intervals:\n * - 3 months: Body composition and bone density (frequently changing metrics)\n * - 6 months: Metabolic panel and nutrients (moderate change rate)\n * - 12 months: Standard blood panels (stable long-term markers)\n */\nexport const CATEGORY_SCREENING_INTERVALS: CategoryScreeningInterval[] = [\n // 3-month intervals - Body composition (frequently changing)\n {\n category: 'composicao-corporal',\n intervalMonths: 3,\n nameEn: 'Body Composition',\n namePt: 'Composição Corporal',\n },\n {\n category: 'densidade-ossea',\n intervalMonths: 3,\n nameEn: 'Bone Density',\n namePt: 'Densidade Óssea',\n },\n\n // 6-month intervals - Metabolic and nutrients\n {\n category: 'metabolico',\n intervalMonths: 6,\n nameEn: 'Metabolic Panel',\n namePt: 'Painel Metabólico',\n },\n {\n category: 'nutrientes',\n intervalMonths: 6,\n nameEn: 'Nutrients',\n namePt: 'Nutrientes',\n },\n {\n category: 'pancreas',\n intervalMonths: 6,\n nameEn: 'Pancreas',\n namePt: 'Pâncreas',\n },\n\n // 12-month intervals - Standard blood panels\n {\n category: 'coracao',\n intervalMonths: 12,\n nameEn: 'Heart Health',\n namePt: 'Saúde Cardiovascular',\n },\n {\n category: 'tireoide',\n intervalMonths: 12,\n nameEn: 'Thyroid',\n namePt: 'Tireoide',\n },\n {\n category: 'sangue',\n intervalMonths: 12,\n nameEn: 'Blood Count',\n namePt: 'Hemograma',\n },\n {\n category: 'figado',\n intervalMonths: 12,\n nameEn: 'Liver Function',\n namePt: 'Função Hepática',\n },\n {\n category: 'rins',\n intervalMonths: 12,\n nameEn: 'Kidney Function',\n namePt: 'Função Renal',\n },\n {\n category: 'saude-feminina',\n intervalMonths: 12,\n nameEn: \"Women's Health\",\n namePt: 'Saúde Feminina',\n },\n {\n category: 'saude-masculina',\n intervalMonths: 12,\n nameEn: \"Men's Health\",\n namePt: 'Saúde Masculina',\n },\n {\n category: 'eletrolitos',\n intervalMonths: 12,\n nameEn: 'Electrolytes',\n namePt: 'Eletrólitos',\n },\n {\n category: 'estresse-envelhecimento',\n intervalMonths: 12,\n nameEn: 'Stress & Aging',\n namePt: 'Estresse e Envelhecimento',\n },\n {\n category: 'autoimunidade',\n intervalMonths: 12,\n nameEn: 'Autoimmunity',\n namePt: 'Autoimunidade',\n },\n {\n category: 'regulacao-imunologica',\n intervalMonths: 12,\n nameEn: 'Immune Regulation',\n namePt: 'Regulação Imunológica',\n },\n {\n category: 'toxinas-ambientais',\n intervalMonths: 12,\n nameEn: 'Environmental Toxins',\n namePt: 'Toxinas Ambientais',\n },\n {\n category: 'urina',\n intervalMonths: 12,\n nameEn: 'Urinalysis',\n namePt: 'Urina',\n },\n];\n\n/**\n * Get screening interval for a category\n */\nexport const getScreeningInterval = (category: string): CategoryScreeningInterval | undefined => {\n return CATEGORY_SCREENING_INTERVALS.find((c) => c.category === category);\n};\n\n/**\n * Get all categories with a specific interval\n */\nexport const getCategoriesByInterval = (\n intervalMonths: ScreeningIntervalMonths,\n): CategoryScreeningInterval[] => {\n return CATEGORY_SCREENING_INTERVALS.filter((c) => c.intervalMonths === intervalMonths);\n};\n\n/**\n * Calculate next screening date based on last test date and category\n */\nexport const calculateNextScreeningDate = (lastTestDate: Date, category: string): Date | null => {\n const interval = getScreeningInterval(category);\n if (!interval) return null;\n\n const nextDate = new Date(lastTestDate);\n nextDate.setMonth(nextDate.getMonth() + interval.intervalMonths);\n return nextDate;\n};\n\n/**\n * Check if a category is due for screening\n */\nexport const isScreeningDue = (\n lastTestDate: Date,\n category: string,\n referenceDate: Date = new Date(),\n): boolean => {\n const nextDate = calculateNextScreeningDate(lastTestDate, category);\n if (!nextDate) return false;\n return referenceDate >= nextDate;\n};\n\n/**\n * Get categories that are due for screening based on last test dates\n */\nexport const getDueCategories = (\n lastTestDates: Record<string, Date>,\n referenceDate: Date = new Date(),\n): CategoryScreeningInterval[] => {\n return CATEGORY_SCREENING_INTERVALS.filter((interval) => {\n const lastDate = lastTestDates[interval.category];\n if (!lastDate) return true; // Never tested = due\n return isScreeningDue(lastDate, interval.category, referenceDate);\n });\n};\n\n/**\n * Get days until next screening for a category\n */\nexport const getDaysUntilScreening = (\n lastTestDate: Date,\n category: string,\n referenceDate: Date = new Date(),\n): number | null => {\n const nextDate = calculateNextScreeningDate(lastTestDate, category);\n if (!nextDate) return null;\n\n const diffTime = nextDate.getTime() - referenceDate.getTime();\n return Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n};\n","/**\n * Portuguese pluralization utility using native Intl.PluralRules\n * Provides automatic pluralization for common words used in the app\n */\n\nconst pluralRules = new Intl.PluralRules('pt-BR');\n\n/**\n * Dictionary of Portuguese words with their plural forms\n * Key is the singular form, value is the plural form\n */\nconst dictionary: Record<string, string> = {\n // Common nouns\n arquivo: 'arquivos',\n biomarcador: 'biomarcadores',\n // Past participles (masculine)\n cadastrado: 'cadastrados',\n // Past participles (feminine)\n concluída: 'concluídas',\n confirmado: 'confirmados',\n convertido: 'convertidos',\n convidado: 'convidados',\n convite: 'convites',\n disponível: 'disponíveis',\n documento: 'documentos',\n enviado: 'enviados',\n exame: 'exames',\n excluída: 'excluídas',\n\n excluído: 'excluídos',\n // Verbs (3rd person)\n falhou: 'falharam',\n falta: 'faltam',\n ignorado: 'ignorados',\n item: 'itens',\n outro: 'outros',\n página: 'páginas',\n pendente: 'pendentes',\n registro: 'registros',\n removido: 'removidos',\n\n resultado: 'resultados',\n revisão: 'revisões',\n\n revogado: 'revogados',\n usuário: 'usuários',\n};\n\n/**\n * Get the plural form of a word from the dictionary\n * Falls back to adding 's' if word is not in dictionary\n */\nconst getPluralForm = (singular: string): string => {\n return dictionary[singular] ?? `${singular}s`;\n};\n\n/**\n * Returns the correct singular or plural form based on count\n * Uses Intl.PluralRules for proper locale-aware pluralization\n *\n * @example\n * plural(1, 'usuário') // 'usuário'\n * plural(3, 'usuário') // 'usuários'\n * plural(0, 'registro') // 'registros'\n */\nexport const plural = (count: number, word: string): string => {\n const rule = pluralRules.select(count);\n return rule === 'one' ? word : getPluralForm(word);\n};\n\n/**\n * Returns count with the correct singular or plural form\n *\n * @example\n * pluralCount(1, 'usuário') // '1 usuário'\n * pluralCount(3, 'usuário') // '3 usuários'\n */\nexport const pluralCount = (count: number, word: string): string => {\n return `${count} ${plural(count, word)}`;\n};\n\n/**\n * Returns the correct form for compound phrases (noun + adjective)\n * Both words are pluralized together\n *\n * @example\n * pluralPhrase(1, 'usuário', 'cadastrado') // 'usuário cadastrado'\n * pluralPhrase(3, 'usuário', 'cadastrado') // 'usuários cadastrados'\n * pluralPhrase(2, 'revisão', 'excluída') // 'revisões excluídas'\n */\nexport const pluralPhrase = (count: number, noun: string, adjective: string): string => {\n const rule = pluralRules.select(count);\n if (rule === 'one') {\n return `${noun} ${adjective}`;\n }\n return `${getPluralForm(noun)} ${getPluralForm(adjective)}`;\n};\n\n/**\n * Returns count with the correct compound phrase form\n *\n * @example\n * pluralPhraseCount(1, 'usuário', 'cadastrado') // '1 usuário cadastrado'\n * pluralPhraseCount(3, 'convite', 'enviado') // '3 convites enviados'\n */\nexport const pluralPhraseCount = (count: number, noun: string, adjective: string): string => {\n return `${count} ${pluralPhrase(count, noun, adjective)}`;\n};\n","/**\n * Helpers para identificadores brasileiros — CPF e CNS\n *\n * Validação, formatação e conversão para FHIR Identifier.\n * Algoritmos de validação baseados nas especificações oficiais:\n * - CPF: Receita Federal (mod-11, dois dígitos verificadores)\n * - CNS: Ministério da Saúde (mod-11 para definitivos, soma ponderada para provisórios)\n */\n\nimport type { FHIRIdentifier } from './fhir-types';\n\nconst CPF_SYSTEM = 'http://rnds.saude.gov.br/fhir/r4/NamingSystem/cpf';\nconst CNS_SYSTEM = 'http://rnds.saude.gov.br/fhir/r4/NamingSystem/cns';\n\n/**\n * Remove caracteres não-numéricos de uma string.\n */\nfunction digitsOnly(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Valida um CPF brasileiro usando algoritmo mod-11.\n *\n * @param cpf — CPF com ou sem formatação (ex: \"123.456.789-09\" ou \"12345678909\")\n * @returns true se o CPF é estruturalmente válido\n */\nexport function validateCPF(cpf: string): boolean {\n const digits = digitsOnly(cpf);\n\n if (digits.length !== 11) return false;\n\n // Rejeitar sequências de dígitos iguais (ex: 111.111.111-11)\n if (/^(\\d)\\1{10}$/.test(digits)) return false;\n\n // Primeiro dígito verificador\n let sum = 0;\n for (let i = 0; i < 9; i++) {\n sum += Number(digits[i]) * (10 - i);\n }\n let remainder = (sum * 10) % 11;\n if (remainder === 10) remainder = 0;\n if (remainder !== Number(digits[9])) return false;\n\n // Segundo dígito verificador\n sum = 0;\n for (let i = 0; i < 10; i++) {\n sum += Number(digits[i]) * (11 - i);\n }\n remainder = (sum * 10) % 11;\n if (remainder === 10) remainder = 0;\n if (remainder !== Number(digits[10])) return false;\n\n return true;\n}\n\n/**\n * Valida um CNS (Cartão Nacional de Saúde) brasileiro.\n *\n * CNS definitivos começam com 1 ou 2 (mod-11).\n * CNS provisórios começam com 7, 8 ou 9 (soma ponderada mod-11 = 0).\n *\n * @param cns — CNS com 15 dígitos\n * @returns true se o CNS é estruturalmente válido\n */\nexport function validateCNS(cns: string): boolean {\n const digits = digitsOnly(cns);\n\n if (digits.length !== 15) return false;\n\n const firstDigit = digits[0]!;\n\n // CNS deve começar com 1, 2 (definitivo) ou 7, 8, 9 (provisório)\n if (!['1', '2', '7', '8', '9'].includes(firstDigit)) return false;\n\n // Ambos os tipos usam soma ponderada mod-11 = 0\n let sum = 0;\n for (let i = 0; i < 15; i++) {\n sum += Number(digits[i]) * (15 - i);\n }\n return sum % 11 === 0;\n}\n\n/**\n * Formata um CPF como XXX.XXX.XXX-XX.\n *\n * @param cpf — CPF com 11 dígitos (com ou sem formatação)\n * @returns CPF formatado ou a string original se inválido\n */\nexport function formatCPF(cpf: string): string {\n const digits = digitsOnly(cpf);\n if (digits.length !== 11) return cpf;\n return `${digits.slice(0, 3)}.${digits.slice(3, 6)}.${digits.slice(6, 9)}-${digits.slice(9)}`;\n}\n\n/**\n * Formata um CNS como XXX XXXX XXXX XXXX.\n *\n * @param cns — CNS com 15 dígitos\n * @returns CNS formatado ou a string original se inválido\n */\nexport function formatCNS(cns: string): string {\n const digits = digitsOnly(cns);\n if (digits.length !== 15) return cns;\n return `${digits.slice(0, 3)} ${digits.slice(3, 7)} ${digits.slice(7, 11)} ${digits.slice(11)}`;\n}\n\n/**\n * Converte um CPF para um FHIR Identifier.\n *\n * @param cpf — CPF com 11 dígitos (com ou sem formatação)\n * @returns FHIR Identifier com sistema RNDS para CPF\n * @throws Error se o CPF for inválido\n */\nexport function cpfToFHIRIdentifier(cpf: string): FHIRIdentifier {\n if (!validateCPF(cpf)) {\n throw new Error('CPF inválido');\n }\n return {\n system: CPF_SYSTEM,\n use: 'official',\n value: digitsOnly(cpf),\n };\n}\n\n/**\n * Converte um CNS para um FHIR Identifier.\n *\n * @param cns — CNS com 15 dígitos\n * @returns FHIR Identifier com sistema RNDS para CNS\n * @throws Error se o CNS for inválido\n */\nexport function cnsToFHIRIdentifier(cns: string): FHIRIdentifier {\n if (!validateCNS(cns)) {\n throw new Error('CNS inválido');\n }\n return {\n system: CNS_SYSTEM,\n use: 'official',\n value: digitsOnly(cns),\n };\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/index.cjs","../src/category-groups.ts","../src/intervention-converter.ts","../src/dexa-zone-data.ts","../src/screening-intervals.ts","../src/i18n.ts","../src/identifiers.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACvCO,IAAM,gBAAA,EAA4D;AAAA,EACvE,cAAA,EAAgB;AAAA,IACd,EAAA,EAAI,gBAAA;AAAA,IACJ,EAAA,EAAI,gBAAA;AAAA,IACJ,IAAA,EAAM,gBAAA;AA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ACE,EAAA;AACjC;AAW2C;AACS,EAAA;AACE,EAAA;AACL,EAAA;AACjD;AHmNoD;AACA;AIzTqB;AAAA;AAEvE,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AAAA;AAGA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AAAA;AAGA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;AACM,IAAA;AACR,IAAA;AACA,IAAA;AACV,EAAA;AACA,EAAA;AACY,IAAA;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;AAGxC,EAAA;AACmB,EAAA;AACM,IAAA;AACnC,EAAA;AACoB,EAAA;AACtB;AAQ+C;AAChB,EAAA;AACI,EAAA;AACiB,EAAA;AACpD;AAQ+C;AAChB,EAAA;AACI,EAAA;AACiB,EAAA;AACpD;AASiE;AACxC,EAAA;AACS,IAAA;AAChC,EAAA;AACO,EAAA;AACG,IAAA;AACH,IAAA;AACgB,IAAA;AACvB,EAAA;AACF;AASiE;AACxC,EAAA;AACS,IAAA;AAChC,EAAA;AACO,EAAA;AACG,IAAA;AACH,IAAA;AACgB,IAAA;AACvB,EAAA;AACF;ANudoD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/fhir-brasil/fhir-brasil/packages/core/dist/index.cjs","sourcesContent":[null,"/**\n * Agrupamento de categorias clínicas em 10 grupos de alto nível.\n *\n * `BiomarkerDefinition.category` armazena 20 sub-categorias (granularidade\n * fina, ex: `tireoide`, `pancreas`). Este módulo agrupa essas\n * sub-categorias em 10 buckets clínicos amplos para apresentação no\n * site, na API pública e em material de divulgação.\n *\n * As sub-categorias permanecem como fonte da verdade nos dados; este\n * agrupamento é uma camada derivada.\n */\n\nexport type CategoryGroup =\n | 'cardiovascular'\n | 'metabolico-endocrino'\n | 'renal-eletrolitico'\n | 'hepatico-biliar'\n | 'hematologico'\n | 'imunologico'\n | 'oncologico'\n | 'nutricional-ambiental'\n | 'saude-reprodutiva'\n | 'composicao-envelhecimento';\n\nexport interface CategoryGroupInfo {\n /** Rótulo em inglês */\n en: string;\n /** Rótulo em português */\n pt: string;\n /** Slug (kebab-case, sem acento) */\n slug: CategoryGroup;\n /** Sub-categorias da fonte agrupadas neste bucket */\n subcategories: readonly string[];\n}\n\nexport const CATEGORY_GROUPS: Record<CategoryGroup, CategoryGroupInfo> = {\n cardiovascular: {\n en: 'Cardiovascular',\n pt: 'Cardiovascular',\n slug: 'cardiovascular',\n subcategories: ['coracao'],\n },\n 'composicao-envelhecimento': {\n en: 'Body Composition & Aging',\n pt: 'Composição Corporal e Envelhecimento',\n slug: 'composicao-envelhecimento',\n subcategories: ['composicao-corporal', 'densidade-ossea', 'estresse-envelhecimento'],\n },\n hematologico: {\n en: 'Hematology',\n pt: 'Hematológico',\n slug: 'hematologico',\n subcategories: ['sangue'],\n },\n 'hepatico-biliar': {\n en: 'Hepatic & Biliary',\n pt: 'Hepático e Biliar',\n slug: 'hepatico-biliar',\n subcategories: ['figado'],\n },\n imunologico: {\n en: 'Immunology',\n pt: 'Imunológico',\n slug: 'imunologico',\n subcategories: ['autoimunidade', 'regulacao-imunologica'],\n },\n 'metabolico-endocrino': {\n en: 'Metabolic & Endocrine',\n pt: 'Metabólico e Endócrino',\n slug: 'metabolico-endocrino',\n subcategories: ['metabolico', 'pancreas', 'hormonios', 'tireoide'],\n },\n 'nutricional-ambiental': {\n en: 'Nutrition & Environmental Exposure',\n pt: 'Nutricional e Exposição Ambiental',\n slug: 'nutricional-ambiental',\n subcategories: ['nutrientes', 'toxinas-ambientais'],\n },\n oncologico: {\n en: 'Oncology',\n pt: 'Oncológico',\n slug: 'oncologico',\n subcategories: ['marcadores-tumorais'],\n },\n 'renal-eletrolitico': {\n en: 'Renal & Electrolytes',\n pt: 'Renal e Eletrolítico',\n slug: 'renal-eletrolitico',\n subcategories: ['rins', 'urina', 'eletrolitos'],\n },\n 'saude-reprodutiva': {\n en: 'Reproductive Health',\n pt: 'Saúde Reprodutiva',\n slug: 'saude-reprodutiva',\n subcategories: ['saude-feminina', 'saude-masculina'],\n },\n};\n\nconst SUBCATEGORY_TO_GROUP = new Map<string, CategoryGroup>();\nfor (const group of Object.values(CATEGORY_GROUPS)) {\n for (const sub of group.subcategories) {\n SUBCATEGORY_TO_GROUP.set(sub, group.slug);\n }\n}\n\n/**\n * Resolve a sub-categoria (granular) para o grupo de alto nível (10 buckets).\n */\nexport function getCategoryGroup(subcategory: string): CategoryGroup | undefined {\n return SUBCATEGORY_TO_GROUP.get(subcategory);\n}\n\n/**\n * Lista todas as sub-categorias mapeadas em algum grupo.\n */\nexport function listMappedSubcategories(): readonly string[] {\n return [...SUBCATEGORY_TO_GROUP.keys()];\n}\n","/**\n * FHIR Intervention Converter\n *\n * Converts interventions (medication, supplement, diet, exercise, sleep)\n * to FHIR R4 MedicationStatement and Observation resources.\n */\n\nimport { userProfileToFHIR } from './converter';\nimport type { FHIRBundle, FHIRMedicationStatement, FHIRObservation } from './fhir-types';\nimport type { InterventionData, UserProfileData } from './types';\n\n/**\n * Determine MedicationStatement/Observation status based on end date\n */\nfunction interventionStatus(endDate?: string): 'active' | 'completed' {\n if (!endDate) return 'active';\n return new Date(endDate) < new Date() ? 'completed' : 'active';\n}\n\n/**\n * LOINC-like codes for lifestyle observation types\n */\nconst LIFESTYLE_CODES: Record<string, { code: string; display: string }> = {\n diet: { code: '81259-4', display: 'Diet' },\n exercise: { code: '73985-4', display: 'Exercise activity' },\n sleep: { code: '93832-4', display: 'Sleep duration' },\n};\n\n/**\n * Convert medication/supplement intervention to FHIR MedicationStatement\n */\nexport function interventionToFHIRMedicationStatement(\n intervention: InterventionData,\n patientId: string,\n): FHIRMedicationStatement {\n const statement: FHIRMedicationStatement = {\n category: {\n coding: [\n {\n code: 'patientspecified',\n display: 'Patient Specified',\n system: 'http://terminology.hl7.org/CodeSystem/medication-statement-category',\n },\n ],\n },\n dateAsserted: intervention.startDate,\n effectivePeriod: {\n end: intervention.endDate,\n start: intervention.startDate,\n },\n id: `intervention-${intervention.interventionId}`,\n medicationCodeableConcept: {\n text: intervention.name,\n },\n resourceType: 'MedicationStatement',\n status: interventionStatus(intervention.endDate),\n subject: {\n reference: `Patient/${patientId}`,\n },\n };\n\n if (intervention.notes) {\n statement.note = [{ text: intervention.notes }];\n }\n\n return statement;\n}\n\n/**\n * Convert diet/exercise/sleep intervention to FHIR Observation (social-history)\n */\nexport function interventionToFHIRObservation(\n intervention: InterventionData,\n patientId: string,\n): FHIRObservation {\n const lifestyleCode = LIFESTYLE_CODES[intervention.type];\n\n const observation: FHIRObservation = {\n category: [\n {\n coding: [\n {\n code: 'social-history',\n display: 'Social History',\n system: 'http://terminology.hl7.org/CodeSystem/observation-category',\n },\n ],\n },\n ],\n code: {\n coding: lifestyleCode\n ? [\n {\n code: lifestyleCode.code,\n display: lifestyleCode.display,\n system: 'http://loinc.org',\n },\n ]\n : [],\n text: intervention.name,\n },\n effectivePeriod: {\n end: intervention.endDate,\n start: intervention.startDate,\n },\n id: `intervention-${intervention.interventionId}`,\n resourceType: 'Observation',\n status: 'final',\n subject: {\n reference: `Patient/${patientId}`,\n },\n valueString: intervention.name,\n };\n\n if (intervention.notes) {\n observation.note = [{ text: intervention.notes }];\n }\n\n return observation;\n}\n\n/**\n * Convert all interventions to a FHIR Bundle\n */\nexport function interventionsToFHIRBundle(\n interventions: InterventionData[],\n userProfile: UserProfileData,\n): FHIRBundle {\n const patientId = userProfile.userId;\n const fhirPatient = userProfileToFHIR(userProfile);\n\n const entries = interventions.map((intervention) => {\n const isMedication = intervention.type === 'medication' || intervention.type === 'supplement';\n const resource = isMedication\n ? interventionToFHIRMedicationStatement(intervention, patientId)\n : interventionToFHIRObservation(intervention, patientId);\n\n return {\n fullUrl: `urn:uuid:intervention-${intervention.interventionId}`,\n resource,\n };\n });\n\n return {\n entry: [\n {\n fullUrl: `urn:uuid:${patientId}`,\n resource: fhirPatient,\n },\n ...entries,\n ],\n resourceType: 'Bundle',\n type: 'collection',\n };\n}\n","/**\n * Structured zone data for DEXA body composition and bone density charts.\n *\n * Body fat zones derived from Gallagher et al. Am J Clin Nutr 2000;72:694-701 (PMID: 10966886)\n * and ACSM Guidelines for Exercise Testing, 11th Ed (2021).\n *\n * T-Score zones from WHO criteria (Kanis JA, Osteoporos Int, PMID: 7696835).\n */\n\nexport interface BodyFatZone {\n ageMax: number;\n ageMin: number;\n color: string;\n fatPctMax: number;\n fatPctMin: number;\n label: string;\n sex: 'F' | 'M';\n}\n\ninterface AgeBracket {\n ageMax: number;\n ageMin: number;\n label: string;\n}\n\nconst AGE_BRACKETS: AgeBracket[] = [\n { ageMax: 25, ageMin: 18, label: '18-25' },\n { ageMax: 35, ageMin: 26, label: '26-35' },\n { ageMax: 45, ageMin: 36, label: '36-45' },\n { ageMax: 55, ageMin: 46, label: '46-55' },\n { ageMax: 99, ageMin: 56, label: '56+' },\n];\n\n// Zone boundaries per age bracket for men: [essential, athletic, fitness, average, obese]\n// Each value is the upper bound of the zone\nconst MALE_ZONES: number[][] = [\n [5, 10, 20, 25, 40],\n [5, 11, 21, 26, 40],\n [5, 12, 22, 27, 40],\n [5, 13, 23, 28, 40],\n [5, 14, 24, 29, 40],\n];\n\nconst FEMALE_ZONES: number[][] = [\n [13, 18, 28, 32, 45],\n [13, 18, 29, 33, 45],\n [13, 19, 30, 34, 45],\n [13, 20, 31, 35, 45],\n [13, 20, 32, 36, 45],\n];\n\ninterface ZoneDefinition {\n color: string;\n label: string;\n}\n\nconst ZONE_DEFS: ZoneDefinition[] = [\n { color: '#3b82f6', label: 'Essencial' },\n { color: '#06b6d4', label: 'Atlético' },\n { color: '#22c55e', label: 'Fitness' },\n { color: '#eab308', label: 'Média' },\n { color: '#ef4444', label: 'Obeso' },\n];\n\nfunction buildZones(sex: 'F' | 'M', zoneData: number[][]): BodyFatZone[] {\n const zones: BodyFatZone[] = [];\n for (let i = 0; i < AGE_BRACKETS.length; i++) {\n const bracket = AGE_BRACKETS[i]!;\n const b = zoneData[i]!;\n zones.push({\n ...bracket,\n color: ZONE_DEFS[0]!.color,\n fatPctMax: b[0]!,\n fatPctMin: 0,\n label: ZONE_DEFS[0]!.label,\n sex,\n });\n zones.push({\n ...bracket,\n color: ZONE_DEFS[1]!.color,\n fatPctMax: b[1]!,\n fatPctMin: b[0]!,\n label: ZONE_DEFS[1]!.label,\n sex,\n });\n zones.push({\n ...bracket,\n color: ZONE_DEFS[2]!.color,\n fatPctMax: b[2]!,\n fatPctMin: b[1]!,\n label: ZONE_DEFS[2]!.label,\n sex,\n });\n zones.push({\n ...bracket,\n color: ZONE_DEFS[3]!.color,\n fatPctMax: b[3]!,\n fatPctMin: b[2]!,\n label: ZONE_DEFS[3]!.label,\n sex,\n });\n zones.push({\n ...bracket,\n color: ZONE_DEFS[4]!.color,\n fatPctMax: b[4]!,\n fatPctMin: b[3]!,\n label: ZONE_DEFS[4]!.label,\n sex,\n });\n }\n return zones;\n}\n\nexport const BODY_FAT_ZONES: BodyFatZone[] = [\n ...buildZones('M', MALE_ZONES),\n ...buildZones('F', FEMALE_ZONES),\n];\n\nexport { AGE_BRACKETS, ZONE_DEFS };\n\nexport interface TScoreZone {\n color: string;\n label: string;\n max: number;\n min: number;\n}\n\nexport const T_SCORE_ZONES: TScoreZone[] = [\n { color: '#22c55e', label: 'Normal', max: 4, min: -1.0 },\n { color: '#eab308', label: 'Osteopenia', max: -1.0, min: -2.5 },\n { color: '#ef4444', label: 'Osteoporose', max: -2.5, min: -5 },\n];\n","/**\n * Screening Intervals Configuration\n *\n * Defines recommended screening intervals for different biomarker categories\n * based on clinical guidelines and best practices.\n */\n\n/**\n * Screening interval in months\n */\nexport type ScreeningIntervalMonths = 3 | 6 | 12;\n\n/**\n * Biomarker category with its recommended screening interval\n */\nexport interface CategoryScreeningInterval {\n category: string;\n intervalMonths: ScreeningIntervalMonths;\n nameEn: string;\n namePt: string;\n}\n\n/**\n * Screening interval configuration for each category\n *\n * Categories are grouped by their recommended screening intervals:\n * - 3 months: Body composition and bone density (frequently changing metrics)\n * - 6 months: Metabolic panel and nutrients (moderate change rate)\n * - 12 months: Standard blood panels (stable long-term markers)\n */\nexport const CATEGORY_SCREENING_INTERVALS: CategoryScreeningInterval[] = [\n // 3-month intervals - Body composition (frequently changing)\n {\n category: 'composicao-corporal',\n intervalMonths: 3,\n nameEn: 'Body Composition',\n namePt: 'Composição Corporal',\n },\n {\n category: 'densidade-ossea',\n intervalMonths: 3,\n nameEn: 'Bone Density',\n namePt: 'Densidade Óssea',\n },\n\n // 6-month intervals - Metabolic and nutrients\n {\n category: 'metabolico',\n intervalMonths: 6,\n nameEn: 'Metabolic Panel',\n namePt: 'Painel Metabólico',\n },\n {\n category: 'nutrientes',\n intervalMonths: 6,\n nameEn: 'Nutrients',\n namePt: 'Nutrientes',\n },\n {\n category: 'pancreas',\n intervalMonths: 6,\n nameEn: 'Pancreas',\n namePt: 'Pâncreas',\n },\n\n // 12-month intervals - Standard blood panels\n {\n category: 'coracao',\n intervalMonths: 12,\n nameEn: 'Heart Health',\n namePt: 'Saúde Cardiovascular',\n },\n {\n category: 'tireoide',\n intervalMonths: 12,\n nameEn: 'Thyroid',\n namePt: 'Tireoide',\n },\n {\n category: 'sangue',\n intervalMonths: 12,\n nameEn: 'Blood Count',\n namePt: 'Hemograma',\n },\n {\n category: 'figado',\n intervalMonths: 12,\n nameEn: 'Liver Function',\n namePt: 'Função Hepática',\n },\n {\n category: 'rins',\n intervalMonths: 12,\n nameEn: 'Kidney Function',\n namePt: 'Função Renal',\n },\n {\n category: 'saude-feminina',\n intervalMonths: 12,\n nameEn: \"Women's Health\",\n namePt: 'Saúde Feminina',\n },\n {\n category: 'saude-masculina',\n intervalMonths: 12,\n nameEn: \"Men's Health\",\n namePt: 'Saúde Masculina',\n },\n {\n category: 'eletrolitos',\n intervalMonths: 12,\n nameEn: 'Electrolytes',\n namePt: 'Eletrólitos',\n },\n {\n category: 'estresse-envelhecimento',\n intervalMonths: 12,\n nameEn: 'Stress & Aging',\n namePt: 'Estresse e Envelhecimento',\n },\n {\n category: 'autoimunidade',\n intervalMonths: 12,\n nameEn: 'Autoimmunity',\n namePt: 'Autoimunidade',\n },\n {\n category: 'regulacao-imunologica',\n intervalMonths: 12,\n nameEn: 'Immune Regulation',\n namePt: 'Regulação Imunológica',\n },\n {\n category: 'toxinas-ambientais',\n intervalMonths: 12,\n nameEn: 'Environmental Toxins',\n namePt: 'Toxinas Ambientais',\n },\n {\n category: 'urina',\n intervalMonths: 12,\n nameEn: 'Urinalysis',\n namePt: 'Urina',\n },\n];\n\n/**\n * Get screening interval for a category\n */\nexport const getScreeningInterval = (category: string): CategoryScreeningInterval | undefined => {\n return CATEGORY_SCREENING_INTERVALS.find((c) => c.category === category);\n};\n\n/**\n * Get all categories with a specific interval\n */\nexport const getCategoriesByInterval = (\n intervalMonths: ScreeningIntervalMonths,\n): CategoryScreeningInterval[] => {\n return CATEGORY_SCREENING_INTERVALS.filter((c) => c.intervalMonths === intervalMonths);\n};\n\n/**\n * Calculate next screening date based on last test date and category\n */\nexport const calculateNextScreeningDate = (lastTestDate: Date, category: string): Date | null => {\n const interval = getScreeningInterval(category);\n if (!interval) return null;\n\n const nextDate = new Date(lastTestDate);\n nextDate.setMonth(nextDate.getMonth() + interval.intervalMonths);\n return nextDate;\n};\n\n/**\n * Check if a category is due for screening\n */\nexport const isScreeningDue = (\n lastTestDate: Date,\n category: string,\n referenceDate: Date = new Date(),\n): boolean => {\n const nextDate = calculateNextScreeningDate(lastTestDate, category);\n if (!nextDate) return false;\n return referenceDate >= nextDate;\n};\n\n/**\n * Get categories that are due for screening based on last test dates\n */\nexport const getDueCategories = (\n lastTestDates: Record<string, Date>,\n referenceDate: Date = new Date(),\n): CategoryScreeningInterval[] => {\n return CATEGORY_SCREENING_INTERVALS.filter((interval) => {\n const lastDate = lastTestDates[interval.category];\n if (!lastDate) return true; // Never tested = due\n return isScreeningDue(lastDate, interval.category, referenceDate);\n });\n};\n\n/**\n * Get days until next screening for a category\n */\nexport const getDaysUntilScreening = (\n lastTestDate: Date,\n category: string,\n referenceDate: Date = new Date(),\n): number | null => {\n const nextDate = calculateNextScreeningDate(lastTestDate, category);\n if (!nextDate) return null;\n\n const diffTime = nextDate.getTime() - referenceDate.getTime();\n return Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n};\n","/**\n * Portuguese pluralization utility using native Intl.PluralRules\n * Provides automatic pluralization for common words used in the app\n */\n\nconst pluralRules = new Intl.PluralRules('pt-BR');\n\n/**\n * Dictionary of Portuguese words with their plural forms\n * Key is the singular form, value is the plural form\n */\nconst dictionary: Record<string, string> = {\n // Common nouns\n arquivo: 'arquivos',\n biomarcador: 'biomarcadores',\n // Past participles (masculine)\n cadastrado: 'cadastrados',\n // Past participles (feminine)\n concluída: 'concluídas',\n confirmado: 'confirmados',\n convertido: 'convertidos',\n convidado: 'convidados',\n convite: 'convites',\n disponível: 'disponíveis',\n documento: 'documentos',\n enviado: 'enviados',\n exame: 'exames',\n excluída: 'excluídas',\n\n excluído: 'excluídos',\n // Verbs (3rd person)\n falhou: 'falharam',\n falta: 'faltam',\n ignorado: 'ignorados',\n item: 'itens',\n outro: 'outros',\n página: 'páginas',\n pendente: 'pendentes',\n registro: 'registros',\n removido: 'removidos',\n\n resultado: 'resultados',\n revisão: 'revisões',\n\n revogado: 'revogados',\n usuário: 'usuários',\n};\n\n/**\n * Get the plural form of a word from the dictionary\n * Falls back to adding 's' if word is not in dictionary\n */\nconst getPluralForm = (singular: string): string => {\n return dictionary[singular] ?? `${singular}s`;\n};\n\n/**\n * Returns the correct singular or plural form based on count\n * Uses Intl.PluralRules for proper locale-aware pluralization\n *\n * @example\n * plural(1, 'usuário') // 'usuário'\n * plural(3, 'usuário') // 'usuários'\n * plural(0, 'registro') // 'registros'\n */\nexport const plural = (count: number, word: string): string => {\n const rule = pluralRules.select(count);\n return rule === 'one' ? word : getPluralForm(word);\n};\n\n/**\n * Returns count with the correct singular or plural form\n *\n * @example\n * pluralCount(1, 'usuário') // '1 usuário'\n * pluralCount(3, 'usuário') // '3 usuários'\n */\nexport const pluralCount = (count: number, word: string): string => {\n return `${count} ${plural(count, word)}`;\n};\n\n/**\n * Returns the correct form for compound phrases (noun + adjective)\n * Both words are pluralized together\n *\n * @example\n * pluralPhrase(1, 'usuário', 'cadastrado') // 'usuário cadastrado'\n * pluralPhrase(3, 'usuário', 'cadastrado') // 'usuários cadastrados'\n * pluralPhrase(2, 'revisão', 'excluída') // 'revisões excluídas'\n */\nexport const pluralPhrase = (count: number, noun: string, adjective: string): string => {\n const rule = pluralRules.select(count);\n if (rule === 'one') {\n return `${noun} ${adjective}`;\n }\n return `${getPluralForm(noun)} ${getPluralForm(adjective)}`;\n};\n\n/**\n * Returns count with the correct compound phrase form\n *\n * @example\n * pluralPhraseCount(1, 'usuário', 'cadastrado') // '1 usuário cadastrado'\n * pluralPhraseCount(3, 'convite', 'enviado') // '3 convites enviados'\n */\nexport const pluralPhraseCount = (count: number, noun: string, adjective: string): string => {\n return `${count} ${pluralPhrase(count, noun, adjective)}`;\n};\n","/**\n * Helpers para identificadores brasileiros — CPF e CNS\n *\n * Validação, formatação e conversão para FHIR Identifier.\n * Algoritmos de validação baseados nas especificações oficiais:\n * - CPF: Receita Federal (mod-11, dois dígitos verificadores)\n * - CNS: Ministério da Saúde (mod-11 para definitivos, soma ponderada para provisórios)\n */\n\nimport type { FHIRIdentifier } from './fhir-types';\n\nconst CPF_SYSTEM = 'http://rnds.saude.gov.br/fhir/r4/NamingSystem/cpf';\nconst CNS_SYSTEM = 'http://rnds.saude.gov.br/fhir/r4/NamingSystem/cns';\n\n/**\n * Remove caracteres não-numéricos de uma string.\n */\nfunction digitsOnly(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Valida um CPF brasileiro usando algoritmo mod-11.\n *\n * @param cpf — CPF com ou sem formatação (ex: \"123.456.789-09\" ou \"12345678909\")\n * @returns true se o CPF é estruturalmente válido\n */\nexport function validateCPF(cpf: string): boolean {\n const digits = digitsOnly(cpf);\n\n if (digits.length !== 11) return false;\n\n // Rejeitar sequências de dígitos iguais (ex: 111.111.111-11)\n if (/^(\\d)\\1{10}$/.test(digits)) return false;\n\n // Primeiro dígito verificador\n let sum = 0;\n for (let i = 0; i < 9; i++) {\n sum += Number(digits[i]) * (10 - i);\n }\n let remainder = (sum * 10) % 11;\n if (remainder === 10) remainder = 0;\n if (remainder !== Number(digits[9])) return false;\n\n // Segundo dígito verificador\n sum = 0;\n for (let i = 0; i < 10; i++) {\n sum += Number(digits[i]) * (11 - i);\n }\n remainder = (sum * 10) % 11;\n if (remainder === 10) remainder = 0;\n if (remainder !== Number(digits[10])) return false;\n\n return true;\n}\n\n/**\n * Valida um CNS (Cartão Nacional de Saúde) brasileiro.\n *\n * CNS definitivos começam com 1 ou 2 (mod-11).\n * CNS provisórios começam com 7, 8 ou 9 (soma ponderada mod-11 = 0).\n *\n * @param cns — CNS com 15 dígitos\n * @returns true se o CNS é estruturalmente válido\n */\nexport function validateCNS(cns: string): boolean {\n const digits = digitsOnly(cns);\n\n if (digits.length !== 15) return false;\n\n const firstDigit = digits[0]!;\n\n // CNS deve começar com 1, 2 (definitivo) ou 7, 8, 9 (provisório)\n if (!['1', '2', '7', '8', '9'].includes(firstDigit)) return false;\n\n // Ambos os tipos usam soma ponderada mod-11 = 0\n let sum = 0;\n for (let i = 0; i < 15; i++) {\n sum += Number(digits[i]) * (15 - i);\n }\n return sum % 11 === 0;\n}\n\n/**\n * Formata um CPF como XXX.XXX.XXX-XX.\n *\n * @param cpf — CPF com 11 dígitos (com ou sem formatação)\n * @returns CPF formatado ou a string original se inválido\n */\nexport function formatCPF(cpf: string): string {\n const digits = digitsOnly(cpf);\n if (digits.length !== 11) return cpf;\n return `${digits.slice(0, 3)}.${digits.slice(3, 6)}.${digits.slice(6, 9)}-${digits.slice(9)}`;\n}\n\n/**\n * Formata um CNS como XXX XXXX XXXX XXXX.\n *\n * @param cns — CNS com 15 dígitos\n * @returns CNS formatado ou a string original se inválido\n */\nexport function formatCNS(cns: string): string {\n const digits = digitsOnly(cns);\n if (digits.length !== 15) return cns;\n return `${digits.slice(0, 3)} ${digits.slice(3, 7)} ${digits.slice(7, 11)} ${digits.slice(11)}`;\n}\n\n/**\n * Converte um CPF para um FHIR Identifier.\n *\n * @param cpf — CPF com 11 dígitos (com ou sem formatação)\n * @returns FHIR Identifier com sistema RNDS para CPF\n * @throws Error se o CPF for inválido\n */\nexport function cpfToFHIRIdentifier(cpf: string): FHIRIdentifier {\n if (!validateCPF(cpf)) {\n throw new Error('CPF inválido');\n }\n return {\n system: CPF_SYSTEM,\n use: 'official',\n value: digitsOnly(cpf),\n };\n}\n\n/**\n * Converte um CNS para um FHIR Identifier.\n *\n * @param cns — CNS com 15 dígitos\n * @returns FHIR Identifier com sistema RNDS para CNS\n * @throws Error se o CNS for inválido\n */\nexport function cnsToFHIRIdentifier(cns: string): FHIRIdentifier {\n if (!validateCNS(cns)) {\n throw new Error('CNS inválido');\n }\n return {\n system: CNS_SYSTEM,\n use: 'official',\n value: digitsOnly(cns),\n };\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -8,6 +8,24 @@ export { FHIRImportResult, ImportError, ImportedObservation, MAX_FILE_SIZE, MAX_
8
8
  export { validateFHIRDiagnosticReport, validateFHIRImportBundle, validateFHIRObservation } from './validators.cjs';
9
9
  export { BiomarkerRangeDefinition, BiomarkerReferenceRange, FastingRequirement, PregnancyTrimester, RangeDirection, RangeVariant, ReferenceRangeContext, SexKey, applyFallbackReferenceRanges, biomarkerRangeDefinitions, defaultReferenceRanges, getFallbackReferenceRange, getRangeDirection, getReferenceRange } from './reference-ranges.cjs';
10
10
 
11
+ /**
12
+ * Identificadores de sistema de código usados nos recursos FHIR.
13
+ *
14
+ * Ficam num módulo próprio porque exportação e importação precisam concordar
15
+ * literalmente: o importador procura o coding pelo `system`, e uma string
16
+ * divergente de um lado faz o biomarcador desaparecer sem erro.
17
+ */
18
+ /** LOINC, o vocabulário oficial de exames laboratoriais. */
19
+ declare const LOINC_SYSTEM = "http://loinc.org";
20
+ /**
21
+ * Códigos internos do fhir-brasil.
22
+ *
23
+ * Cobre o que não tem LOINC publicado: composição corporal por DEXA,
24
+ * densidade óssea e escore de cálcio, entre outros. É o que permite o ciclo
25
+ * exportar/importar preservar esses biomarcadores.
26
+ */
27
+ declare const BIOMARKER_CODE_SYSTEM = "http://fhir-brasil.dev/biomarker-codes";
28
+
11
29
  /**
12
30
  * Agrupamento de categorias clínicas em 10 grupos de alto nível.
13
31
  *
@@ -249,4 +267,4 @@ declare function cpfToFHIRIdentifier(cpf: string): FHIRIdentifier;
249
267
  */
250
268
  declare function cnsToFHIRIdentifier(cns: string): FHIRIdentifier;
251
269
 
252
- export { AGE_BRACKETS, BODY_FAT_ZONES, type BodyFatZone, CATEGORY_GROUPS, CATEGORY_SCREENING_INTERVALS, type CategoryGroup, type CategoryGroupInfo, type CategoryScreeningInterval, FHIRBundle, FHIRIdentifier, FHIRMedicationStatement, FHIRObservation, InterventionData, type ScreeningIntervalMonths, type TScoreZone, T_SCORE_ZONES, UserProfileData, ZONE_DEFS, calculateNextScreeningDate, cnsToFHIRIdentifier, cpfToFHIRIdentifier, formatCNS, formatCPF, getCategoriesByInterval, getCategoryGroup, getDaysUntilScreening, getDueCategories, getScreeningInterval, interventionToFHIRMedicationStatement, interventionToFHIRObservation, interventionsToFHIRBundle, isScreeningDue, listMappedSubcategories, plural, pluralCount, pluralPhrase, pluralPhraseCount, validateCNS, validateCPF };
270
+ export { AGE_BRACKETS, BIOMARKER_CODE_SYSTEM, BODY_FAT_ZONES, type BodyFatZone, CATEGORY_GROUPS, CATEGORY_SCREENING_INTERVALS, type CategoryGroup, type CategoryGroupInfo, type CategoryScreeningInterval, FHIRBundle, FHIRIdentifier, FHIRMedicationStatement, FHIRObservation, InterventionData, LOINC_SYSTEM, type ScreeningIntervalMonths, type TScoreZone, T_SCORE_ZONES, UserProfileData, ZONE_DEFS, calculateNextScreeningDate, cnsToFHIRIdentifier, cpfToFHIRIdentifier, formatCNS, formatCPF, getCategoriesByInterval, getCategoryGroup, getDaysUntilScreening, getDueCategories, getScreeningInterval, interventionToFHIRMedicationStatement, interventionToFHIRObservation, interventionsToFHIRBundle, isScreeningDue, listMappedSubcategories, plural, pluralCount, pluralPhrase, pluralPhraseCount, validateCNS, validateCPF };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,24 @@ export { FHIRImportResult, ImportError, ImportedObservation, MAX_FILE_SIZE, MAX_
8
8
  export { validateFHIRDiagnosticReport, validateFHIRImportBundle, validateFHIRObservation } from './validators.js';
9
9
  export { BiomarkerRangeDefinition, BiomarkerReferenceRange, FastingRequirement, PregnancyTrimester, RangeDirection, RangeVariant, ReferenceRangeContext, SexKey, applyFallbackReferenceRanges, biomarkerRangeDefinitions, defaultReferenceRanges, getFallbackReferenceRange, getRangeDirection, getReferenceRange } from './reference-ranges.js';
10
10
 
11
+ /**
12
+ * Identificadores de sistema de código usados nos recursos FHIR.
13
+ *
14
+ * Ficam num módulo próprio porque exportação e importação precisam concordar
15
+ * literalmente: o importador procura o coding pelo `system`, e uma string
16
+ * divergente de um lado faz o biomarcador desaparecer sem erro.
17
+ */
18
+ /** LOINC, o vocabulário oficial de exames laboratoriais. */
19
+ declare const LOINC_SYSTEM = "http://loinc.org";
20
+ /**
21
+ * Códigos internos do fhir-brasil.
22
+ *
23
+ * Cobre o que não tem LOINC publicado: composição corporal por DEXA,
24
+ * densidade óssea e escore de cálcio, entre outros. É o que permite o ciclo
25
+ * exportar/importar preservar esses biomarcadores.
26
+ */
27
+ declare const BIOMARKER_CODE_SYSTEM = "http://fhir-brasil.dev/biomarker-codes";
28
+
11
29
  /**
12
30
  * Agrupamento de categorias clínicas em 10 grupos de alto nível.
13
31
  *
@@ -249,4 +267,4 @@ declare function cpfToFHIRIdentifier(cpf: string): FHIRIdentifier;
249
267
  */
250
268
  declare function cnsToFHIRIdentifier(cns: string): FHIRIdentifier;
251
269
 
252
- export { AGE_BRACKETS, BODY_FAT_ZONES, type BodyFatZone, CATEGORY_GROUPS, CATEGORY_SCREENING_INTERVALS, type CategoryGroup, type CategoryGroupInfo, type CategoryScreeningInterval, FHIRBundle, FHIRIdentifier, FHIRMedicationStatement, FHIRObservation, InterventionData, type ScreeningIntervalMonths, type TScoreZone, T_SCORE_ZONES, UserProfileData, ZONE_DEFS, calculateNextScreeningDate, cnsToFHIRIdentifier, cpfToFHIRIdentifier, formatCNS, formatCPF, getCategoriesByInterval, getCategoryGroup, getDaysUntilScreening, getDueCategories, getScreeningInterval, interventionToFHIRMedicationStatement, interventionToFHIRObservation, interventionsToFHIRBundle, isScreeningDue, listMappedSubcategories, plural, pluralCount, pluralPhrase, pluralPhraseCount, validateCNS, validateCPF };
270
+ export { AGE_BRACKETS, BIOMARKER_CODE_SYSTEM, BODY_FAT_ZONES, type BodyFatZone, CATEGORY_GROUPS, CATEGORY_SCREENING_INTERVALS, type CategoryGroup, type CategoryGroupInfo, type CategoryScreeningInterval, FHIRBundle, FHIRIdentifier, FHIRMedicationStatement, FHIRObservation, InterventionData, LOINC_SYSTEM, type ScreeningIntervalMonths, type TScoreZone, T_SCORE_ZONES, UserProfileData, ZONE_DEFS, calculateNextScreeningDate, cnsToFHIRIdentifier, cpfToFHIRIdentifier, formatCNS, formatCPF, getCategoriesByInterval, getCategoryGroup, getDaysUntilScreening, getDueCategories, getScreeningInterval, interventionToFHIRMedicationStatement, interventionToFHIRObservation, interventionsToFHIRBundle, isScreeningDue, listMappedSubcategories, plural, pluralCount, pluralPhrase, pluralPhraseCount, validateCNS, validateCPF };
package/dist/index.js CHANGED
@@ -3,14 +3,18 @@ import {
3
3
  labReportToFHIR,
4
4
  labResultToFHIRBundle,
5
5
  userProfileToFHIR
6
- } from "./chunk-6TQ24JCA.js";
6
+ } from "./chunk-SN5ZJHWS.js";
7
7
  import {
8
8
  MAX_FILE_SIZE,
9
9
  MAX_OBSERVATIONS,
10
10
  extractObservationsFromBundle,
11
11
  mapFHIRObservationToInternal,
12
12
  processImportBundle
13
- } from "./chunk-OZGOBYLX.js";
13
+ } from "./chunk-YYANW65U.js";
14
+ import {
15
+ BIOMARKER_CODE_SYSTEM,
16
+ LOINC_SYSTEM
17
+ } from "./chunk-A6HR4XDK.js";
14
18
  import {
15
19
  BIOMARKER_DEFINITIONS,
16
20
  CAC_INDICATOR_CODES,
@@ -608,6 +612,7 @@ function cnsToFHIRIdentifier(cns) {
608
612
  }
609
613
  export {
610
614
  AGE_BRACKETS,
615
+ BIOMARKER_CODE_SYSTEM,
611
616
  BIOMARKER_DEFAULT_UNIT,
612
617
  BIOMARKER_DEFINITIONS,
613
618
  BIOMARKER_UNITS,
@@ -617,6 +622,7 @@ export {
617
622
  CATEGORY_SCREENING_INTERVALS,
618
623
  DEXA_CATEGORIES,
619
624
  DEXA_INDICATOR_CODES,
625
+ LOINC_SYSTEM,
620
626
  MAX_FILE_SIZE,
621
627
  MAX_OBSERVATIONS,
622
628
  T_SCORE_ZONES,