-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump_mocks2.js
More file actions
31 lines (31 loc) · 776 Bytes
/
dump_mocks2.js
File metadata and controls
31 lines (31 loc) · 776 Bytes
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
const fs = require("fs");
const path = require("path");
async function dumpPatient() {
const data = JSON.parse(
fs.readFileSync("ui/public/mock/patient.json", "utf8"),
);
if (data.patients && data.patients.length > 0) {
const firstId = data.patients[0].id;
console.log(`Fetching patient details for ${firstId}...`);
const pRes = await fetch(
`http://localhost:3000/api/patient?patientId=${encodeURIComponent(
firstId,
)}`,
);
if (pRes.ok) {
const pData = await pRes.json();
fs.writeFileSync(
"ui/public/mock/patient_default.json",
JSON.stringify(
{
id: firstId,
data: pData,
},
null,
2,
),
);
}
}
}
dumpPatient();