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

Willian Kazuo Solution #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

williankazuo
Copy link

Pull Request Template

Description

Create an algorithm that will process a set of historical patient data and compute a score for each patient that (1 as the lowest, 10 as the highest) that represents the chance of a patient accepting the offer off the waitlist.

Checklist:

  • I have performed a self-review of my own code
  • I have tested my code to prove my fix is effective or that my feature works
  • I have commented my code in areas where it's hard to make the code speak for itself
  • My changes breaks no tests

Implementation

  • Load json data once, parse the patients data, and get min and max for each property to use for normalization later.
  • Calculate distance between patients location and facility using Haversine Formula, get max and min distances.
  • Normalize data. The data has different scales of values, so we have to normalize and transform the scale to 0~1.
  • Limit distance to 1000 kilometers, not scoring when patient is more than 1000 km away. This would still be a high value in real life, but we're just going to limit to 1000 for this demo.
  • Scoring, apply the weight to normalized values.
  • Created endpoint /api/v1/top-patients that takes latitude and longitude as query params, and returns an ordered list of 10 patients who will most likely accept the appointment offer.

Considerations

  • Younger patients are more likely to accept.
  • Penalize patients with many canceled offers.
  • Boost patients closer to facility.
  • Boost patients with lower response time.

How to run

  • Clone
  • Run npm install
  • Run npm run dev
  • If using port default, it would be 3000. Make a get request to localhost:3000/api/v1/top-patients?latitude=?&longitude=?

Tests

npm run test
npm run test:coverage

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.

1 participant