Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Goal: This API takes into account the demographic and behavioral status of the patients to rank them based on their likelihood of accepting an appointment.
It also randomly includes patients with lower social engagement to ensure they have a chance to be called as well.
How Has This Been Tested?
You can read the
HOW-TO.md
file at theHow to Use
section to test the APIChecklist:
Requirements
Technologies
Modules
Distance Module
This module is responsible for exposing a service class that will calculate the distance between two points on the globe using the Haversine method.
Normalization Module
This module is responsible for exposing a service class that will normalize data based on maximum and minimum values.
Ranking Module
This module is responsible for exposing a service class. This class is responsible for using the Distance Module to calculate the distance of the patient from the position provided in the API. It will retrieve the maximum and minimum values for age, accepted offers, canceled offers, average response time, and distance, to normalize (using the Normalization Module) these values and calculate the behavioral, demographic, and overall scores. Patients are then sorted by the best overall score and worst score by behavior.
Patient Module
This module is responsible for retrieving patients from the JSON file and using the Ranking Module. It will return the number of ranked patients requested in the request according to the required page.
Assumptions
Age Normalization
For age normalization, I assumed that younger patients would have a better score for this criterion.
Accepted Offers Normalization
For accepted offers normalization, I assumed that patients with a higher number of accepted offers would have a better score for this criterion.
Canceled Offers Normalization
For canceled offers normalization, I assumed that patients with a lower number of canceled offers would have a better score for this criterion.
Average Response Time Normalization
For average response time normalization, I assumed that patients with a lower average response time would have a better score for this criterion.
Distance Normalization
For distance normalization, I assumed that patients with a smaller distance would have a better score for this criterion.
How to Use
.env.example
file to.env
.yarn # or npm install
yarn start # or npm start
The server will be responding on the URL http://localhost:3000/patients/waitlist?lat=-50.53&long=-108.98
You can change the lat and long values to any value. You can also access the Swagger of the application to test it.
Validations:
page: optional value, default 1. When provided, it must be a numeric value, with 1 being the smallest accepted value.
perPage: optional value, default 10. When provided, it must be a numeric value, with 1 being the smallest accepted value.
lat: required value representing the latitude of the provided position, must have a minimum value of -90 and a maximum value of 90.
long: required value representing the longitude of the provided position, must have a minimum value of -180 and a maximum value of 180.
percentLittleBehavior: optional value, default 20. When provided, it must be a numeric value, with a minimum value of 20 and a maximum value of 100.
Tests
yarn test:cov # or npm run test:cov