@precisa-saude/fhir 0.36.0 → 0.37.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/index.d.cts CHANGED
@@ -344,4 +344,144 @@ declare const HL7_SPECIMEN_TYPE_SYSTEM = "http://terminology.hl7.org/CodeSystem/
344
344
  */
345
345
  declare const specimenTypeCoding: (text: string) => FHIRCoding | undefined;
346
346
 
347
- export { AGE_BRACKETS, Addressable, BIOMARKER_CODE_SYSTEM, BODY_FAT_ZONES, BR_TIPO_AMOSTRA_VALUESET, type BodyFatZone, CATEGORY_GROUPS, CATEGORY_SCREENING_INTERVALS, type CategoryGroup, type CategoryGroupInfo, type CategoryScreeningInterval, FHIRBundle, FHIRCoding, FHIRIdentifier, FHIRMedicationStatement, FHIRObservation, FHIR_BRASIL_EXTENSIONS, HL7_SPECIMEN_TYPE_SYSTEM, IG_CANONICAL, 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, specimenTypeCoding, validateCNS, validateCPF };
347
+ declare const LOINC_SNAPSHOT: LoincSnapshot;
348
+
349
+ /**
350
+ * Os eixos e os grupos LOINC de cada código do catálogo, como o servidor
351
+ * oficial os publica, conferidos todo mês pelo `scripts/verify-loinc.ts`.
352
+ *
353
+ * Os dados vêm de `loinc-snapshot.generated.ts`, cópia do
354
+ * `scripts/loinc-snapshot.json` feita pelo gerador. Toda leitura daqui carrega
355
+ * o código e o display juntos, e quem republicar deve levar `LOINC_SNAPSHOT._notice`.
356
+ */
357
+
358
+ /** Um código LOINC no snapshot, com os eixos na grafia em que o LOINC os exibe. */
359
+ interface LoincEntry {
360
+ component: string | null;
361
+ display: string;
362
+ /** LOINC Groups (`LG…`) a que o código pertence, com o nome de cada um. */
363
+ groups?: Record<string, string>;
364
+ /** Único eixo opcional: a maioria dos códigos não afirma método. */
365
+ method: string | null;
366
+ property: string | null;
367
+ scale: string | null;
368
+ status: string | null;
369
+ system: string | null;
370
+ time: string | null;
371
+ }
372
+ interface LoincSnapshot {
373
+ _checkedAt: string;
374
+ _loincVersion: string | null;
375
+ /** Aviso da seção 10.1 da licença do LOINC. */
376
+ _notice: string;
377
+ codes: Record<string, LoincEntry>;
378
+ }
379
+
380
+ /** Os eixos de um código do catálogo, ou `undefined` se ele não está no snapshot. */
381
+ declare function getLoincEntry(loinc: string): LoincEntry | undefined;
382
+
383
+ /**
384
+ * Registro de decisão de cada mapeamento LOINC do catálogo.
385
+ *
386
+ * O catálogo em `biomarkers.ts` guarda a conclusão (o código). Este arquivo
387
+ * guarda por que aquele código e não outro: o que o laudo mostrou, o que
388
+ * decidiu, os irmãos descartados e quem revisou. É o diff que uma revisão de
389
+ * mapeamento lê.
390
+ *
391
+ * A maioria das entradas é `nameOnly`: o código foi escolhido pelo nome do
392
+ * exame, sem registro de unidade, método, material ou bula, e ninguém revisou
393
+ * de fora. É o registro honesto do que existe, e não justificativa inventada.
394
+ * As entradas com evidência vieram dos comentários em `biomarkers.ts` que já
395
+ * documentavam a troca. `reviewer` fica vazio até uma revisão independente.
396
+ *
397
+ * `loinc` repete o código do catálogo de propósito: trocar o código em
398
+ * `biomarkers.ts` sem tocar aqui falha em `mapping-decisions.test.ts`, e a
399
+ * troca chega à revisão com o registro ao lado.
400
+ *
401
+ * Sem import em runtime: o `scripts/verify-loinc.ts` lê este arquivo direto com
402
+ * o type stripping do Node, que não resolve import sem extensão. A ficha que
403
+ * junta registro, catálogo e eixos fica em `mapping-sheet.ts`.
404
+ */
405
+ /** O que o laudo mostrou e pesou na escolha do código. */
406
+ type MappingEvidence = 'assay-insert' | 'method-line' | 'name' | 'specimen' | 'unit';
407
+ interface RejectedSibling {
408
+ loinc: string;
409
+ reason: string;
410
+ }
411
+ interface MappingDecision {
412
+ evidence: MappingEvidence[];
413
+ /** O código escolhido. Tem que ser o `loinc` do biomarcador no catálogo. */
414
+ loinc: string;
415
+ /** Versão do LOINC em que a revisão conferiu o código. */
416
+ loincVersion?: string;
417
+ note?: string;
418
+ reviewedAt?: string;
419
+ reviewer?: string;
420
+ /** Qual evidência decidiu. Está sempre em `evidence`. */
421
+ settledBy: MappingEvidence;
422
+ siblingsRejected: RejectedSibling[];
423
+ }
424
+ /**
425
+ * Por que uma entrada não tem LOINC.
426
+ *
427
+ * - `no-concept`: procurado, e o LOINC não tem o conceito.
428
+ * - `ambiguous`: há candidatos, e nenhum é a mesma grandeza.
429
+ * - `pending-review`: ninguém registrou a busca.
430
+ * - `not-lab`: fora do escopo de exame laboratorial.
431
+ */
432
+ type NoLoincReason = 'ambiguous' | 'no-concept' | 'not-lab' | 'pending-review';
433
+ interface NoLoincDecision {
434
+ note: string;
435
+ reason: NoLoincReason;
436
+ }
437
+ declare const MAPPING_DECISIONS: Record<string, MappingDecision>;
438
+ declare const NO_LOINC_DECISIONS: Record<string, NoLoincDecision>;
439
+ declare function getMappingDecision(code: string): MappingDecision | undefined;
440
+ declare function getNoLoincDecision(code: string): NoLoincDecision | undefined;
441
+
442
+ /** Um código candidato com os eixos que o snapshot guarda dele. */
443
+ interface MappingCandidate {
444
+ axes?: LoincEntry;
445
+ loinc: string;
446
+ role: 'chosen' | 'method-variant' | 'rejected';
447
+ /** Pista impressa da variante, ou o motivo da rejeição. */
448
+ why?: string;
449
+ }
450
+ /** A ficha de um mapeamento, no formato da planilha de um mapeador. */
451
+ interface MappingSheet {
452
+ candidates: MappingCandidate[];
453
+ code: string;
454
+ decision?: MappingDecision;
455
+ /** LOINC Groups do código escolhido. */
456
+ groups: Record<string, string>;
457
+ localNames: string[];
458
+ method: string | null;
459
+ noLoinc?: NoLoincDecision;
460
+ specimen: string | null;
461
+ unit?: string;
462
+ }
463
+ /** Aceita o código interno ou qualquer LOINC que resolva para o biomarcador. */
464
+ declare function getMappingSheet(codeOrLoinc: string): MappingSheet | undefined;
465
+
466
+ type SpecimenClass = 'blood' | 'urine';
467
+ /** Classe do material impresso, ou `undefined` quando a palavra inicial não diz. */
468
+ declare function specimenClassOf(material: string): SpecimenClass | undefined;
469
+ /** Classe do eixo System do código, ou `undefined` fora do snapshot ou das duas classes. */
470
+ declare function loincSpecimenClass(loinc: string): SpecimenClass | undefined;
471
+ interface SpecimenMismatch {
472
+ /** Classe do eixo System do código. */
473
+ code: SpecimenClass;
474
+ loinc: string;
475
+ /** Classe do material impresso. */
476
+ material: SpecimenClass;
477
+ reason: 'specimen-mismatch';
478
+ system: string;
479
+ }
480
+ /**
481
+ * O conflito entre o material impresso e o código, ou `null` sem conflito
482
+ * afirmável. Quem chama decide o que fazer com o resultado, e a decisão que não
483
+ * existe é trocar o código por um palpite: conflito é lacuna, e sai como tal.
484
+ */
485
+ declare function specimenMismatch(material: string, loinc: string): SpecimenMismatch | null;
486
+
487
+ export { AGE_BRACKETS, Addressable, BIOMARKER_CODE_SYSTEM, BODY_FAT_ZONES, BR_TIPO_AMOSTRA_VALUESET, type BodyFatZone, CATEGORY_GROUPS, CATEGORY_SCREENING_INTERVALS, type CategoryGroup, type CategoryGroupInfo, type CategoryScreeningInterval, FHIRBundle, FHIRCoding, FHIRIdentifier, FHIRMedicationStatement, FHIRObservation, FHIR_BRASIL_EXTENSIONS, HL7_SPECIMEN_TYPE_SYSTEM, IG_CANONICAL, InterventionData, LOINC_SNAPSHOT, LOINC_SYSTEM, type LoincEntry, type LoincSnapshot, MAPPING_DECISIONS, type MappingCandidate, type MappingDecision, type MappingEvidence, type MappingSheet, NO_LOINC_DECISIONS, type NoLoincDecision, type NoLoincReason, type RejectedSibling, type ScreeningIntervalMonths, type SpecimenClass, type SpecimenMismatch, type TScoreZone, T_SCORE_ZONES, UserProfileData, ZONE_DEFS, calculateNextScreeningDate, cnsToFHIRIdentifier, cpfToFHIRIdentifier, formatCNS, formatCPF, getCategoriesByInterval, getCategoryGroup, getDaysUntilScreening, getDueCategories, getLoincEntry, getMappingDecision, getMappingSheet, getNoLoincDecision, getScreeningInterval, interventionToFHIRMedicationStatement, interventionToFHIRObservation, interventionsToFHIRBundle, isScreeningDue, listMappedSubcategories, loincSpecimenClass, plural, pluralCount, pluralPhrase, pluralPhraseCount, specimenClassOf, specimenMismatch, specimenTypeCoding, validateCNS, validateCPF };
package/dist/index.d.ts CHANGED
@@ -344,4 +344,144 @@ declare const HL7_SPECIMEN_TYPE_SYSTEM = "http://terminology.hl7.org/CodeSystem/
344
344
  */
345
345
  declare const specimenTypeCoding: (text: string) => FHIRCoding | undefined;
346
346
 
347
- export { AGE_BRACKETS, Addressable, BIOMARKER_CODE_SYSTEM, BODY_FAT_ZONES, BR_TIPO_AMOSTRA_VALUESET, type BodyFatZone, CATEGORY_GROUPS, CATEGORY_SCREENING_INTERVALS, type CategoryGroup, type CategoryGroupInfo, type CategoryScreeningInterval, FHIRBundle, FHIRCoding, FHIRIdentifier, FHIRMedicationStatement, FHIRObservation, FHIR_BRASIL_EXTENSIONS, HL7_SPECIMEN_TYPE_SYSTEM, IG_CANONICAL, 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, specimenTypeCoding, validateCNS, validateCPF };
347
+ declare const LOINC_SNAPSHOT: LoincSnapshot;
348
+
349
+ /**
350
+ * Os eixos e os grupos LOINC de cada código do catálogo, como o servidor
351
+ * oficial os publica, conferidos todo mês pelo `scripts/verify-loinc.ts`.
352
+ *
353
+ * Os dados vêm de `loinc-snapshot.generated.ts`, cópia do
354
+ * `scripts/loinc-snapshot.json` feita pelo gerador. Toda leitura daqui carrega
355
+ * o código e o display juntos, e quem republicar deve levar `LOINC_SNAPSHOT._notice`.
356
+ */
357
+
358
+ /** Um código LOINC no snapshot, com os eixos na grafia em que o LOINC os exibe. */
359
+ interface LoincEntry {
360
+ component: string | null;
361
+ display: string;
362
+ /** LOINC Groups (`LG…`) a que o código pertence, com o nome de cada um. */
363
+ groups?: Record<string, string>;
364
+ /** Único eixo opcional: a maioria dos códigos não afirma método. */
365
+ method: string | null;
366
+ property: string | null;
367
+ scale: string | null;
368
+ status: string | null;
369
+ system: string | null;
370
+ time: string | null;
371
+ }
372
+ interface LoincSnapshot {
373
+ _checkedAt: string;
374
+ _loincVersion: string | null;
375
+ /** Aviso da seção 10.1 da licença do LOINC. */
376
+ _notice: string;
377
+ codes: Record<string, LoincEntry>;
378
+ }
379
+
380
+ /** Os eixos de um código do catálogo, ou `undefined` se ele não está no snapshot. */
381
+ declare function getLoincEntry(loinc: string): LoincEntry | undefined;
382
+
383
+ /**
384
+ * Registro de decisão de cada mapeamento LOINC do catálogo.
385
+ *
386
+ * O catálogo em `biomarkers.ts` guarda a conclusão (o código). Este arquivo
387
+ * guarda por que aquele código e não outro: o que o laudo mostrou, o que
388
+ * decidiu, os irmãos descartados e quem revisou. É o diff que uma revisão de
389
+ * mapeamento lê.
390
+ *
391
+ * A maioria das entradas é `nameOnly`: o código foi escolhido pelo nome do
392
+ * exame, sem registro de unidade, método, material ou bula, e ninguém revisou
393
+ * de fora. É o registro honesto do que existe, e não justificativa inventada.
394
+ * As entradas com evidência vieram dos comentários em `biomarkers.ts` que já
395
+ * documentavam a troca. `reviewer` fica vazio até uma revisão independente.
396
+ *
397
+ * `loinc` repete o código do catálogo de propósito: trocar o código em
398
+ * `biomarkers.ts` sem tocar aqui falha em `mapping-decisions.test.ts`, e a
399
+ * troca chega à revisão com o registro ao lado.
400
+ *
401
+ * Sem import em runtime: o `scripts/verify-loinc.ts` lê este arquivo direto com
402
+ * o type stripping do Node, que não resolve import sem extensão. A ficha que
403
+ * junta registro, catálogo e eixos fica em `mapping-sheet.ts`.
404
+ */
405
+ /** O que o laudo mostrou e pesou na escolha do código. */
406
+ type MappingEvidence = 'assay-insert' | 'method-line' | 'name' | 'specimen' | 'unit';
407
+ interface RejectedSibling {
408
+ loinc: string;
409
+ reason: string;
410
+ }
411
+ interface MappingDecision {
412
+ evidence: MappingEvidence[];
413
+ /** O código escolhido. Tem que ser o `loinc` do biomarcador no catálogo. */
414
+ loinc: string;
415
+ /** Versão do LOINC em que a revisão conferiu o código. */
416
+ loincVersion?: string;
417
+ note?: string;
418
+ reviewedAt?: string;
419
+ reviewer?: string;
420
+ /** Qual evidência decidiu. Está sempre em `evidence`. */
421
+ settledBy: MappingEvidence;
422
+ siblingsRejected: RejectedSibling[];
423
+ }
424
+ /**
425
+ * Por que uma entrada não tem LOINC.
426
+ *
427
+ * - `no-concept`: procurado, e o LOINC não tem o conceito.
428
+ * - `ambiguous`: há candidatos, e nenhum é a mesma grandeza.
429
+ * - `pending-review`: ninguém registrou a busca.
430
+ * - `not-lab`: fora do escopo de exame laboratorial.
431
+ */
432
+ type NoLoincReason = 'ambiguous' | 'no-concept' | 'not-lab' | 'pending-review';
433
+ interface NoLoincDecision {
434
+ note: string;
435
+ reason: NoLoincReason;
436
+ }
437
+ declare const MAPPING_DECISIONS: Record<string, MappingDecision>;
438
+ declare const NO_LOINC_DECISIONS: Record<string, NoLoincDecision>;
439
+ declare function getMappingDecision(code: string): MappingDecision | undefined;
440
+ declare function getNoLoincDecision(code: string): NoLoincDecision | undefined;
441
+
442
+ /** Um código candidato com os eixos que o snapshot guarda dele. */
443
+ interface MappingCandidate {
444
+ axes?: LoincEntry;
445
+ loinc: string;
446
+ role: 'chosen' | 'method-variant' | 'rejected';
447
+ /** Pista impressa da variante, ou o motivo da rejeição. */
448
+ why?: string;
449
+ }
450
+ /** A ficha de um mapeamento, no formato da planilha de um mapeador. */
451
+ interface MappingSheet {
452
+ candidates: MappingCandidate[];
453
+ code: string;
454
+ decision?: MappingDecision;
455
+ /** LOINC Groups do código escolhido. */
456
+ groups: Record<string, string>;
457
+ localNames: string[];
458
+ method: string | null;
459
+ noLoinc?: NoLoincDecision;
460
+ specimen: string | null;
461
+ unit?: string;
462
+ }
463
+ /** Aceita o código interno ou qualquer LOINC que resolva para o biomarcador. */
464
+ declare function getMappingSheet(codeOrLoinc: string): MappingSheet | undefined;
465
+
466
+ type SpecimenClass = 'blood' | 'urine';
467
+ /** Classe do material impresso, ou `undefined` quando a palavra inicial não diz. */
468
+ declare function specimenClassOf(material: string): SpecimenClass | undefined;
469
+ /** Classe do eixo System do código, ou `undefined` fora do snapshot ou das duas classes. */
470
+ declare function loincSpecimenClass(loinc: string): SpecimenClass | undefined;
471
+ interface SpecimenMismatch {
472
+ /** Classe do eixo System do código. */
473
+ code: SpecimenClass;
474
+ loinc: string;
475
+ /** Classe do material impresso. */
476
+ material: SpecimenClass;
477
+ reason: 'specimen-mismatch';
478
+ system: string;
479
+ }
480
+ /**
481
+ * O conflito entre o material impresso e o código, ou `null` sem conflito
482
+ * afirmável. Quem chama decide o que fazer com o resultado, e a decisão que não
483
+ * existe é trocar o código por um palpite: conflito é lacuna, e sai como tal.
484
+ */
485
+ declare function specimenMismatch(material: string, loinc: string): SpecimenMismatch | null;
486
+
487
+ export { AGE_BRACKETS, Addressable, BIOMARKER_CODE_SYSTEM, BODY_FAT_ZONES, BR_TIPO_AMOSTRA_VALUESET, type BodyFatZone, CATEGORY_GROUPS, CATEGORY_SCREENING_INTERVALS, type CategoryGroup, type CategoryGroupInfo, type CategoryScreeningInterval, FHIRBundle, FHIRCoding, FHIRIdentifier, FHIRMedicationStatement, FHIRObservation, FHIR_BRASIL_EXTENSIONS, HL7_SPECIMEN_TYPE_SYSTEM, IG_CANONICAL, InterventionData, LOINC_SNAPSHOT, LOINC_SYSTEM, type LoincEntry, type LoincSnapshot, MAPPING_DECISIONS, type MappingCandidate, type MappingDecision, type MappingEvidence, type MappingSheet, NO_LOINC_DECISIONS, type NoLoincDecision, type NoLoincReason, type RejectedSibling, type ScreeningIntervalMonths, type SpecimenClass, type SpecimenMismatch, type TScoreZone, T_SCORE_ZONES, UserProfileData, ZONE_DEFS, calculateNextScreeningDate, cnsToFHIRIdentifier, cpfToFHIRIdentifier, formatCNS, formatCPF, getCategoriesByInterval, getCategoryGroup, getDaysUntilScreening, getDueCategories, getLoincEntry, getMappingDecision, getMappingSheet, getNoLoincDecision, getScreeningInterval, interventionToFHIRMedicationStatement, interventionToFHIRObservation, interventionsToFHIRBundle, isScreeningDue, listMappedSubcategories, loincSpecimenClass, plural, pluralCount, pluralPhrase, pluralPhraseCount, specimenClassOf, specimenMismatch, specimenTypeCoding, validateCNS, validateCPF };