Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'd approach it like this. First a database table that links schedule slots to available carers...</p> <pre><code>Table schedules_shifts id service_user_schedules_id carer_available_shifts_id </code></pre> <p>Now a function that matches available carers to required schedule slots and populates the table...</p> <pre><code>* Fetch service_user_schedules for the next week * For each service_user_schedules row * Fetch carer_available_shifts that match the schedule slot * For each carer_available_shift row * If results * Fetch schedules_shifts rows where carer_available_shifts_id is already used * If no results * Insert a row in the schedules_shifts table for each carer * Otherwise carer is busy, do nothing and continue * If no results, flag for review or trigger e-mail to manager, or other action * Trigger e-mail or save log of completion for peace of mind </code></pre> <p>The new table now has possible carer matches for schedule slots with no duplicate allocation of a carer's time. It does however match multiple carer's shifts with a schedule slot. This could be a feature! Leave them as-is and add a <code>confirmed</code> column on <code>schedules_shifts</code> so a manager can manually assign the work, or carers can volunteer, or automatically mark the first match as <code>confirmed</code> and keep the other rows as alternatives in case the first carer can't make it.</p> <p>This can all be triggered by a cron every week, or when the final career updates their week's schedule. Probably the first because users are often unpredictable.</p> <p>Now the automated data is in a table you can open it up for editing. Create a normal admin console as you would to change the rows in <code>schedules_shifts</code> as appropriate, or flag different rows "confirmed".</p> <p>Translating it into a generic class shouldn't be too difficult - just a matter of using generic terminology. It's late and I can't think of any though :)</p> <p>It's possible to do all the data sifting in PHP arrays rather than the database dance I've created above, but I think SQL is more appropriate for sorting through the data and making amendments.</p> <p>Genetic algorithms sound interesting though, and if you've got the time investigate them ^_^</p> <p>Hope that helps?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload