forked from yehster/NHANESImport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
importMain.js
163 lines (132 loc) · 4.28 KB
/
importMain.js
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
var request=require('request');
var path = require('path');
var fs = require('fs');
var asyncLoop = require('node-async-loop');
var cheerio = require('cheerio');
var serverData={
server_name: 'http://192.168.249.129/libreehr'
,userid: 'admin'
,password: 'password'
}
var mysql=require('mysql');
var dbConn = mysql.createConnection({
host: 'localhost',
user : 'root',
password : 'mydbpwd',
database : 'nhanes',
multipleStatements: true
});
dbConn.connect();
var EHRConnection=require("./EHRConnection.js").EHRConnection;
var EHRconn = new EHRConnection(serverData);
var NHANESconn=require("./NHANESData.js").NHANESData(dbConn,"_g");
function createPatients()
{
NHANESconn.load_demographics().then(()=>{
console.log(NHANESconn.patient_list.length);
EHRconn.login().then((data)=>{
asyncLoop(NHANESconn.patient_list,EHRconn.createPatientLoop);
});
});
}
function loadMCQProblemData()
{
NHANESconn.load_mcq_data().then(()=>{
console.log("MCQ Data Loaded");
EHRconn.login().then((data)=>{
asyncLoop(NHANESconn.mcq_data,EHRconn.addProblemListLoop);
});
});// End load_mcq_data
}
function loadBPQProblemData()
{
NHANESconn.load_bpq_data().then(()=>{
console.log("BPQ Data Loaded");
EHRconn.login().then((data)=>{
asyncLoop(NHANESconn.bpq_data,EHRconn.addProblemListLoop);
});
});// End load_bpq_data
}
function loadDIQProblemData()
{
NHANESconn.load_diq_data().then(()=>{
console.log("DIQ Data Loaded");
console.log(JSON.stringify(NHANESconn.diq_data));
EHRconn.login().then((data)=>{
asyncLoop(NHANESconn.diq_data,EHRconn.addProblemListLoop);
});
});// End load_diq_data
}
function loadKIQ_UProblemData()
{
NHANESconn.load_kiq_u_data().then(()=>{
console.log("KIQ_U Data Loaded");
console.log(JSON.stringify(NHANESconn.kiq_u_data));
EHRconn.login().then((data)=>{
asyncLoop(NHANESconn.kiq_u_data,EHRconn.addProblemListLoop);
});
});// End load_diq_data
}
function loadRXQ_RX_Data()
{
NHANESconn.load_rxq_rx_data().then(()=>{
console.log("RXQ_RX Data Loaded");
console.log(JSON.stringify(NHANESconn.rxq_rx_data));
EHRconn.login().then((data)=>{
asyncLoop(NHANESconn.rxq_rx_data,EHRconn.addMedicationsListLoop);
});
});
}
function loadBP_Data()
{
NHANESconn.load_bpx_data().then(()=>{
console.log("BP Data loaded");
console.log(JSON.stringify(NHANESconn.bpx_data));
EHRconn.login().then((data)=>{
asyncLoop(NHANESconn.bpx_data,EHRconn.addBPDataListLoop);
});
});
}
function loadLab_Data()
{
NHANESconn.load_lab_data().then(()=>{
console.log("Lab data loaded");
EHRconn.login().then((data)=>{
asyncLoop(NHANESconn.lab_data,EHRconn.addLabDataListLoop);
});
});
}
function loadInsurance_Data()
{
NHANESconn.load_insurance_data()
.then(()=>{return EHRconn.login();})
.then(()=>{return EHRconn.addInsuranceDataLoop(NHANESconn.insurance_data);});
}
function updateDemographics()
{
NHANESconn.load_demographics()
.then(()=>{return EHRconn.login();})
.then(()=>{return EHRconn.updateDemographicsLoop(NHANESconn.patient_list);});
}
function updateSocialData()
{
NHANESconn.load_social_data()
.then(()=>{return EHRconn.login();})
.then(()=>{return EHRconn.updateSocialLoop(NHANESconn.social_data);});
// .then(()=>{return EHRconn.updateDemographicsLoop(NHANESconn.patient_list);});
}
//createPatients();
loadMCQProblemData();
//loadBPQProblemData();
//loadDIQProblemData();
//loadKIQ_UProblemData();
//loadRXQ_RX_Data();
//loadLab_Data();
//loadInsurance_Data();
//updateDemographics();
//updateSocialData();