Skip to content

Commit

Permalink
chore: update referral api input payload (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Apr 3, 2024
1 parent 4ac89e1 commit 53ac746
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 37 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cloud.google.com/go/firestore v1.15.0
cloud.google.com/go/pubsub v1.37.0
cloud.google.com/go/storage v1.39.1
github.com/99designs/gqlgen v0.17.45
github.com/99designs/gqlgen v0.17.36
github.com/SebastiaanKlippert/go-wkhtmltopdf v1.9.2
github.com/ahmetb/go-linq/v3 v3.2.0
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
Expand Down Expand Up @@ -97,7 +97,6 @@ require (
github.com/prometheus/prometheus v0.51.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sosodev/duration v1.2.0 // indirect
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect
github.com/ttacon/libphonenumber v1.2.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,14 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
github.com/99designs/gqlgen v0.13.0/go.mod h1:NV130r6f4tpRWuAI+zsrSdooO/eWUv+Gyyoi3rEfXIk=
github.com/99designs/gqlgen v0.17.45 h1:bH0AH67vIJo8JKNKPJP+pOPpQhZeuVRQLf53dKIpDik=
github.com/99designs/gqlgen v0.17.45/go.mod h1:Bas0XQ+Jiu/Xm5E33jC8sES3G+iC2esHBMXcq0fUPs0=
github.com/99designs/gqlgen v0.17.36 h1:u/o/rv2SZ9s5280dyUOOrkpIIkr/7kITMXYD3rkJ9go=
github.com/99designs/gqlgen v0.17.36/go.mod h1:6RdyY8puhCoWAQVr2qzF2OMVfudQzc8ACxzpzluoQm4=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno=
github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
github.com/PuerkitoBio/goquery v1.9.1 h1:mTL6XjbJTZdpfL+Gwl5U2h1l9yEkJjhmlTeV9VPW7UI=
github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY=
github.com/SebastiaanKlippert/go-wkhtmltopdf v1.9.2 h1:enQwehstpeaAnsyse1Aqb6r0sU5UJbiNvIqVmPo+KWI=
github.com/SebastiaanKlippert/go-wkhtmltopdf v1.9.2/go.mod h1:SQq4xfIdvf6WYKSDxAJc+xOJdolt+/bc1jnQKMtPMvQ=
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
Expand All @@ -99,8 +97,6 @@ github.com/ahmetb/go-linq/v3 v3.2.0/go.mod h1:haQ3JfOeWK8HpVxMtHHEMPVgBKiYyQ+f1/
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
Expand Down Expand Up @@ -530,8 +526,6 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg=
github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM=
github.com/sosodev/duration v1.2.0 h1:pqK/FLSjsAADWY74SyWDCjOcd5l7H8GSnnOGEB9A1Us=
github.com/sosodev/duration v1.2.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
Expand Down
9 changes: 8 additions & 1 deletion pkg/clinical/application/dto/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,17 @@ type ReferralInput struct {
ReferralType ReferralTypeEnum `json:"referralType"`
Tests []string `json:"tests,omitempty"`
Specialist string `json:"specialist,omitempty"`
Facility string `json:"facility"`
Facility *FacilityInput `json:"facility"`
ReferralNote string `json:"notes"`
}

// FacilityInput represents the facility payload passed when referring a patient
type FacilityInput struct {
Name string `json:"name,omitempty"`
County string `json:"county,omitempty"`
Contact string `json:"contact,omitempty"`
}

func (r ReferralInput) Validate() error {
v := validator.New()
err := v.Struct(r)
Expand Down
4 changes: 2 additions & 2 deletions pkg/clinical/presentation/graph/clinical.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 73 additions & 18 deletions pkg/clinical/presentation/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion pkg/clinical/presentation/graph/inputs.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ input ReferralInput {
referralType: ReferralTypeEnum!
tests: [String]
specialist: String
facility: String!
facility: FacilityInput!
referralNote: String!
}

input FacilityInput {
name: String!
county: String!
contact: String
}
14 changes: 12 additions & 2 deletions pkg/clinical/usecases/clinical/referral_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,22 @@ func (c *UseCasesClinicalImpl) GenerateReferralReportPDF(ctx context.Context, se
Sex: patient.Resource.Gender.String(),
}

var referredFacilityName string
var referredFacilityName, referredFacilityCounty, referredFacilityContact string

for _, extension := range serviceRequest.Resource.Extension {
if extension.URL == "http://savannahghi.org/fhir/StructureDefinition/referred-facility" {
for _, ext := range extension.Extension {
if ext.URL == "facilityName" {
referredFacilityName = ext.ValueString
}

if ext.URL == "facilityCounty" {
referredFacilityCounty = ext.ValueString
}

if ext.URL == "facilityContact" {
referredFacilityContact = ext.ValueString
}
}
}
}
Expand All @@ -143,7 +151,9 @@ func (c *UseCasesClinicalImpl) GenerateReferralReportPDF(ctx context.Context, se
Patient: patientData,
NextOfKin: NextOfKin{},
Facility: Facility{
Name: referredFacilityName,
Name: referredFacilityName,
Contact: referredFacilityContact,
Location: referredFacilityCounty,
},
Referral: Referral{
Reason: referralReason,
Expand Down
12 changes: 10 additions & 2 deletions pkg/clinical/usecases/clinical/servicerequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ func (c *UseCasesClinicalImpl) ReferPatient(
},
}

if input.Facility != "" {
if input.Facility != nil {
facilityExtension := &domain.FHIRExtension{
URL: "http://savannahghi.org/fhir/StructureDefinition/referred-facility",
Extension: []domain.Extension{
{
URL: "facilityName",
ValueString: input.Facility,
ValueString: input.Facility.Name,
},
{
URL: "facilityContact",
ValueString: input.Facility.Contact,
},
{
URL: "facilityCounty",
ValueString: input.Facility.County,
},
},
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/clinical/usecases/clinical/servicerequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ func TestUseCasesClinicalImpl_ReferPatient(t *testing.T) {
ReferralType: "DIAGNOSTICS",
Tests: []string{"VIA"},
Specialist: "Oncologist",
Facility: "KNH",
Facility: &dto.FacilityInput{
Name: "KNH",
County: "Nairobi",
Contact: "+254710100100",
},
ReferralNote: "",
},
},
Expand Down

0 comments on commit 53ac746

Please sign in to comment.