Personal Physical Therapy is a Node.js prototype.
Purpose: an introduction to a prospective software to measure the progress of a personal physical therapy
Welcome to my case study! Here is a brief introduction with some of the reasons that led me to develop it: during my work years for a medical device company, I realised implied and essential aspects of the healthcare sector, for instance a reliable traceability of the events, the carefulness towards the sensitive data privacy, or even the pursuit of the best balance between innovative options and sustainable technological solutions… But first of all the culture of the patient's health care and the communication among the medical industry professionals and their patients, the subject of this case study.
The prototype code of this case study and all the other related information must be intended as a good starting point, even if they remain hypothetical and not exhaustive of a real development.
It is a web application with restricted access to preset user roles: physiotherapist and patient.
The user management depends on the intended use of this software, some sample:
- is it intended to be distributed to a set of clinics? The clinic staff can assign roles to the users through a dedicated administrative area
- is it an open system? Users can register on a self-service website/app
Database schema
Profiling
Table of the CRUD operations with permissions per role
|
Physiotherapist |
Patient |
|
C |
R |
U |
D |
C |
R |
U |
D |
User |
|
✔️ |
|
|
|
✔️ |
|
|
Therapy Program |
✔️ |
✔️ |
✔️ |
✔️ |
|
✔️ |
|
|
Task |
✔️ |
✔️ |
✔️ |
✔️ |
|
✔️ |
|
|
Completion |
|
|
|
|
✔️ |
✔️ |
✔️ |
✔️ |
|
Physiotherapist |
|
C |
R |
U |
D |
User |
|
✔️ |
|
|
Therapy Program |
✔️ |
✔️ |
✔️ |
✔️ |
Task |
✔️ |
✔️ |
✔️ |
✔️ |
Completion |
|
|
|
|
|
Patient |
|
C |
R |
U |
D |
User |
|
✔️ |
|
|
Therapy Program |
|
✔️ |
|
|
Task |
|
✔️ |
|
|
Completion |
✔️ |
✔️ |
✔️ |
✔️ |
Routes
// HOME
router.get('/', ensureAuthenticated, (req, res) => { ... })
// LOGIN LOGOUT
router.get('/login', (req, res) => { ... })
router.post('/login', (req, res, next) => { ... })
router.get('/logout', (req, res) => { ... })
// THERAPY PROGRAM
router.post('/therapyprograms/new', ensureAuthenticated, (req, res) => { ... })
router.post('/therapyprograms/:id/update', ensureAuthenticated, (req, res) => { ... })
router.delete('/therapyprograms/:id/delete', ensureAuthenticated, (req, res) => { ... })
router.post('/therapyprograms/:id/export', ensureAuthenticated, (req, res) => { ... })
// TASK
router.post('/tasks/new', ensureAuthenticated, (req, res) => { ... })
router.post('/tasks/:id/update', ensureAuthenticated, (req, res) => { ... })
router.delete('/tasks/:id/delete', ensureAuthenticated, (req, res) => { ... })
// COMPLETION
router.post('/completions/new', ensureAuthenticated, (req, res) => { ... })
router.post('/completions/:id/update', ensureAuthenticated, (req, res) => { ... })
router.delete('/completions/:id/delete', ensureAuthenticated, (req, res) => { ... })
Applicative and Modelling aspects
Therapy program with multiple tasks: with a preliminary JSON field would be more than enough.
For instance I would have considered a plugin like
Alpaca forms in jQuery.
But in the view of a wider development, I opted for a classical structured data related to the task completion level registration just here below…
A task can be completed multiple times. A deep dive into the model of a task completion: I wanted to take advantage of the polymorphism of MongoDB, so instead of a simple boolean status like "done", I chose to use a discriminator because it gives an extensible structure and allows to collect different kind of information according to a task type:
- the user that did it
- when the user did it
- potential notes such as issues encountered during the task (a note field is a usual request!)
- completion info according to the task type: intensity level in case of an exercise task
const ExerciseCompletion = Completion.discriminator(constants.COMPLETION_TYPES.exercise, Schema({
intensity: { type: constants.EXERCISE_INTENSITY_LEVELS, required: false }
})
)
In order to export the program results I quickly built a report with a HTML-to-PDF conversion, choosing the light
node-html-pdf which uses Phantom. For more complex and cross platform needs I may consider the super powerful and versatile
jsreport.
Ciao, I am Valentina Benedetti author of this code, I work as a freelance Programmer and help entrepreneurs, web designers and developers to create Custom Web site and Applications, especially in Ruby on Rails, Laravel, Node.js.