Add refresh parameter to force regenerate cached discharge content in PDF
Problem:
- PDF shows old cached content with 'Date of Discharge: 2026-06-05'
- Debug page shows correct new format (status header only)
- Discharge content is cached in ipd_discharge table
- PDF generation uses cached content from database
- Fix only affects newly generated content, not cached content
Root Cause:
When discharge is first created, content is generated and saved to DB.
PDF generation flow (show_discharge method):
1. Load cached content from ipd_discharge table
2. Only regenerate if content is empty
3. Apply template and render PDF
So old discharges still have old format cached.
Solution:
Added 'refresh' parameter to show_discharge() method:
- If refresh=1, ignore cached content and regenerate
- Regenerate using buildAutoDischargeContent() (has fix)
- Save new content to database
- Then render PDF
Code Change (line 5900-5913):
Added:
\ = (int) (\->request->getGet('refresh') ?? 0) === 1;
Changed:
if (\ || trim(strip_tags(\)) === '') {
Usage:
1. Original URL (uses cache):
http://localhost:8080/Ipd_discharge/show_discharge/1/1?tpl=1
2. Force refresh (regenerates):
http://localhost:8080/Ipd_discharge/show_discharge/1/1?tpl=1&refresh=1
3. After first refresh, cache is updated with new format
Subsequent views will use new cached content
Note:
- preview_discharge_report() already has 'regen=1' parameter
- Same functionality, different parameter name
- Both methods now support force regeneration
For existing discharges:
- Add &refresh=1 to URL once to update cache
- Or recreate discharge from edit page
- Or clear ipd_discharge.content for that IPD ID"
This commit is contained in:
parent
aa7ed25a50
commit
89c150324f
|
|
@ -5901,8 +5901,11 @@ class Ipd_discharge extends BaseController
|
|||
return $this->response->setStatusCode(404)->setBody('IPD not found');
|
||||
}
|
||||
|
||||
// Check if user wants to force regenerate content (ignoring cache)
|
||||
$forceRegenerate = (int) ($this->request->getGet('refresh') ?? 0) === 1;
|
||||
|
||||
$content = $this->getDischargeContent($ipdId);
|
||||
if (trim(strip_tags($content)) === '') {
|
||||
if ($forceRegenerate || trim(strip_tags($content)) === '') {
|
||||
$content = $this->buildAutoDischargeContent($ipdId, $panelData);
|
||||
if (trim(strip_tags($content)) !== '') {
|
||||
$this->saveDischargeContent($ipdId, $content);
|
||||
|
|
|
|||
4298
pdf_test_html.html
4298
pdf_test_html.html
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user