Business · Product · Technology · AI

Compare document approval, rejection and review-state contracts

Ten isolated ClinicX handler cases compare early refusals, approval/rejection update fields, optional rejection reasons, reviewer timestamps, returned rows and selected update failures.

Work directly with Omer Muneer Qazi · Reviewed 30 November 2026

The scenario: approval and rejection carry different record contracts

A document-submission workflow needs explicit review outcomes. Approval and rejection may share role and clinic checks while changing different fields. A review label, a verification flag, an active-state flag and a reviewer timestamp are related pieces of application state, but none alone proves that the underlying document has been clinically assessed. A useful engineering account follows their exact source-level handoff.

This case compares pinned ClinicX approval and rejection handlers through ten isolated JavaScript research cases, five for each route. Both complete source files are retained after dependency-import substitution and TypeScript type erasure. Synthetic headers and fake query/update responses expose the selected control flow. No real patient, reviewer, document, token, database or provider is used or changed.

Preserve both handlers and disclose the execution boundary

The preparation redirects each route's dependency imports to one local fake module. TypeScript transpilation removes types with an ES2022 target; no function body is manually rewritten. Source and execution-copy hashes identify both routes. The fake records client construction, lookup arguments, update payloads and returned results.

The runner receives an allowlisted environment and no inherited provider credentials. A global fetch guard refuses that API, without claiming an operating-system network sandbox. Direct function invocation does not run Next.js, middleware, exported matcher rules or real database queries. These cases complement the earlier patient-upload and identity-forwarding chapters rather than silently extending their scope to a complete moderation workflow.

Keep early role and identifier refusals ahead of client work

The approval cases supply a selected nonstaff role and a missing document identifier and observe refusal before client construction. The rejection cases exercise those selected gates as well. Their fake requests contain invented identity strings; the role sets come from the retained source.

This establishes how the handlers interpret those controlled inputs. It does not authenticate the headers or certify every role combination. The surrounding request path must establish who may supply identity and clinic context. The earlier middleware-tail suite uses its own fake verifier and response API, so combining these local passes still does not demonstrate actual JWT verification or framework request propagation.

Observe document absence and clinic mismatch before update

Each handler performs a document lookup before selecting its update. The fixtures return either no document or a synthetic document belonging to a different selected clinic. The handlers return their not-found or clinic-mismatch responses without invoking the fake update method. That separates these refusals from an update operation that later returns an error.

The lookup and update calls record the selected document identifier. No SQL, row-level policy or concurrent record access is evaluated. These are query-construction and branch observations, not tenant-isolation certification. A permitted integration case should verify the actual identity, record scope and database contract before making a broader operational claim.

Identify the approval payload exactly

The approval success case checks an APPROVED review label, a true verification flag and the supplied synthetic reviewer identifier. The reviewedAt and updatedAt fields share the selected timestamp, and it parses as a date in this fixture. The approval payload does not include an isActive field.

That final observation concerns the update patch, not the resulting active state of a real record. A database may retain an existing value when a field is absent, and surrounding workflow requirements determine which transitions should be allowed. This suite does not test reactivation or classify repeated approval as correct or incorrect. Those are explicit state-machine and integration questions rather than conclusions inferred from a patch shape.

Keep selected reviewer and administrator inputs explicit

A separate approval case supplies the selected super-admin role with a different synthetic clinic and observes the source's clinic-check exception. The same case omits a reviewer header and observes null in the update payload's reviewer field. These are input/result contracts of the retained handler.

Neither result establishes the identity of an administrator or the validity of a real review. Authentication, administrator scope selection and reviewer-account requirements need their own acceptance. In particular, a value called isVerified describes application state in this route; it does not itself certify a document's authenticity, a clinician's participation or a medical decision.

Compare rejection flags with approval flags

The rejection success case checks a REJECTED review label, a false verification flag and an explicit false active-state flag. It also checks the synthetic reviewer and the paired review/update timestamps. These assertions show that the rejection patch has a different state contract from the approval patch.

The fixture does not navigate a patient application or prove that every reader filters inactive records. Downstream lists, downloads, notifications and caches may have separate eligibility rules. A complete workflow should verify those consumers against the intended state transition. This chapter establishes the selected write payload rather than the user-visible consequences throughout the product.

Exercise rejection reasons without calling a description an audit service

One rejection case supplies a synthetic reason with an existing description and observes the selected appended text. A second branch starts without a description and observes the selected reason prefix. Another case supplies no reason, a nonstring reason, an empty string and a request whose JSON parsing rejects; the selected original description is preserved in these fixtures.

These are string and optional-body behaviors in the handler. They do not establish durable audit delivery, immutable history, reason quality or safe presentation in every consumer. The source stores a selected description value in an update payload; that is different from an independently accepted audit system. No genuine rejection reason or patient narrative is read or published.

Observe selected update failures independently for both routes

For each handler, a case supplies either an update error or no returned updated row. The handler returns its selected failure response rather than an ordinary document success body. The fake confirms that an update invocation occurred, which distinguishes this path from the earlier role, identifier, lookup and clinic refusals.

The supplied error does not prove whether a real database committed or rolled back a change, and a missing returned row is not a diagnosis of a live incident. Retry behavior, transaction outcomes and reconciliation require permitted integration evidence. The current research does not modify a document state to discover those outcomes.

Inspect the returned result at this handler boundary

The selected success cases return the fake updated row inside a document response. A synthetic extra field supplied by the fake remains present. This differs from the explicit field projection tested in the upload handlers, and it should be recorded as this route's own return contract.

That observation is not a current data-exposure finding. Actual returned columns, policies, trusted caller requirements and response consumers must be traced before assessing the intended disclosure boundary. The fixture uses invented fields and values. It demonstrates why response assumptions should follow the imported route rather than be copied from another endpoint with a similar document-related name.

Handover for the review-state workflow

Retain ten unique case names, two pinned source hashes, execution copies, dependency doubles and the minimal-environment receipt. Keep the five approval cases and five rejection cases separate from the existing upload, storage and identity suites. Their combined contribution is a concrete comparison of selected review-write and response contracts.

The next acceptance should define permitted starting states, repeat/concurrent review behavior, reviewer identity requirements and downstream handling of inactive or approved records. Then connect complete request dispatch and trusted identity to actual database behavior using isolated synthetic records under explicit permission. Current authentication, clinical suitability, durable audit history, downstream visibility and deployed operation remain independent work. The published evidence supports a precise engineering handover without presenting a pair of direct handler invocations as proof of a live medical-review process.

Compare the reviewed boundaries

The selected update patches have different contracts

On smaller screens, scroll across to compare every column. Keyboard users can focus the table and use the arrow keys.

Field or boundaryApproval fixtureRejection fixture
Review stateAPPROVEDREJECTED
Verification flagtruefalse
Active-state field in patchNot suppliedfalse
Reviewer and timeSelected ID or null; paired timestampsSelected ID; paired timestamps
Description behaviorNot supplied in selected patchSelected reason appended or original preserved
Actual clinical reviewNot establishedNot established

About this engineering series

Written by Omer Muneer Qazi from a review of Movo-X implementation and dated engineering records. This article explains source behaviour and historical observations; current production, clinical outcomes and store availability require their own verification. Examples are synthetic and proposed test cases are identified as such.

Explore the Movo-X engineering series → · Related implementation experience →

Discuss a similar engineering problem

Send the workflow, current platform and the decision your team needs to make. I can help define an implementation or review scope with concrete acceptance evidence.

Discuss your project on WhatsApp ↗
WhatsApp Omer about this project ↗