@openhealth/oht-custom-parser-lib 0.2.75 → 0.2.76

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.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export { postDataImportFileUploadToCore, postReportPreviewToCore } from './service/reportCreator.service';
2
2
  export { parseExternalPatientId, parseGender, isPatientAgeValid, handleRejection, queryFileUploadsWithFilters, postFileUploadSetStatus, DigitalizationUpdateFields } from './service/auxiliaryFunctions.service';
3
- export { ohtAgnosticMeasurementsExtractor, agnosticCheckValueForPlausibleValues, agnosticExtractReferenceRanges, agnosticExtractReferenceAnnotation, agnosticParseExamValue, agnosticExtractUnit, agnosticExtractValueFromGreaterLowerThan } from './service/ohtAgnosticMeasurementsExtractor.service';
3
+ export { ohtReportMeasurementsExtractor, } from './service/ohtReportMeasurementsExtractor.service';
4
4
  export { ohtMeasurementsExtractor, checkValueForPlausibleValues, extractReferenceRanges, extractReferenceAnnotation, parseExamValue, getRangeFromPositionAndRegex, extractUnit, extractValueFromGreaterLowerThan } from './service/ohtMeasurementsExtractor.service';
5
5
  export { getSlackFileIssueNotificationMessage, sendMessageToSlack } from './service/slackMessages.service';
6
6
  export { aggregateMessages, aggregateBiMessages, publishToTopic, generateBIMessages } from './service/errorHandling.service';
7
7
  export { applyRules as applyTransformationRules, validateJsonataExpression as validateTransformationRuleExpression, } from './service/transformationRules.service';
8
8
  export { LabToOhtContract, LabToOhtMapper, UnknownMeasurementExtraction, ReferenceAsAnnotation, UnitExtraction, RangeExtraction, RangeExtractionResponse, ValueExtraction, unitSynonyms, ValueExtractionResponse, SynonymUnit, UnknownUnits, } from './types/custom-parser.types';
9
- export { AcfBiomarkerRangeAnnotationCheck, AcfBiomarkerGenericDisclaimerLogic, ManualCheck, BiomarkerCompatibility, ReferenceRangeType, AcfReferenceRange, VisualRange, NameAlias, AlternativeUnit, BiomarkerAcf, Biomarker, PipelineStep, DigitizationStatus, MeasurementValueComparator, BiomarkerValueType, DataImportFileUploadStatus, Sex, Digitization, PatientInfo, UnknownMeasurement, Measurement, DataImportFileUpload, MessagePayload, SignedUpload, ReportStyleConfig, LanguageCode, BiomarkerCustomisation, PartnerCustomPanel, ReportDisplaySettings, ReportCustomisation, OHTPartner, UploadType, RejectReason, } from './types/oht.types';
9
+ export { AcfBiomarkerRangeAnnotationCheck, AcfBiomarkerGenericDisclaimerLogic, ManualCheck, BiomarkerCompatibility, ReferenceRangeType, AcfReferenceRange, VisualRange, NameAlias, AlternativeUnit, BiomarkerAcf, Biomarker, PipelineStep, DigitizationStatus, MeasurementValueComparator, BiomarkerValueType, DataImportFileUploadStatus, Sex, Digitization, PatientInfo, UnknownMeasurement, UnmappedLabKey, Measurement, DataImportFileUpload, MessagePayload, SignedUpload, ReportStyleConfig, LanguageCode, BiomarkerCustomisation, PartnerCustomPanel, ReportDisplaySettings, ReportCustomisation, OHTPartner, UploadType, RejectReason, } from './types/oht.types';
10
10
  export { ErrorMessage } from './types/error.types';
11
11
  export type { TransformationRule, TransformationContext, ApplyRulesResult as TransformationApplyRulesResult, ApplyRulesOptions as TransformationApplyRulesOptions, ValidationResult as TransformationValidationResult, } from './types/transformationRules.types';
12
12
  export { makeApiCallWithRetry, parseErrorObj } from './util-ts/apiUtils';
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isBiomarkerExternalNoVisualRange = exports.isBiomarkerValueNumerical = exports.extractValue = exports.parseErrorObj = exports.makeApiCallWithRetry = exports.RejectReason = exports.UploadType = exports.Sex = exports.DataImportFileUploadStatus = exports.BiomarkerValueType = exports.MeasurementValueComparator = exports.DigitizationStatus = exports.PipelineStep = exports.ReferenceRangeType = exports.BiomarkerCompatibility = exports.ManualCheck = exports.AcfBiomarkerGenericDisclaimerLogic = exports.AcfBiomarkerRangeAnnotationCheck = exports.unitSynonyms = exports.validateTransformationRuleExpression = exports.applyTransformationRules = exports.generateBIMessages = exports.publishToTopic = exports.aggregateBiMessages = exports.aggregateMessages = exports.sendMessageToSlack = exports.getSlackFileIssueNotificationMessage = exports.extractValueFromGreaterLowerThan = exports.extractUnit = exports.getRangeFromPositionAndRegex = exports.parseExamValue = exports.extractReferenceAnnotation = exports.extractReferenceRanges = exports.checkValueForPlausibleValues = exports.ohtMeasurementsExtractor = exports.agnosticExtractValueFromGreaterLowerThan = exports.agnosticExtractUnit = exports.agnosticParseExamValue = exports.agnosticExtractReferenceAnnotation = exports.agnosticExtractReferenceRanges = exports.agnosticCheckValueForPlausibleValues = exports.ohtAgnosticMeasurementsExtractor = exports.postFileUploadSetStatus = exports.queryFileUploadsWithFilters = exports.handleRejection = exports.isPatientAgeValid = exports.parseGender = exports.parseExternalPatientId = exports.postReportPreviewToCore = exports.postDataImportFileUploadToCore = void 0;
7
- exports.parseRange = exports.getMappedBiomarkers = exports.getLowerThanPatterns = exports.getGreaterThanPatterns = exports.pinoLogger = exports.uploadFileBufferToGCS = exports.readFileFromBucket = exports.resolveUnitFromSynonyms = exports.fetchSynonymUnits = exports.processAppendedMappings = void 0;
6
+ exports.pinoLogger = exports.uploadFileBufferToGCS = exports.readFileFromBucket = exports.resolveUnitFromSynonyms = exports.fetchSynonymUnits = exports.processAppendedMappings = exports.isBiomarkerExternalNoVisualRange = exports.isBiomarkerValueNumerical = exports.extractValue = exports.parseErrorObj = exports.makeApiCallWithRetry = exports.RejectReason = exports.UploadType = exports.Sex = exports.DataImportFileUploadStatus = exports.BiomarkerValueType = exports.MeasurementValueComparator = exports.DigitizationStatus = exports.PipelineStep = exports.ReferenceRangeType = exports.BiomarkerCompatibility = exports.ManualCheck = exports.AcfBiomarkerGenericDisclaimerLogic = exports.AcfBiomarkerRangeAnnotationCheck = exports.unitSynonyms = exports.validateTransformationRuleExpression = exports.applyTransformationRules = exports.generateBIMessages = exports.publishToTopic = exports.aggregateBiMessages = exports.aggregateMessages = exports.sendMessageToSlack = exports.getSlackFileIssueNotificationMessage = exports.extractValueFromGreaterLowerThan = exports.extractUnit = exports.getRangeFromPositionAndRegex = exports.parseExamValue = exports.extractReferenceAnnotation = exports.extractReferenceRanges = exports.checkValueForPlausibleValues = exports.ohtMeasurementsExtractor = exports.ohtReportMeasurementsExtractor = exports.postFileUploadSetStatus = exports.queryFileUploadsWithFilters = exports.handleRejection = exports.isPatientAgeValid = exports.parseGender = exports.parseExternalPatientId = exports.postReportPreviewToCore = exports.postDataImportFileUploadToCore = void 0;
7
+ exports.parseRange = exports.getMappedBiomarkers = exports.getLowerThanPatterns = exports.getGreaterThanPatterns = void 0;
8
8
  // ### SERVICES ###
9
9
  var reportCreator_service_1 = require("./service/reportCreator.service");
10
10
  Object.defineProperty(exports, "postDataImportFileUploadToCore", { enumerable: true, get: function () { return reportCreator_service_1.postDataImportFileUploadToCore; } });
@@ -16,14 +16,8 @@ Object.defineProperty(exports, "isPatientAgeValid", { enumerable: true, get: fun
16
16
  Object.defineProperty(exports, "handleRejection", { enumerable: true, get: function () { return auxiliaryFunctions_service_1.handleRejection; } });
17
17
  Object.defineProperty(exports, "queryFileUploadsWithFilters", { enumerable: true, get: function () { return auxiliaryFunctions_service_1.queryFileUploadsWithFilters; } });
18
18
  Object.defineProperty(exports, "postFileUploadSetStatus", { enumerable: true, get: function () { return auxiliaryFunctions_service_1.postFileUploadSetStatus; } });
19
- var ohtAgnosticMeasurementsExtractor_service_1 = require("./service/ohtAgnosticMeasurementsExtractor.service");
20
- Object.defineProperty(exports, "ohtAgnosticMeasurementsExtractor", { enumerable: true, get: function () { return ohtAgnosticMeasurementsExtractor_service_1.ohtAgnosticMeasurementsExtractor; } });
21
- Object.defineProperty(exports, "agnosticCheckValueForPlausibleValues", { enumerable: true, get: function () { return ohtAgnosticMeasurementsExtractor_service_1.agnosticCheckValueForPlausibleValues; } });
22
- Object.defineProperty(exports, "agnosticExtractReferenceRanges", { enumerable: true, get: function () { return ohtAgnosticMeasurementsExtractor_service_1.agnosticExtractReferenceRanges; } });
23
- Object.defineProperty(exports, "agnosticExtractReferenceAnnotation", { enumerable: true, get: function () { return ohtAgnosticMeasurementsExtractor_service_1.agnosticExtractReferenceAnnotation; } });
24
- Object.defineProperty(exports, "agnosticParseExamValue", { enumerable: true, get: function () { return ohtAgnosticMeasurementsExtractor_service_1.agnosticParseExamValue; } });
25
- Object.defineProperty(exports, "agnosticExtractUnit", { enumerable: true, get: function () { return ohtAgnosticMeasurementsExtractor_service_1.agnosticExtractUnit; } });
26
- Object.defineProperty(exports, "agnosticExtractValueFromGreaterLowerThan", { enumerable: true, get: function () { return ohtAgnosticMeasurementsExtractor_service_1.agnosticExtractValueFromGreaterLowerThan; } });
19
+ var ohtReportMeasurementsExtractor_service_1 = require("./service/ohtReportMeasurementsExtractor.service");
20
+ Object.defineProperty(exports, "ohtReportMeasurementsExtractor", { enumerable: true, get: function () { return ohtReportMeasurementsExtractor_service_1.ohtReportMeasurementsExtractor; } });
27
21
  var ohtMeasurementsExtractor_service_1 = require("./service/ohtMeasurementsExtractor.service");
28
22
  Object.defineProperty(exports, "ohtMeasurementsExtractor", { enumerable: true, get: function () { return ohtMeasurementsExtractor_service_1.ohtMeasurementsExtractor; } });
29
23
  Object.defineProperty(exports, "checkValueForPlausibleValues", { enumerable: true, get: function () { return ohtMeasurementsExtractor_service_1.checkValueForPlausibleValues; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;AAAA,mBAAmB;AACnB,yEAGyC;AAFvC,uIAAA,8BAA8B,OAAA;AAC9B,gIAAA,uBAAuB,OAAA;AAEzB,mFAQ8C;AAP5C,oIAAA,sBAAsB,OAAA;AACtB,yHAAA,WAAW,OAAA;AACX,+HAAA,iBAAiB,OAAA;AACjB,6HAAA,eAAe,OAAA;AACf,yIAAA,2BAA2B,OAAA;A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AAc,OAAA;AACd,2HAAA,kBAAkB,OAAA;AAEpB,qFAG+C;AAF7C,uIAAA,UAAU,OAA4B;AACtC,mJAAA,yBAAyB,OAAwC;AAGnE,gBAAgB;AAChB,mEAaqC;AAJnC,mHAAA,YAAY,OAAA;AAKd,+CAmC2B;AAlCzB,6HAAA,gCAAgC,OAAA;AAChC,+HAAA,kCAAkC,OAAA;AAClC,wGAAA,WAAW,OAAA;AACX,mHAAA,sBAAsB,OAAA;AACtB,+GAAA,kBAAkB,OAAA;AAOlB,yGAAA,YAAY,OAAA;AACZ,+GAAA,kBAAkB,OAAA;AAClB,uHAAA,0BAA0B,OAAA;AAC1B,+GAAA,kBAAkB,OAAA;AAClB,uHAAA,0BAA0B,OAAA;AAC1B,gGAAA,GAAG,OAAA;AAgBH,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AAWd,kBAAkB;AAClB,+CAAuE;AAA/D,gHAAA,oBAAoB,OAAA;AAAE,yGAAA,aAAa,OAAA;AAC3C,iDAAmL;AAA3K,yGAAA,YAAY,OAAA;AAAE,sHAAA,yBAAyB,OAAA;AAAE,6HAAA,gCAAgC,OAAA;AAAE,oHAAA,uBAAuB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAAE,oHAAA,uBAAuB,OAAA;AACtJ,mEAAuF;AAA/E,wHAAA,kBAAkB,OAAA;AAAE,2HAAA,qBAAqB,OAAA;AACjD,mDAA2D;AAAnD,yHAAA,OAAO,OAAc;AAC7B,mDAAkF;AAA1E,oHAAA,sBAAsB,OAAA;AAAE,kHAAA,oBAAoB,OAAA;AACpD,iDAA0D;AAAlD,gHAAA,mBAAmB,OAAA;AAC3B,6DAAqD;AAA7C,6GAAA,UAAU,OAAA"}
@@ -0,0 +1,157 @@
1
+ import { UnknownUnits, TransformationRulesChains } from "../types/custom-parser.types";
2
+ import { Measurement, PatientInfo, UnknownMeasurement, Exam, UnmappedLabKey } from "../types/oht.types";
3
+ import { ErrorMessage } from "../types/error.types";
4
+ type ApplyTransformationRulesResult = {
5
+ transformedExams: Exam[];
6
+ applicationErrorMessages: string[];
7
+ };
8
+ /**
9
+ * Extracts measurements from OHT report exams by processing each exam through biomarker mapping,
10
+ * transformation rules, and value extraction.
11
+ *
12
+ * This function is the main entry point for converting raw exam data into standardized OHT measurements.
13
+ * It handles biomarker mapping, unit extraction, value parsing, range extraction, and error reporting.
14
+ *
15
+ * ## Processing Flow:
16
+ *
17
+ * ### Step 1: Initialization and Validation
18
+ * - Validates that exams array is not empty
19
+ * - Initializes result arrays (measurements, unknownMeasurements, unknownUnits, unmappedLabKeys)
20
+ * - Sets up error tracking and transformation rules error tracking
21
+ *
22
+ * ### Step 2: Fetch Biomarker Mappings
23
+ * - Calls `getMappedBiomarkers()` to retrieve biomarker mappings from OHT Core backend
24
+ * - Maps labKeys to OHT biomarker IDs (ohtBmId) for the given partner
25
+ * - Logs the number of mappings retrieved
26
+ *
27
+ * ### Step 3: Apply Transformation Rules
28
+ * - Applies transformation rules to all exams using `applyTransformationRulesToExams()`
29
+ * - Transformation rules can modify exam data before processing (e.g., normalize units, fix values)
30
+ * - Creates a map of transformed exams for quick lookup during processing
31
+ * - Collects and reports any transformation rule errors
32
+ *
33
+ * ### Step 4: Collect Biomarker IDs and Fetch Biomarker Details
34
+ * - Iterates through all exams to collect unique OHT biomarker IDs from mappings
35
+ * - Filters out ignored biomarkers and unmapped biomarkers (ohtBmId === -1)
36
+ * - Makes API call to OHT Core to fetch full biomarker details (standard units, ranges, etc.)
37
+ * - Fetches synonym units from API if partnerId is provided (for unit resolution)
38
+ *
39
+ * ### Step 5: Process Each Exam
40
+ * For each exam in the input array:
41
+ *
42
+ * #### 5.1: Create UnmappedLabKey (Always)
43
+ * - **Always** creates an `unmappedLabKey` entry for every exam, regardless of mapping status
44
+ * - This ensures all labKeys are tracked for unmapped biomarker analysis
45
+ * - Includes exam metadata: labKey, biomarkerName, value, unit, annotation, originalName, dataOrigin
46
+ *
47
+ * #### 5.2: Check Biomarker Mapping Status
48
+ * - Retrieves backend mapping for the exam's labKey
49
+ * - Skips processing if biomarker is marked as `isIgnored === true`
50
+ * - Uses `handleBiomarkerId()` to determine final `ohtBmId` and `annotationConfig`
51
+ * - Handles unmapped biomarkers (ohtBmId === -1)
52
+ * - Handles `keepAsUnmapped` flag override
53
+ *
54
+ * #### 5.3: Process Mapped Biomarkers (ohtBmId !== -1 and !== undefined)
55
+ *
56
+ * ##### 5.3.1: Duplicate Check
57
+ * - Checks if biomarker ID already exists in measurements array
58
+ * - If duplicate, logs warning and adds error message, then continues to next exam
59
+ *
60
+ * ##### 5.3.2: Fetch Biomarker Details
61
+ * - Finds biomarker object from API response using `ohtBmId`
62
+ * - If not found, logs warning, adds error, and continues to next exam
63
+ *
64
+ * ##### 5.3.3: Extract Unit
65
+ * - Calls `ohtReportExtractUnit()` to extract and validate unit
66
+ * - Handles arbitrary units, standard units, alternative units, and synonym units
67
+ * - If unit cannot be resolved, adds to `unknownUnits` array
68
+ * - Logs warning and marks measurement as incorrectly parsed if unit extraction fails
69
+ *
70
+ * ##### 5.3.4: Parse Exam Value
71
+ * - Calls `ohtReportParseExamValue()` to extract value from exam
72
+ * - Determines value type (NUMERICAL or ALPHANUMERICAL) based on biomarker configuration
73
+ * - Handles greater than/less than comparators (e.g., ">10", "<5")
74
+ * - Logs warning and marks measurement as incorrectly parsed if value extraction fails
75
+ *
76
+ * ##### 5.3.5: Handle Numerical Without Valid Result
77
+ * - Checks if value is numerical but cannot be parsed as a valid number
78
+ * - If true, creates `unknownMeasurement` and continues to next exam
79
+ *
80
+ * ##### 5.3.6: Validate Plausible Values (for NUMERICAL biomarkers)
81
+ * - Calls `ohtReportCheckValueForPlausibleValues()` to validate value is within expected range
82
+ * - Converts value to standard unit if necessary using conversion factors
83
+ * - Logs warning and marks measurement as incorrectly parsed if value is not plausible
84
+ *
85
+ * ##### 5.3.7: Extract Reference Ranges (for NUMERICAL biomarkers)
86
+ * - Calls `ohtReportExtractReferenceRanges()` which uses `parseRange()` internally
87
+ * - Extracts min/max normal values based on patient age, sex, and range data
88
+ * - Filters ranges by patient demographics and selects most appropriate range
89
+ * - Logs warning and marks measurement as incorrectly parsed if range extraction fails
90
+ *
91
+ * ##### 5.3.8: Extract Reference Annotation
92
+ * - Calls `ohtReportExtractReferenceAnnotation()` to extract annotation text
93
+ * - Handles appended mappings (combines values from multiple related biomarkers)
94
+ * - Merges annotation from exam data with appended mapping results
95
+ *
96
+ * ##### 5.3.9: Build Measurement Object
97
+ * - Constructs complete `Measurement` object with all extracted data:
98
+ * - Biomarker ID, value type, value, alphanumeric value
99
+ * - Unit, original unit, arbitrary unit flag
100
+ * - Reference range (min/max normal values)
101
+ * - Range annotation
102
+ * - Material, method
103
+ * - Collection dates (collectionDate, effectiveDate, examCollectionDate, examEffectiveDate)
104
+ * - Original name for document search
105
+ * - Digitalization approval flags
106
+ * - Adds measurement to `measurements` array
107
+ *
108
+ * #### 5.4: Process Unmapped Biomarkers (no mapping or ohtBmId === -1)
109
+ * - Creates `unknownMeasurement` object with:
110
+ * - LabKey, biomarker name (mnemonic:examName), value, unit, annotation
111
+ * - Data origin information
112
+ * - Original exam data for reference
113
+ * - Adds to `unknownMeasurements` array
114
+ *
115
+ * ### Step 6: Summary and Return
116
+ * - Logs processing summary (total labKeys, mapped biomarkers, unmapped biomarkers, errors)
117
+ * - Returns result object containing:
118
+ * - `measurements`: Array of successfully parsed and mapped measurements
119
+ * - `unknownMeasurements`: Array of measurements that could not be mapped or parsed
120
+ * - `unknownUnits`: Array of units that could not be resolved
121
+ * - `unmappedLabKeys`: Array of all labKeys (always created for every exam)
122
+ * - `isReportCorrectlyParsed`: Boolean indicating if all measurements were parsed correctly
123
+ * - `transformationRulesErrors`: Array of errors from transformation rules application
124
+ *
125
+ * ## Error Handling:
126
+ * - All errors are added to the `errorMessages` array passed as parameter
127
+ * - Errors are categorized by destination (slack, notes, bi)
128
+ * - Processing continues even if individual exams fail
129
+ * - Errors are logged with context (filename, labKey, ohtBmId, etc.)
130
+ *
131
+ * ## Key Behaviors:
132
+ * - **UnmappedLabKeys**: Always created for ALL exams, regardless of mapping status
133
+ * - **UnknownMeasurements**: Created when:
134
+ * - No backend mapping exists for labKey
135
+ * - ohtBmId === -1 (explicitly unmapped)
136
+ * - Value is numerical but cannot be parsed as valid number
137
+ * - **Measurements**: Created only when biomarker is successfully mapped and all extraction steps succeed
138
+ *
139
+ * @param exams - Array of Exam objects containing ohtExam and originalExam data
140
+ * @param sourceFilename - Name of the source file being processed (for error reporting)
141
+ * @param patientInfo - Patient information (sex, birthdate) for range extraction
142
+ * @param documentDate - Document date for age calculation and range extraction
143
+ * @param transformationRules - Map of labKey to transformation rule chains to apply
144
+ * @param ohtCoreApiKey - API key for OHT Core API calls
145
+ * @param partnerId - Partner ID for fetching biomarker mappings and synonym units
146
+ * @param errorMessages - Array to accumulate error messages (modified in-place)
147
+ * @returns Promise resolving to extraction result with measurements, unknownMeasurements, unknownUnits, unmappedLabKeys, parsing status, and transformation errors
148
+ */
149
+ declare function ohtReportMeasurementsExtractor(exams: Exam[], sourceFilename: string, patientInfo: PatientInfo, documentDate: Date | undefined, transformationRules: TransformationRulesChains, ohtCoreApiKey: string, partnerId: string, errorMessages: ErrorMessage[]): Promise<{
150
+ measurements: Measurement[];
151
+ unknownMeasurements: UnknownMeasurement[];
152
+ unknownUnits: UnknownUnits[];
153
+ unmappedLabKeys: UnmappedLabKey[];
154
+ isReportCorrectlyParsed: boolean;
155
+ transformationRulesErrors: string[];
156
+ }>;
157
+ export { ApplyTransformationRulesResult, ohtReportMeasurementsExtractor, };