Skip to content

Commit

Permalink
chore: update referral form details (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Apr 12, 2024
1 parent 5a897c0 commit 387f8b9
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 27 deletions.
71 changes: 47 additions & 24 deletions pkg/clinical/application/utils/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const ReferralFormTemplate = `
<td class="logo-cell">
<img alt="Empower Logo">
</td>
<td >
<td>
<h1 class="header-title">{{ .ReferringFacility.Name }}</h1>
</td>
<td class="details-cell">
Expand All @@ -161,33 +161,47 @@ const ReferralFormTemplate = `
<div class="detail-section">
<table>
<tr>
{{if .Patient.Name}}
<td>
{{if .Patient.Name}}<div class="detail">Name: <strong>{{.Patient.Name}}</strong></div>{{end}}
</td>
<td >
{{if .Patient.EmpowerID}}<div class="detail">Empower ID: <strong>{{.Patient.EmpowerID}}</strong></div>{{end}}
<div class="detail">Name: <strong>{{.Patient.Name}}</strong></div>
</td>
{{end}}
{{if .Patient.PhoneNumber}}
<td>
<div class="detail">Phone number: <strong>{{.Patient.PhoneNumber}}</strong></div>
</td>
{{end}}
</tr>
<tr>
{{if .Patient.DateOfBirth}}
<td>
<div class="detail">Date of birth: <strong>{{.Patient.DateOfBirth}}</strong></div>
</td>
{{end}}
{{if .Patient.Age}}
<td>
{{if .Patient.NationalID}}<div class="detail">National ID: <strong>{{.Patient.NationalID}}</strong></div>{{end}}
</td>
<td >
{{if .Patient.PhoneNumber}}<div class="detail">Phone number: <strong>{{.Patient.PhoneNumber}}</strong></div>{{end}}
</td>
<div class="detail">Age: <strong>{{.Patient.Age}}</strong></div>
</td>
{{end}}
</tr>
<tr>
{{if .Patient.Sex}}
<td>
{{if .Patient.DateOfBirth}}<div class="detail">Date of birth: <strong>{{.Patient.DateOfBirth}}</strong></div>{{end}}
</td>
<td >
{{if .Patient.Age}}<div class="detail">Age: <strong>{{.Patient.Age}}</strong></div>{{end}}
</td>
<div class="detail">Sex: <strong>{{.Patient.Sex}}</strong></div>
</td>
{{end}}
</tr>
<tr>
{{if .Patient.NationalID}}
<td>
{{if .Patient.Sex}}<div class="detail">Sex: <strong>{{.Patient.Sex}}</strong></div>{{end}}
</td>
<div class="detail">National ID: <strong>{{.Patient.NationalID}}</strong></div>
</td>
{{end}}
{{if .Patient.EmpowerID}}
<td>
<div class="detail">Empower ID: <strong>{{.Patient.EmpowerID}}</strong></div>
</td>
{{end}}
</tr>
</table>
</div>
Expand Down Expand Up @@ -256,15 +270,24 @@ const ReferralFormTemplate = `
{{if .MedicalHistory.Medication}}<div class="detail">Medication: <strong>{{.MedicalHistory.Medication}}</strong></div>{{end}}
{{if .MedicalHistory.ReferralNotes}}<div class="detail">Referral notes: <strong>{{.MedicalHistory.ReferralNotes}}</strong></div>{{end}}
{{if .MedicalHistory.Tests}}
<div class="tests">
<table>
<thead>
<tr>
<th>Test</th>
<th>Result</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{{range .MedicalHistory.Tests}}
<div>
{{if .Name}}<div class="detail">Test: <strong>{{.Name}}</strong></div>{{end}}
{{if .Results}}<div class="detail">Results: <strong>{{.Results}}</strong></div>{{end}}
{{if .Date}}<div class="detail">Date: <strong>{{.Date}}</strong></div>{{end}}
</div>
<tr>
{{if .Name}}<td>{{.Name}}</td>{{else}}<td></td>{{end}}
{{if .Results}}<td>{{.Results}}</td>{{else}}<td></td>{{end}}
{{if .Date}}<td>{{.Date}}</td>{{else}}<td></td>{{end}}
</tr>
{{end}}
</div>
</tbody>
</table>
{{end}}
</div>
{{end}}
Expand Down
5 changes: 4 additions & 1 deletion pkg/clinical/usecases/clinical/observation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 27 additions & 2 deletions pkg/clinical/usecases/clinical/referral_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
Expand Down

0 comments on commit 387f8b9

Please sign in to comment.