ohcnetwork / care

Care is a Digital Public Good enabling TeleICU & Decentralised Administration of Healthcare Capacity across States.
https://careapi.ohc.network/swagger
MIT License
250 stars 293 forks source link

N+1 API queries in prescription administration table #2333

Open rithviknishad opened 1 year ago

rithviknishad commented 1 year ago

Currently, the code flow in fetching data for the prescription administration table is:

  1. List prescriptions for a consultation.
  2. Computing the overall start and end administration date range to initialize pagination
  3. Compute the latest range required to be shown in view (eg. last X hours)
  4. Listing administrations for each of the prescriptions within that range.

TODO: A solution to be discussed

github-actions[bot] commented 1 year ago

Hi, @gigincg, @nihal467, @khavinshankar, @mathew-alex, @aparnacoronasafe, This issue has been automatically marked as stale because it has not had any recent activity.

github-actions[bot] commented 8 months ago

Hi, @gigincg, @nihal467, @khavinshankar, @mathew-alex, @aparnacoronasafe, This issue has been automatically marked as stale because it has not had any recent activity.

aeswibon commented 7 months ago

@rithviknishad Is there by solution discussed for this?

rithviknishad commented 7 months ago

No @aeswibon

Feel free to comment a solution

gigincg commented 3 months ago

@rithviknishad Can you update here if we are still using the unoptimized logic for Prescription Administration? Reassign to me post update

rithviknishad commented 3 months ago

Yes @gigincg We are still using the unoptimized logic to query the prescription administrations in the MAR table (same flow as mentioned in the issue body).

We could consider fetching administrations across prescriptions in 1 API call. But we would need to pass a higher pagination size limit to account for getting all administrations across all prescriptions for the given time range.

image