Skip to content

Commit

Permalink
feat: register patient
Browse files Browse the repository at this point in the history
  • Loading branch information
Muchogoc committed Mar 22, 2023
1 parent 1786215 commit 8395469
Show file tree
Hide file tree
Showing 22 changed files with 1,477 additions and 178 deletions.
2 changes: 1 addition & 1 deletion gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ resolver:
dir: pkg/clinical/presentation/graph

autobind:
- "github.com/savannahghi/clinical/pkg/clinical/application/dto"
- "github.com/savannahghi/scalarutils"
- "github.com/savannahghi/enumutils"
- "github.com/savannahghi/firebasetools"
- "github.com/savannahghi/clinical/pkg/clinical/application/dto"
- "github.com/savannahghi/clinical/pkg/clinical/domain"
- "github.com/savannahghi/clinical/pkg/clinical/presentation/graph"
- "github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/openconceptlab"
Expand Down
5 changes: 0 additions & 5 deletions pkg/clinical/application/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import (
"github.com/sirupsen/logrus"
)

const (
// MaxClinicalRecordPageSize is the maximum number of encounters we can show on a timeline
MaxClinicalRecordPageSize = 50
)

// BaseExtension is an interface that represents some methods in base
// The `onboarding` service has a dependency on `base` library.
// Our first step to making some functions are testable is to remove the base dependency.
Expand Down
10 changes: 0 additions & 10 deletions pkg/clinical/application/common/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ const (
timeFormatStr = "2006-01-02T15:04:05+03:00"
healthCloudIdentifiers = "healthcloud.identifiers"
healthCloudIdentifiersVersion = "0.0.1"
// SendEmailEndpoint is the endpoint used to send an email
SendEmailEndpoint = "internal/send_email"
// SendSMSEndpoint is the endpoint used to send sms
SendSMSEndpoint = "internal/send_sms"
// EmailWelcomeSubject is the subject of the welcome email
EmailWelcomeSubject = "Welcome to Be.Well"
// DefaultLanguage ...
DefaultLanguage = "English"
// CallCenterNumber is Savannah's call center number
CallCenterNumber = "0790 360 360"

// CreatePatientTopic is the topic ID where patient data is published to
CreatePatientTopic = "patient.create"
Expand Down
2 changes: 0 additions & 2 deletions pkg/clinical/application/common/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ const (
IDIdentifierSystem = "healthcloud.iddocument"
MSISDNIdentifierSystem = "healthcloud.msisdn"
DefaultVersion = "0.0.1"
DefaultPhotoTitle = "Patient Photo"
DefaultPhotoFilename = "photo.jpg"
)

// ComposeOneHealthEpisodeOfCare is used to create an episode of care
Expand Down
27 changes: 27 additions & 0 deletions pkg/clinical/application/dto/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,30 @@ const (
MedicationStatementStatusEnumInActive MedicationStatementStatusEnum = "inactive"
MedicationStatementStatusEnumUnknown MedicationStatementStatusEnum = "unknown"
)

type IdentifierType string

const (
IdentifierTypeNationalID IdentifierType = "NATIONAL_ID"
IdentifierTypePassport IdentifierType = "PASSPORT"
IdentifierTypeAlienID IdentifierType = "ALIEN_ID"
IdentifierTypeCCCNumber IdentifierType = "CCC_NUMBER"
)

type ContactType string

const (
ContactTypePhoneNumber ContactType = "PHONE_NUMBER"
)

// Gender is a FHIR enum
type Gender string

const (
// GenderMale ...
GenderMale Gender = "male"
// GenderFemale ...
GenderFemale Gender = "female"
// GenderOther ...
GenderOther Gender = "other"
)
25 changes: 24 additions & 1 deletion pkg/clinical/application/dto/input.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package dto

import "github.com/go-playground/validator"
import (
"github.com/go-playground/validator"
"github.com/savannahghi/scalarutils"
)

type OrganizationIdentifier struct {
Type OrganizationIdentifierType `json:"type,omitempty"`
Expand Down Expand Up @@ -31,3 +34,23 @@ func (o ObservationInput) Validate() error {

return err
}

type PatientInput struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
OtherNames *string `json:"otherNames"`
BirthDate scalarutils.Date `json:"birthDate"`
Gender Gender `json:"gender"`
Identifiers []IdentifierInput `json:"identifiers"`
Contacts []ContactInput `json:"contacts"`
}

type IdentifierInput struct {
Type IdentifierType `json:"type"`
Value string `json:"value"`
}

type ContactInput struct {
Type ContactType `json:"type"`
Value string `json:"value"`
}
9 changes: 9 additions & 0 deletions pkg/clinical/application/dto/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,12 @@ type MedicalData struct {
ViralLoad []*Observation
CD4Count []*Observation
}

type Patient struct {
ID string `json:"id"`
Active bool `json:"active"`
Name string `json:"name"`
PhoneNumber []string `json:"phoneNumber"`
Gender Gender `json:"gender"`
BirthDate scalarutils.Date `json:"birthDate"`
}
3 changes: 0 additions & 3 deletions pkg/clinical/application/utils/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const (
// OrganizationIDContextKey is the key used to add an organizationID to the context
OrganizationIDContextKey = ContextKey("OrganizationID")

// ProgramIDContextKey is the key used to add a program to the context
ProgramIDContextKey = ContextKey("ProgramID")

// FacilityIDContextKey is the key used to add a facility to the context
FacilityIDContextKey = ContextKey("FacilityID")
)
Expand Down
4 changes: 1 addition & 3 deletions pkg/clinical/domain/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ func (p FHIRPatient) IsEntity() {}
// PatientPayload is used to return patient records and ancillary data after
// mutations.
type PatientPayload struct {
PatientRecord *FHIRPatient `json:"patientRecord,omitempty"`
HasOpenEpisodes bool `json:"hasOpenEpisodes,omitempty"`
OpenEpisodes []*FHIREpisodeOfCare `json:"openEpisodes,omitempty"`
PatientRecord *FHIRPatient `json:"patientRecord,omitempty"`
}

// RetirePatientInput is used to retire patient records.
Expand Down
3 changes: 0 additions & 3 deletions pkg/clinical/infrastructure/datastore/cloudhealthcare/fhir.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,9 +1339,6 @@ func (fh *StoreImpl) CreateFHIRPatient(_ context.Context, input domain.FHIRPatie

output := &domain.PatientPayload{
PatientRecord: resource,
// The patient is newly created so we can assume they have no open episodes
HasOpenEpisodes: false,
OpenEpisodes: []*domain.FHIREpisodeOfCare{},
}

return output, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,19 @@ func NewFHIRMock() *FHIRMock {
return &domain.FHIRMedicationRelayPayload{}, nil
},
MockCreateFHIRPatientFn: func(ctx context.Context, input domain.FHIRPatientInput) (*domain.PatientPayload, error) {
male := domain.PatientGenderEnumMale
return &domain.PatientPayload{
PatientRecord: &domain.FHIRPatient{
ID: new(string),
Text: &domain.FHIRNarrative{},
Identifier: []*domain.FHIRIdentifier{},
Active: new(bool),
Name: []*domain.FHIRHumanName{},
ID: new(string),
Text: &domain.FHIRNarrative{},
Gender: &male,
Identifier: []*domain.FHIRIdentifier{},
Active: new(bool),
Name: []*domain.FHIRHumanName{
{
Text: gofakeit.Name(),
},
},
Telecom: []*domain.FHIRContactPoint{},
BirthDate: &scalarutils.Date{},
DeceasedBoolean: new(bool),
Expand All @@ -589,8 +595,6 @@ func NewFHIRMock() *FHIRMock {
ManagingOrganization: &domain.FHIRReference{},
Link: []*domain.FHIRPatientLink{},
},
HasOpenEpisodes: false,
OpenEpisodes: []*domain.FHIREpisodeOfCare{},
}, nil
},
MockPatchFHIRPatientFn: func(ctx context.Context, id string, params []map[string]interface{}) (*domain.FHIRPatient, error) {
Expand Down
16 changes: 0 additions & 16 deletions pkg/clinical/presentation/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@ var ClinicalAllowedOrigins = []string{
"https://clinical-prod.bewell.co.ke",
}

// ClinicalAllowedHeaders is a list of CORS allowed headers for the clinical
// service
var ClinicalAllowedHeaders = []string{
"Accept",
"Accept-Charset",
"Accept-Language",
"Accept-Encoding",
"Origin",
"Host",
"User-Agent",
"Content-Length",
"Content-Type",
"Authorization",
"X-Authorization",
}

var (
authServerEndpoint = serverutils.MustGetEnvVar("AUTHSERVER_ENDPOINT")
clientID = serverutils.MustGetEnvVar("CLIENT_ID")
Expand Down
4 changes: 4 additions & 0 deletions pkg/clinical/presentation/graph/clinical.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ extend type Mutation {
recordPulseRate(input: ObservationInput!): Observation!
recordBloodPressure(input: ObservationInput!): Observation!
recordBMI(input: ObservationInput!): Observation!

# Patient
createPatient(input: PatientInput!): Patient!

}
7 changes: 7 additions & 0 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.

17 changes: 17 additions & 0 deletions pkg/clinical/presentation/graph/enums.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,21 @@ enum MedicationStatementStatusEnum {
active
inactive
unknown
}

enum Gender {
male
female
other
}

enum IdentifierType {
NATIONAL_ID
PASSPORT
ALIEN_ID
CCC_NUMBER
}

enum ContactType {
PHONE_NUMBER
}

0 comments on commit 8395469

Please sign in to comment.