Portal-Assisted Medical Certificate Upload
TL;DR
- Some applicants send their Medical Certificate (MC) to OPS by WhatsApp or email, not in the APP.
- A new portal page lists the applicants who cancelled a job but did not upload an MC.
- OPS uploads the MC for the applicant on that page.
- After the upload, the system notifies the applicant.
Words used in this doc
| Word | Meaning |
|---|---|
| Applicant | A jodder who applied to a gig job, and the hiring manager selected them |
| Medical Certificate (MC) | The document an applicant uploads to explain a late cancellation |
| OPS | The internal Jod team that receives MCs by WhatsApp or email and reviews each MC |
| Portal | The internal web app that OPS uses |
| APP | The mobile app for applicants |
The table account_suspensions | One row per cancellation that puts an applicant at risk of suspension |
Problem
An applicant sends a valid MC to OPS by WhatsApp or email, but OPS cannot attach it in the portal.
- The applicant misses the grace deadline.
- The system suspends the applicant, although a valid MC exists.
User stories
- US-1: As OPS, I want to list who cancelled without an MC, so I know whose MC to upload.
- US-2: As OPS, I want to upload an MC for an applicant, so a sick applicant is not suspended.
- US-3: As an applicant, I want a notification when OPS uploads my MC, so I know OPS received it.
Flow
- The applicant sends the MC to OPS by WhatsApp or email.
- OPS downloads the MC file.
- OPS opens the new page in the portal.
- OPS finds the applicant by name, job id or job start date.
- OPS uploads the MC file on the applicant's row.
- The system notifies the applicant that OPS uploaded the MC.
Rules
| Rule | Applies to | Example |
|---|---|---|
The page lists account_suspensions rows with processed: false, under_grace_period: true and no MC | US-1 | Mei's row for Job E shows until an MC is attached |
| The page does not list a row the system suspended at once, with no grace period | US-1 | A row from SuspendedService::suspendImmediately never shows |
| OPS can filter the list by applicant name, job id and job start date | US-1 | OPS types "Mei" and sees her row |
| Only OPS can open the page and upload | always | An employer user cannot see the page |
| An OPS upload counts toward the same monthly limit as an APP upload | always | Mei's MC from OPS is upload 1 of 3 |
The system sends the CleverTap event Medical Certificate Uploaded by OPS after each OPS upload, and a CleverTap journey sends the push notification | US-3 | Mei gets "OPS uploaded your medical certificate" |
The system stores the users.id of the OPS user who uploaded the MC | always | account_suspensions.document_uploaded_by holds the id of the OPS user |
Design
Database
One column goes on the table account_suspensions, next to account_suspensions.document_uploaded_at.
Schema::table('account_suspensions', function (Blueprint $table) {
$table->unsignedBigInteger('document_uploaded_by')->nullable()
->comment('users.id of the OPS user who uploaded the MC in the portal, null for an APP upload');
});
account_suspensions.document_uploaded_byisnullwhen the applicant uploaded the MC in the APP.- The name matches the existing column
account_suspensions.document_approved_by. - Old rows keep
account_suspensions.document_uploaded_byempty.
Backend
Two new endpoints go in the applicantuser group in routes/api.php.
- The group is already behind the middleware
auth:api,auth.portaland2fa. - Each form request calls
UserAuthorizationTrait::isUserAdmininauthorize(), so only OPS can call them.
| Endpoint | What it does |
|---|---|
GET /api/portal/applicantuser/pending-cancellation-documents | Lists the rows without an MC, with the filters name, job_id and job_start_date |
POST /api/portal/applicantuser/{id}/upload-cancellation-document | Stores the MC file for one account_suspensions row. {id} is the applicant's users.id |
Both endpoints are in app/Http/Controllers/PendingSuspensionController.php, and the logic is in app/Services/PendingSuspensionService.php.
| Endpoint | Controller method | Service method |
|---|---|---|
| List | getListPendingCancellationDocument | getListPendingCancellationDocument |
| Upload | uploadCancellationDocumentByAdmin | uploadCancellationDocumentByAdmin |
List endpoint
The list endpoint accepts these query parameters.
| Parameter | Rule |
|---|---|
limit | Integer from 1 to 100, default 10 |
page | Integer from 1, default 1 |
name | Part of the applicant's first and last name |
job_id | jod_jobs.id |
job_start_date | Y-m-d. For a slot cancellation, this is the start date of the slot |
sort_field | grace_deadline, created_at, applicant_name or job_start_date, default grace_deadline |
sort_order | asc or desc, default desc |
The response is a Laravel paginator in data, so the rows are in data.data. Each row has these fields.
| Field | Meaning |
|---|---|
id | account_suspensions.id |
applicant_id | The applicant's users.id |
applicant_name | The applicant's first and last name |
jod_job_id, job_title | The job |
slot_id | The slot, or null for a job cancellation |
job_start_date | The start of the slot, or the start of the job |
grace_deadline | When AutoSuspensionCommand suspends the applicant if there is still no MC |
created_at | When the applicant cancelled |
mc_uploads_used_this_month | The number of MCs the applicant uploaded this calendar month |
mc_upload_monthly_limit | The limit from the table configurations |
- OPS sees
mc_uploads_used_this_monthandmc_upload_monthly_limitbefore the upload.- At the limit, OPS knows that the system will reject the MC and suspend the applicant.
Upload endpoint
The upload endpoint accepts a multipart/form-data body.
| Field | Rule |
|---|---|
account_suspension_id | The account_suspensions.id of the row |
cancellation_document | jpg, jpeg, png, heif, heic or pdf, with a maximum size of 5 MB |
- An iPhone sends a photo as
image/heic, so the endpoint acceptsheicas well asheif.
The upload endpoint follows these steps.
- Check that the row belongs to the applicant,
account_suspensions.processedisfalseandaccount_suspensions.under_grace_periodistrue.- A row from
SuspendedService::suspendImmediatelyis also unprocessed, but it has no grace period, so OPS cannot upload for it.
- A row from
- Check that the applicant is still on the job or slot, and that the row has no MC yet.
- Write the file to
job_user.cancellation_documentorslot_user.cancellation_document.- The scheduled command
AutoSuspensionCommandreads this column, so without it the command still suspends the applicant.
- The scheduled command
- Set
account_suspensions.document_uploaded_byto theusers.idof the OPS user. - Run the same monthly limit check as an APP upload, from Limit Medical Certificate Uploads Per Month, Backend.
- Steps 3 to 5 run in one database transaction. If one step fails, the system removes the stored file.
- Send the CleverTap event
MC_UPLOADED_BY_OPS, namedMedical Certificate Uploaded by OPSin CleverTap, with the suspension reason.- The push notification goes out only after a CleverTap journey is set up for this event.
- When the MC goes over the limit, the applicant also gets
USER_SUSPENDED, so the journey text must not say "under review".
A successful upload returns these fields.
| Field | Meaning |
|---|---|
data.account_suspension_id | The account_suspensions.id of the row |
data.cancellation_document_url | The URL of the stored file |
data.is_mc_auto_rejected | true when the system rejected the MC for the monthly limit and suspended the applicant |
The upload endpoint stops with an error in these cases, and stores no file.
| Case | Error |
|---|---|
| The row does not belong to the applicant, is processed, or has no grace period | Validation error on account_suspension_id |
| The file type or size is wrong | Validation error on cancellation_document |
| The applicant is no longer on the job or slot | "The applicant is no longer on this job or slot." |
| The applicant already uploaded an MC for the row | "The applicant already uploaded an MC for this cancellation." |
Portal
The portal gets one new page for OPS.
- The page shows one row per cancellation without an MC.
- Each row shows the applicant name, the job id, the job start date and the MCs used this month.
- The page has three filters: applicant name, job id and job start date.
- Each row has an Upload MC button that opens a file picker.
- After a successful upload, the row leaves the list.
Worked example: Mei on 12 September
- Mei cancels Job E on 12 September, less than 3 hours before it starts.
- The APP crashes when she attaches the photo, so she sends it to OPS by WhatsApp.
- OPS downloads the photo and opens the new page in the portal.
- OPS filters by the name "Mei" and finds her row for Job E.
- OPS uploads the photo with Upload MC.
- The system writes the file to
job_user.cancellation_document, soAutoSuspensionCommanddoes not suspend Mei. - The system sets
account_suspensions.document_uploaded_byto theusers.idof the OPS user. - This is Mei's first MC this month, so the MC goes to OPS for review.
- The system sends the CleverTap event
Medical Certificate Uploaded by OPS, and the CleverTap journey sends Mei a push notification. - Mei's row leaves the list.