-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js.template
116 lines (100 loc) · 3.7 KB
/
config.js.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
'use strict';
// S4S Discovery Data Server
// File: config.js
const version = '20200814';
// Required modules
const argv = require('optimist').argv;
const fs = require('fs');
if (argv.help) {
console.log('Usage: ' + argv.$0 + ' {--dev | --development}');
process.exit();
}
var config = {};
// ----- COMMON -----
config.logLevel = 'info';
config.timezone = 'America/Los_Angeles';
config.providerConnectTimeout = 250;
config.providerRequestTimeout = 1000;
config.retries = 1;
config.minRetryTimeout = 250;
config.requestCount=50;
// ----- Per deployment -----
if (argv.dev || argv.development) {
// DEVELOPMENT
config.deploy = 'DEVELOPMENT';
config.listenPort = 8081;
config.logFile = 'discovery-data.log';
} else {
// PRODUCTION (default)
config.deploy = 'PRODUCTION';
config.listenPort = 80;
config.logFile = '/var/log/discovery-data.log';
}
// ----- Providers & Participants -----
// Get the object representing all providers:
// { "provider1-name": { group: "group-name", "base: "url", path: "path", refPath: "path", useOrg: true|false, randLow: "low", randHigh: "high" },
// ... }
config.providers = JSON.parse(fs.readFileSync('providers.json'));
// Get the object representing all participants:
// { "id1": { name: "name", flagged: true/false, gender: F/M, dob: "date", dateRange: year1-year2, valueCount: num,
// providers: [{ providerName: "name", patientId: "id"}, ... ]},
// ... }
config.participants = JSON.parse(fs.readFileSync('participants.json'));
// Return the array of available provider names
config.providerNames = function () {
let names = [];
for (let name in config.providers) {
names.push(name);
}
return names;
}
// Return the array of providers for this id/participant (each { providerName: "name", patientId: "id" })
config.providersForParticipant = function (id) {
const thisParticipant = config.participants[id];
return thisParticipant ? thisParticipant.providers : [];
}
// Return the array of group names for this id/participant
config.groupsForParticipant = function (id) {
const thisParticipant = config.participants[id];
const providersForParticipant = thisParticipant ? thisParticipant.providers : [];
let groupNames = [];
for (let thisProvider of providersForParticipant) {
let providerInfo = config.providers[thisProvider.providerName];
if (providerInfo) {
let groupName = providerInfo.group;
if (groupName && !groupNames.includes(groupName)) {
groupNames.push(groupName);
}
}
}
return groupNames;
}
// Return the array of providers for this participant and group (each { providerName: "name", patientId: "patient-id", randLow: "low", randHigh: "high" })
config.providersForGroup = function (id, groupName) {
let providersForGroup = [];
for (let providerName in config.providers) {
let thisProvider = config.providers[providerName];
if (thisProvider.group === groupName) {
let thisParticipant = config.participants[id];
let providerForParticipant = thisParticipant.providers.find(elt => elt.providerName === providerName);
if (providerForParticipant) {
providersForGroup.push({ providerName: providerName, patientId: providerForParticipant.patientId,
randLow: thisProvider.randLow, randHigh: thisProvider.randHigh });
}
}
}
return providersForGroup;
}
// ----- Data -----
config.dataName = 'Discovery';
config.uploadDir = 'uploadedData';
config.dataUploadUrl = function(id) {
return `http://THIS/data/upload/${id}`;
}
config.dataInfoUrl = 'about:blank';
config.dataContinueLabel = 'Continue';
config.dataContinueUrl = function(id) {
return `http://APP/uploaded/${id}`;
}
config.dataSuccessMessage = 'Data successfully uploaded.';
module.exports = config;