@openhealth/oht-custom-parser-lib 0.2.60 → 0.2.62
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.
|
@@ -5,15 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.postDataImportFileUploadToCore = postDataImportFileUploadToCore;
|
|
7
7
|
const oht_types_1 = require("../types/oht.types");
|
|
8
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
|
-
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
10
|
-
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
11
|
-
dayjs_1.default.extend(customParseFormat_1.default);
|
|
12
|
-
dayjs_1.default.extend(utc_1.default);
|
|
13
8
|
const pinoLogger_1 = __importDefault(require("../util-ts/pinoLogger"));
|
|
14
9
|
const logger = (0, pinoLogger_1.default)();
|
|
15
10
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
16
|
-
const auxiliaryFunctions_service_1 = require("./auxiliaryFunctions.service");
|
|
17
11
|
const dataUtils_1 = require("../util-ts/dataUtils");
|
|
18
12
|
const apiUtils_1 = require("../util-ts/apiUtils");
|
|
19
13
|
dotenv_1.default.config({ path: `.env.local` });
|
|
@@ -23,8 +17,7 @@ async function postDataImportFileUploadToCore(dataImportFileUpload, unknownMeasu
|
|
|
23
17
|
? oht_types_1.DataImportFileUploadStatus.PROCESSED
|
|
24
18
|
: oht_types_1.DataImportFileUploadStatus.FOR_REVIEW;
|
|
25
19
|
const patchStatus = rejectedStatus ?? status;
|
|
26
|
-
const
|
|
27
|
-
const ohtCoreFileUploadUrl = `${OHT_CORE_URL}/v1/file-uploads/${dataImportFileUpload.id}`;
|
|
20
|
+
const ohtCoreIngestionUrl = `${OHT_CORE_URL}/v1/file-uploads/${dataImportFileUpload.id}/ingestion`;
|
|
28
21
|
const ohtCoreDigitalizationUrl = `${OHT_CORE_URL}/v1/file-uploads/${dataImportFileUpload.id}/digitalization`;
|
|
29
22
|
// Get the owner user binding to update the user with patient information
|
|
30
23
|
const userBindingUrl = `${OHT_CORE_URL}/v1/useruploadbinding/useruploadbindings/${dataImportFileUpload.id}`;
|
|
@@ -51,17 +44,7 @@ async function postDataImportFileUploadToCore(dataImportFileUpload, unknownMeasu
|
|
|
51
44
|
const userResponse = await (0, apiUtils_1.makeApiCallWithRetry)('patch', userUrl, userPayload, ohtCoreApiKey);
|
|
52
45
|
logger.info({ response: userResponse.data }, `Resp: PATCH USER /v1/users/${ownerUserId}, filename: ${filename}`);
|
|
53
46
|
try {
|
|
54
|
-
|
|
55
|
-
...dataImportFileUpload,
|
|
56
|
-
status: patchStatus,
|
|
57
|
-
rejectReason,
|
|
58
|
-
digitalization: {
|
|
59
|
-
...dataImportFileUpload.digitalization,
|
|
60
|
-
pipelineStep: oht_types_1.PipelineStep.SENDING_RESULTS,
|
|
61
|
-
},
|
|
62
|
-
}, ohtCoreApiKey);
|
|
63
|
-
logger.info({ response: initialResponse.data }, `Resp: PATCH status: ${patchStatus} ${ohtCoreFileUploadUrl}, filename: ${filename}`);
|
|
64
|
-
// Send unknown measurements if they exist
|
|
47
|
+
// Send unknown measurements if they exist (before ingestion)
|
|
65
48
|
if (unknownMeasurements.unmappedlabkeys.length > 0) {
|
|
66
49
|
try {
|
|
67
50
|
await (0, dataUtils_1.updatePartnerCustomParserUnmappedLabKeys)(dataImportFileUpload.partnerId, unknownMeasurements, ohtCoreApiKey);
|
|
@@ -90,29 +73,38 @@ async function postDataImportFileUploadToCore(dataImportFileUpload, unknownMeasu
|
|
|
90
73
|
}, `Failed to send unknown units to server, filename: ${filename}`);
|
|
91
74
|
}
|
|
92
75
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
// Use ingestion endpoint - handles report creation and READY status automatically
|
|
77
|
+
const ingestionResponse = await (0, apiUtils_1.makeApiCallWithRetry)('patch', ohtCoreIngestionUrl, {
|
|
78
|
+
...dataImportFileUpload,
|
|
79
|
+
status: patchStatus,
|
|
80
|
+
rejectReason,
|
|
81
|
+
digitalization: {
|
|
82
|
+
...dataImportFileUpload.digitalization,
|
|
83
|
+
pipelineStep: oht_types_1.PipelineStep.SENDING_RESULTS,
|
|
84
|
+
},
|
|
85
|
+
}, ohtCoreApiKey);
|
|
86
|
+
logger.info({ response: ingestionResponse.data }, `Resp: PATCH ingestion status: ${patchStatus} ${ohtCoreIngestionUrl}, filename: ${filename}`);
|
|
87
|
+
// Ingestion endpoint returns acknowledgment: { message: "Ingestion started", fileUploadId: "..." }
|
|
88
|
+
// Processing (user updates, report creation, READY status) happens asynchronously in background
|
|
89
|
+
// For PROCESSED status, it will automatically:
|
|
90
|
+
// - Create report
|
|
91
|
+
// - Handle LabOrderID version deprecation (if labOrderId is present)
|
|
92
|
+
// - Set status to READY
|
|
93
|
+
// - Trigger all notifications and webhooks
|
|
94
|
+
if (!isReportParsedCorrectly || rejectedStatus !== undefined) {
|
|
95
|
+
logger.warn({
|
|
96
|
+
isReportParsedCorrectly,
|
|
97
|
+
rejectedStatus,
|
|
98
|
+
ingestionResponse: ingestionResponse.data,
|
|
99
|
+
}, `Report not parsed correctly fileUploadID ${dataImportFileUpload.id}, filename: ${filename}`);
|
|
105
100
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
initialResponse: initialResponse,
|
|
110
|
-
}, `Report not parsed correctly fileUploadID ${dataImportFileUpload.id}, filename: ${filename}`);
|
|
111
|
-
return initialResponse?.data;
|
|
101
|
+
// Return null since ingestion is asynchronous and we don't have the updated file upload object
|
|
102
|
+
// The caller should not rely on the returned value for status checking
|
|
103
|
+
return null;
|
|
112
104
|
}
|
|
113
105
|
catch (error) {
|
|
114
106
|
const errorDetail = (0, apiUtils_1.parseErrorObj)(error);
|
|
115
|
-
logger.error({ patchStatus, resp: errorDetail }, `ERROR: on report generation url:${
|
|
107
|
+
logger.error({ patchStatus, resp: errorDetail }, `ERROR: on report generation url:${ohtCoreIngestionUrl} filename: ${filename}`);
|
|
116
108
|
// set digitalization error
|
|
117
109
|
await (0, apiUtils_1.makeApiCallWithRetry)('patch', ohtCoreDigitalizationUrl, {
|
|
118
110
|
status: oht_types_1.DigitizationStatus.ERROR,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportCreator.service.js","sourceRoot":"","sources":["../../service/reportCreator.service.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"reportCreator.service.js","sourceRoot":"","sources":["../../service/reportCreator.service.ts"],"names":[],"mappings":";;;;;AAsMS,wEAA8B;AAtMvC,kDAM4B;AAG5B,uEAA+C;AAC/C,MAAM,MAAM,GAAG,IAAA,oBAAU,GAAE,CAAC;AAE5B,oDAA4B;AAC5B,oDAAoH;AACpH,kDAA0E;AAC1E,gBAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AAEtC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAE9C,KAAK,UAAU,8BAA8B,CAC3C,oBAA0C,EAC1C,mBAA4C,EAC5C,YAA4B,EAC5B,cAAkC,EAClC,YAAgC,EAChC,uBAAgC,EAChC,QAAgB,EAChB,aAAqB;IAErB,IAAI,MAAM,GAAG,uBAAuB;QAClC,CAAC,CAAC,sCAA0B,CAAC,SAAS;QACtC,CAAC,CAAC,sCAA0B,CAAC,UAAU,CAAC;IAE1C,MAAM,WAAW,GAAG,cAAc,IAAI,MAAM,CAAC;IAC7C,MAAM,mBAAmB,GAAG,GAAG,YAAY,oBAAoB,oBAAoB,CAAC,EAAE,YAAY,CAAC;IACnG,MAAM,wBAAwB,GAAG,GAAG,YAAY,oBAAoB,oBAAoB,CAA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3B,MAAM,IAAA,+BAAoB,EACxB,OAAO,EACP,wBAAwB,EACxB;YACE,MAAM,EAAE,8BAAkB,CAAC,KAAK;YAChC,YAAY,EAAE,wBAAY,CAAC,qBAAqB;YAChD,gBAAgB,EAAE,YAAY;SAC/B,EACD,aAAa,CACd,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/util-ts/apiUtils.js
CHANGED
|
@@ -35,7 +35,7 @@ const makeApiCall = limiter.wrap(async function (method, url, data, ohtCoreApiKe
|
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
// Function to handle API calls with retries
|
|
38
|
-
async function makeApiCallWithRetry(method, url, data, ohtCoreApiKey, retries =
|
|
38
|
+
async function makeApiCallWithRetry(method, url, data, ohtCoreApiKey, retries = 1) {
|
|
39
39
|
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
40
40
|
try {
|
|
41
41
|
return await makeApiCall(method, url, data, ohtCoreApiKey);
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@openhealth/oht-custom-parser-lib",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Shared nodejs lib with with reusable functions",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"/dist"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"test": "jest"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [],
|
|
14
|
-
"author": "",
|
|
15
|
-
"license": "ISC",
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@google-cloud/pubsub": "^4.10.0",
|
|
18
|
-
"@google-cloud/storage": "^7.7.0",
|
|
19
|
-
"axios": "^1.6.7",
|
|
20
|
-
"bottleneck": "^2.19.5",
|
|
21
|
-
"dayjs": "^1.11.13",
|
|
22
|
-
"dotenv": "^16.4.5",
|
|
23
|
-
"jsonata": "^2.1.0",
|
|
24
|
-
"moment": "^2.30.1",
|
|
25
|
-
"mongodb": "^6.3.0",
|
|
26
|
-
"pino": "^8.19.0"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/jest": "^29.5.14",
|
|
30
|
-
"axios-mock-adapter": "^2.1.0",
|
|
31
|
-
"jest": "^29.7.0",
|
|
32
|
-
"ts-jest": "^29.2.5"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@openhealth/oht-custom-parser-lib",
|
|
3
|
+
"version": "0.2.62",
|
|
4
|
+
"description": "Shared nodejs lib with with reusable functions",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "jest"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@google-cloud/pubsub": "^4.10.0",
|
|
18
|
+
"@google-cloud/storage": "^7.7.0",
|
|
19
|
+
"axios": "^1.6.7",
|
|
20
|
+
"bottleneck": "^2.19.5",
|
|
21
|
+
"dayjs": "^1.11.13",
|
|
22
|
+
"dotenv": "^16.4.5",
|
|
23
|
+
"jsonata": "^2.1.0",
|
|
24
|
+
"moment": "^2.30.1",
|
|
25
|
+
"mongodb": "^6.3.0",
|
|
26
|
+
"pino": "^8.19.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/jest": "^29.5.14",
|
|
30
|
+
"axios-mock-adapter": "^2.1.0",
|
|
31
|
+
"jest": "^29.7.0",
|
|
32
|
+
"ts-jest": "^29.2.5"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
# oht-custom-parser-lib
|
|
2
|
-
|
|
3
|
-
`oht-custom-parser-lib` is a shared library designed for use across multiple Node.js cloud functions. It contains common MongoDB connectors and data utilities that can be reused to avoid code duplication and ensure consistency.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Installation](#installation)
|
|
8
|
-
- [Usage](#usage)
|
|
9
|
-
- [Development](#development)
|
|
10
|
-
- [Patch Versions](#patch-versions)
|
|
11
|
-
- [Publish to npm Registry](#publish-to-npm-registry)
|
|
12
|
-
- [Using the Library in Cloud Functions](#using-the-library-in-cloud-functions)
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
To install `oht-custom-parser-lib`, you can add it as a dependency in your project using npm:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install oht-custom-parser-lib
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Or, if you want to install a specific version:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install oht-custom-parser-lib@<version>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
29
|
-
|
|
30
|
-
After installing, you can import and use the library in your cloud functions:
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
const { connectToMongoDB } = require('oht-custom-parser-lib');
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Development
|
|
37
|
-
|
|
38
|
-
### Patch Versions
|
|
39
|
-
|
|
40
|
-
When making changes to the `oht-custom-parser-lib`, you need to update the version number before publishing. Follow these steps:
|
|
41
|
-
|
|
42
|
-
1. **Update the version number**: Use npm's version command to bump the version:
|
|
43
|
-
- **Patch** for bug fixes:
|
|
44
|
-
```bash
|
|
45
|
-
npm version patch
|
|
46
|
-
```
|
|
47
|
-
- **Minor** for new features:
|
|
48
|
-
```bash
|
|
49
|
-
npm version minor
|
|
50
|
-
```
|
|
51
|
-
- **Major** for breaking changes:
|
|
52
|
-
```bash
|
|
53
|
-
npm version major
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
This command will automatically update the version in the `package.json` and create a git tag.
|
|
57
|
-
|
|
58
|
-
2. **Commit Changes**: Ensure your changes and the version bump are committed to the repository.
|
|
59
|
-
|
|
60
|
-
### Publish to npm Registry
|
|
61
|
-
|
|
62
|
-
After updating the version, you can publish the library to the npm registry:
|
|
63
|
-
|
|
64
|
-
1. **Login to npm** (if you haven't already):
|
|
65
|
-
```bash
|
|
66
|
-
npm login
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
2. **Publish the package**:
|
|
70
|
-
```bash
|
|
71
|
-
npm publish
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
If this is a private package, use:
|
|
75
|
-
```bash
|
|
76
|
-
npm publish --access restricted
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
3. **Verify the publish**: You can check the package on [npmjs.com](https://www.npmjs.com/) to verify that the new version is available.
|
|
80
|
-
|
|
81
|
-
## Using the Library in Cloud Functions
|
|
82
|
-
|
|
83
|
-
To use `oht-custom-parser-lib` in your cloud functions:
|
|
84
|
-
|
|
85
|
-
1. **Install the Library**: Add `oht-custom-parser-lib` as a dependency in the cloud function's `package.json`:
|
|
86
|
-
|
|
87
|
-
```json
|
|
88
|
-
{
|
|
89
|
-
"dependencies": {
|
|
90
|
-
"oht-custom-parser-lib": "^1.0.0"
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Replace `^1.0.0` with the appropriate version as needed.
|
|
96
|
-
|
|
97
|
-
2. **Install Dependencies**: Run `npm install` to install the library along with other dependencies.
|
|
98
|
-
|
|
99
|
-
3. **Deploy Your Function**: Deploy your cloud function as usual, ensuring that the updated dependencies are included.
|
|
1
|
+
# oht-custom-parser-lib
|
|
2
|
+
|
|
3
|
+
`oht-custom-parser-lib` is a shared library designed for use across multiple Node.js cloud functions. It contains common MongoDB connectors and data utilities that can be reused to avoid code duplication and ensure consistency.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Development](#development)
|
|
10
|
+
- [Patch Versions](#patch-versions)
|
|
11
|
+
- [Publish to npm Registry](#publish-to-npm-registry)
|
|
12
|
+
- [Using the Library in Cloud Functions](#using-the-library-in-cloud-functions)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
To install `oht-custom-parser-lib`, you can add it as a dependency in your project using npm:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install oht-custom-parser-lib
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or, if you want to install a specific version:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install oht-custom-parser-lib@<version>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
After installing, you can import and use the library in your cloud functions:
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
const { connectToMongoDB } = require('oht-custom-parser-lib');
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Development
|
|
37
|
+
|
|
38
|
+
### Patch Versions
|
|
39
|
+
|
|
40
|
+
When making changes to the `oht-custom-parser-lib`, you need to update the version number before publishing. Follow these steps:
|
|
41
|
+
|
|
42
|
+
1. **Update the version number**: Use npm's version command to bump the version:
|
|
43
|
+
- **Patch** for bug fixes:
|
|
44
|
+
```bash
|
|
45
|
+
npm version patch
|
|
46
|
+
```
|
|
47
|
+
- **Minor** for new features:
|
|
48
|
+
```bash
|
|
49
|
+
npm version minor
|
|
50
|
+
```
|
|
51
|
+
- **Major** for breaking changes:
|
|
52
|
+
```bash
|
|
53
|
+
npm version major
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This command will automatically update the version in the `package.json` and create a git tag.
|
|
57
|
+
|
|
58
|
+
2. **Commit Changes**: Ensure your changes and the version bump are committed to the repository.
|
|
59
|
+
|
|
60
|
+
### Publish to npm Registry
|
|
61
|
+
|
|
62
|
+
After updating the version, you can publish the library to the npm registry:
|
|
63
|
+
|
|
64
|
+
1. **Login to npm** (if you haven't already):
|
|
65
|
+
```bash
|
|
66
|
+
npm login
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
2. **Publish the package**:
|
|
70
|
+
```bash
|
|
71
|
+
npm publish
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
If this is a private package, use:
|
|
75
|
+
```bash
|
|
76
|
+
npm publish --access restricted
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
3. **Verify the publish**: You can check the package on [npmjs.com](https://www.npmjs.com/) to verify that the new version is available.
|
|
80
|
+
|
|
81
|
+
## Using the Library in Cloud Functions
|
|
82
|
+
|
|
83
|
+
To use `oht-custom-parser-lib` in your cloud functions:
|
|
84
|
+
|
|
85
|
+
1. **Install the Library**: Add `oht-custom-parser-lib` as a dependency in the cloud function's `package.json`:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"oht-custom-parser-lib": "^1.0.0"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Replace `^1.0.0` with the appropriate version as needed.
|
|
96
|
+
|
|
97
|
+
2. **Install Dependencies**: Run `npm install` to install the library along with other dependencies.
|
|
98
|
+
|
|
99
|
+
3. **Deploy Your Function**: Deploy your cloud function as usual, ensuring that the updated dependencies are included.
|