Upstream sync

This commit is contained in:
Senad Uka
2018-05-22 12:40:22 +02:00
parent 39c614fb98
commit 6e903b4d57
31 changed files with 948 additions and 83 deletions

View File

@@ -58,6 +58,7 @@ type ProviderRepo interface {
Get(query string, lat float64, long float64, distance int64, planCode string, productID string, mukID string, internalID string, sort string, user entity.User) ([]entity.Provider, error)
GetByMukID(mukID string, user entity.User) (entity.Provider, error)
GetByUUID(providerUUID string, user entity.User) (entity.Provider, error)
GetByNPI(NPI string, user entity.User) (entity.Provider, error)
}
// NotificationRepo defines the data set for Notification
@@ -74,6 +75,7 @@ type OrganizationRepo interface {
GetAllTypes() ([]entity.OrganizationType, error)
GetByType(organizationTypeKey string, user entity.User) ([]entity.Organization, error)
GetByUUID(organizationUUID string, user entity.User) (entity.Organization, error)
GetByTypeAndReferenceID(typeKey string, referenceID int64, user entity.User) (entity.Organization, error)
GetContactsByOrganizationUUID(organizationUUID string) ([]entity.OrganizationContact, error)
GetContactsByOrganizationID(organizationID int64) ([]entity.OrganizationContact, error)
GetContactsByUUID(contactUUID string) (entity.OrganizationContact, error)

View File

@@ -26,6 +26,7 @@ type Provider struct {
Keys []ProviderKey `json:"keys"`
Address ProviderAddress `json:"address"`
Distance float64 `json:"distance"`
Organization Organization `json:"organization"`
}
type ProviderKey struct {

View File

@@ -28,6 +28,10 @@ func (s *organizationService) GetByName(name string, searchType string, user ent
return s.svc.db.Organization().GetByName(name, searchType, user)
}
func (s *organizationService) GetByTypeAndReferenceID(typeKey string, referenceID int64, user entity.User) (entity.Organization, error) {
return s.svc.db.Organization().GetByTypeAndReferenceID(typeKey, referenceID, user)
}
func (s *organizationService) GetByUUID(organizationUUID string, user entity.User) (entity.Organization, error) {
organization, err := s.svc.db.Organization().GetByUUID(organizationUUID, user)
if err != nil {

View File

@@ -42,9 +42,46 @@ func (s *providerService) Get(query string, lat float64, long float64, distance
}
func (s *providerService) GetByMukID(mukID string, user entity.User) (entity.Provider, error) {
return s.svc.db.Provider().GetByMukID(mukID, user)
provider, err := s.svc.db.Provider().GetByMukID(mukID, user)
if err != nil {
return provider, err
}
organization, err := s.svc.db.Organization().GetByTypeAndReferenceID("provider", provider.ProviderID, user)
if err != nil {
return provider, err
}
provider.Organization = organization
return provider, nil
}
func (s *providerService) GetByUUID(providerUUID string, user entity.User) (entity.Provider, error) {
return s.svc.db.Provider().GetByUUID(providerUUID, user)
provider, err := s.svc.db.Provider().GetByUUID(providerUUID, user)
if err != nil {
return provider, err
}
organization, err := s.svc.db.Organization().GetByTypeAndReferenceID("provider", provider.ProviderID, user)
if err != nil {
return provider, err
}
provider.Organization = organization
return provider, nil
}
func (s *providerService) GetByNPI(NPI string, user entity.User) (entity.Provider, error) {
provider, err := s.svc.db.Provider().GetByNPI(NPI, user)
if err != nil {
return provider, err
}
organization, err := s.svc.db.Organization().GetByTypeAndReferenceID("provider", provider.ProviderID, user)
if err != nil {
return provider, err
}
provider.Organization = organization
return provider, nil
}