Thoughts on my approach (before beginning):
- Create a ScheduleVisit model, include the fields in the request:
{
"start_date_time": "2023-06-26T23:00:00.000Z",
"end_date_time": "2023-06-27T22:59:59.999Z",
"client": 1,
"carer": 1
}
- Add a revision field to the model to track the latest revision
GET /schedule/latest
- Return the latest schedule, we just need to query for the maximum value of the "revision" fieldPOST /schedule
- Create a new schedulePUT /schedule/visit/{id}
- Update a schedule, if the schedule already exists we need to increment the revision fieldDELETE /schedule/{id}
- Delete a schedule, this is a "soft" delete, so we need to set a delete flag in the model, we can copy the last schedule visit for now and increment the revision + set delete. Delete should return an empty responseGET /schedule/{revision}
- Get a schedule by its revision, we can use this to get a specific revision of a schedule
python manage.py runserver