@openhealth/oht-custom-parser-lib 0.2.8 → 0.2.9
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.
|
@@ -32,7 +32,6 @@ const limiter = new bottleneck_1.default({
|
|
|
32
32
|
maxConcurrent: 1, // Maximum number of tasks running at the same time
|
|
33
33
|
});
|
|
34
34
|
// Wrap the API call function
|
|
35
|
-
// Wrap the API call function
|
|
36
35
|
const makeApiCall = limiter.wrap(async function (method, url, data, ohtCoreApiKey) {
|
|
37
36
|
const authHeader = `Basic ${ohtCoreApiKey}`;
|
|
38
37
|
const headers = {
|
|
@@ -88,8 +87,8 @@ async function postDataImportFileUploadToCore(dataImportFileUpload, rejectedStat
|
|
|
88
87
|
oht_types_1.DataImportFileUploadStatus.PROCESSED :
|
|
89
88
|
oht_types_1.DataImportFileUploadStatus.FOR_REVIEW;
|
|
90
89
|
const patchStatus = rejectedStatus ?? status;
|
|
90
|
+
const ohtCoreUpdateFileUploadUrl = `${OHT_CORE_URL}/v1/file-uploads/${dataImportFileUpload.id}/update`;
|
|
91
91
|
const ohtCoreFileUploadUrl = `${OHT_CORE_URL}/v1/file-uploads/${dataImportFileUpload.id}`;
|
|
92
|
-
const ohtCoreFileUploadSetStatusUrl = `${OHT_CORE_URL}/v1/file-uploads/status/set/${dataImportFileUpload.id}`;
|
|
93
92
|
const ohtCoreDigitalizationUrl = `${OHT_CORE_URL}/v1/file-uploads/${dataImportFileUpload.id}/digitalization`;
|
|
94
93
|
try {
|
|
95
94
|
const initialResponse = await makeApiCallWithRetry('patch', ohtCoreFileUploadUrl, {
|
|
@@ -104,11 +103,18 @@ async function postDataImportFileUploadToCore(dataImportFileUpload, rejectedStat
|
|
|
104
103
|
logger.info({ response: initialResponse }, `Resp: PATCH status: ${patchStatus} ${ohtCoreFileUploadUrl}, filename: ${filename}`);
|
|
105
104
|
if (isReportParsedCorrectly && rejectedStatus === undefined) {
|
|
106
105
|
try {
|
|
107
|
-
|
|
106
|
+
if (dataImportFileUpload?.labOrderId?.length > 0) {
|
|
107
|
+
// deprecate any previous fileUpload with same labOrderId and update current to READY
|
|
108
|
+
await makeApiCallWithRetry('post', ohtCoreUpdateFileUploadUrl, {}, ohtCoreApiKey);
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return await (0, auxiliaryFunctions_service_1.postFileUploadSetStatus)({ status: oht_types_1.DataImportFileUploadStatus.READY, digitalization: { status: 'DONE', lastUpdated: dayjs_1.default.utc() } }, dataImportFileUpload.id, filename, ohtCoreApiKey);
|
|
113
|
+
}
|
|
108
114
|
}
|
|
109
115
|
catch (error) {
|
|
110
116
|
const errorDetail = parseErrorObj(error);
|
|
111
|
-
logger.error({ resp: errorDetail }, `ERROR: POST status: READY
|
|
117
|
+
logger.error({ resp: errorDetail }, `ERROR: POST status: READY /status/set/${dataImportFileUpload.id}, filename: ${filename}`);
|
|
112
118
|
throw error;
|
|
113
119
|
}
|
|
114
120
|
}
|
|
@@ -128,7 +134,7 @@ async function postDataImportFileUploadToCore(dataImportFileUpload, rejectedStat
|
|
|
128
134
|
pipelineStep: oht_types_1.PipelineStep.EXTRACTING_BIOMARKERS,
|
|
129
135
|
pipelineStepData: rejectReason,
|
|
130
136
|
}, ohtCoreApiKey);
|
|
131
|
-
return null;
|
|
137
|
+
return null;
|
|
132
138
|
}
|
|
133
139
|
}
|
|
134
140
|
//# sourceMappingURL=reportCreator.service.js.map
|
|
@@ -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":";;;;;AA8KQ,wEAA8B;AAAE,oDAAoB;AAAE,sCAAa;AA9K3E,kDAA0B;AAC1B,4DAAoC;AACpC,kDAA0B;AAC1B,kDAAsH;AACtH,kDAA0B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aAAa,CAAC,KAAK,CAAC,CAAC;gBACzC,MAAM,CAAC,KAAK,CAAC,EAAC,IAAI,EAAE,WAAW,EAAC,EAAE,yCAAyC,oBAAoB,CAAC,EAAE,eAAe,QAAQ,EAAE,CAAC,CAAC;gBAC7H,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,uBAAuB;YACvB,cAAc;YACd,eAAe;SAChB,EAAE,4CAA4C,oBAAoB,CAAC,EAAE,eAAe,QAAQ,EAAE,CAAC,CAAC;QAEjG,OAAO,eAAe,EAAE,IAAI,CAAA;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,CACV,EAAC,IAAI,EAAE,WAAW,EAAC,EACnB,wBAAwB,WAAW,IAAI,oBAAoB,qBAAqB,cAAc,cAAc,QAAQ,EAAE,CACvH,CAAC;QACF,2BAA2B;QAC3B,MAAM,oBAAoB,CACxB,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oht.types.js","sourceRoot":"","sources":["../../types/oht.types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"oht.types.js","sourceRoot":"","sources":["../../types/oht.types.ts"],"names":[],"mappings":";;;AA6KA,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,oBAAa,CAAA;IACb,wBAAiB,CAAA;IACjB,sBAAe,CAAA;AACjB,CAAC,EAJW,GAAG,mBAAH,GAAG,QAId;AAED,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,qDAAuC,CAA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BAAZ,YAAY,QAIvB;AAsCD,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,6CAAuB,CAAA;IACvB,2CAAqB,CAAA;IACrB,uDAAiC,CAAA;AACnC,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B;AAED,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,+CAAqB,CAAA;IACrB,+CAAqB,CAAA;IACrB,4EAAkD,CAAA;IAClD,4EAAkD,CAAA;IAClD,4DAAkC,CAAA;IAClC,2CAAiB,CAAA;AACnB,CAAC,EAPW,sBAAsB,sCAAtB,sBAAsB,QAOjC;AAED,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,wBAAS,CAAA;IACT,sCAAuB,CAAA;AACzB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAED,IAAY,kCAGX;AAHD,WAAY,kCAAkC;IAC5C,6DAAuB,CAAA;IACvB,iEAA2B,CAAA;AAC7B,CAAC,EAHW,kCAAkC,kDAAlC,kCAAkC,QAG7C;AAED,IAAY,gCAMX;AAND,WAAY,gCAAgC;IAC1C,2DAAuB,CAAA;IACvB,6EAAyC,CAAA;IACzC,+EAA2C,CAAA;IAC3C,2FAAuD,CAAA;IACvD,uFAAmD,CAAA;AACrD,CAAC,EANW,gCAAgC,gDAAhC,gCAAgC,QAM3C"}
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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
|
-
"moment": "^2.30.1",
|
|
24
|
-
"mongodb": "^6.3.0",
|
|
25
|
-
"pino": "^8.19.0"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/jest": "^29.5.14",
|
|
29
|
-
"axios-mock-adapter": "^2.1.0",
|
|
30
|
-
"jest": "^29.7.0",
|
|
31
|
-
"ts-jest": "^29.2.5"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@openhealth/oht-custom-parser-lib",
|
|
3
|
+
"version": "0.2.9",
|
|
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
|
+
"moment": "^2.30.1",
|
|
24
|
+
"mongodb": "^6.3.0",
|
|
25
|
+
"pino": "^8.19.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/jest": "^29.5.14",
|
|
29
|
+
"axios-mock-adapter": "^2.1.0",
|
|
30
|
+
"jest": "^29.7.0",
|
|
31
|
+
"ts-jest": "^29.2.5"
|
|
32
|
+
}
|
|
33
|
+
}
|
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.
|