Skip to content

Commit aa94e8d

Browse files
author
Sarah Drury
committed
Merge branch 'main' of https://github.com/thomasbeck95/CTM
2 parents 60ca4ca + 119b5ed commit aa94e8d

File tree

3 files changed

+214
-84
lines changed

3 files changed

+214
-84
lines changed

.github/workflows/fortify.yml

-84
This file was deleted.

javascript_prototype/index.html

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<title>Task Manager Demo</title>
7+
<style>
8+
.hidden {
9+
display: none;
10+
}
11+
12+
.card {
13+
border: 1px solid #333;
14+
padding: 1rem;
15+
margin: 0.5rem 0;
16+
}
17+
18+
.modal-backdrop {
19+
position: fixed;
20+
inset: 0;
21+
background: rgba(0, 0, 0, 0.3);
22+
}
23+
24+
.modal-backdrop.hidden {
25+
display: none;
26+
}
27+
28+
.modal {
29+
background: white;
30+
margin: 5rem auto;
31+
max-width: 500px;
32+
padding: 1rem;
33+
}
34+
</style>
35+
</head>
36+
37+
<body>
38+
<h1>Task Manager Demo</h1>
39+
40+
<!-- FORM to add a new task -->
41+
<form id="taskForm">
42+
<label>Task Type:</label>
43+
<select name="task_type">
44+
<option value="PrescriptionRequest">Prescription Request</option>
45+
<option value="ReviewResults">Review Results</option>
46+
<option value="PatientCommunication">Patient Communication</option>
47+
<option value="SickNotes">Sick Notes</option>
48+
<option value="ReferralLetters">Referral Letters</option>
49+
<option value="MedicalReports">Medical Reports</option>
50+
</select>
51+
52+
<label>Time in pipeline (days):</label>
53+
<input type="number" name="time_in_pipeline" value="1" />
54+
55+
<!-- Add any other fields you want, e.g. checkboxes for comorbidities, etc. -->
56+
<button type="submit">Add Task</button>
57+
</form>
58+
59+
<hr />
60+
61+
<h2>Tasks</h2>
62+
<div id="tasks"></div>
63+
64+
<!-- Simple modal for editing tasks -->
65+
<div class="modal-backdrop hidden">
66+
<div class="modal">
67+
<form id="editForm">
68+
<h3>Edit Task</h3>
69+
<label>Task Type:</label>
70+
<select name="task_type">
71+
<option value="PrescriptionRequest">Prescription Request</option>
72+
<option value="ReviewResults">Review Results</option>
73+
<option value="PatientCommunication">Patient Communication</option>
74+
<option value="SickNotes">Sick Notes</option>
75+
<option value="ReferralLetters">Referral Letters</option>
76+
<option value="MedicalReports">Medical Reports</option>
77+
</select>
78+
79+
<label>Time in pipeline (days):</label>
80+
<input type="number" name="time_in_pipeline" />
81+
82+
<!-- More fields as needed -->
83+
84+
<button id="saveButton" type="submit">Save</button>
85+
<button id="cancelButton" type="button">Cancel</button>
86+
</form>
87+
</div>
88+
</div>
89+
90+
<script src="./main.js"></script>
91+
</body>
92+
93+
</html>

javascript_prototype/main.js

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
function scoreTask(task) {
2+
3+
const taskTypeScores = {
4+
PrescriptionRequest: 3,
5+
ReviewResults: 3,
6+
PatientCommunication: 1,
7+
SickNotes: 1,
8+
ReferralLetters: 1,
9+
MedicalReports: 1,
10+
};
11+
12+
const baseScore = taskTypeScores[task.task_type] || 0;
13+
const timeDays = Number(task.time_in_pipeline) || 0;
14+
const timingPenalty = 0.1 * (timeDays * timeDays);
15+
16+
return baseScore + timingPenalty;
17+
}
18+
19+
const taskForm = document.querySelector("#taskForm");
20+
const taskContainer = document.querySelector("#tasks");
21+
const modalBackdrop = document.querySelector(".modal-backdrop");
22+
const editForm = document.querySelector("#editForm");
23+
24+
let tasks = JSON.parse(localStorage.getItem("tasks")) || [];
25+
26+
// 1) RENDER TASKS
27+
function renderTasks() {
28+
// Clear the container
29+
taskContainer.innerHTML = "";
30+
31+
// Sort tasks by severity descending
32+
// We recalculate severity each time because
33+
// it might have changed if user edits
34+
tasks.forEach((task) => {
35+
task.severity = scoreTask(task);
36+
});
37+
tasks.sort((a, b) => b.severity - a.severity);
38+
39+
tasks.forEach((task, i) => {
40+
const card = document.createElement("div");
41+
card.classList.add("card");
42+
const heading = document.createElement("h4");
43+
heading.textContent = `${task.task_type} (score: ${task.severity.toFixed(2)})`;
44+
45+
// Example: show time in pipeline
46+
const pTime = document.createElement("p");
47+
pTime.textContent = `Time in pipeline: ${task.time_in_pipeline} days`;
48+
49+
// “Delete” button
50+
const delBut = document.createElement("button");
51+
delBut.innerText = "Delete";
52+
delBut.addEventListener("click", function () {
53+
tasks.splice(i, 1);
54+
saveTasks();
55+
renderTasks();
56+
});
57+
58+
// “Edit” button
59+
const editBut = document.createElement("button");
60+
editBut.innerText = "Edit";
61+
editBut.addEventListener("click", function () {
62+
openEditForm(task, i);
63+
});
64+
65+
card.appendChild(heading);
66+
card.appendChild(pTime);
67+
card.appendChild(delBut);
68+
card.appendChild(editBut);
69+
taskContainer.appendChild(card);
70+
});
71+
}
72+
73+
// 2) ADD A NEW TASK
74+
taskForm.addEventListener("submit", function (event) {
75+
event.preventDefault();
76+
const newTask = {
77+
task_type: taskForm.task_type.value,
78+
time_in_pipeline: taskForm.time_in_pipeline.value,
79+
// If you had more fields, you'd gather them here
80+
};
81+
tasks.push(newTask);
82+
saveTasks();
83+
renderTasks();
84+
});
85+
86+
// 3) EDIT TASK
87+
function openEditForm(task, index) {
88+
modalBackdrop.classList.remove("hidden");
89+
90+
// Fill in form with existing values
91+
editForm.task_type.value = task.task_type;
92+
editForm.time_in_pipeline.value = task.time_in_pipeline;
93+
94+
// Swap out the old “saveButton” event so it doesn’t stack
95+
const saveButton = document.querySelector("#saveButton");
96+
// In case a prior open edit used the same button
97+
saveButton.onclick = function (e) {
98+
e.preventDefault();
99+
// Update the existing task
100+
tasks[index].task_type = editForm.task_type.value;
101+
tasks[index].time_in_pipeline = editForm.time_in_pipeline.value;
102+
103+
saveTasks();
104+
renderTasks();
105+
closeModal();
106+
};
107+
}
108+
109+
// 4) CANCEL EDIT
110+
document.querySelector("#cancelButton").addEventListener("click", closeModal);
111+
function closeModal() {
112+
modalBackdrop.classList.add("hidden");
113+
}
114+
115+
// 5) SAVE to localStorage
116+
function saveTasks() {
117+
localStorage.setItem("tasks", JSON.stringify(tasks));
118+
}
119+
120+
// 6) INITIAL RENDER
121+
renderTasks();

0 commit comments

Comments
 (0)