Spaces:
Sleeping
Sleeping
dylanglenister
commited on
Commit
·
cc7ea57
1
Parent(s):
2e2a4b0
Debugging
Browse files- static/js/patient.js +5 -2
static/js/patient.js
CHANGED
|
@@ -71,12 +71,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 71 |
past_assessment_summary: document.getElementById('summary').value.trim() || null
|
| 72 |
};
|
| 73 |
try {
|
|
|
|
| 74 |
if (isEditMode && currentPatientId) {
|
| 75 |
const resp = await fetch(`/patients/${currentPatientId}`, {
|
| 76 |
method: 'PATCH',
|
| 77 |
headers: { 'Content-Type': 'application/json' },
|
| 78 |
body: JSON.stringify(payload)
|
| 79 |
});
|
|
|
|
| 80 |
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 81 |
result.textContent = 'Patient updated successfully.';
|
| 82 |
result.style.color = 'green';
|
|
@@ -86,11 +88,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 86 |
headers: { 'Content-Type': 'application/json' },
|
| 87 |
body: JSON.stringify(payload)
|
| 88 |
});
|
|
|
|
| 89 |
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 90 |
const data = await resp.json();
|
| 91 |
const pid = data.patient_id;
|
| 92 |
localStorage.setItem('medicalChatbotPatientId', pid);
|
| 93 |
-
|
| 94 |
// Add to localStorage for future suggestions
|
| 95 |
const existingPatients = JSON.parse(localStorage.getItem('medicalChatbotPatients') || '[]');
|
| 96 |
const newPatient = {
|
|
@@ -105,7 +108,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 105 |
existingPatients.push(newPatient);
|
| 106 |
localStorage.setItem('medicalChatbotPatients', JSON.stringify(existingPatients));
|
| 107 |
}
|
| 108 |
-
|
| 109 |
// Show success modal (stay in create view until user opts to edit)
|
| 110 |
if (createdIdEl) createdIdEl.textContent = pid;
|
| 111 |
successModal.classList.add('show');
|
|
|
|
| 71 |
past_assessment_summary: document.getElementById('summary').value.trim() || null
|
| 72 |
};
|
| 73 |
try {
|
| 74 |
+
console.log("Start");
|
| 75 |
if (isEditMode && currentPatientId) {
|
| 76 |
const resp = await fetch(`/patients/${currentPatientId}`, {
|
| 77 |
method: 'PATCH',
|
| 78 |
headers: { 'Content-Type': 'application/json' },
|
| 79 |
body: JSON.stringify(payload)
|
| 80 |
});
|
| 81 |
+
console.log("A");
|
| 82 |
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 83 |
result.textContent = 'Patient updated successfully.';
|
| 84 |
result.style.color = 'green';
|
|
|
|
| 88 |
headers: { 'Content-Type': 'application/json' },
|
| 89 |
body: JSON.stringify(payload)
|
| 90 |
});
|
| 91 |
+
console.log("B");
|
| 92 |
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 93 |
const data = await resp.json();
|
| 94 |
const pid = data.patient_id;
|
| 95 |
localStorage.setItem('medicalChatbotPatientId', pid);
|
| 96 |
+
|
| 97 |
// Add to localStorage for future suggestions
|
| 98 |
const existingPatients = JSON.parse(localStorage.getItem('medicalChatbotPatients') || '[]');
|
| 99 |
const newPatient = {
|
|
|
|
| 108 |
existingPatients.push(newPatient);
|
| 109 |
localStorage.setItem('medicalChatbotPatients', JSON.stringify(existingPatients));
|
| 110 |
}
|
| 111 |
+
|
| 112 |
// Show success modal (stay in create view until user opts to edit)
|
| 113 |
if (createdIdEl) createdIdEl.textContent = pid;
|
| 114 |
successModal.classList.add('show');
|