Skip to content

Fix: Medicine Fields in Prescription API Response

Satyapranavanadh Rayapureddy requested to merge prescription-status-update into develop

Title (semantic)

fix(prescriptions): return replacement medicine details when marked out of stock

Description

This merge request addresses an API-related issue in the prescriptions module.

When a prescription item is marked as Out of Stock and replacement medicine details are provided, the API response still returns null for the fields:

  • replaced_by_medicine_id
  • replaced_quantity

This indicates that the replacement data is either not being stored correctly or not being returned in the response payload.

Affected API Endpoint(s)

  • GET /api/v1/consultations/{consultation_id}/prescriptions
  • PUT /api/v1/consultations/prescriptions/{prescription_id}
  • Prescription create/update endpoint where replacement details are submitted

Current Response

{ "medicine_id": 16, "dispatch_status": "pending", "replaced_by_medicine_id": null, "replaced_quantity": null }

This occurs even after marking the medicine as Out of Stock and selecting a replacement medicine with quantity.

Expected Behavior

If a medicine is marked as Out of Stock and replacement details are provided:

  • replaced_by_medicine_id should return the selected replacement medicine ID.
  • replaced_quantity should return the entered replacement quantity.

If replacement details are not provided or invalid:

  • Both fields should correctly return null.

Additional Context

This issue affects prescription accuracy and inventory tracking. The API response must reflect the actual saved data to ensure consistency between frontend display and backend records.

Checklist

  • Code follows project API guidelines.
  • Tests for API endpoints are included and passing.
  • API documentation is updated (if applicable).
  • Performance considerations have been addressed.

Related Issue(s)

Closes #

Merge request reports

Loading