Skip to main content

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​

WordMeaning
ApplicantA 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
OPSThe internal Jod team that receives MCs by WhatsApp or email and reviews each MC
PortalThe internal web app that OPS uses
APPThe mobile app for applicants
The table account_suspensionsOne 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​

  1. The applicant sends the MC to OPS by WhatsApp or email.
  2. OPS downloads the MC file.
  3. OPS opens the new page in the portal.
  4. OPS finds the applicant by name, job id or job start date.
  5. OPS uploads the MC file on the applicant's row.
  6. The system notifies the applicant that OPS uploaded the MC.

Rules​

RuleApplies toExample
The page lists account_suspensions rows with processed: false, under_grace_period: true and no MCUS-1Mei'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 periodUS-1A row from SuspendedService::suspendImmediately never shows
OPS can filter the list by applicant name, job id and job start dateUS-1OPS types "Mei" and sees her row
Only OPS can open the page and uploadalwaysAn employer user cannot see the page
An OPS upload counts toward the same monthly limit as an APP uploadalwaysMei'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 notificationUS-3Mei gets "OPS uploaded your medical certificate"
The system stores the users.id of the OPS user who uploaded the MCalwaysaccount_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_by is null when 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_by empty.

Backend​

Two new endpoints go in the applicantuser group in routes/api.php.

  • The group is already behind the middleware auth:api, auth.portal and 2fa.
  • Each form request calls UserAuthorizationTrait::isUserAdmin in authorize(), so only OPS can call them.
EndpointWhat it does
GET /api/portal/applicantuser/pending-cancellation-documentsLists the rows without an MC, with the filters name, job_id and job_start_date
POST /api/portal/applicantuser/{id}/upload-cancellation-documentStores 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.

EndpointController methodService method
ListgetListPendingCancellationDocumentgetListPendingCancellationDocument
UploaduploadCancellationDocumentByAdminuploadCancellationDocumentByAdmin

List endpoint​

The list endpoint accepts these query parameters.

ParameterRule
limitInteger from 1 to 100, default 10
pageInteger from 1, default 1
namePart of the applicant's first and last name
job_idjod_jobs.id
job_start_dateY-m-d. For a slot cancellation, this is the start date of the slot
sort_fieldgrace_deadline, created_at, applicant_name or job_start_date, default grace_deadline
sort_orderasc or desc, default desc

The response is a Laravel paginator in data, so the rows are in data.data. Each row has these fields.

FieldMeaning
idaccount_suspensions.id
applicant_idThe applicant's users.id
applicant_nameThe applicant's first and last name
jod_job_id, job_titleThe job
slot_idThe slot, or null for a job cancellation
job_start_dateThe start of the slot, or the start of the job
grace_deadlineWhen AutoSuspensionCommand suspends the applicant if there is still no MC
created_atWhen the applicant cancelled
mc_uploads_used_this_monthThe number of MCs the applicant uploaded this calendar month
mc_upload_monthly_limitThe limit from the table configurations
  • OPS sees mc_uploads_used_this_month and mc_upload_monthly_limit before 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.

FieldRule
account_suspension_idThe account_suspensions.id of the row
cancellation_documentjpg, jpeg, png, heif, heic or pdf, with a maximum size of 5 MB
  • An iPhone sends a photo as image/heic, so the endpoint accepts heic as well as heif.

The upload endpoint follows these steps.

  1. Check that the row belongs to the applicant, account_suspensions.processed is false and account_suspensions.under_grace_period is true.
    • A row from SuspendedService::suspendImmediately is also unprocessed, but it has no grace period, so OPS cannot upload for it.
  2. Check that the applicant is still on the job or slot, and that the row has no MC yet.
  3. Write the file to job_user.cancellation_document or slot_user.cancellation_document.
    • The scheduled command AutoSuspensionCommand reads this column, so without it the command still suspends the applicant.
  4. Set account_suspensions.document_uploaded_by to the users.id of the OPS user.
  5. 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.
  6. Send the CleverTap event MC_UPLOADED_BY_OPS, named Medical Certificate Uploaded by OPS in 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.

FieldMeaning
data.account_suspension_idThe account_suspensions.id of the row
data.cancellation_document_urlThe URL of the stored file
data.is_mc_auto_rejectedtrue 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.

CaseError
The row does not belong to the applicant, is processed, or has no grace periodValidation error on account_suspension_id
The file type or size is wrongValidation 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​

  1. Mei cancels Job E on 12 September, less than 3 hours before it starts.
  2. The APP crashes when she attaches the photo, so she sends it to OPS by WhatsApp.
  3. OPS downloads the photo and opens the new page in the portal.
  4. OPS filters by the name "Mei" and finds her row for Job E.
  5. OPS uploads the photo with Upload MC.
  6. The system writes the file to job_user.cancellation_document, so AutoSuspensionCommand does not suspend Mei.
  7. The system sets account_suspensions.document_uploaded_by to the users.id of the OPS user.
  8. This is Mei's first MC this month, so the MC goes to OPS for review.
  9. The system sends the CleverTap event Medical Certificate Uploaded by OPS, and the CleverTap journey sends Mei a push notification.
  10. Mei's row leaves the list.