Socket
Socket
Sign inDemoInstall

mbs-importer-jps

Package Overview
Dependencies
189
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.12 to 1.0.13

9

dist/MBSXMLImporter.d.ts
import { AbstractJob, JobConfig } from "server-socket-framework-jps";
export declare class MBSXMLImporter extends AbstractJob {
import { Db } from 'mongodb';
import { DatabaseAvailableListener } from "mongo-access-jps";
export declare class MBSXMLImporter extends AbstractJob implements DatabaseAvailableListener {
private static _instance;

@@ -9,2 +11,3 @@ private readonly importPath;

private fileName;
private db;
constructor();

@@ -14,5 +17,7 @@ static getInstance(): MBSXMLImporter;

private handleCompleted;
import(fileName: string): Promise<number>;
importWithConnection(fileName: string, db: Db): Promise<number>;
import(fileName: string): void;
databaseConnected(db: Db): void;
executeJob(runId: string): void;
getConfig(): JobConfig;
}

@@ -25,3 +25,2 @@ "use strict";

const moment_1 = __importDefault(require("moment"));
const data_source_controller_1 = require("data-source-controller");
require('dotenv').config();

@@ -65,9 +64,9 @@ const converters = require('./util/fieldConverters');

}
import(fileName) {
importWithConnection(fileName, db) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
let parser = new xml2js_1.default.Parser();
const importFile = `${this.importPath}${fileName}`;
if (fs_1.default.existsSync(importFile)) {
let data = fs_1.default.readFileSync(importFile);
const fullFileName = `${this.importPath}${fileName}`;
if (fs_1.default.existsSync(fullFileName)) {
let data = fs_1.default.readFileSync(fullFileName);
if (data) {

@@ -128,6 +127,6 @@ parser.parseString(data, (err, result) => {

});
data_source_controller_1.DataSourceController.getInstance().deleteAll(this.collection).then((result) => {
data_source_controller_1.DataSourceController.getInstance().insertMany(this.collection, processedItems).then((result) => {
// now we need to calculate the derived values
data_source_controller_1.DataSourceController.getInstance().find(this.collection, { isDerived: true }).then((derivedItems) => {
db.collection(this.collection).deleteMany({}).then((result) => {
db.collection(this.collection).insertMany(processedItems).then((result) => {
// now we need to calculated the derived values
db.collection(this.collection).find({ isDerived: true }).toArray().then((derivedItems) => {
/*

@@ -198,3 +197,3 @@ compute the derived fee

}
data_source_controller_1.DataSourceController.getInstance().replaceOne(this.collection, item);
db.collection(this.collection).replaceOne({ _id: item._id }, item);
});

@@ -212,7 +211,7 @@ resolve(processedItems.length);

else {
resolve(0);
reject(`No data in file ${fullFileName}`);
}
}
else {
reject({ message: `${importFile} does not exist` });
reject(`File ${fullFileName} not present`);
}

@@ -222,19 +221,37 @@ });

}
import(fileName) {
this.fileName = fileName;
}
databaseConnected(db) {
this.db = db;
}
executeJob(runId) {
this.import(this.fileName).then((result) => {
this.handleCompleted(this.fileName);
if (this.cb)
this.cb(runId, this.getConfig(), server_socket_framework_jps_1.JobStatus.completed, null);
})
.catch((err) => {
if (this.db) {
this.importWithConnection(this.fileName, this.db).then((result) => {
this.handleCompleted(this.fileName);
if (this.cb)
this.cb(runId, this.getConfig(), server_socket_framework_jps_1.JobStatus.completed, null);
})
.catch((err) => {
const error = {
errorPriority: server_socket_framework_jps_1.JobErrorPriority.severe,
jobName: "MBS XML Importer",
message: err.message,
runId: runId
};
this.handleError(this.fileName);
if (this.cb)
this.cb(runId, this.getConfig(), server_socket_framework_jps_1.JobStatus.failed, [error]);
});
}
else {
const error = {
errorPriority: server_socket_framework_jps_1.JobErrorPriority.severe,
jobName: "MBS XML Importer",
message: err.message,
message: "database not available",
runId: runId
};
this.handleError(this.fileName);
if (this.cb)
this.cb(runId, this.getConfig(), server_socket_framework_jps_1.JobStatus.failed, [error]);
});
}
}

@@ -241,0 +258,0 @@ getConfig() {

{
"name": "mbs-importer-jps",
"version": "1.0.12",
"version": "1.0.13",
"description": "A patient management web application",

@@ -18,3 +18,3 @@ "main": "dist/MBSXMLImporter.js",

"buffer": "^5.7.1",
"data-source-controller": "^0.1.4",
"data-source-controller": "^0.2.6",
"debug": "^2.6.9",

@@ -21,0 +21,0 @@ "dotenv": "^10.0.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc