-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEQRScript.js
94 lines (63 loc) · 2.42 KB
/
EQRScript.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
function generateQRCode() {
const box = document.getElementById("qrcode");
if (box.childNodes.length > 0){
document.getElementById(box).innerHTML = "";
}
// Retrieve user input values
var name = document.getElementById("name").value;
var age = document.getElementById("age").value;
var bloodType = document.getElementById("bloodType").value;
var allergies = document.getElementById("allergies").value;
var medConditions = document.getElementById("medConditions").value;
var emergencyContact1 = document.getElementById("emergencyContact1").value;
if (!name){
name = "Unknown"
}
if (!age){
age = "Unknown"
}
if (!allergies) {
allergies = "None";
}
if (!bloodType) {
bloodType = "Unknown";
} else {
bloodType.toUpperCase();
}
if (!medConditions) {
medConditions = "None";
}
if(!emergencyContact1) {
emergencyContact1 = "N/A"
}
name=name.replace(/ /g,"_");
age=age.replace(/ /g,"_");
bloodType=bloodType.replace(/ /g,"_");
allergies=allergies.replace(/ /g,"_");
medConditions=medConditions.replace(/ /g,"_");
emergencyContact1=emergencyContact1.replace(/ /g,"_");
// Create user String with the input values
var userInfo = name + ", " + age + ", " + bloodType + ", " + allergies + ", " + medConditions + ", " + emergencyContact1;
var patientInfoURL = "https://resqr.pages.dev/patientinfo.html?n=" + name + "&a=" + age + "&bl=" + bloodType + "&all=" + allergies + "&cd=" + medConditions + "&ct=" + emergencyContact1
console.log(patientInfoURL);
// Generate the QR code using a QR code library
var qrCode = new QRCode(document.getElementById("qrcode"), {
text: patientInfoURL,
width: 300,
height: 300,
});
// Create a download link for the QR code
var downloadLink = document.createElement("a");
downloadLink.href = document.getElementById("qrcode").getElementsByTagName("canvas")[0].toDataURL("image/jpeg");
downloadLink.download = "qrcode.jpg";
downloadLink.innerHTML = "Download QR Code";
document.getElementById("qrcode-container").appendChild(downloadLink);
var x = document.getElementById("viewprofile");
x.style.display = "block";
document.getElementById("viewprofile").href=patientInfoURL;
}
function prepare(){
var x = document.getElementById("viewprofile");
x.style.display = "none";
}
window.onload = prepare;