updates to actually a working server sorta

This commit is contained in:
Chris Cochrun 2023-05-25 17:09:44 -05:00
parent 3f6fef03df
commit 9acb2b309a
2 changed files with 83 additions and 9 deletions

View file

@ -44,12 +44,13 @@
document.getElementById('warning-image').style.margin = '0';
}
if (!document.getElementById("agreement").unchecked) {
if (!document.getElementById("agreement").checked) {
document.getElementById('warning').style.visibility = 'visible';
document.getElementById('warning').style.height = '';
document.getElementById('warning').style.margin = '';
}
}
};
function submitForm(e) {
e.preventDefault();
const form = document.getElementById('form');
@ -59,11 +60,21 @@
const birthdate = new Date(data.get("birthdate"));
const age = calculate_age(birthdate);
data.append("age", age);
/* data.delete("image"); */
validate(data);
let req = new Request();
/* console.log(JSON.stringify(data)); */
fetch("http://localhost:4242/health-form", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(Object.fromEntries(data))
}).then((res) => {
console.log(res);
});
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
@ -77,8 +88,8 @@
* window.location.href = '/thankyou/'; */
}
};
xhr.open("POST", "https://n8n.tfcconnection.org/webhook-test/testy");
xhr.send(data);
/* xhr.open("POST", "http://localhost:4242/health-form"); */
/* xhr.send(data); */
console.log(data);
console.log("Hallo!");
/* window.location.replace("https://tfcconnection.org/thankyou/"); */
@ -89,7 +100,7 @@
var age_dt = new Date(diff_ms);
return Math.abs(age_dt.getUTCFullYear() - 1970);
}
};
function process() {
var covered = document.getElementById("medical-coverage").checked;

View file

@ -31,14 +31,77 @@
;; (print (format nil "Json: ~A" (com.inuoe.jzon:stringify json-obj)))
(uiop:println "Received Health Form")
(render-json json-obj)
(setq last json-obj)
(process-form json-obj)
data)))))
(defvar *last*)
(defvar last)
(defun print-hash-entry (key value)
(format t "~S: ~S~%" key value))
(defun process-form (form)
"Processes the form and sends it on"
(uiop:println (gethash "yes" form)))
(let ((firstname (gethash "firstname" form))
(lastname (gethash "lastname" form))
(parentfirstname (gethash "parentfirstname" form))
(parentlastname (gethash "parentlastname" form))
(street (gethash "street" form))
(city (gethash "city" form))
(state (gethash "state" form))
(zip (gethash "zip" form))
(cellphone (gethash "cellphone" form))
(homephone (gethash "homephone" form))
(add-emergency-contact (gethash "add-emergency-contact" form))
(add-emergency-contact-phone (gethash "add-emergency-contact-phone" form))
(doctorname (gethash "doctorname" form))
(doctorcity (gethash "doctorcity" form))
(doctorphone (gethash "doctorphone" form))
(medical-coverage (gethash "medical-coverage" form))
(insurance-name (gethash "insurance-name" form))
(policy-number (gethash "policy-number" form))
(image (gethash "image" form))
(agreement (gethash "agreement" form))
(allergies (gethash "allergies" form))
(allergies-other (gethash "allergies-other" form))
(specific-allergies (gethash "specific-allergies" form))
(allergic-treatment (gethash "allergic-treatment" form))
(conditions (gethash "conditions" form))
(tetanus-shot (gethash "tetanus-shot" form))
(swimming-ability (gethash "swimming-ability" form))
(medication-schedule (gethash "medication-schedule" form))
(other-notes (gethash "other-notes" form))
(age (gethash "age" form)))
(uiop:println firstname)
(uiop:println lastname)
(uiop:println parentfirstname)
(uiop:println parentlastname)
(uiop:println street)
(uiop:println city)
(uiop:println state)
(uiop:println zip)
(uiop:println cellphone)
(uiop:println homephone)
(uiop:println add-emergency-contact)
(uiop:println add-emergency-contact-phone)
(uiop:println doctorname)
(uiop:println doctorcity)
(uiop:println doctorphone)
(uiop:println medical-coverage)
(uiop:println insurance-name)
(uiop:println policy-number)
(uiop:println image)
(uiop:println agreement)
(uiop:println allergies)
(uiop:println allergies-other)
(uiop:println specific-allergies)
(uiop:println allergic-treatment)
(uiop:println conditions)
(uiop:println tetanus-shot)
(uiop:println swimming-ability)
(uiop:println medication-schedule)
(uiop:println other-notes)
(uiop:println age)))
(defun render-json (object)