Upstream sync

This commit is contained in:
Senad Uka
2018-05-18 18:55:00 +02:00
parent 2e5444bed8
commit a9f113b9e9
17 changed files with 227 additions and 43 deletions

View File

@@ -16,6 +16,7 @@ import (
"bitbucket.org/nemt/nemt-portal-api/server/router/placesroute"
"bitbucket.org/nemt/nemt-portal-api/server/router/profileroute"
"bitbucket.org/nemt/nemt-portal-api/server/router/providerroute"
"bitbucket.org/nemt/nemt-portal-api/server/router/selfregisterroute"
"bitbucket.org/nemt/nemt-portal-api/server/router/tncroute"
"bitbucket.org/nemt/nemt-portal-api/server/router/twilioroute"
"bitbucket.org/nemt/nemt-portal-api/server/router/usersroute"
@@ -37,6 +38,7 @@ func Register(e *echo.Echo, cfg *config.Config, svc *applicationservice.Service,
lyfthookroute.Register(prefixGroup.Group("/lyfthook"), cfg, svc, tnc, notification)
externalroute.Register(prefixGroup.Group("/ext"), cfg, svc, tnc, notification)
authenticateroute.Register(prefixGroup.Group("/authenticate"), cfg, svc)
selfregisterroute.Register(prefixGroup.Group("/selfregister"), cfg, svc)
appGroup := prefixGroup.Group("/" + cfg.App.Name)
usersroute.Register(appGroup.Group("/users"), cfg, svc)
@@ -47,4 +49,5 @@ func Register(e *echo.Echo, cfg *config.Config, svc *applicationservice.Service,
placesroute.Register(appGroup.Group("/places"), cfg, svc)
profileroute.Register(appGroup.Group("/profile"), cfg, svc)
organizationroute.Register(appGroup.Group("/organization"), cfg, svc)
}

View File

@@ -0,0 +1,38 @@
package selfregisterroute
import (
"sync"
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
"bitbucket.org/nemt/nemt-portal-api/application/third/eligibility/bcbsi"
"bitbucket.org/nemt/nemt-portal-api/infra/config"
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
"github.com/labstack/echo"
)
var (
instance *controller
once sync.Once
)
type controller struct {
svc *applicationservice.Service
cfg *config.Config
bcbsi *bcbsi.Service
}
func controllerInstance(svc *applicationservice.Service, cfg *config.Config) *controller {
once.Do(func() {
instance = &controller{
svc: svc,
cfg: cfg,
bcbsi: bcbsi.New(cfg),
}
})
return instance
}
func (c *controller) handle(ctx echo.Context) error {
return routeutils.ResponseAPIOK(ctx, "OK")
}

View File

@@ -0,0 +1,18 @@
package selfregisterroute
import (
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
"bitbucket.org/nemt/nemt-portal-api/infra/config"
"github.com/labstack/echo"
)
const (
rootRoute = "/"
)
// Register registers the routes in the echo group
func Register(r *echo.Group, cfg *config.Config, svc *applicationservice.Service) {
ctrl := controllerInstance(svc, cfg)
r.POST(rootRoute, ctrl.handle)
}

View File

@@ -228,9 +228,6 @@ func (c *controller) handle(ctx echo.Context) error {
if err != nil {
return routeutils.HandleAPIError(ctx, err)
}
if user.ID == "" {
return routeutils.ResponseAPIValidationError(ctx, "User not found")
}
//Validate ride request
if validationErrors := validation.ValidateRide(&requestRide, &user) ; len(validationErrors) > 0 {

View File

@@ -1,12 +1,17 @@
package visitroute
import (
"fmt"
"sync"
"time"
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
"bitbucket.org/nemt/nemt-portal-api/application/third/eligibility/bcbsi"
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
"bitbucket.org/nemt/nemt-portal-api/infra/auth"
"bitbucket.org/nemt/nemt-portal-api/infra/config"
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
"bitbucket.org/nemt/nemt-portal-api/server/validation"
"github.com/labstack/echo"
)
@@ -16,20 +21,66 @@ var (
)
type controller struct {
svc *applicationservice.Service
cfg *config.Config
svc *applicationservice.Service
cfg *config.Config
bcbsi *bcbsi.Service
}
func controllerInstance(svc *applicationservice.Service, cfg *config.Config) *controller {
once.Do(func() {
instance = &controller{
svc: svc,
cfg: cfg,
svc: svc,
cfg: cfg,
bcbsi: bcbsi.New(cfg),
}
})
return instance
}
func (c *controller) handle(ctx echo.Context) error {
var visit viewmodel.Visit
if err := ctx.Bind(&visit); err != nil {
fmt.Println(err)
return routeutils.ResponseAPIValidationError(ctx, "invalid parameters")
}
user, err := auth.GetUserDetail(ctx, c.cfg)
if err != nil {
return routeutils.HandleAPIError(ctx, err)
}
provider, err := c.svc.Provider.GetByUUID(visit.Provider.ProviderUUID, user)
if err != nil {
fmt.Println(err)
return routeutils.ResponseAPIValidationError(ctx, "invalid provider")
}
if validationErrors := validation.ValidateVisit(&visit, &user); len(validationErrors) > 0 {
return routeutils.ResponseAPICustomValidationError(ctx, "visit validation failed", validationErrors)
}
eligibility := viewmodel.Eligibility{}
eligibility.Provider.ProviderNPI = provider.InternalID
eligibility.Provider.ProviderName = provider.Name
eligibility.TrackingID = *visit.User.Member
eligibility.Subscriber.SubscriberID = *visit.User.Member
eligibility.Subscriber.PatientType = *visit.User.Type
eligibility.Subscriber.Name.First = visit.User.First
eligibility.Subscriber.Name.Last = visit.User.Last
eligibility.Subscriber.DemographicInfo.DateOfBirth = *visit.User.BirthDate
eligibility.Subscriber.DemographicInfo.Gender = *visit.User.Gender
eligibility.ServiceInfo.DateOfService = time.Now()
eligibility.ServiceInfo.ServiceTypeCodes = []string{"30"}
resp, err := c.bcbsi.BXE.Get271(eligibility)
if err != nil {
fmt.Println(err)
return routeutils.ResponseAPIValidationError(ctx, err.Error())
}
return routeutils.ResponseAPIOK(ctx, resp)
}
func (c *controller) handleGetByID(ctx echo.Context) error {
visit_uuid := ctx.Param("visit_uuid")
if visit_uuid == "" {

View File

@@ -15,6 +15,8 @@ const (
func Register(r *echo.Group, cfg *config.Config, svc *applicationservice.Service) {
ctrl := controllerInstance(svc, cfg)
r.POST(rootRoute, ctrl.handle)
r.GET(rootRoute, ctrl.handleGetAll)
r.GET(idRoute, ctrl.handleGetByID)
}