modified-dicom-pacs 1.0.1 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/dicomweb-pacs +12 -6
- package/config/default.js +6 -1
- package/package.json +4 -4
- package/src/app.js +13 -11
- package/src/start-server.js +195 -203
- package/src/utils.js +3 -2
package/bin/dicomweb-pacs
CHANGED
@@ -3,16 +3,22 @@
|
|
3
3
|
const config = require('config');
|
4
4
|
var fs = require('fs');
|
5
5
|
const fs1 = require('fs-extra');
|
6
|
+
const path = require('path');
|
6
7
|
var spawn = require('child_process').spawn;
|
7
|
-
console.log(
|
8
|
+
console.log("startServer runs?");
|
8
9
|
|
9
|
-
|
10
|
+
// console.log("Current __dirname:", __dirname);
|
11
|
+
let baseDir = path.resolve(__dirname.split('webpacsApp')[0]);
|
12
|
+
// console.log("baseDir", baseDir);
|
13
|
+
|
14
|
+
console.log('starting modified-dicom-pacs...');
|
15
|
+
|
16
|
+
process.chdir('./node_modules/modified-dicom-pacs');
|
10
17
|
const ls = spawn('node', ['src/app.js']);
|
11
18
|
|
12
|
-
|
13
|
-
let
|
14
|
-
let
|
15
|
-
let DataNativeFolder = `${__dirname.split('\\webpacsApp')[0]}\\data\\Native`;
|
19
|
+
let TestsTxtFile = path.join(baseDir, 'webpacsApp', 'node_modules', 'modified-dicom-pacs', 'Testss.Txt');
|
20
|
+
let getTxtFile = path.join(baseDir, 'webpacsApp', 'node_modules', 'modified-dicom-pacs', 'getText.txt');
|
21
|
+
let DataNativeFolder = path.join(baseDir, 'data', 'Native');
|
16
22
|
|
17
23
|
ls.stdout.on('data', (data) => {
|
18
24
|
console.log(`stdout mao out: ${data}`)
|
package/config/default.js
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
3
|
+
let baseDir = path.resolve(__dirname.split('webpacsApp')[0]);
|
4
|
+
let DataNativeFolder = path.join(baseDir, 'data', 'Native');
|
5
|
+
|
1
6
|
const config = {
|
2
7
|
|
3
8
|
//helical app
|
@@ -22,7 +27,7 @@ const config = {
|
|
22
27
|
transferSyntax: '1.2.840.10008.1.2.4.70', // attention: compression not yet working with wado-rs
|
23
28
|
logDir: "./logs",
|
24
29
|
// storagePath: `${__dirname.split("\\dicomweb-pacs\\config\\")[0]}\\data\\Native`,
|
25
|
-
storagePath:
|
30
|
+
storagePath: DataNativeFolder,
|
26
31
|
webserverPort: 5001,
|
27
32
|
qidoMinChars: 0, // do not issue c-find if search contains less characters
|
28
33
|
qidoAppendWildcard: true, // auto append * for patient name query
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "modified-dicom-pacs",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.5",
|
4
4
|
"description": "A modified version of DICOM PACS implementation",
|
5
5
|
"main": "app.js",
|
6
6
|
"scripts": {
|
@@ -9,7 +9,7 @@
|
|
9
9
|
},
|
10
10
|
"repository": {
|
11
11
|
"type": "git",
|
12
|
-
"url": "
|
12
|
+
"url": "https://github.com/knopkem/dicomweb-pacs"
|
13
13
|
},
|
14
14
|
"keywords": [
|
15
15
|
"DICOMWEB",
|
@@ -22,9 +22,9 @@
|
|
22
22
|
"dicomweb-pacs": "bin/dicomweb-pacs"
|
23
23
|
},
|
24
24
|
"bugs": {
|
25
|
-
"url": "https://github.com/
|
25
|
+
"url": "https://github.com/knopkem/dicomweb-pacs/issues"
|
26
26
|
},
|
27
|
-
"homepage": "https://github.com/
|
27
|
+
"homepage": "https://github.com/knopkem/dicomweb-pacs#readme",
|
28
28
|
"dependencies": {
|
29
29
|
"config": "^3.3.9",
|
30
30
|
"dicom-data-dictionary": "^0.3.1",
|
package/src/app.js
CHANGED
@@ -10,11 +10,12 @@ const dimse = require('dicom-dimse-native');
|
|
10
10
|
const fs1 = require('fs-extra');
|
11
11
|
// let DataNativeFolder = `${__dirname.split("\\node_modules\\dicomweb-pacs\\")[0]}\\data\\Native`;
|
12
12
|
// let DataNativeFolder = `${__dirname.split('\\DicomPacs\\dicomweb-pacs\\src')[0]}\\data\\Native`;
|
13
|
-
console.log("checkpath=-=-", `${__dirname.split('\\webpacsApp')[0]}\\data\\Native`);
|
14
|
-
let DataNativeFolder = `${__dirname.split('\\webpacsApp')[0]}\\data\\Native`;
|
15
|
-
console.log("checkpath after=-=-", DataNativeFolder);
|
16
13
|
|
17
|
-
let
|
14
|
+
let baseDir = path.resolve(__dirname.split('webpacsApp')[0]);
|
15
|
+
let DataNativeFolder = path.join(baseDir, 'data', 'Native');
|
16
|
+
let DataTargerFolder = path.join(baseDir, 'data', 'Target');
|
17
|
+
let getTxtFile = path.join(baseDir, 'webpacsApp', 'calling.txt');
|
18
|
+
let databaseFile = path.join(baseDir, 'database.sqlite3');
|
18
19
|
|
19
20
|
// console.log(`${__dirname.split("\\\Pacs2\\dicomweb-pacs\\src")[0]}\\database.sqlite3`,"*******Path DataNative********")
|
20
21
|
console.log(DataNativeFolder, '*******Path DataNative********');
|
@@ -307,7 +308,7 @@ fastify.listen(port, '0.0.0.0', (err, address) => {
|
|
307
308
|
var preAetLength;
|
308
309
|
|
309
310
|
//connection starts
|
310
|
-
let db = new sqlite3.Database(
|
311
|
+
let db = new sqlite3.Database(databaseFile, sqlite3.OPEN_READWRITE, (err) => {
|
311
312
|
if (err) {
|
312
313
|
return console.error('line 11 database err', err.message);
|
313
314
|
}
|
@@ -335,7 +336,7 @@ fastify.listen(port, '0.0.0.0', (err, address) => {
|
|
335
336
|
newAetLength = await rows.length;
|
336
337
|
});
|
337
338
|
|
338
|
-
await console.log('preAetLength', preAetLength, 'newAetLength', newAetLength);
|
339
|
+
// await console.log('preAetLength', preAetLength, 'newAetLength', newAetLength);
|
339
340
|
|
340
341
|
if (newAetLength != preAetLength && newAetLength != 'undefined' && newAetLength != '' && newAetLength != null) {
|
341
342
|
console.log('chalaaaaa');
|
@@ -371,13 +372,13 @@ fastify.listen(port, '0.0.0.0', (err, address) => {
|
|
371
372
|
//database target work srats
|
372
373
|
// read data from database target starts
|
373
374
|
setInterval(() => {
|
374
|
-
console.log('MsourceMsourceMsourceMsource', Msource);
|
375
|
+
// console.log('MsourceMsourceMsourceMsource', Msource);
|
375
376
|
|
376
377
|
sql = `SELECT * FROM TargetNode`;
|
377
378
|
db.all(sql, [], (err, rows) => {
|
378
379
|
if (err) return console.error('line 306 database error', err.message);
|
379
380
|
|
380
|
-
console.log('db appjssssssssssssss', rows, 'length=', rows.length);
|
381
|
+
// console.log('db appjssssssssssssss', rows, 'length=', rows.length);
|
381
382
|
|
382
383
|
if (rows.length > 0) {
|
383
384
|
console.log('yes target exist');
|
@@ -388,7 +389,7 @@ fastify.listen(port, '0.0.0.0', (err, address) => {
|
|
388
389
|
// j.target = j.source;
|
389
390
|
j.target = rows[0];
|
390
391
|
// j.sourcePath = path.join(__dirname, '../../../data/Target');
|
391
|
-
j.sourcePath =
|
392
|
+
j.sourcePath = DataTargerFolder;
|
392
393
|
// j.sourcePath = path.join(__dirname, '../export');
|
393
394
|
j.verbose = true;
|
394
395
|
dimse.storeScu(j, (result) => {
|
@@ -397,12 +398,12 @@ fastify.listen(port, '0.0.0.0', (err, address) => {
|
|
397
398
|
console.log(JSON.parse(result));
|
398
399
|
if (JSON.parse(result).message == 'request succeeded' || JSON.parse(result).message == 'Failed to send DICOM files to target') {
|
399
400
|
// fs1.emptyDirSync(path.join(__dirname, '../../../data/Target'));
|
400
|
-
fs1.emptyDirSync(
|
401
|
+
fs1.emptyDirSync(DataTargerFolder);
|
401
402
|
}
|
402
403
|
|
403
404
|
if (JSON.parse(result).message == 'Target not set') {
|
404
405
|
// fs1.emptyDirSync(path.join(__dirname, '../../../data/Target'));
|
405
|
-
fs1.emptyDirSync(
|
406
|
+
fs1.emptyDirSync(DataTargerFolder);
|
406
407
|
}
|
407
408
|
} catch (e) {
|
408
409
|
console.error(e, result);
|
@@ -427,6 +428,7 @@ fastify.listen(port, '0.0.0.0', (err, address) => {
|
|
427
428
|
|
428
429
|
//----------------------------------------change froldes starts-----------------------------
|
429
430
|
setInterval(() => {
|
431
|
+
// console.log("chnage folder setInterval running");
|
430
432
|
fs.stat(DataNativeFolder, (err, stats) => {
|
431
433
|
if (err) {
|
432
434
|
console.log("check err is 432", err);
|
package/src/start-server.js
CHANGED
@@ -1,229 +1,221 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env node
|
2
|
+
"use strict";
|
2
3
|
const config = require('config');
|
3
4
|
var fs = require('fs');
|
4
5
|
const fs1 = require('fs-extra');
|
6
|
+
const path = require('path');
|
5
7
|
var spawn = require('child_process').spawn;
|
8
|
+
console.log("startServer runs?");
|
6
9
|
|
7
|
-
|
10
|
+
// console.log("Current __dirname:", __dirname);
|
11
|
+
let baseDir = path.resolve(__dirname.split('webpacsApp')[0]);
|
12
|
+
// console.log("baseDir", baseDir);
|
8
13
|
|
9
|
-
|
10
|
-
let getTxtFile = `${__dirname.split('\\webpacsApp')[0]}\\webpacsApp\\node_modules\\dicomweb-pacs\\getText.txt`;
|
11
|
-
let DataNativeFolder = `${__dirname.split('\\webpacsApp')[0]}\\data\\Native`;
|
14
|
+
console.log('starting modified-dicom-pacs...');
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
TestsTxtFile = `${__dirname.split('\\webpacsApp')[0]}\\webpacsApp\\node_modules\\dicomweb-pacs\\Testss.Txt`;
|
16
|
-
getTxtFile = `${__dirname.split('\\webpacsApp')[0]}\\webpacsApp\\node_modules\\dicomweb-pacs\\getText.txt`;
|
17
|
-
DataNativeFolder = `${__dirname.split('\\webpacsApp')[0]}\\data\\Native`;
|
18
|
-
}
|
16
|
+
process.chdir('./node_modules/modified-dicom-pacs');
|
17
|
+
const ls = spawn('node', ['src/app.js']);
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
let TestsTxtFile = path.join(baseDir, 'webpacsApp', 'node_modules', 'modified-dicom-pacs', 'Testss.Txt');
|
20
|
+
let getTxtFile = path.join(baseDir, 'webpacsApp', 'node_modules', 'modified-dicom-pacs', 'getText.txt');
|
21
|
+
let DataNativeFolder = path.join(baseDir, 'data', 'Native');
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
ls.stdout.on('data', (data) => {
|
24
|
+
console.log(`stdout mao out: ${data}`)
|
25
|
+
});
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
ls.stderr.on('data', (data) => {
|
28
|
+
|
29
|
+
fs.appendFileSync(TestsTxtFile, data);
|
30
|
+
const contents2 = fs.readFileSync(TestsTxtFile, 'utf-8');
|
31
31
|
|
32
|
-
|
32
|
+
var newString = contents2.toString();
|
33
33
|
|
34
|
-
|
34
|
+
let result1 = newString.replace(/\s/g, '');
|
35
35
|
|
36
|
-
|
36
|
+
let result2 = result1.replace(/['"]+/g, '');
|
37
37
|
|
38
|
-
|
38
|
+
const citrus = result2.slice(result2.indexOf("I:AssociationReceived") + 37, result2.indexOf("I:AssociationReceived") + 75);
|
39
39
|
|
40
|
-
|
40
|
+
var mySubString = citrus.substring(
|
41
|
+
citrus.indexOf(":") + 1,
|
42
|
+
citrus.lastIndexOf("->")
|
43
|
+
);
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
mySubString.length < 20 &&
|
46
|
-
!mySubString.includes(':') &&
|
47
|
-
!mySubString.includes('.') &&
|
48
|
-
!mySubString.includes('&')
|
49
|
-
) {
|
50
|
-
fs.writeFileSync(getTxtFile, mySubString);
|
51
|
-
}
|
45
|
+
if(mySubString != "DICOMWEB_PACS" && mySubString.length > 2 && mySubString.length < 20 && !mySubString.includes(":") && !mySubString.includes(".") && !mySubString.includes("&")){
|
46
|
+
fs.writeFileSync(getTxtFile, mySubString);
|
47
|
+
}
|
52
48
|
|
53
|
-
|
49
|
+
|
50
|
+
//latest code
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
//1. catch edit aet and create folder.
|
53
|
+
const gettext = fs.readFileSync(getTxtFile, 'utf8');
|
54
|
+
console.log("gettext", gettext);
|
58
55
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
}catch(err){
|
63
|
-
console.log("check err is 63", err);
|
56
|
+
//read folders in Native
|
57
|
+
const getfolder = fs.readdirSync(DataNativeFolder);
|
58
|
+
console.log("getfolder", getfolder);
|
64
59
|
|
60
|
+
const getfolder2 = getfolder.filter((cur) => cur != "image.db");
|
61
|
+
|
62
|
+
//get latest time folder then replace with desktop name
|
63
|
+
let dateaArr = [];
|
64
|
+
let nameOfLatestFolder = "";
|
65
|
+
for(var i = 0; i < getfolder2.length - 1; i++){
|
66
|
+
|
67
|
+
fs.stat(`${DataNativeFolder}/${getfolder2[i]}`, (error, stats) => {
|
68
|
+
// in case of any error
|
69
|
+
if (error) {
|
70
|
+
console.log(error);
|
71
|
+
return;
|
65
72
|
}
|
66
|
-
|
67
|
-
console.log(
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
//
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
// in case of any error
|
77
|
-
if (error) {
|
78
|
-
console.log("check err is 72", error);
|
79
|
-
return;
|
80
|
-
}
|
81
|
-
// else show creation time from stats object
|
82
|
-
console.log('File created at: ', stats.birthtime);
|
83
|
-
dateaArr.push(stats.birthtime);
|
84
|
-
console.log('dateaArr === ', dateaArr);
|
85
|
-
console.log('Folders === ', getfolder2);
|
86
|
-
//find latest created folder
|
87
|
-
var largest = 0;
|
88
|
-
for (i = 0; i < dateaArr.length; i++) {
|
89
|
-
if (dateaArr[i] > largest) {
|
90
|
-
largest = dateaArr[i];
|
91
|
-
}
|
73
|
+
// else show creation time from stats object
|
74
|
+
console.log("File created at: ", stats.birthtime);
|
75
|
+
dateaArr.push(stats.birthtime);
|
76
|
+
console.log("dateaArr === ", dateaArr);
|
77
|
+
console.log("Folders === ", getfolder2);
|
78
|
+
//find latest created folder
|
79
|
+
var largest= 0;
|
80
|
+
for (i=0; i<dateaArr.length; i++){
|
81
|
+
if (dateaArr[i]>largest) {
|
82
|
+
largest=dateaArr[i];
|
92
83
|
}
|
93
|
-
//find index of latest created folder and name of that folder
|
94
|
-
const indexOfLatestDate = dateaArr.indexOf(largest);
|
95
|
-
nameOfLatestFolder = getfolder2[indexOfLatestDate];
|
96
|
-
});
|
97
84
|
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
// console.log("start");
|
102
|
-
// fs.readFile(getTxtFile, 'utf8', function(err, data){
|
103
|
-
// if(data){
|
104
|
-
// if(data != "DICOMWEB_PACS"){
|
105
|
-
// var dir = `${DataNativeFolder}/${data}`;
|
106
|
-
// // if (!fs.existsSync(dir)){
|
107
|
-
// // fs.mkdirSync(dir);
|
108
|
-
// // }
|
109
|
-
// }
|
110
|
-
// }else{
|
111
|
-
// console.log("see data", err);
|
112
|
-
// }
|
113
|
-
// });
|
114
|
-
// }, 1000);
|
115
|
-
|
116
|
-
// //now sote incoming file in date folder, date can be created wehn file sent
|
117
|
-
// setTimeout(() => {
|
118
|
-
// if(nameOfLatestFolder.includes(".")){
|
119
|
-
// const src = `${DataNativeFolder}/${nameOfLatestFolder}`
|
120
|
-
// const d = new Date();
|
121
|
-
// const day = d.getDate();
|
122
|
-
// const year = d.getFullYear();
|
123
|
-
// const month = d.getMonth() + 1;
|
124
|
-
// let finalDate = `${year}${month}${day}`
|
125
|
-
// const dest = `${DataNativeFolder}/${gettext}/${finalDate}/${nameOfLatestFolder}`
|
126
|
-
// if(gettext != "DICOMWEB_PACS" && gettext.length > 2 && gettext.length < 20){
|
127
|
-
// fs1.move(src, dest, { overwrite: false }, function(err, data){
|
128
|
-
// if(data){
|
129
|
-
// console.log("files has been succcessfully moved", data);
|
130
|
-
// }else{
|
131
|
-
// console.log("files has not been moved", err);
|
132
|
-
// }
|
133
|
-
// });
|
134
|
-
// }
|
135
|
-
// }
|
136
|
-
// }, 12000);
|
137
|
-
|
138
|
-
// //----------------------------------------reading tags starts-----------------------------
|
139
|
-
// setInterval(() => {
|
140
|
-
// fs.stat(DataNativeFolder, (err, stats) => {
|
141
|
-
// if (err) {
|
142
|
-
// throw err
|
143
|
-
// }
|
144
|
-
|
145
|
-
// var diff = Math.abs(new Date() - stats.ctime);
|
146
|
-
// function millisToMinutesAndSeconds(millis) {
|
147
|
-
// var minutes = Math.floor(millis / 60000);
|
148
|
-
// var seconds = ((millis % 60000) / 1000).toFixed(0);
|
149
|
-
// return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
|
150
|
-
// }
|
151
|
-
// // console.log("differencedifferencedifference=", millisToMinutesAndSeconds(diff));
|
152
|
-
|
153
|
-
// var timeSplit = millisToMinutesAndSeconds(diff).split(":");
|
154
|
-
// // console.log("splitsplitsplit", timeSplit[0]);
|
155
|
-
// // var delay = Math.ceil(files.length/25);
|
156
|
-
// console.log("change folder interval is ", timeSplit);
|
157
|
-
|
158
|
-
// if(parseInt(timeSplit[0]) >= 1 || parseInt(timeSplit[1]) >= 50){
|
159
|
-
|
160
|
-
// fs.readdir(DataNativeFolder, (err, topFolders) => {
|
161
|
-
// if (err)
|
162
|
-
// console.log(err);
|
163
|
-
// else {
|
164
|
-
// if(topFolders.length > 1){
|
165
|
-
// var Mfolders1 = topFolders.filter((cur) => cur !== 'image.db');
|
166
|
-
// var Mfolders2 = Mfolders1.filter((cur) => cur.includes("."));
|
167
|
-
|
168
|
-
// if(Mfolders2.length >= 1){
|
169
|
-
|
170
|
-
// console.log("Mfolders2Mfolders2", Mfolders2);
|
171
|
-
|
172
|
-
// const gettext = fs.readFileSync(getTxtFile, 'utf8');
|
173
|
-
// console.log("gettext", gettext);
|
174
|
-
|
175
|
-
// Mfolders2.forEach((cur) => {
|
176
|
-
|
177
|
-
// const src = `${DataNativeFolder}/${cur}`
|
178
|
-
// const d = new Date();
|
179
|
-
// const day = d.getDate();
|
180
|
-
// const year = d.getFullYear();
|
181
|
-
// const month = d.getMonth() + 1;
|
182
|
-
// let finalDate = `${year}${month}${day}`
|
183
|
-
// const dest = `${DataNativeFolder}/${gettext}/${finalDate}/${cur}`
|
184
|
-
// if(gettext != "DICOMWEB_PACS" && gettext.length > 2 && gettext.length < 20){
|
185
|
-
// fs1.move(src, dest, { overwrite: false }, function(err, data){
|
186
|
-
// if(data){
|
187
|
-
// console.log("files has been succcessfully moved", data);
|
188
|
-
// }else{
|
189
|
-
// console.log("files has not been moved", err);
|
190
|
-
// }
|
191
|
-
// });
|
192
|
-
// }
|
193
|
-
|
194
|
-
// });
|
195
|
-
|
196
|
-
// }
|
197
|
-
|
198
|
-
// }
|
199
|
-
|
200
|
-
// }
|
201
|
-
// });
|
202
|
-
|
203
|
-
// }
|
204
|
-
// })
|
205
|
-
|
206
|
-
// }, 5000);
|
207
|
-
|
208
|
-
// //--------------------------------reding tags ends-----------------------------------
|
209
|
-
|
210
|
-
setTimeout(() => {
|
211
|
-
fs.writeFileSync(TestsTxtFile, '');
|
212
|
-
console.log('set time out for test.txt clear nameOfLatestFolder', nameOfLatestFolder);
|
213
|
-
console.log('gettext length', gettext.length);
|
214
|
-
|
215
|
-
if (gettext.length > 2) {
|
216
|
-
console.log('yes greater than 1', gettext.length);
|
217
|
-
} else {
|
218
|
-
console.log('no not greater than 1', gettext.length);
|
219
|
-
}
|
220
|
-
}, 2000);
|
221
|
-
console.error(`stderr mao err: ${data}`);
|
222
|
-
});
|
223
|
-
|
224
|
-
ls.on('close', (code) => {
|
225
|
-
console.log(`child process exited with code ${code}`);
|
85
|
+
//find index of latest created folder and name of that folder
|
86
|
+
const indexOfLatestDate = dateaArr.indexOf(largest);
|
87
|
+
nameOfLatestFolder = getfolder2[indexOfLatestDate];
|
226
88
|
});
|
227
89
|
}
|
228
90
|
|
229
|
-
|
91
|
+
//create folder of gettext
|
92
|
+
// setTimeout(() => {
|
93
|
+
// console.log("start");
|
94
|
+
// fs.readFile(getTxtFile, 'utf8', function(err, data){
|
95
|
+
// if(data){
|
96
|
+
// if(data != "DICOMWEB_PACS"){
|
97
|
+
// var dir = `${DataNativeFolder}/${data}`;
|
98
|
+
// // if (!fs.existsSync(dir)){
|
99
|
+
// // fs.mkdirSync(dir);
|
100
|
+
// // }
|
101
|
+
// }
|
102
|
+
// }else{
|
103
|
+
// console.log("see data", err);
|
104
|
+
// }
|
105
|
+
// });
|
106
|
+
// }, 1000);
|
107
|
+
|
108
|
+
// //now sote incoming file in date folder, date can be created wehn file sent
|
109
|
+
// setTimeout(() => {
|
110
|
+
// if(nameOfLatestFolder.includes(".")){
|
111
|
+
// const src = `${DataNativeFolder}/${nameOfLatestFolder}`
|
112
|
+
// const d = new Date();
|
113
|
+
// const day = d.getDate();
|
114
|
+
// const year = d.getFullYear();
|
115
|
+
// const month = d.getMonth() + 1;
|
116
|
+
// let finalDate = `${year}${month}${day}`
|
117
|
+
// const dest = `${DataNativeFolder}/${gettext}/${finalDate}/${nameOfLatestFolder}`
|
118
|
+
// if(gettext != "DICOMWEB_PACS" && gettext.length > 2 && gettext.length < 20){
|
119
|
+
// fs1.move(src, dest, { overwrite: false }, function(err, data){
|
120
|
+
// if(data){
|
121
|
+
// console.log("files has been succcessfully moved", data);
|
122
|
+
// }else{
|
123
|
+
// console.log("files has not been moved", err);
|
124
|
+
// }
|
125
|
+
// });
|
126
|
+
// }
|
127
|
+
// }
|
128
|
+
// }, 12000);
|
129
|
+
|
130
|
+
// //----------------------------------------reading tags starts-----------------------------
|
131
|
+
// setInterval(() => {
|
132
|
+
// fs.stat(DataNativeFolder, (err, stats) => {
|
133
|
+
// if (err) {
|
134
|
+
// throw err
|
135
|
+
// }
|
136
|
+
|
137
|
+
// var diff = Math.abs(new Date() - stats.ctime);
|
138
|
+
// function millisToMinutesAndSeconds(millis) {
|
139
|
+
// var minutes = Math.floor(millis / 60000);
|
140
|
+
// var seconds = ((millis % 60000) / 1000).toFixed(0);
|
141
|
+
// return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
|
142
|
+
// }
|
143
|
+
// // console.log("differencedifferencedifference=", millisToMinutesAndSeconds(diff));
|
144
|
+
|
145
|
+
// var timeSplit = millisToMinutesAndSeconds(diff).split(":");
|
146
|
+
// // console.log("splitsplitsplit", timeSplit[0]);
|
147
|
+
// // var delay = Math.ceil(files.length/25);
|
148
|
+
// console.log("change folder interval is ", timeSplit);
|
149
|
+
|
150
|
+
// if(parseInt(timeSplit[0]) >= 1 || parseInt(timeSplit[1]) >= 50){
|
151
|
+
|
152
|
+
|
153
|
+
// fs.readdir(DataNativeFolder, (err, topFolders) => {
|
154
|
+
// if (err)
|
155
|
+
// console.log(err);
|
156
|
+
// else {
|
157
|
+
// if(topFolders.length > 1){
|
158
|
+
// var Mfolders1 = topFolders.filter((cur) => cur !== 'image.db');
|
159
|
+
// var Mfolders2 = Mfolders1.filter((cur) => cur.includes("."));
|
160
|
+
|
161
|
+
// if(Mfolders2.length >= 1){
|
162
|
+
|
163
|
+
// console.log("Mfolders2Mfolders2", Mfolders2);
|
164
|
+
|
165
|
+
// const gettext = fs.readFileSync(getTxtFile, 'utf8');
|
166
|
+
// console.log("gettext", gettext);
|
167
|
+
|
168
|
+
// Mfolders2.forEach((cur) => {
|
169
|
+
|
170
|
+
// const src = `${DataNativeFolder}/${cur}`
|
171
|
+
// const d = new Date();
|
172
|
+
// const day = d.getDate();
|
173
|
+
// const year = d.getFullYear();
|
174
|
+
// const month = d.getMonth() + 1;
|
175
|
+
// let finalDate = `${year}${month}${day}`
|
176
|
+
// const dest = `${DataNativeFolder}/${gettext}/${finalDate}/${cur}`
|
177
|
+
// if(gettext != "DICOMWEB_PACS" && gettext.length > 2 && gettext.length < 20){
|
178
|
+
// fs1.move(src, dest, { overwrite: false }, function(err, data){
|
179
|
+
// if(data){
|
180
|
+
// console.log("files has been succcessfully moved", data);
|
181
|
+
// }else{
|
182
|
+
// console.log("files has not been moved", err);
|
183
|
+
// }
|
184
|
+
// });
|
185
|
+
// }
|
186
|
+
|
187
|
+
// });
|
188
|
+
|
189
|
+
|
190
|
+
// }
|
191
|
+
|
192
|
+
// }
|
193
|
+
|
194
|
+
// }
|
195
|
+
// });
|
196
|
+
|
197
|
+
// }
|
198
|
+
// })
|
199
|
+
|
200
|
+
// }, 5000);
|
201
|
+
|
202
|
+
|
203
|
+
// //--------------------------------reding tags ends-----------------------------------
|
204
|
+
|
205
|
+
setTimeout(() => {
|
206
|
+
fs.writeFileSync(TestsTxtFile, "");
|
207
|
+
console.log("set time out for test.txt clear nameOfLatestFolder", nameOfLatestFolder);
|
208
|
+
console.log("gettext length", gettext.length);
|
209
|
+
|
210
|
+
if(gettext.length > 2){
|
211
|
+
console.log("yes greater than 1", gettext.length);
|
212
|
+
}else{
|
213
|
+
console.log("no not greater than 1", gettext.length);
|
214
|
+
}
|
215
|
+
}, 2000);
|
216
|
+
console.error(`stderr mao err: ${data}`);
|
217
|
+
});
|
218
|
+
|
219
|
+
ls.on('close', (code) => {
|
220
|
+
console.log(`child process exited with code ${code}`);
|
221
|
+
});
|
package/src/utils.js
CHANGED
@@ -8,11 +8,12 @@ const shell = require('shelljs');
|
|
8
8
|
const path = require('path');
|
9
9
|
const sqlite3 = require('sqlite3').verbose();
|
10
10
|
let sql;
|
11
|
+
let baseDir = path.resolve(__dirname.split('webpacsApp')[0]);
|
11
12
|
// // open database in memory
|
12
13
|
// console.log("path=-=", path.join(__dirname, '../../../database.sqlite3'));
|
13
|
-
|
14
|
+
let databaseFile = path.join(baseDir, 'database.sqlite3');
|
14
15
|
//connect to db
|
15
|
-
let db = new sqlite3.Database(
|
16
|
+
let db = new sqlite3.Database(databaseFile, sqlite3.OPEN_READWRITE, (err) => {
|
16
17
|
if (err) {
|
17
18
|
return console.error('line 11 database err', err.message);
|
18
19
|
}
|