Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 44 commits into from
Jul 24, 2024

Conversation

samau3
Copy link
Contributor

@samau3 samau3 commented Apr 9, 2024

Closes #45.

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

  • Feedback is provided if no query is provided
  • A unique response if a variation of none is used
  • A not found response is provided if the query term isn't found in the respective table

Allergy Demo

samau3 added 30 commits April 4, 2024 22:17
@samau3 samau3 requested a review from francisli April 9, 2024 01:06
@samau3 samau3 changed the title [Closes 45] Admin/Staff/Volunteer can search allergy/medication/condition data [Closes #45] Admin/Staff/Volunteer can search allergy/medication/condition data Apr 10, 2024
server/routes/api/v1/allergies/index.js Outdated Show resolved Hide resolved
server/routes/api/v1/allergies/index.js Outdated Show resolved Hide resolved
server/routes/api/v1/allergies/index.js Outdated Show resolved Hide resolved
@samau3 samau3 marked this pull request as draft April 26, 2024 04:50
@samau3 samau3 marked this pull request as ready for review July 2, 2024 20:19
@samau3 samau3 requested a review from francisli July 2, 2024 20:24
Copy link
Contributor

@francisli francisli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @samau3 welcome back...!

I was out of town for a few weeks but I'm back and have taken a look here...

This is looking good! A few more changes...

Right now you're only selecting the name to be returned in the results, I think we should return all the attributes of the corresponding object (id, name, type, system, code, etc) so that the caller has everything they might need.

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 instead.

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. This implementation is based on how the Github does their pagination in their REST APIs (https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api)

@samau3
Copy link
Contributor Author

samau3 commented Jul 24, 2024

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.

Copy link
Contributor

@francisli francisli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Great work...!

@francisli francisli merged commit 20a9496 into dev Jul 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API Client with Admin/Staff/Volunteer role can search Allergy/Condition/Medication records
2 participants