diff --git a/pkg/clinical/usecases/clinical/referral_report.go b/pkg/clinical/usecases/clinical/referral_report.go index feca424..fd364c3 100644 --- a/pkg/clinical/usecases/clinical/referral_report.go +++ b/pkg/clinical/usecases/clinical/referral_report.go @@ -146,7 +146,7 @@ func (c *UseCasesClinicalImpl) GenerateReferralReportPDF(ctx context.Context, se } data := TemplateData{ - Date: time.Now().Format("Monday Jan 2"), + Date: time.Now().Format("Monday Jan 2 2023"), Time: time.Now().Format("15:04"), Patient: patientData, NextOfKin: NextOfKin{}, @@ -158,7 +158,7 @@ func (c *UseCasesClinicalImpl) GenerateReferralReportPDF(ctx context.Context, se Referral: Referral{ Reason: referralReason, }, - MedicalHistory: MedicalHistory{Procedure: "Screening", Medication: "None", ReferralNotes: "Patient complains of severe abdominal pain and intermittent bleeding.", Tests: []Test{{Name: "VIA", Results: "Positive", Date: "13th May 2024"}}}, + MedicalHistory: MedicalHistory{Procedure: "Screening", Medication: "None", ReferralNotes: referralReason, Tests: []Test{{Name: "VIA", Results: "Positive", Date: "13th May 2024"}}}, Footer: Footer{}, } @@ -168,7 +168,6 @@ func (c *UseCasesClinicalImpl) GenerateReferralReportPDF(ctx context.Context, se return nil, err } - // Fill the template with data var htmlBuffer bytes.Buffer err = tmpl.Execute(&htmlBuffer, data) @@ -177,20 +176,16 @@ func (c *UseCasesClinicalImpl) GenerateReferralReportPDF(ctx context.Context, se return nil, err } - // Convert template output to string htmlContent := htmlBuffer.String() - // Create a new PDF generator pdfg, err := wkhtmltopdf.NewPDFGenerator() if err != nil { utils.ReportErrorToSentry(err) return nil, err } - // Add one page from an URL, a file, or HTML content pdfg.AddPage(wkhtmltopdf.NewPageReader(strings.NewReader(htmlContent))) - // Create PDF document in internal buffer err = pdfg.Create() if err != nil { utils.ReportErrorToSentry(err) diff --git a/templates/referral_report_template.html b/templates/referral_report_template.html index deba2b3..21fb9fc 100644 --- a/templates/referral_report_template.html +++ b/templates/referral_report_template.html @@ -4,114 +4,228 @@ Referral Report -
-
- - Empower Coast General Hospital -
-
- {{if .Date}} -
Date: {{.Date}}
- {{end}} - {{if .Time}} -
Time: {{.Time}}
- {{end}} - {{if .Reason}} -
Reason: {{.Reason}}
- {{end}} -
-
+ + + + + + +
+ Empower Logo + +

Empower Coast General Hospital

+
+ {{if .Date}}
Date: {{.Date}}
{{end}} + {{if .Time}}
Time: {{.Time}}
{{end}} + {{if .Reason}}
Reason: {{.Reason}}
{{end}} +
+
Referral Report
-
- {{if .Patient}} -
-

Patient details

- {{if .Patient.Name}}
Name: {{.Patient.Name}}
{{end}} - {{if .Patient.EmpowerID}}
Empower ID: {{.Patient.EmpowerID}}
{{end}} - {{if .Patient.NationalID}}
National ID: {{.Patient.NationalID}}
{{end}} - {{if .Patient.PhoneNumber}}
Phone number: {{.Patient.PhoneNumber}}
{{end}} - {{if .Patient.DateOfBirth}}
Date of birth: {{.Patient.DateOfBirth}}
{{end}} - {{if .Patient.Age}}
Age: {{.Patient.Age}}
{{end}} - {{if .Patient.Sex}}
Sex: {{.Patient.Sex}}
{{end}} -
- {{end}} - {{if or .NextOfKin.Name .NextOfKin.PhoneNumber .NextOfKin.Relationship}} -
-

Next of kin details

- {{if .NextOfKin.Name}}
Name: {{.NextOfKin.Name}}
{{end}} - {{if .NextOfKin.Relationship}}
Relationship: {{.NextOfKin.Relationship}}
{{end}} - {{if .NextOfKin.PhoneNumber}}
Phone number: {{.NextOfKin.PhoneNumber}}
{{end}} -
- {{end}} + {{if .Patient}} +

Patient details

+
+ {{if .Patient.Name}}
Name: {{.Patient.Name}}
{{end}} + {{if .Patient.EmpowerID}}
Empower ID: {{.Patient.EmpowerID}}
{{end}} + {{if .Patient.NationalID}}
National ID: {{.Patient.NationalID}}
{{end}} + {{if .Patient.PhoneNumber}}
Phone number: {{.Patient.PhoneNumber}}
{{end}} + {{if .Patient.DateOfBirth}}
Date of birth: {{.Patient.DateOfBirth}}
{{end}} + {{if .Patient.Age}}
Age: {{.Patient.Age}}
{{end}} + {{if .Patient.Sex}}
Sex: {{.Patient.Sex}}
{{end}} +
+ {{end}} - {{if .Facility}} -
-

Receiving facility details

- {{if .Facility.Name}}
Referred to: {{.Facility.Name}}
{{end}} - {{if .Facility.Location}}
Location: {{.Facility.Location}}
{{end}} - {{if .Facility.Contact}}
Hospital contact: {{.Facility.Contact}}
{{end}} -
- {{end}} + {{if or .NextOfKin.Name .NextOfKin.PhoneNumber .NextOfKin.Relationship}} +

Next of kin details

+
+ {{if .NextOfKin.Name}}
Name: {{.NextOfKin.Name}}
{{end}} + {{if .NextOfKin.PhoneNumber}}
Phone number: {{.NextOfKin.PhoneNumber}}
{{end}} + {{if .NextOfKin.Relationship}}
Relationship: {{.NextOfKin.Relationship}}
{{end}} +
+ {{end}} - {{if .Referral.Reason}} -
-

Referral reason

-
Reason for referral: {{.Referral.Reason}}
-
- {{end}} + {{if .Facility}} +

Receiving facility details

+
+ {{if .Facility.Name}}
Referred to: {{.Facility.Name}}
{{end}} + {{if .Facility.Contact}}
Hospital Contact: {{.Facility.Contact}}
{{end}} + {{if .Facility.Location}}
Location: {{.Facility.Location}}
{{end}} +
+ {{end}} - {{if .MedicalHistory}} -
-

Medical history

- {{if .MedicalHistory.Procedure}}
Procedure: {{.MedicalHistory.Procedure}}
{{end}} - {{if .MedicalHistory.Medication}}
Medication: {{.MedicalHistory.Medication}}
{{end}} - {{if .MedicalHistory.ReferralNotes}}
Referral notes: {{.MedicalHistory.ReferralNotes}}
{{end}} - {{if .MedicalHistory.Tests}} - {{range .MedicalHistory.Tests}} -
Test done: {{.Name}} Results: {{.Results}} Date: {{.Date}}
- {{end}} + {{if .Referral.Reason}} +

Referral reason

+
+
Reason for Referral: {{.Referral.Reason}}
+
+ {{end}} + + {{if .MedicalHistory}} +

Medical History

+
+ {{if .MedicalHistory.Procedure}}
Procedure: {{.MedicalHistory.Procedure}}
{{end}} + {{if .MedicalHistory.Medication}}
Medication: {{.MedicalHistory.Medication}}
{{end}} + {{if .MedicalHistory.ReferralNotes}}
Referral notes: {{.MedicalHistory.ReferralNotes}}
{{end}} + {{if .MedicalHistory.Tests}} +
+ {{range .MedicalHistory.Tests}} +
+ {{if .Name}}
Test: {{.Name}}
{{end}} + {{if .Results}}
Results: {{.Results}}
{{end}} + {{if .Date}}
Date: {{.Date}}
{{end}} +
{{end}}
{{end}} +
+ {{end}} + +

Referred by

+
+
Referring Officer:
+
Designation:
+
Phone:
+
Signature:
+
-
-

Referred by

-
Referring Officer:
-
Designation:
-
Phone:
-
Signature:
-
{{if or .Footer.Phone .Footer.Email .Footer.Address}} {{end}} + \ No newline at end of file