Skip to content

Commit 2fb85ad

Browse files
authored
Merge pull request #186 from CodeForPhilly/update-queues-163
Update queues 163
2 parents d1dfada + c89058c commit 2fb85ad

22 files changed

+1156
-948
lines changed

core/management/commands/seed.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
DEFAULT_DEV_ENV_PASS = "password123"
3131
DEFAULT_GROUPS = [FRONT_DESK, CASE_MANAGER, ADMIN]
32-
DEFAULT_NUMBER_PARTICIPANTS = 10
32+
DEFAULT_NUMBER_PARTICIPANTS = 1000
3333
DEFAULT_NUMBER_VISITS = 100
3434
DEFAULT_NUMBER_INSURERS = 10
3535

@@ -290,7 +290,6 @@ def create_visits(output=True, uds=True, medication=True):
290290
)
291291
)
292292

293-
294293
def create_event(visit, type):
295294
"""Create a FrontDeskEvent for thie visit and of this type, e.g. ARRIVED, STEPPED_OUT. Events are created now(), i.e. today"""
296295
f = FrontDeskEvent()
@@ -299,32 +298,21 @@ def create_event(visit, type):
299298
f.full_clean()
300299
f.save()
301300

302-
303301
def arrived(visit):
304302
"""After ARRIVED, can be either LEFT, SEEN, STEPPED_OUT or pending (still in ARRIVED status)"""
305303
create_event(visit, "ARRIVED")
306304
random.choice([left, seen, stepped_out, pending])(visit)
307305

308-
309306
def left(visit):
310307
create_event(visit, "LEFT")
311308

312-
313309
def seen(visit):
314310
create_event(visit, "SEEN")
315311

316-
317312
def stepped_out(visit):
318-
"""After STEPPED_OUT can be either LEFT, CAME_BACK or pending (still in STEPPED_OUT status)"""
313+
"""After STEPPED_OUT can be either LEFT, ARRIVED or pending (still in STEPPED_OUT status)"""
319314
create_event(visit, "STEPPED_OUT")
320-
random.choice([left, came_back, pending])(visit)
321-
322-
323-
def came_back(visit):
324-
"""After CAME_BACK, either LEFT, SEEN or pending (still in CAME_BACK status)"""
325-
create_event(visit, "CAME_BACK")
326-
random.choice([left, seen, pending])(visit)
327-
315+
random.choice([left, arrived, pending])(visit)
328316

329317
def pending(visit):
330318
pass

core/models/visit.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77

88
class UrgencyLevel(Enum):
9-
ONE = 1
10-
TWO = 2
11-
THREE = 3
12-
FOUR = 4
13-
FIVE = 5
9+
_1 = 1
10+
_2 = 2
11+
_3 = 3
12+
_4 = 4
13+
_5 = 5
1414

1515

1616
class Visit(models.Model):
@@ -21,4 +21,4 @@ class Visit(models.Model):
2121
ProgramServiceMap, null=True, on_delete=models.CASCADE
2222
)
2323
notes = models.TextField("Visit Notes", null=True, blank=True)
24-
urgency = models.CharField(choices=URGENCY_LEVEL, max_length=20, default=UrgencyLevel.ONE)
24+
urgency = models.CharField(choices=URGENCY_LEVEL, max_length=20, default=UrgencyLevel._1)

core/queue/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def retrieve(self, request, program_id=None):
2828
visits_queryset = Visit.objects.filter(
2929
program_service_map__program_id=program_id,
3030
created_at__date=datetime.date.today(),
31-
)
31+
).order_by("urgency", "-created_at")
3232

3333
todays_visit_data = VisitWithPopulationSerializer(
3434
visits_queryset, many=True, context={'request': request}

core/tests/visits.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_create_visit(self):
3737
"program": 1,
3838
"service": 1,
3939
"notes": "hello prevention point",
40-
"urgency": "ONE",
40+
"urgency": "_1",
4141
}
4242
response = self.client.post(url, data, format="json", follow=True, **headers)
4343

@@ -56,7 +56,7 @@ def test_update_visit_notes(self):
5656
"participant": 1,
5757
"program": 1,
5858
"service": 1,
59-
"urgency": UrgencyLevel.TWO.name,
59+
"urgency": "_2",
6060
}
6161
create_response = self.client.post(
6262
"/api/visits/", data, format="json", **headers
@@ -91,7 +91,7 @@ def test_get_visits(self):
9191
"program": 1,
9292
"service": 2,
9393
"notes": "hello prevention point",
94-
"urgency": UrgencyLevel.THREE.name,
94+
"urgency": "_3",
9595
}
9696
post_response = self.client.post(url, data, format="json", **headers)
9797
self.assertEqual(post_response.status_code, status.HTTP_201_CREATED)
@@ -132,7 +132,7 @@ def test_create_visit_and_medical_data(self):
132132
"participant_id": 1,
133133
"program_service_map_id": 1,
134134
"notes": "hello prevention point",
135-
"urgency": UrgencyLevel.TWO.name,
135+
"urgency": "_2",
136136
}
137137

138138
visit = Visit.objects.create(**new_visit)

frontend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"mobx-react-lite": "^1.3.0",
6161
"moment": "^2.24.0",
6262
"node-sass": "^4.11.0",
63-
"object-hash": "^2.0.0",
6463
"prop-types": "^15.7.2",
6564
"react": "^16.3.0",
6665
"react-dom": "^16.3.0",

frontend/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const App = observer(() => {
2828
}
2929
}
3030
stillAuthenticated()
31+
//Suppress eslint error for []
32+
//eslint-disable-next-line react-hooks/exhaustive-deps
3133
}, []) // Hooks equivalent to "componentDidMount"
3234

3335
if (rootStore.authStore.isAuthenticated === null) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const getFrontDeskEvent = api => async id =>
2+
await api.get(`front-desk-events/${id}/`)
3+
4+
export const postFrontDeskEvent = api => async data =>
5+
await api.post("front-desk-events/", data)
6+
7+
export const patchFrontDeskEvent = api => async (id, data) =>
8+
await api.patch(`front-desk-events/${id}/`, data)

frontend/src/api/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import refreshAuthLogic from "./refreshAuthLogic"
44
import { getParticipants } from "./participantEndpoints"
55
import { createToken, verifyToken } from "./authEndpoints"
66
import { getQueue } from "./queueEndpoints"
7-
import { getVisits, updateVisits, createVisits } from "./visitsEndpoint"
7+
import { postFrontDeskEvent } from "./frontDeskEventEndpoints"
8+
import {
9+
getVisits,
10+
updateVisits,
11+
createVisits,
12+
patchVisit,
13+
} from "./visitEndpoints"
814

915
const create = () => {
1016
const api = apisauce.create({
@@ -26,10 +32,12 @@ const create = () => {
2632
createToken: createToken(api),
2733
verifyToken: verifyToken(api),
2834
getQueue: getQueue(api),
35+
postFrontDeskEvent: postFrontDeskEvent(api),
2936
getParticipants: getParticipants(api),
3037
getVisits: getVisits(api),
3138
updateVisits: updateVisits(api),
3239
createVisits: createVisits(api),
40+
patchVisit: patchVisit(api),
3341
}
3442
}
3543

frontend/src/api/visitsEndpoint.js renamed to frontend/src/api/visitEndpoints.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ export const updateVisits = api => async (id, body) =>
77

88
export const createVisits = api => async body =>
99
await api.post("/visits/", body)
10+
11+
export const patchVisit = api => async (visitId, data) =>
12+
await api.patch(`visits/${visitId}/`, data)

frontend/src/components/AllQueues.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,22 @@ function QueueTab(props) {
8787
const AllQueues = observer(() => {
8888
const queueStore = useContext(QueueStoreContext)
8989
const queueSize = Object.keys(queueStore.queues).length
90-
91-
useEffect(() => {
92-
for (let i = 1; i <= queueSize; i++) queueStore.getQueue(i)
93-
})
9490
const classes = useStyles()
9591
const [tabValue, setTabValue] = useState(0)
9692
function handleChange(event, newValue) {
9793
setTabValue(newValue)
9894
}
9995

96+
//Update all queues on first rendering
97+
useEffect(() => {
98+
for (let i = 1; i <= queueSize; i++) queueStore.getQueue(i)
99+
}, [queueSize, queueStore])
100+
101+
//Update queue of selected tab
102+
useEffect(() => {
103+
queueStore.getQueue(tabValue + 1)
104+
}, [queueStore, tabValue])
105+
100106
const tabArray = []
101107
for (let i = 1; i <= queueSize; i++) {
102108
tabArray.push(

0 commit comments

Comments
 (0)