sfbrigade / sf-lifeline

GNU Affero General Public License v3.0
7 stars 4 forks source link

[Closes #45] Admin/Staff/Volunteer can search allergy/medication/condition data #70

Closed samau3 closed 4 months ago

samau3 commented 7 months ago

Closes #45.

This PR creates three protected routes that correspond to querying the allergy, medication, and condition tables of the database.

Allergy Demo

samau3 commented 4 months ago

Thanks for the feedback @francisli!

return all the attributes of the corresponding object (id, name, type, system, code, etc) so that the caller has everything they might need.

I've updated all the three routes to return all attributes instead of just the name.

For the pagination, you're manually specifying the take parameter, doing the count, and formatting a string with the results. However, there are some pagination helpers that have since been added into the codebase that you can use

See server/routes/api/v1/users/list.js for an example of how these helpers are used. The query helper is in server/prisma/client.js and the response helper (which sets the pagination values in headers) is in server/plugins/pagination.js.

I've updated the routes to use the helpers rather than the manual formatting I had before.