' . '

E-Atria Hospital

' . '

DISCHARGE SUMMARY

' . '' . '' . '' . '' . '' . '
Patient Name: DEVENDER SINGHIPD No: A26090000009
Patient ID: 11Gender / Age: Male / 47 Yrs
Admission Date: 28-08-2026Discharge Date: 06-09-2026
Doctor: Dr. R.K.SUNDRIYALDiagnosis: VIRAL DISEASE
' . '

Discharge Medications

' . '' . '' . '' . '' . '
MedicineDosage
ACILOCTake 1 tablet twice daily before meals
PANTOP DSRTake 1 tablet once daily before meals
' . '

Advice / Follow-up

' . '

Dietary Advice: Fruits and Vegetables daily. Avoid spicy & oily food.

' . '

Review After: 1 Month (02-10-2026)

' . ''; $mpdf = new \Mpdf\Mpdf([ 'mode' => 'utf-8', 'format' => 'A4', 'margin_left' => 15, 'margin_right' => 15, 'margin_top' => 15, 'margin_bottom' => 15, 'default_font' => 'freeserif' ]); $mpdf->WriteHTML($html); $pdfBytes = $mpdf->Output('', \Mpdf\Output\Destination::STRING_RETURN); $pdfBase64 = base64_encode($pdfBytes); echo "Generated PDF size: " . strlen($pdfBytes) . " bytes (" . strlen($pdfBase64) . " base64 chars)\n"; // Load bundle without pdf $bundle = json_decode(file_get_contents(__DIR__ . '/bundle_without_pdf.json'), true); $docRefId = "1863138e-1e2b-475a-89bf-e3a9bcb73eaa"; $docRefUuid = "urn:uuid:" . $docRefId; // 1. Add section in Composition $bundle['entry'][0]['resource']['section'][] = [ "title" => "Document Reference", "code" => [ "coding" => [ [ "system" => "http://snomed.info/sct", "code" => "373942005", "display" => "Discharge summary" ] ] ], "entry" => [ [ "reference" => $docRefUuid, "display" => "Discharge Summary" ] ] ]; // 2. Add DocumentReference entry strictly adhering to NRCES profile $bundle['entry'][] = [ "fullUrl" => $docRefUuid, "resource" => [ "resourceType" => "DocumentReference", "id" => $docRefId, "meta" => [ "profile" => [ "https://nrces.in/ndhm/fhir/r4/StructureDefinition/DocumentReference" ] ], "status" => "current", "docStatus" => "final", "type" => [ "coding" => [ [ "system" => "http://snomed.info/sct", "code" => "373942005", "display" => "Discharge Summary" ] ], "text" => "Discharge Summary" ], "subject" => [ "reference" => "urn:uuid:11cef8a6-4cd1-4733-afd0-92898eb57901", "display" => "DEVENDER SINGH" ], "content" => [ [ "attachment" => [ "contentType" => "application/pdf", "language" => "en-IN", "data" => $pdfBase64, "title" => "Discharge Summary", "creation" => "2026-09-06T02:08:00+05:30" ] ] ] ] ]; $bundle['id'] = "discharge-A26090000009-v" . time(); $bundle['identifier']['value'] = $bundle['id']; $validator = new \App\Libraries\Abdm\Fhir\Support\FhirBundleValidator(); $val = $validator->validate($bundle); echo "Validation Result (With Official DocumentReference):\n"; echo "Valid: " . ($val->valid ? "YES" : "NO") . " | Score: " . $val->score . "%\n"; echo "Total Entries: " . count($bundle['entry']) . "\n"; if (!empty($val->errors)) { echo "Errors: " . print_r($val->errors, true) . "\n"; } file_put_contents(__DIR__ . '/bundle_with_pdf.json', json_encode($bundle, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));