diff --git a/pkg/clinical/application/utils/templates.go b/pkg/clinical/application/utils/templates.go
index 5bd0485..7ce4ce0 100644
--- a/pkg/clinical/application/utils/templates.go
+++ b/pkg/clinical/application/utils/templates.go
@@ -141,7 +141,7 @@ const ReferralFormTemplate = `
|
-
+ |
|
@@ -161,33 +161,47 @@ const ReferralFormTemplate = `
+ {{if .Patient.Name}}
- {{if .Patient.Name}} Name: {{.Patient.Name}} {{end}}
- |
-
- {{if .Patient.EmpowerID}} Empower ID: {{.Patient.EmpowerID}} {{end}}
+ Name: {{.Patient.Name}}
+ |
+ {{end}}
+ {{if .Patient.PhoneNumber}}
+
+ Phone number: {{.Patient.PhoneNumber}}
|
+ {{end}}
+ {{if .Patient.DateOfBirth}}
+
+ Date of birth: {{.Patient.DateOfBirth}}
+ |
+ {{end}}
+ {{if .Patient.Age}}
- {{if .Patient.NationalID}} National ID: {{.Patient.NationalID}} {{end}}
- |
-
- {{if .Patient.PhoneNumber}} Phone number: {{.Patient.PhoneNumber}} {{end}}
- |
+ Age: {{.Patient.Age}}
+
+ {{end}}
+ {{if .Patient.Sex}}
- {{if .Patient.DateOfBirth}} Date of birth: {{.Patient.DateOfBirth}} {{end}}
- |
-
- {{if .Patient.Age}} Age: {{.Patient.Age}} {{end}}
- |
+ Sex: {{.Patient.Sex}}
+
+ {{end}}
+ {{if .Patient.NationalID}}
- {{if .Patient.Sex}} Sex: {{.Patient.Sex}} {{end}}
- |
+ National ID: {{.Patient.NationalID}}
+
+ {{end}}
+ {{if .Patient.EmpowerID}}
+
+ Empower ID: {{.Patient.EmpowerID}}
+ |
+ {{end}}
@@ -256,15 +270,24 @@ const ReferralFormTemplate = `
{{if .MedicalHistory.Medication}}Medication: {{.MedicalHistory.Medication}} {{end}}
{{if .MedicalHistory.ReferralNotes}}Referral notes: {{.MedicalHistory.ReferralNotes}} {{end}}
{{if .MedicalHistory.Tests}}
-
+
+
+
+ Test |
+ Result |
+ Date |
+
+
+
{{range .MedicalHistory.Tests}}
-
- {{if .Name}} Test: {{.Name}} {{end}}
- {{if .Results}} Results: {{.Results}} {{end}}
- {{if .Date}} Date: {{.Date}} {{end}}
-
+
+ {{if .Name}}{{.Name}} | {{else}} | {{end}}
+ {{if .Results}}{{.Results}} | {{else}} | {{end}}
+ {{if .Date}}{{.Date}} | {{else}} | {{end}}
+
{{end}}
-
+
+
{{end}}
{{end}}
diff --git a/pkg/clinical/usecases/clinical/observation.go b/pkg/clinical/usecases/clinical/observation.go
index 3f2bdc6..aed6102 100644
--- a/pkg/clinical/usecases/clinical/observation.go
+++ b/pkg/clinical/usecases/clinical/observation.go
@@ -431,7 +431,10 @@ func (c *UseCasesClinicalImpl) GetPatientObservations(ctx context.Context, patie
searchParams := map[string]interface{}{
"patient": patientReference,
- "code": observationCode,
+ }
+
+ if observationCode != "" {
+ searchParams["code"] = observationCode
}
if encounterID != nil {
diff --git a/pkg/clinical/usecases/clinical/referral_report.go b/pkg/clinical/usecases/clinical/referral_report.go
index eec1073..34a1f13 100644
--- a/pkg/clinical/usecases/clinical/referral_report.go
+++ b/pkg/clinical/usecases/clinical/referral_report.go
@@ -180,8 +180,33 @@ func (c *UseCasesClinicalImpl) GenerateReferralReportPDF(ctx context.Context, se
}
}
+ observations, err := c.GetPatientObservations(
+ ctx,
+ *patient.Resource.ID,
+ serviceRequest.Resource.Encounter.ID,
+ nil,
+ "",
+ &dto.Pagination{},
+ )
+ if err != nil {
+ utils.ReportErrorToSentry(err)
+ return nil, err
+ }
+
+ var tests []Test
+
+ for _, observation := range observations.Edges {
+ obs := Test{
+ Name: observation.Node.Name,
+ Results: observation.Node.Value,
+ Date: observation.Node.TimeRecorded,
+ }
+
+ tests = append(tests, obs)
+ }
+
data := TemplateData{
- Date: time.Now().Format("Monday, Jan 2, 2006"),
+ Date: time.Now().Format("Jan 2, 2006"),
Time: time.Now().Format("15:04"),
ReferringFacility: Facility{
Name: *facility.Resource.Name,
@@ -196,7 +221,7 @@ func (c *UseCasesClinicalImpl) GenerateReferralReportPDF(ctx context.Context, se
Referral: Referral{
Reason: referralReason,
},
- MedicalHistory: MedicalHistory{Procedure: "Screening", Medication: "None", ReferralNotes: referralReason, Tests: []Test{{Name: "VIA", Results: "Positive", Date: "13th May 2024"}}},
+ MedicalHistory: MedicalHistory{Procedure: "Screening", Medication: "None", ReferralNotes: referralReason, Tests: tests},
Footer: Footer{
Phone: facilityContact,
},
|