@openhealth/oht-custom-parser-lib 0.5.62 → 0.5.63
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 +2 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/service/ohtReportMeasurementsExtractor.service.d.ts +1 -0
- package/dist/service/ohtReportMeasurementsExtractor.service.js +6 -2
- package/dist/service/ohtReportMeasurementsExtractor.service.js.map +1 -1
- package/dist/service/reportCreator.service.d.ts +8 -3
- package/dist/service/reportCreator.service.js +42 -2
- package/dist/service/reportCreator.service.js.map +1 -1
- package/dist/types/oht.types.d.ts +12 -0
- package/dist/types/oht.types.js.map +1 -1
- package/dist/util-ts/extractionUtils.d.ts +3 -1
- package/dist/util-ts/extractionUtils.js +6 -3
- package/dist/util-ts/extractionUtils.js.map +1 -1
- package/dist/util-ts/loincMapping.d.ts +5 -0
- package/dist/util-ts/loincMapping.js +81 -0
- package/dist/util-ts/loincMapping.js.map +1 -0
- package/package.json +1 -1
- package/dist/service/ohtAgnosticMeasurementsExtractor.service.d.ts +0 -59
- package/dist/service/ohtAgnosticMeasurementsExtractor.service.js +0 -603
- package/dist/service/ohtAgnosticMeasurementsExtractor.service.js.map +0 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEffectiveLoincMapping = getEffectiveLoincMapping;
|
|
4
|
+
exports.buildLoincMappingByOhtBmId = buildLoincMappingByOhtBmId;
|
|
5
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
6
|
+
function trimField(value) {
|
|
7
|
+
return (value ?? '').trim();
|
|
8
|
+
}
|
|
9
|
+
function normalizeLoincCodeKey(code) {
|
|
10
|
+
return trimField(code).replace(/\s+/g, '');
|
|
11
|
+
}
|
|
12
|
+
function extractUuid(value) {
|
|
13
|
+
const trimmed = trimField(value);
|
|
14
|
+
if (!trimmed) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const lower = trimmed.toLowerCase();
|
|
18
|
+
return UUID_RE.test(lower) ? lower : undefined;
|
|
19
|
+
}
|
|
20
|
+
function normalizeLoincMapping(lm) {
|
|
21
|
+
if (!lm) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const loincCode = normalizeLoincCodeKey(lm.loincCode ?? '');
|
|
25
|
+
const bmObjectUuid = extractUuid(lm.bmObjectUuid);
|
|
26
|
+
if (!loincCode && !bmObjectUuid) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const result = {};
|
|
30
|
+
if (loincCode) {
|
|
31
|
+
result.loincCode = loincCode;
|
|
32
|
+
}
|
|
33
|
+
if (bmObjectUuid) {
|
|
34
|
+
result.bmObjectUuid = bmObjectUuid;
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
/** Prefer structured loincMapping; fall back to legacy taggedLoincCode. */
|
|
39
|
+
function getEffectiveLoincMapping(mapping) {
|
|
40
|
+
if (!mapping) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const fromStructured = normalizeLoincMapping(mapping.loincMapping);
|
|
44
|
+
if (fromStructured) {
|
|
45
|
+
return fromStructured;
|
|
46
|
+
}
|
|
47
|
+
const tagged = trimField(mapping.taggedLoincCode);
|
|
48
|
+
if (!tagged) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const uuid = extractUuid(tagged);
|
|
52
|
+
if (uuid && uuid === tagged.toLowerCase()) {
|
|
53
|
+
return { bmObjectUuid: uuid };
|
|
54
|
+
}
|
|
55
|
+
const codeKey = normalizeLoincCodeKey(tagged);
|
|
56
|
+
if (codeKey) {
|
|
57
|
+
return { loincCode: codeKey };
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
/** Build ohtBmId → effective loincMapping from fetched partner biomarker mappings. */
|
|
62
|
+
function buildLoincMappingByOhtBmId(mappedBiomarkers) {
|
|
63
|
+
const index = new Map();
|
|
64
|
+
if (!mappedBiomarkers) {
|
|
65
|
+
return index;
|
|
66
|
+
}
|
|
67
|
+
for (const mapping of Object.values(mappedBiomarkers)) {
|
|
68
|
+
if (!mapping || mapping.isIgnored || mapping.ohtBmId <= 0) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const effective = getEffectiveLoincMapping(mapping);
|
|
72
|
+
if (!effective) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (!index.has(mapping.ohtBmId)) {
|
|
76
|
+
index.set(mapping.ohtBmId, effective);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return index;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=loincMapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loincMapping.js","sourceRoot":"","sources":["../../util-ts/loincMapping.ts"],"names":[],"mappings":";;AAyCA,4DA4BC;AAGD,gEAsBC;AA5FD,MAAM,OAAO,GAAG,iEAAiE,CAAC;AAElF,SAAS,SAAS,CAAC,KAAgC;IACjD,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAY;IACzC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,WAAW,CAAC,KAAgC;IACnD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACpC,OAAO,OAAO,CAAC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AAC;IAChC,CAAC;IAED,MAAM,OAAO,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,sFAAsF;AACtF,SAAgB,0BAA0B,CACxC,gBAA4E;IAE5E,MAAM,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC9C,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACtD,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC;YAC1D,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS;QACX,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { LabToOhtContract, LabToOhtMapper, RangeExtractionResponse, SynonymUnit, UnknownUnits, TransformationRulesChains } from "../types/custom-parser.types";
|
|
2
|
-
import { Biomarker, BiomarkerValueType, Measurement, MeasurementValueComparator, PatientInfo, UnknownMeasurement, Exam } from "../types/oht.types";
|
|
3
|
-
/**
|
|
4
|
-
* Extracts unit from rawData (OhtExam object)
|
|
5
|
-
* @param rawData - OhtExam object (not a JSON string)
|
|
6
|
-
* @param ohtBiomarker - Biomarker information
|
|
7
|
-
* @param synonymUnits - Synonym units for unit resolution
|
|
8
|
-
* @param partnerId - Partner ID for synonym resolution
|
|
9
|
-
*/
|
|
10
|
-
declare function agnosticExtractUnit(rawData: any, ohtBiomarker: Biomarker, synonymUnits?: SynonymUnit[] | null, partnerId?: string | null | undefined): {
|
|
11
|
-
unit: string;
|
|
12
|
-
isUnitParsedCorrectly: boolean;
|
|
13
|
-
originalUnit: string;
|
|
14
|
-
isArbitraryUnit: boolean;
|
|
15
|
-
unknownUnit: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Extracts reference annotation from rawExam (OhtExam object)
|
|
19
|
-
* @param labToOhtMapper - Lab to OHT mapper configuration
|
|
20
|
-
* @param rawExam - OhtExam object (not a JSON string)
|
|
21
|
-
* @param patientInfo - Patient information
|
|
22
|
-
* @param documentDate - Document date
|
|
23
|
-
* @param exams - Array of exams for appended mappings
|
|
24
|
-
*/
|
|
25
|
-
declare function agnosticExtractReferenceAnnotation(labToOhtMapper: LabToOhtMapper, rawExam: any, patientInfo: PatientInfo, documentDate?: Date, exams?: Exam[]): string;
|
|
26
|
-
/**
|
|
27
|
-
* Extracts reference ranges from rawData (OhtExam object)
|
|
28
|
-
* Always uses parseRange function from extractionUtils for range extraction
|
|
29
|
-
*/
|
|
30
|
-
declare function agnosticExtractReferenceRanges(labToOhtMapper: LabToOhtMapper, rawData: any, patientInfo: PatientInfo, documentDate?: Date): RangeExtractionResponse;
|
|
31
|
-
declare function agnosticExtractValueFromGreaterLowerThan(value: string): {
|
|
32
|
-
extractedValue: number | null;
|
|
33
|
-
extractedValueComparator: MeasurementValueComparator | null;
|
|
34
|
-
valueParsedCorrectly: boolean;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Parses exam value from rawExamObj (OhtExam object)
|
|
38
|
-
* Now uses value directly from ohtExam
|
|
39
|
-
*/
|
|
40
|
-
declare function agnosticParseExamValue(rawExamObj: any, ohtBiomarker: Biomarker): {
|
|
41
|
-
valueType: BiomarkerValueType;
|
|
42
|
-
alphanumericalValue: string | null;
|
|
43
|
-
numberValue: number | null;
|
|
44
|
-
valueComparator: MeasurementValueComparator;
|
|
45
|
-
isValueParsedCorrectly: boolean;
|
|
46
|
-
};
|
|
47
|
-
declare function agnosticCheckValueForPlausibleValues(labToOhtMapper: LabToOhtMapper, ohtBiomarker: Biomarker, unit: string, value: number, isUnitParsedCorrectly: boolean): boolean;
|
|
48
|
-
type ApplyTransformationRulesResult = {
|
|
49
|
-
transformedExams: Exam[];
|
|
50
|
-
applicationErrorMessages: string[];
|
|
51
|
-
};
|
|
52
|
-
declare function ohtAgnosticMeasurementsExtractor(labToOhtContract: LabToOhtContract, exams: Exam[], transformationRules: TransformationRulesChains, ohtCoreApiKey: string, partnerId?: string | null | undefined): Promise<{
|
|
53
|
-
measurements: Measurement[];
|
|
54
|
-
unknownMeasurements: UnknownMeasurement[];
|
|
55
|
-
unknownUnits: UnknownUnits[];
|
|
56
|
-
isReportCorrectlyParsed: boolean;
|
|
57
|
-
transformationRulesErrors: string[];
|
|
58
|
-
}>;
|
|
59
|
-
export { ApplyTransformationRulesResult, ohtAgnosticMeasurementsExtractor, agnosticCheckValueForPlausibleValues, agnosticExtractReferenceRanges, agnosticExtractReferenceAnnotation, agnosticParseExamValue, agnosticExtractUnit, agnosticExtractValueFromGreaterLowerThan };
|