Skip to content

Commit

Permalink
fix: update patient registration workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Mar 23, 2022
1 parent d93834f commit c267dce
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 58 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ require (
github.com/rs/xid v1.3.0
github.com/savannahghi/converterandformatter v0.0.11
github.com/savannahghi/enumutils v0.0.3
github.com/savannahghi/errorcodeutil v0.0.5 // indirect
github.com/savannahghi/feedlib v0.0.6 // indirect
github.com/savannahghi/errorcodeutil v0.0.5
github.com/savannahghi/feedlib v0.0.6
github.com/savannahghi/firebasetools v0.0.15
github.com/savannahghi/interserviceclient v0.0.18
github.com/savannahghi/onboarding v0.0.22
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcju
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -388,7 +390,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/savannahghi/converterandformatter v0.0.3/go.mod h1:0o7yieYU10WabPqKuqj+5QL52eTL1eGElxjb+A68bbA=
Expand Down Expand Up @@ -441,6 +445,7 @@ github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
Expand Down Expand Up @@ -475,6 +480,7 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
Expand Down Expand Up @@ -580,6 +586,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -797,6 +804,7 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
15 changes: 15 additions & 0 deletions pkg/clinical/application/common/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ const (

// CreatePatientTopic is the topic ID where patient data is published to
CreatePatientTopic = "patient.create"

// VitalsTopicName is the topic for publishing a patient's vital signs
VitalsTopicName = "vitals.create"

// AllergyTopicName is the topic for publishing a patient's allergy
AllergyTopicName = "allergy.create"

// MedicationTopicName is the topic for publishing a patient's medication
MedicationTopicName = "medication.create"

// TestResultTopicName is the topic for publishing a patient's test results
TestResultTopicName = "test.result.create"

//TestOrderTopicName is the topic for publishing a patient's test order
TestOrderTopicName = "test.order.create"
)

// DefaultIdentifier assigns a patient a code to function as their
Expand Down
5 changes: 5 additions & 0 deletions pkg/clinical/infrastructure/services/pubsub/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ func (ps ServicePubSubMessaging) TopicIDs() []string {
return []string{
ps.AddPubSubNamespace(TestTopicName, ClinicalServiceName),
ps.AddPubSubNamespace(common.CreatePatientTopic, ClinicalServiceName),
ps.AddPubSubNamespace(common.VitalsTopicName, ClinicalServiceName),
ps.AddPubSubNamespace(common.MedicationTopicName, ClinicalServiceName),
ps.AddPubSubNamespace(common.AllergyTopicName, ClinicalServiceName),
ps.AddPubSubNamespace(common.TestResultTopicName, ClinicalServiceName),
ps.AddPubSubNamespace(common.TestOrderTopicName, ClinicalServiceName),
}
}

Expand Down
11 changes: 6 additions & 5 deletions pkg/clinical/infrastructure/services/pubsub/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pubsubmessaging
import (
"encoding/json"
"net/http"
"strings"

"github.com/savannahghi/clinical/pkg/clinical/application/common"
"github.com/savannahghi/clinical/pkg/clinical/application/dto"
Expand Down Expand Up @@ -58,16 +59,16 @@ func (ps ServicePubSubMessaging) ReceivePubSubPushMessages(
}

year, month, day := profile.DateOfBirth.Date()
patientName := strings.Split(profile.Name, " ")
payload := domain.SimplePatientRegistrationInput{
ID: *profile.ID,
Names: []*domain.NameInput{{FirstName: profile.Name, OtherNames: &profile.Username}},
IdentificationDocuments: []*domain.IdentificationDocument{},
ID: *profile.ID,
Names: []*domain.NameInput{{FirstName: patientName[0], LastName: patientName[1]}},
BirthDate: scalarutils.Date{
Year: year,
Month: int(month),
Day: day,
},
PhoneNumbers: []*domain.PhoneNumberInput{{Msisdn: profile.Contacts.ContactValue}},
PhoneNumbers: []*domain.PhoneNumberInput{{Msisdn: profile.Contacts.ContactValue, CommunicationOptIn: true}},
Gender: string(profile.Gender),
Active: profile.Active,
}
Expand All @@ -81,7 +82,7 @@ func (ps ServicePubSubMessaging) ReceivePubSubPushMessages(
return
}

err = ps.infra.MyCareHub.AddFHIRIDToPatientProfile(ctx, *patient.PatientRecord.ID, *profile.ID)
err = ps.infra.MyCareHub.AddFHIRIDToPatientProfile(ctx, *patient.PatientRecord.ID, data.ID)
if err != nil {
serverutils.WriteJSONResponse(w, errorcodeutil.CustomError{
Err: err,
Expand Down
57 changes: 30 additions & 27 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.

6 changes: 3 additions & 3 deletions pkg/clinical/presentation/graph/healthpassport.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ input SimplePatientRegistrationInput {
id: ID
names: [NameInput!]!
gender: String!
identificationDocuments: [IdentificationDocument!]!
identificationDocuments: [IdentificationDocument!]
birthDate: Date!
phoneNumbers: [PhoneNumberInput!]!
photos: [PhotoInput]
Expand Down Expand Up @@ -156,8 +156,8 @@ input IdentificationDocument {

input PhoneNumberInput {
msisdn: String!
verificationCode: String!
isUSSD: Boolean!
verificationCode: String
isUSSD: Boolean
communicationOptIn: Boolean!
}

Expand Down
11 changes: 0 additions & 11 deletions pkg/clinical/usecases/fhir.go
Original file line number Diff line number Diff line change
Expand Up @@ -2069,17 +2069,6 @@ func (fh *FHIRUseCaseImpl) GetFHIRPatient(ctx context.Context, id string) (*doma

// DeleteFHIRPatient deletes the FHIRPatient identified by the supplied ID
func (fh *FHIRUseCaseImpl) DeleteFHIRPatient(ctx context.Context, id string) (bool, error) {
user, err := fh.infrastructure.BaseExtension.GetLoggedInUser(ctx)
if err != nil {
return false, fmt.Errorf("unable to get user: %w", err)
}
isAuthorized, err := auth.IsAuthorized(user, auth.ProblemSummaryView)
if err != nil {
return false, err
}
if !isAuthorized {
return false, fmt.Errorf("user not authorized to access this resource")
}
patientEverythingBs, err := fh.infrastructure.FHIRRepo.GetFHIRPatientEverything(id)
if err != nil {
return false, fmt.Errorf("unable to get patient's compartment: %v", err)
Expand Down
14 changes: 4 additions & 10 deletions pkg/clinical/usecases/patient.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,23 +471,17 @@ func (c *ClinicalUseCaseImpl) ContactsToContactPointInput(ctx context.Context, p
use := domain.ContactPointUseEnumHome

for _, phone := range phones {
if phone.IsUssd {
continue // don't verify USSD
}
isVerified, normalized, err := c.infrastructure.Engagement.VerifyOTP(
ctx, phone.Msisdn, phone.VerificationCode)
normalized, err := converterandformatter.NormalizeMSISDN(phone.Msisdn)
if err != nil {
return nil, fmt.Errorf("invalid phone: %w", err)
}
if !isVerified {
return nil, fmt.Errorf("invalid OTP")
return nil, fmt.Errorf("failed to normalize phonenumber")
}

phoneContact := &domain.FHIRContactPointInput{
System: &phoneSystem,
Use: &use,
Rank: &rank,
Period: common.DefaultPeriodInput(),
Value: &normalized,
Value: normalized,
}
output = append(output, phoneContact)
rank++
Expand Down

0 comments on commit c267dce

Please sign in to comment.