Compare commits
8 Commits
zip-code-t
...
verify-eli
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88d46b51f6 | ||
|
|
d8737a558b | ||
|
|
94229831e0 | ||
|
|
6e903b4d57 | ||
|
|
39c614fb98 | ||
|
|
157b23da3c | ||
|
|
cf5b94edcc | ||
|
|
a9f113b9e9 |
@@ -1,4 +1,11 @@
|
|||||||
FROM amazonlinux
|
FROM nginx:latest
|
||||||
|
|
||||||
|
RUN apt-get update; apt-get install -y openssl
|
||||||
|
RUN apt-get install -y ca-certificates
|
||||||
|
|
||||||
|
RUN rm -rf /etc/nginx/conf.d/*;
|
||||||
|
COPY ./dist/default.conf /etc/nginx/conf.d/
|
||||||
|
COPY ./dist/nginx.conf /etc/nginx/
|
||||||
|
|
||||||
# Sets the arguments.
|
# Sets the arguments.
|
||||||
ARG BIN_NAME=nemt-portal-api
|
ARG BIN_NAME=nemt-portal-api
|
||||||
@@ -7,12 +14,14 @@ ARG WORKDIR=/opt/app/
|
|||||||
|
|
||||||
# Creates the necessary directories.
|
# Creates the necessary directories.
|
||||||
RUN mkdir -p /opt/app/docs
|
RUN mkdir -p /opt/app/docs
|
||||||
|
RUN mkdir -p /opt/app/certs
|
||||||
RUN mkdir -p /opt/app/static
|
RUN mkdir -p /opt/app/static
|
||||||
RUN mkdir -p /var/log/bsbsi
|
RUN mkdir -p /var/log/bsbsi
|
||||||
|
|
||||||
# Copies the files to the container.
|
# Copies the files to the container.
|
||||||
COPY ./dist/${BIN_NAME} /opt/app/${BIN_NAME}
|
COPY ./dist/${BIN_NAME} /opt/app/${BIN_NAME}
|
||||||
ADD ./dist/docs/ /opt/app/docs/
|
ADD ./dist/docs/ /opt/app/docs/
|
||||||
|
ADD ./dist/certs/ /opt/app/certs/
|
||||||
ADD ./dist/static/ /opt/app/static/
|
ADD ./dist/static/ /opt/app/static/
|
||||||
ADD ./dist/config.toml /opt/app/config.toml
|
ADD ./dist/config.toml /opt/app/config.toml
|
||||||
ADD ./dist/authorization_model.conf /opt/app/authorization_model.conf
|
ADD ./dist/authorization_model.conf /opt/app/authorization_model.conf
|
||||||
@@ -20,5 +29,8 @@ ADD ./dist/authorization_policy.csv /opt/app/authorization_policy.csv
|
|||||||
|
|
||||||
# Sets and executes the app.
|
# Sets and executes the app.
|
||||||
WORKDIR /opt/app
|
WORKDIR /opt/app
|
||||||
EXPOSE 5000
|
|
||||||
CMD ./nemt-portal-api
|
EXPOSE 80
|
||||||
|
EXPOSE 443
|
||||||
|
|
||||||
|
CMD nginx & ./nemt-portal-api
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -12,7 +12,7 @@ RUN_CONTAINER_NAME = ${APP_NAME}-run
|
|||||||
#############################
|
#############################
|
||||||
|
|
||||||
set-loc:
|
set-loc:
|
||||||
$(eval DEPLOY_ENV := loc)
|
$(eval DEPLOY_ENV := dev)
|
||||||
|
|
||||||
set-dev:
|
set-dev:
|
||||||
$(eval DEPLOY_ENV := dev)
|
$(eval DEPLOY_ENV := dev)
|
||||||
@@ -49,6 +49,7 @@ build: clean create-build-container
|
|||||||
# Creates the necessary folders.
|
# Creates the necessary folders.
|
||||||
mkdir -p dist/static
|
mkdir -p dist/static
|
||||||
mkdir -p dist/docs
|
mkdir -p dist/docs
|
||||||
|
mkdir -p dist/certs
|
||||||
|
|
||||||
# Builds inside the container.
|
# Builds inside the container.
|
||||||
docker run \
|
docker run \
|
||||||
@@ -66,6 +67,9 @@ build: clean create-build-container
|
|||||||
# Copies the docs and the static files to the correct folder.
|
# Copies the docs and the static files to the correct folder.
|
||||||
cp -R static/* ./dist/static/
|
cp -R static/* ./dist/static/
|
||||||
cp -R docs/swagger/ ./dist/docs/
|
cp -R docs/swagger/ ./dist/docs/
|
||||||
|
cp -R certs/${DEPLOY_ENV}/ ./dist/certs/
|
||||||
|
cp default.${DEPLOY_ENV}.conf ./dist/default.conf
|
||||||
|
cp nginx.conf ./dist/nginx.conf
|
||||||
cp config.${DEPLOY_ENV}.toml ./dist/config.toml
|
cp config.${DEPLOY_ENV}.toml ./dist/config.toml
|
||||||
cp authorization_model.conf ./dist/authorization_model.conf
|
cp authorization_model.conf ./dist/authorization_model.conf
|
||||||
cp authorization_policy.csv ./dist/authorization_policy.csv
|
cp authorization_policy.csv ./dist/authorization_policy.csv
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ type Service struct {
|
|||||||
Notification *notificationService
|
Notification *notificationService
|
||||||
Profile *profileService
|
Profile *profileService
|
||||||
Organization *organizationService
|
Organization *organizationService
|
||||||
|
Zipcodes *zipcodeService
|
||||||
|
Plan *planService
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new domain Service instance
|
// New returns a new domain Service instance
|
||||||
@@ -36,6 +38,8 @@ func New(svc *service.Service, mapper *entitymapping.Mapper, notification *notif
|
|||||||
Notification: newNotificationService(svc, mapper, notification, cfg),
|
Notification: newNotificationService(svc, mapper, notification, cfg),
|
||||||
Profile: newProfileService(svc, mapper),
|
Profile: newProfileService(svc, mapper),
|
||||||
Organization: newOrganizationService(svc, mapper),
|
Organization: newOrganizationService(svc, mapper),
|
||||||
|
Zipcodes: newZipcodeService(svc, mapper),
|
||||||
|
Plan: newPlanService(svc, mapper),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,16 @@ func (s *organizationService) GetByType(organizationTypeKey string, user viewmod
|
|||||||
func (s *organizationService) GetByUUID(organizationUUID string, user viewmodel.User) (viewmodel.Organization, error) {
|
func (s *organizationService) GetByUUID(organizationUUID string, user viewmodel.User) (viewmodel.Organization, error) {
|
||||||
userEntity := s.mapEntity.User.ToUserEntity(user)
|
userEntity := s.mapEntity.User.ToUserEntity(user)
|
||||||
result, err := s.svc.Organization.GetByUUID(organizationUUID, userEntity)
|
result, err := s.svc.Organization.GetByUUID(organizationUUID, userEntity)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to get the Organization data by UUID", err)
|
||||||
|
return viewmodel.Organization{}, err
|
||||||
|
}
|
||||||
|
return s.mapEntity.Organization.ToOrganizationModel(result), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *organizationService) GetByTypeAndReferenceID(typeKey string, referenceID int64, user viewmodel.User) (viewmodel.Organization, error) {
|
||||||
|
userEntity := s.mapEntity.User.ToUserEntity(user)
|
||||||
|
result, err := s.svc.Organization.GetByTypeAndReferenceID(typeKey, referenceID, userEntity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return viewmodel.Organization{}, err
|
return viewmodel.Organization{}, err
|
||||||
}
|
}
|
||||||
@@ -185,17 +195,17 @@ func (s *organizationService) AddOrganization(organization viewmodel.Organizatio
|
|||||||
var provider npdmodel.ProviderResponse
|
var provider npdmodel.ProviderResponse
|
||||||
bProvider, err := ffjson.Marshal(organization.Reference)
|
bProvider, err := ffjson.Marshal(organization.Reference)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error to marshal provider")
|
fmt.Println("Error to marshal provider", err)
|
||||||
return viewmodel.Organization{}, nil
|
return viewmodel.Organization{}, nil
|
||||||
}
|
}
|
||||||
if err := ffjson.Unmarshal(bProvider, &provider); err != nil {
|
if err := ffjson.Unmarshal(bProvider, &provider); err != nil {
|
||||||
fmt.Println("Error to convert provider")
|
fmt.Println("Error to convert provider", err)
|
||||||
return viewmodel.Organization{}, nil
|
return viewmodel.Organization{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
eProviders, err := s.svc.Provider.Save(s.mapEntity.Provider.ToProviderEntitySlice([]npdmodel.ProviderResponse{provider}), enUser)
|
eProviders, err := s.svc.Provider.Save(s.mapEntity.Provider.ToProviderEntitySlice([]npdmodel.ProviderResponse{provider}), enUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error to save provider")
|
fmt.Println("Error to save provider", err)
|
||||||
return viewmodel.Organization{}, nil
|
return viewmodel.Organization{}, nil
|
||||||
}
|
}
|
||||||
respProvider := eProviders[0]
|
respProvider := eProviders[0]
|
||||||
@@ -203,17 +213,19 @@ func (s *organizationService) AddOrganization(organization viewmodel.Organizatio
|
|||||||
|
|
||||||
lat, _ := strconv.ParseFloat(provider.Latitude, 64)
|
lat, _ := strconv.ParseFloat(provider.Latitude, 64)
|
||||||
long, _ := strconv.ParseFloat(provider.Longitude, 64)
|
long, _ := strconv.ParseFloat(provider.Longitude, 64)
|
||||||
address := entity.OrganizationAddress{
|
if lat != 0 && long != 0 && len(provider.StreetName1) > 0 {
|
||||||
InternalID: provider.MukID,
|
address := entity.OrganizationAddress{
|
||||||
Name: "Main Address",
|
InternalID: provider.MukID,
|
||||||
Address: fmt.Sprintf("%s %s - %s, %s (%s)", provider.StreetName1, provider.StreetName2, provider.CityName, provider.State, provider.ZipCode),
|
Name: "Main Address",
|
||||||
Latitude: lat,
|
Address: fmt.Sprintf("%s %s - %s, %s (%s)", provider.StreetName1, provider.StreetName2, provider.CityName, provider.State, provider.ZipCode[:5]),
|
||||||
Longitude: long,
|
Latitude: lat,
|
||||||
CreatedUser: enOrg.Author,
|
Longitude: long,
|
||||||
UpdatedUser: enOrg.LastEditor,
|
CreatedUser: enOrg.Author,
|
||||||
|
UpdatedUser: enOrg.LastEditor,
|
||||||
|
}
|
||||||
|
enOrg.Addresses = append(enOrg.Addresses, address)
|
||||||
}
|
}
|
||||||
enOrg.Addresses = append(enOrg.Addresses, address)
|
|
||||||
fmt.Println("Phone Number: ", provider.PhoneNumber)
|
|
||||||
if provider.PhoneNumber != "" {
|
if provider.PhoneNumber != "" {
|
||||||
formattedPhone := "+1" + strings.Replace(provider.PhoneNumber, "-", "", -1)
|
formattedPhone := "+1" + strings.Replace(provider.PhoneNumber, "-", "", -1)
|
||||||
contact := entity.OrganizationContact{
|
contact := entity.OrganizationContact{
|
||||||
@@ -232,8 +244,9 @@ func (s *organizationService) AddOrganization(organization viewmodel.Organizatio
|
|||||||
|
|
||||||
enOrg, err = s.svc.Organization.AddOrganization(enOrg, enUser)
|
enOrg, err = s.svc.Organization.AddOrganization(enOrg, enUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Error to save organization on DB", err)
|
||||||
return viewmodel.Organization{}, nil
|
return viewmodel.Organization{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.GetByUUID(enOrg.UUID, user)
|
return s.mapEntity.Organization.ToOrganizationModel(enOrg), nil
|
||||||
}
|
}
|
||||||
|
|||||||
57
application/applicationservice/plan.go
Normal file
57
application/applicationservice/plan.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package applicationservice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/entitymapping"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/domain/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
// providerService holds methods to provider application service
|
||||||
|
type planService struct {
|
||||||
|
svc *service.Service
|
||||||
|
mapEntity *entitymapping.Mapper
|
||||||
|
}
|
||||||
|
|
||||||
|
// newProviderService returns a providerService instance
|
||||||
|
func newPlanService(svc *service.Service, mapper *entitymapping.Mapper) *planService {
|
||||||
|
return &planService{
|
||||||
|
svc: svc,
|
||||||
|
mapEntity: mapper,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *planService) GetByAlphaPrefix(alphaPrefix string) (viewmodel.Plan, error) {
|
||||||
|
plan, err := s.svc.Plans.GetByAlphaPrefix(alphaPrefix)
|
||||||
|
if err != nil {
|
||||||
|
return viewmodel.Plan{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.Plan.ToPlanModel(plan), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *planService) GetByUUID(planUUID string) ([]viewmodel.Plan, error) {
|
||||||
|
plans, err := s.svc.Plans.GetByUUID(planUUID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.Plan.ToPlanModelSlice(plans), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *planService) GetByID(planID int64) ([]viewmodel.Plan, error) {
|
||||||
|
plans, err := s.svc.Plans.GetByID(planID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.Plan.ToPlanModelSlice(plans), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *planService) GetByPrefixUUID(prefixUUID string) (viewmodel.Plan, error) {
|
||||||
|
plan, err := s.svc.Plans.GetByPrefixUUID(prefixUUID)
|
||||||
|
if err != nil {
|
||||||
|
return viewmodel.Plan{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.Plan.ToPlanModel(plan), nil
|
||||||
|
}
|
||||||
@@ -48,3 +48,33 @@ func (s *providerService) Get(query string, lat float64, long float64, distance
|
|||||||
}
|
}
|
||||||
return s.mapEntity.Provider.ToProviderRespModelSlice(providers), nil
|
return s.mapEntity.Provider.ToProviderRespModelSlice(providers), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *providerService) GetByUUID(providerUUID string, user viewmodel.User) (viewmodel.ProviderResp, error) {
|
||||||
|
eUser := s.mapEntity.User.ToUserEntity(user)
|
||||||
|
provider, err := s.svc.Provider.GetByUUID(providerUUID, eUser)
|
||||||
|
if err != nil {
|
||||||
|
return viewmodel.ProviderResp{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.Provider.ToProviderRespModel(provider), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *providerService) GetByNPI(NPI string, user viewmodel.User) (viewmodel.ProviderResp, error) {
|
||||||
|
eUser := s.mapEntity.User.ToUserEntity(user)
|
||||||
|
provider, err := s.svc.Provider.GetByNPI(NPI, eUser)
|
||||||
|
if err != nil {
|
||||||
|
return viewmodel.ProviderResp{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.Provider.ToProviderRespModel(provider), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *providerService) GetByOrganization(organizationUUID string, user viewmodel.User) (viewmodel.ProviderResp, error) {
|
||||||
|
eUser := s.mapEntity.User.ToUserEntity(user)
|
||||||
|
provider, err := s.svc.Provider.GetByOrganization(organizationUUID, eUser)
|
||||||
|
if err != nil {
|
||||||
|
return viewmodel.ProviderResp{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.Provider.ToProviderRespModel(provider), nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -51,6 +51,16 @@ func (s *userService) GetByUUID(uuid string, profile string) (retVal viewmodel.U
|
|||||||
return s.mapEntity.User.ToUserModel(user), nil
|
return s.mapEntity.User.ToUserModel(user), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetByID returns a specific user by its ID
|
||||||
|
func (s *userService) GetByMemberID(memberID string) (retVal viewmodel.User, err error) {
|
||||||
|
user, err := s.svc.Users.GetByMemberID(memberID)
|
||||||
|
if err != nil {
|
||||||
|
return retVal, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.User.ToUserModel(user), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Login returns a specific user by email and pass
|
// Login returns a specific user by email and pass
|
||||||
func (s *userService) FullLogin(loginType string, key string, pass string, profile string) (retVal viewmodel.User, err error) {
|
func (s *userService) FullLogin(loginType string, key string, pass string, profile string) (retVal viewmodel.User, err error) {
|
||||||
user, err := s.svc.Users.FullLogin(loginType, key, pass, profile)
|
user, err := s.svc.Users.FullLogin(loginType, key, pass, profile)
|
||||||
@@ -131,6 +141,11 @@ func (s *userService) RemoveAddress(addressUUID string) error {
|
|||||||
return s.svc.Users.RemoveAddress(addressUUID)
|
return s.svc.Users.RemoveAddress(addressUUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *userService) UpdateLogin(user viewmodel.User) error {
|
||||||
|
eUser := s.mapEntity.User.ToUserEntity(user)
|
||||||
|
return s.svc.Users.UpdateLogin(eUser)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *userService) SaveAddress(address viewmodel.Address) (retVal viewmodel.Address, err error) {
|
func (s *userService) SaveAddress(address viewmodel.Address) (retVal viewmodel.Address, err error) {
|
||||||
entity := s.mapEntity.Address.ToAddressEntity(address)
|
entity := s.mapEntity.Address.ToAddressEntity(address)
|
||||||
entity, err = s.svc.Users.SaveAddress(entity)
|
entity, err = s.svc.Users.SaveAddress(entity)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package applicationservice
|
package applicationservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/entitymapping"
|
"bitbucket.org/nemt/nemt-portal-api/application/entitymapping"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/domain/service"
|
"bitbucket.org/nemt/nemt-portal-api/domain/service"
|
||||||
@@ -21,6 +23,43 @@ func newVisitService(svc *service.Service, mapper *entitymapping.Mapper) *visitS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *visitService) Save(visit viewmodel.Visit) (viewmodel.Visit, error) {
|
||||||
|
entity := s.mapEntity.Visit.ToVisitEntity(visit)
|
||||||
|
for _, a := range visit.User.Addresses {
|
||||||
|
if a.AddressType == "home" {
|
||||||
|
address, err := s.svc.Users.GetAddressByUUID(a.UUID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Application Visit: Address UUID: ", a.UUID)
|
||||||
|
fmt.Println("Application Visit: Address Error: ", err.Error())
|
||||||
|
return viewmodel.Visit{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.PickupAddressID = address.ID
|
||||||
|
entity.Pickup.Address = address.Address
|
||||||
|
entity.Pickup.ID = address.UUID
|
||||||
|
entity.Pickup.Latitude = address.Latitude
|
||||||
|
entity.Pickup.Longitude = address.Longitude
|
||||||
|
entity.Pickup.Name = address.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider, err := s.svc.Provider.GetByUUID(entity.Provider.ProviderUUID, entity.CreatedUser)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Application Visit: Provider UUID: ", entity.Provider.ProviderUUID)
|
||||||
|
fmt.Println("Application Visit: Provider Error: ", err.Error())
|
||||||
|
return viewmodel.Visit{}, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
entity.Provider = provider
|
||||||
|
|
||||||
|
retVal, err := s.svc.Visits.Create(entity)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Application Visit: Create Visit Error: ", err.Error())
|
||||||
|
return viewmodel.Visit{}, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.Visit.ToVisitModel(retVal), err
|
||||||
|
}
|
||||||
|
|
||||||
// Save a new ride
|
// Save a new ride
|
||||||
func (s *visitService) Create(visit viewmodel.Visit) (viewmodel.Visit, error) {
|
func (s *visitService) Create(visit viewmodel.Visit) (viewmodel.Visit, error) {
|
||||||
entity := s.mapEntity.Visit.ToVisitEntity(visit)
|
entity := s.mapEntity.Visit.ToVisitEntity(visit)
|
||||||
@@ -48,8 +87,23 @@ func (s *visitService) GetByUUID(visitUUID string, user viewmodel.User) (viewmod
|
|||||||
eUser := s.mapEntity.User.ToUserEntity(user)
|
eUser := s.mapEntity.User.ToUserEntity(user)
|
||||||
retVal, err := s.svc.Visits.GetByUUID(visitUUID, eUser)
|
retVal, err := s.svc.Visits.GetByUUID(visitUUID, eUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Visit Application: Error getting visit: ", err.Error())
|
||||||
return viewmodel.Visit{}, errors.Wrap(err)
|
return viewmodel.Visit{}, errors.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
visitUser, err := s.svc.Users.GetByUUID(retVal.User.UUID, "US")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Visit Application: Error getting user: ", err.Error())
|
||||||
|
return viewmodel.Visit{}, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
retVal.User = visitUser
|
||||||
|
|
||||||
|
provider, err := s.svc.Provider.GetByUUID(retVal.Provider.ProviderUUID, eUser)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Visit Application: Error getting provider: ", err.Error())
|
||||||
|
return viewmodel.Visit{}, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
retVal.Provider = provider
|
||||||
|
|
||||||
return s.mapEntity.Visit.ToVisitModel(retVal), err
|
return s.mapEntity.Visit.ToVisitModel(retVal), err
|
||||||
}
|
}
|
||||||
|
|||||||
37
application/applicationservice/zipcode.go
Normal file
37
application/applicationservice/zipcode.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package applicationservice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/entitymapping"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/domain/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
// zipcodeService holds methods to participating zipcode application service
|
||||||
|
type zipcodeService struct {
|
||||||
|
svc *service.Service
|
||||||
|
mapEntity *entitymapping.Mapper
|
||||||
|
}
|
||||||
|
|
||||||
|
// newZipcodeService returns a zipcodeService instance
|
||||||
|
func newZipcodeService(svc *service.Service, mapper *entitymapping.Mapper) *zipcodeService {
|
||||||
|
return &zipcodeService{
|
||||||
|
svc: svc,
|
||||||
|
mapEntity: mapper,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *zipcodeService) GetAll() ([]viewmodel.Zipcode, error) {
|
||||||
|
result, err := s.svc.Zipcodes.GetAll()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.mapEntity.Zipcode.ToZipcodeModelSlice(result), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *zipcodeService) GetByParticipatingZipcode(zipcode string) (viewmodel.Zipcode, error) {
|
||||||
|
result, err := s.svc.Zipcodes.GetByParticipatingZipcode(zipcode)
|
||||||
|
if err != nil {
|
||||||
|
return viewmodel.Zipcode{}, err
|
||||||
|
}
|
||||||
|
return s.mapEntity.Zipcode.ToZipcodeModel(result), nil
|
||||||
|
}
|
||||||
@@ -21,6 +21,8 @@ type Mapper struct {
|
|||||||
Notification *notificationMapping
|
Notification *notificationMapping
|
||||||
Profile *profileMapping
|
Profile *profileMapping
|
||||||
Organization *organizationMapping
|
Organization *organizationMapping
|
||||||
|
Zipcode *zipcodeMapping
|
||||||
|
Plan *planMapping
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns an EntityMapper for fluent mapping
|
// New returns an EntityMapper for fluent mapping
|
||||||
@@ -36,6 +38,8 @@ func New() *Mapper {
|
|||||||
instance.Notification = ¬ificationMapping{instance}
|
instance.Notification = ¬ificationMapping{instance}
|
||||||
instance.Profile = &profileMapping{instance}
|
instance.Profile = &profileMapping{instance}
|
||||||
instance.Organization = &organizationMapping{instance}
|
instance.Organization = &organizationMapping{instance}
|
||||||
|
instance.Zipcode = &zipcodeMapping{instance}
|
||||||
|
instance.Plan = &planMapping{instance}
|
||||||
})
|
})
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|||||||
65
application/entitymapping/plan.go
Normal file
65
application/entitymapping/plan.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package entitymapping
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
// providerMapping has method to map provider entities to view models
|
||||||
|
type planMapping struct {
|
||||||
|
mapper *Mapper
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||||
|
func (mapping *planMapping) ToPlanEntitySlice(list []viewmodel.Plan) (retVal []entity.Plan) {
|
||||||
|
retVal = make([]entity.Plan, 0)
|
||||||
|
|
||||||
|
for _, item := range list {
|
||||||
|
retVal = append(retVal, mapping.ToPlanEntity(item))
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mapping *planMapping) ToPlanEntity(model viewmodel.Plan) entity.Plan {
|
||||||
|
return entity.Plan{
|
||||||
|
UUID: model.ID,
|
||||||
|
Name: model.Name,
|
||||||
|
InternalID: model.InternalID,
|
||||||
|
Status: model.Status,
|
||||||
|
PlanEntityID: model.PlanEntityID,
|
||||||
|
EntityID: model.EntityID,
|
||||||
|
PayerID: model.PayerID,
|
||||||
|
PayerName: model.PayerName,
|
||||||
|
PrefixUUID: model.PrefixID,
|
||||||
|
AlphaPrefix: model.AlphaPrefix,
|
||||||
|
Active: model.Active,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||||
|
func (mapping *planMapping) ToPlanModelSlice(list []entity.Plan) (retVal []viewmodel.Plan) {
|
||||||
|
retVal = make([]viewmodel.Plan, 0)
|
||||||
|
|
||||||
|
for _, item := range list {
|
||||||
|
retVal = append(retVal, mapping.ToPlanModel(item))
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mapping *planMapping) ToPlanModel(model entity.Plan) viewmodel.Plan {
|
||||||
|
return viewmodel.Plan{
|
||||||
|
ID: model.UUID,
|
||||||
|
Name: model.Name,
|
||||||
|
InternalID: model.InternalID,
|
||||||
|
Status: model.Status,
|
||||||
|
PlanEntityID: model.PlanEntityID,
|
||||||
|
EntityID: model.EntityID,
|
||||||
|
PayerID: model.PayerID,
|
||||||
|
PayerName: model.PayerName,
|
||||||
|
PrefixID: model.PrefixUUID,
|
||||||
|
AlphaPrefix: model.AlphaPrefix,
|
||||||
|
Active: model.Active,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,7 @@ func (mapping *providerMapping) ToProviderRespEntity(item viewmodel.ProviderResp
|
|||||||
LastName: item.LastName,
|
LastName: item.LastName,
|
||||||
Title: item.Title,
|
Title: item.Title,
|
||||||
Distance: item.Distance,
|
Distance: item.Distance,
|
||||||
|
Organization: mapping.mapper.Organization.ToOrganizationEntity(item.Organization),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ func (mapping *providerMapping) ToProviderRespModel(item entity.Provider) viewmo
|
|||||||
Keys: mapping.ToProviderKeyModelSlice(item.Keys),
|
Keys: mapping.ToProviderKeyModelSlice(item.Keys),
|
||||||
Address: mapping.ToProviderRespAddressModel(item.Address),
|
Address: mapping.ToProviderRespAddressModel(item.Address),
|
||||||
Distance: item.Distance,
|
Distance: item.Distance,
|
||||||
|
Organization: mapping.mapper.Organization.ToOrganizationModel(item.Organization),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
51
application/entitymapping/zipcode.go
Normal file
51
application/entitymapping/zipcode.go
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package entitymapping
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
// zipcodeMapping has method to map zipcode entities to view models
|
||||||
|
type zipcodeMapping struct {
|
||||||
|
mapper *Mapper
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||||
|
func (mapping *zipcodeMapping) ToZipcodeEntitySlice(list []viewmodel.Zipcode) (retVal []entity.Zipcode) {
|
||||||
|
retVal = make([]entity.Zipcode, 0)
|
||||||
|
|
||||||
|
for _, item := range list {
|
||||||
|
retVal = append(retVal, mapping.ToZipcodeEntity(item))
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mapping *zipcodeMapping) ToZipcodeEntity(model viewmodel.Zipcode) entity.Zipcode {
|
||||||
|
return entity.Zipcode{
|
||||||
|
ID: model.ID,
|
||||||
|
UUID: model.UUID,
|
||||||
|
Zipcode: model.Zipcode,
|
||||||
|
Participating: model.Participating,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||||
|
func (mapping *zipcodeMapping) ToZipcodeModelSlice(list []entity.Zipcode) (retVal []viewmodel.Zipcode) {
|
||||||
|
retVal = make([]viewmodel.Zipcode, 0)
|
||||||
|
|
||||||
|
for _, item := range list {
|
||||||
|
retVal = append(retVal, mapping.ToZipcodeModel(item))
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mapping *zipcodeMapping) ToZipcodeModel(model entity.Zipcode) viewmodel.Zipcode {
|
||||||
|
return viewmodel.Zipcode{
|
||||||
|
ID: model.ID,
|
||||||
|
UUID: model.UUID,
|
||||||
|
Zipcode: model.Zipcode,
|
||||||
|
Participating: model.Participating,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -98,13 +98,10 @@ func (s bxeService) Get271(eligibility viewmodel.Eligibility) (bcbsimodel.Interc
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s bxeService) CheckEligibility(eligibility viewmodel.Eligibility) (bcbsimodel.MemberEligibilityResponse, error) {
|
func (s bxeService) CheckEligibility(eligibility viewmodel.Eligibility) (bcbsimodel.MemberEligibilityResponse, error) {
|
||||||
// payer, err := s.GetPayerDetails(eligibility.Subscriber.SubscriberID)
|
if eligibility.Payer.PayerID == "" || eligibility.Payer.PayerName == "" {
|
||||||
// if err != nil {
|
eligibility.Payer.PayerID = "621"
|
||||||
// return bcbsimodel.MemberEligibilityResponse{}, err
|
eligibility.Payer.PayerName = "blue_cross_blue_shield_il"
|
||||||
// }
|
}
|
||||||
|
|
||||||
eligibility.Payer.PayerID = "621"
|
|
||||||
eligibility.Payer.PayerName = "blue_cross_blue_shield_il"
|
|
||||||
|
|
||||||
envelope := bcbsimodel.GetEnvelope(eligibility)
|
envelope := bcbsimodel.GetEnvelope(eligibility)
|
||||||
apiKey := s.cfg.BXE.APIKey
|
apiKey := s.cfg.BXE.APIKey
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ func (s *lyftService) RequestRide(rideRequest viewmodel.RideRequest) (viewmodel.
|
|||||||
|
|
||||||
if raw.Error != "" {
|
if raw.Error != "" {
|
||||||
fmt.Println("Error to call Lyft: ", raw.Error+" - "+raw.ErrorDescription)
|
fmt.Println("Error to call Lyft: ", raw.Error+" - "+raw.ErrorDescription)
|
||||||
|
fmt.Println("Full body error: ", string(body))
|
||||||
return viewmodel.RideRequest{}, errors.New("Lyft Error: " + raw.Error + " - " + raw.ErrorDescription)
|
return viewmodel.RideRequest{}, errors.New("Lyft Error: " + raw.Error + " - " + raw.ErrorDescription)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ type Eligibility struct {
|
|||||||
Provider Provider `json:"provider,omitempty"`
|
Provider Provider `json:"provider,omitempty"`
|
||||||
Subscriber Subscriber `json:"subscriber,omitempty"`
|
Subscriber Subscriber `json:"subscriber,omitempty"`
|
||||||
ServiceInfo ServiceInfo `json:"service_info,omitempty"`
|
ServiceInfo ServiceInfo `json:"service_info,omitempty"`
|
||||||
|
User User `json:"user,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Payer struct {
|
type Payer struct {
|
||||||
|
|||||||
15
application/viewmodel/plan.go
Normal file
15
application/viewmodel/plan.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package viewmodel
|
||||||
|
|
||||||
|
type Plan struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
InternalID string `json:"key,omitempty"`
|
||||||
|
Status bool `json:"desc,omitempty"`
|
||||||
|
PlanEntityID int64 `json:"plan_entity_id,omitempty"`
|
||||||
|
EntityID int64 `json:"entity_id,omitempty"`
|
||||||
|
PayerID int64 `json:"payer_id,omitempty"`
|
||||||
|
PayerName string `json:"payer_name,omitempty"`
|
||||||
|
PrefixID string `json:"prefix_uuid,omitempty"`
|
||||||
|
AlphaPrefix string `json:"alpha_prefix,omitempty"`
|
||||||
|
Active bool `json:"active,omitempty"`
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ type ProviderResp struct {
|
|||||||
Keys []ProviderKey `json:"keys,omitempty"`
|
Keys []ProviderKey `json:"keys,omitempty"`
|
||||||
Address ProviderAddress `json:"address,omitempty"`
|
Address ProviderAddress `json:"address,omitempty"`
|
||||||
Distance float64 `json:"distance,omitempty"`
|
Distance float64 `json:"distance,omitempty"`
|
||||||
|
Organization Organization `json:"organization,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProviderKey struct {
|
type ProviderKey struct {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ type User struct {
|
|||||||
BirthDate *time.Time `json:"birthdate,omitempty"`
|
BirthDate *time.Time `json:"birthdate,omitempty"`
|
||||||
Email *string `json:"email,omitempty"`
|
Email *string `json:"email,omitempty"`
|
||||||
PhoneNumber *string `json:"phonenumber,omitempty"`
|
PhoneNumber *string `json:"phonenumber,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
Pass string `json:"pass,omitempty"`
|
Pass string `json:"pass,omitempty"`
|
||||||
Active bool `json:"active,omitempty"`
|
Active bool `json:"active,omitempty"`
|
||||||
Created time.Time `json:"created,omitempty"`
|
Created time.Time `json:"created,omitempty"`
|
||||||
@@ -23,6 +24,8 @@ type User struct {
|
|||||||
Profiles []Profile `json:"profiles,omitempty"`
|
Profiles []Profile `json:"profiles,omitempty"`
|
||||||
Types []OrganizationType `json:"types,omitempty"`
|
Types []OrganizationType `json:"types,omitempty"`
|
||||||
Organizations []Organization `json:"organizations,omitempty"`
|
Organizations []Organization `json:"organizations,omitempty"`
|
||||||
|
Provider *ProviderResp `json:"provider,omitempty"`
|
||||||
|
Consent bool `json:"consent,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Contact struct {
|
type Contact struct {
|
||||||
|
|||||||
@@ -12,22 +12,23 @@ type VisitStatus struct {
|
|||||||
|
|
||||||
// Visit entity data
|
// Visit entity data
|
||||||
type Visit struct {
|
type Visit struct {
|
||||||
UUID string `json:"visit_uuid,omitempty"`
|
UUID string `json:"visit_uuid,omitempty"`
|
||||||
Status VisitStatus `json:"visit_status,omitempty"`
|
Status VisitStatus `json:"visit_status,omitempty"`
|
||||||
User User `json:"user,omitempty"`
|
User User `json:"user,omitempty"`
|
||||||
VisitDatetime time.Time `json:"visit_datetime,omitempty"`
|
VisitDatetime time.Time `json:"visit_datetime,omitempty"`
|
||||||
VisitDuration int64 `json:"visit_duration,omitempty"`
|
VisitDuration int64 `json:"visit_duration,omitempty"`
|
||||||
PickupDatetime time.Time `json:"pickup_datetime,omitempty"`
|
PickupDatetime time.Time `json:"pickup_datetime,omitempty"`
|
||||||
Notes *string `json:"notes,omitempty"`
|
Notes *string `json:"notes,omitempty"`
|
||||||
PickupAddressID int64 `json:"pickup_address_id,omitempty"`
|
PickupAddressID int64 `json:"pickup_address_id,omitempty"`
|
||||||
DestinationAddressID int64 `json:"destination_address_id,omitempty"`
|
DestinationAddressID int64 `json:"destination_address_id,omitempty"`
|
||||||
Pickup Location `json:"pickup,omitempty"`
|
Pickup Location `json:"pickup,omitempty"`
|
||||||
Provider ProviderResp `json:"provider,omitempty"`
|
Provider ProviderResp `json:"provider,omitempty"`
|
||||||
CreatedUser User `json:"created_user,omitempty"`
|
CreatedUser User `json:"created_user,omitempty"`
|
||||||
CreatedDate time.Time `json:"created,omitempty"`
|
CreatedDate time.Time `json:"created,omitempty"`
|
||||||
UpdatedDate time.Time `json:"updated,omitempty"`
|
UpdatedDate time.Time `json:"updated,omitempty"`
|
||||||
ReturnDate *time.Time `json:"return_date,omitempty"`
|
ReturnDate *time.Time `json:"return_date,omitempty"`
|
||||||
TripType TripType `json:"trip_type,omitempty"`
|
TripType TripType `json:"trip_type,omitempty"`
|
||||||
ExternalID string `json:"visit_external_id,omitempty"`
|
ExternalID string `json:"visit_external_id,omitempty"`
|
||||||
Rides []Ride `json:"rides,omitempty"`
|
Rides []Ride `json:"rides,omitempty"`
|
||||||
|
RawProvider ProviderResponse `json:"raw_provider,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
8
application/viewmodel/zipcode.go
Normal file
8
application/viewmodel/zipcode.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package viewmodel
|
||||||
|
|
||||||
|
type Zipcode struct {
|
||||||
|
ID int64 `json:"-"`
|
||||||
|
UUID string `json:"uuid"`
|
||||||
|
Zipcode string `json:"zipcode"`
|
||||||
|
Participating bool `json:"participating"`
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ pipelines:
|
|||||||
master:
|
master:
|
||||||
- step:
|
- step:
|
||||||
script:
|
script:
|
||||||
- curl https://glide.sh/get | sh
|
- curl https://glide.sh/get -L -o - | sh
|
||||||
- mkdir -p /go/src/bitbucket.org/nemt/nemt-portal-api
|
- mkdir -p /go/src/bitbucket.org/nemt/nemt-portal-api
|
||||||
- pwd
|
- pwd
|
||||||
- ls -al
|
- ls -al
|
||||||
@@ -14,11 +14,14 @@ pipelines:
|
|||||||
- rm -rf vendor/
|
- rm -rf vendor/
|
||||||
- glide install -force
|
- glide install -force
|
||||||
- go build -o nemt-portal-api
|
- go build -o nemt-portal-api
|
||||||
- mkdir -p dist/{static,docs}
|
- mkdir -p dist/{static,docs,certs}
|
||||||
- cp nemt-portal-api ./dist/
|
- cp nemt-portal-api ./dist/
|
||||||
- cp -R static/* ./dist/static/
|
- cp -R static/* ./dist/static/
|
||||||
- cp -R docs/swagger/ ./dist/docs/
|
- cp -R docs/swagger/ ./dist/docs/
|
||||||
|
- cp -R certs/prd/* ./dist/certs/
|
||||||
- cp config.prd.toml ./dist/config.toml
|
- cp config.prd.toml ./dist/config.toml
|
||||||
|
- cp default.prd.conf ./dist/default.conf
|
||||||
|
- cp nginx.conf ./dist/nginx.conf
|
||||||
- cp authorization_model.conf ./dist/authorization_model.conf
|
- cp authorization_model.conf ./dist/authorization_model.conf
|
||||||
- cp authorization_policy.csv ./dist/authorization_policy.csv
|
- cp authorization_policy.csv ./dist/authorization_policy.csv
|
||||||
- docker build -f Dockerfile.run -t nemt-portal-api-run:prod --force-rm --build-arg BIN_NAME=nemt-portal-api --build-arg APP_NAME=nemt-portal-api .
|
- docker build -f Dockerfile.run -t nemt-portal-api-run:prod --force-rm --build-arg BIN_NAME=nemt-portal-api --build-arg APP_NAME=nemt-portal-api .
|
||||||
@@ -33,7 +36,7 @@ pipelines:
|
|||||||
development:
|
development:
|
||||||
- step:
|
- step:
|
||||||
script:
|
script:
|
||||||
- curl https://glide.sh/get | sh
|
- curl https://glide.sh/get -L -o - | sh
|
||||||
- mkdir -p /go/src/bitbucket.org/nemt/nemt-portal-api
|
- mkdir -p /go/src/bitbucket.org/nemt/nemt-portal-api
|
||||||
- pwd
|
- pwd
|
||||||
- ls -al
|
- ls -al
|
||||||
@@ -43,11 +46,14 @@ pipelines:
|
|||||||
- rm -rf vendor/
|
- rm -rf vendor/
|
||||||
- glide install -force
|
- glide install -force
|
||||||
- go build -o nemt-portal-api
|
- go build -o nemt-portal-api
|
||||||
- mkdir -p dist/{static,docs}
|
- mkdir -p dist/{static,docs,certs}
|
||||||
- cp nemt-portal-api ./dist/
|
- cp nemt-portal-api ./dist/
|
||||||
- cp -R static/* ./dist/static/
|
- cp -R static/* ./dist/static/
|
||||||
- cp -R docs/swagger/ ./dist/docs/
|
- cp -R docs/swagger/ ./dist/docs/
|
||||||
|
- cp -R certs/stg/* ./dist/certs/
|
||||||
- cp config.stg.toml ./dist/config.toml
|
- cp config.stg.toml ./dist/config.toml
|
||||||
|
- cp default.stg.conf ./dist/default.conf
|
||||||
|
- cp nginx.conf ./dist/nginx.conf
|
||||||
- cp authorization_model.conf ./dist/authorization_model.conf
|
- cp authorization_model.conf ./dist/authorization_model.conf
|
||||||
- cp authorization_policy.csv ./dist/authorization_policy.csv
|
- cp authorization_policy.csv ./dist/authorization_policy.csv
|
||||||
- docker build -f Dockerfile.run -t nemt-portal-api-run:dev --force-rm --build-arg BIN_NAME=nemt-portal-api --build-arg APP_NAME=nemt-portal-api .
|
- docker build -f Dockerfile.run -t nemt-portal-api-run:dev --force-rm --build-arg BIN_NAME=nemt-portal-api --build-arg APP_NAME=nemt-portal-api .
|
||||||
|
|||||||
28
certs/dev/private.key
Normal file
28
certs/dev/private.key
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC0VyKNSM/a/CzE
|
||||||
|
16vidZzip1p4B7+EhJVyENoofRDk7D7afDddWV33yHUvI5opsyKIEMuGFRNIROH/
|
||||||
|
ZX47vV3H2ST/5UmkXhghEVjA/xQFUqx2hUxAjI+EkHyf+D3cofcoqFBGA7DVQ9MK
|
||||||
|
qgbRmwV09IgfQmdlFlF/D3/ZROYNYhY7NC5W+9d+JdmkV45Kp2zIDEa990roDF2p
|
||||||
|
oN6Nk0WsDMNn5nhyFtGyeuFmYcWwKeCI/XlMu5roko7tJtY0oC0boKSZ8S7xiEPK
|
||||||
|
uBUxw9cWcHVbkLyeJXIr7lfIzg5xejX3A5/KA7UuKtPAc3HQh09TEOD40Rof5Mts
|
||||||
|
l5njh/MhAgMBAAECggEAHSE+CYhLWtoE+T7FGu1YjBvwNxc5TlSEN0qVkpixE+k9
|
||||||
|
Ndl+r+txjEaq9xRPIJE48LWVynC5DqFhx/lC7K9n6JIgsdz9ijlQuHau2W3adAmo
|
||||||
|
pfReHscVn5ofJ0/X3j2jSMP3Q3fxJmGwQza3pz/dH8kn+7SkMuXqABYm1peUeXCr
|
||||||
|
BOIl0/C9UpuIlDrK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o
|
||||||
|
HAb5yVRkj2VDBnWl//BEAxXKj+r1KOqESdqaKeQcYzXzAMQ36DJia7DOiej7HNSx
|
||||||
|
Y3ydXe8hO8lutgiU5rsBNVLM
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
88
certs/dev/ssl_certificate.cer
Executable file
88
certs/dev/ssl_certificate.cer
Executable file
@@ -0,0 +1,88 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIGvjCCBaagAwIBAgIQC3nVkJVbuOa1WFfJQc+IMDANBgkqhkiG9w0BAQsFADBN
|
||||||
|
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5E
|
||||||
|
aWdpQ2VydCBTSEEyIFNlY3VyZSBTZXJ2ZXIgQ0EwHhcNMTgwNTIxMDAwMDAwWhcN
|
||||||
|
MjAwNTIwMTIwMDAwWjCBhTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCElsbGlub2lz
|
||||||
|
MRAwDgYDVQQHEwdDaGljYWdvMS8wLQYDVQQKEyZCbHVlIENyb3NzIGFuZCBCbHVl
|
||||||
|
IFNoaWVsZCBBc3NvY2lhdGlvbjEgMB4GA1UEAwwXKi5kZXYuYmNic2luc3RpdHV0
|
||||||
|
ZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC0VyKNSM/a/CzE
|
||||||
|
16vidZzip1p4B7+EhJVyENoofRDk7D7afDddWV33yHUvI5opsyKIEMuGFRNIROH/
|
||||||
|
ZX47vV3H2ST/5UmkXhghEVjA/xQFUqx2hUxAjI+EkHyf+D3cofcoqFBGA7DVQ9MK
|
||||||
|
qgbRmwV09IgfQmdlFlF/D3/ZROYNYhY7NC5W+9d+JdmkV45Kp2zIDEa990roDF2p
|
||||||
|
oN6Nk0WsDMNn5nhyFtGyeuFmYcWwKeCI/XlMu5roko7tJtY0oC0boKSZ8S7xiEPK
|
||||||
|
uBUxw9cWcHVbkLyeJX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32RMA
|
||||||
|
AAFjhC1xQwAABAMASDBGAiEAzo+0zJUoqV0X0IqzaZ+9boXzWvIzZCR/OqT1qcAe
|
||||||
|
a3QCIQCdMYaIEYnhnsaOXPMsyShv+ry41lQ9UvUZ3EAvhjgCeQB3ALvZ37wfinG1
|
||||||
|
k5Qjl6qSe0c4V5UKq1LoGpCWZDaOHtGFAAABY4QtcKQAAAQDAEgwRgIhAJ4XGViz
|
||||||
|
vfkGsR3/UWlVZhX9t5rLAlyhW/t1K17vkNjJAiEAhzQycmcTPIVb1Ul1Ug5UgWQ4
|
||||||
|
eD2rp/4raewQVACs26QwDQYJKoZIhvcNAQELBQADggEBADjGzhdcyCYxemKuWoP9
|
||||||
|
Umd0jnS6gHPivwgpy2Ra4SSsFCkucHX8dRMi63MRghiKi4FPj9LsFoLpdHacfi+6
|
||||||
|
Q1lX3fZ6Mv2ZpNjMtBe/g6SATLsFxUQl+UP5bMShEXHsQduinAvSW3m8UpQZ2UxG
|
||||||
|
7L/XmNfeW8x213Mi4G2DNUJKDMjO28bO/GbCNB85HGfhnaDxj7OsQYllbE5oEDXN
|
||||||
|
Wkx1QZFrvqE3/2zoOa1ga36xymRXt0Sn3OSFr/ukZh3MCWAL5fuT4zjnSjybHDqT
|
||||||
|
2qdmV08ECgXwVNUMtbTFq9kenBN0xTrfPFR0Y0IPzqXQP5kTPktgrrYiAf+S875J
|
||||||
|
IVo=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIElDCCA3ygAwIBAgIQAf2j627KdciIQ4tyS8+8kTANBgkqhkiG9w0BAQsFADBh
|
||||||
|
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||||
|
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
|
||||||
|
QTAeFw0xMzAzMDgxMjAwMDBaFw0yMzAzMD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CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97
|
||||||
|
nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
|
||||||
|
43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
|
||||||
|
T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4
|
||||||
|
gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO
|
||||||
|
BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR
|
||||||
|
TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw
|
||||||
|
DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr
|
||||||
|
hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg
|
||||||
|
06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF
|
||||||
|
PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls
|
||||||
|
YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
|
||||||
|
CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
28
certs/prd/private.key
Normal file
28
certs/prd/private.key
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCB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
dtKcsAqJsUtKsVWclei+XucBrN0lrzDBii/ewcq/EH2GEknGwg0ooTG0mUD9nbCu
|
||||||
|
L9a3NUxBLxdKLZaDVsl7sxkbL9HIn4yGvznqfo4rjA4X8jY5OB7X6oR8yWdKhFJf
|
||||||
|
dT8Yi1YfjwKBgQCtSLSiaGVa0FuvTKSDzy1XJnsUJuvUxXjoBfKwWJYZRu5YAlvQ
|
||||||
|
G17LB7BlJVibRs+Tudm4VmAjVOGeLc+XB7lt1Tl8AXfG3EzGih4EKXrWoQIvuRoX
|
||||||
|
zRHjwnrjmpEulak8G5WNJOPYVu+xDy5hxwXnB9NMfvjr538B+K1JKKj6RQKBgHmI
|
||||||
|
K+sm2YZYvdAhAvCiVkPNocXcvS/bhHbQr+tT+hOvtWFx1RQTeDn4Ft4mbWbQ1ViO
|
||||||
|
gWoCpDqpL027jSnpZeAAD59irJS8nLYruVB96ElzE0fVgy6BEaTwIwmt/bhbj8cQ
|
||||||
|
REQdjgVSJdL3NNLQ+AKtdNq4CIVGiF2tdJ5/NI6jAoGBAJnsp+bti4F+LrQVPMNb
|
||||||
|
Ptyxw1eOfNkjqyoAJQXJ6HBN3uDVes/peR+9k4ATsZRMUyo+P07ggAo397+i8PY2
|
||||||
|
FeAwbzACVIb0TVNki8dP/U30e7087DgyxzMK9/ggeCuzcHczEekkioTVQubfd5vJ
|
||||||
|
4N4yQGflInls/OMIodPBir1j
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
88
certs/prd/ssl_certificate.cer
Executable file
88
certs/prd/ssl_certificate.cer
Executable file
@@ -0,0 +1,88 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIGxzCCBa+gAwIBAgIQDARDXxHDhGyEB0wVou2tYTANBgkqhkiG9w0BAQsFADBN
|
||||||
|
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5E
|
||||||
|
aWdpQ2VydCBTSEEyIFNlY3VyZSBTZXJ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W0YKvZj2oHq34KjaVkmWX4VXHmyHTd9TI
|
||||||
|
YJyHifiMrfZ/BCkS5FDg32J1Vocp89k5YDS+pHxlLLxqqMsrz80v5mtblhDhqenx
|
||||||
|
2dsdwYErlbrAvNp95BKdwqcVbqvg2IHBhJ8myB5kgGLgU6Sn96SfsF5wytW+qnQx
|
||||||
|
gIn3qfPkwXVou/mq8PbZSqsrNvggjOTKbkNj8k4u+/OAHd9nP4p/CBGN7hb5RxXs
|
||||||
|
e24Ql2MFqKXx2EIrsMs+ow2xnz6hNRAD39vsYp7HSFj7Ph32Wi8X1O+J68PiNbaW
|
||||||
|
ZblXGGMRXKXUfFA=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIElDCCA3ygAwIBAgIQAf2j627KdciIQ4tyS8+8kTANBgkqhkiG9w0BAQsFADBh
|
||||||
|
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||||
|
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
|
||||||
|
QTAeFw0xMzAzMDgxMjAwMDBaFw0yMzAzMDgxMjAwMDBaME0xCzAJBgNVBAYTAlVT
|
||||||
|
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxJzAlBgNVBAMTHkRpZ2lDZXJ0IFNIQTIg
|
||||||
|
U2VjdXJlIFNlcnZlciBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
|
||||||
|
ANyuWJBNwcQwFZA1W248ghX1LFy949v/cUP6ZCWA1O4Yok3wZtAKc24RmDYXZK83
|
||||||
|
nf36QYSvx6+M/hpzTc8zl5CilodTgyu5pnVILR1WN3vaMTIa16yrBvSqXUu3R0bd
|
||||||
|
KpPDkC55gIDvEwRqFDu1m5K+wgdlTvza/P96rtxcflUxDOg5B6TXvi/TC2rSsd9f
|
||||||
|
/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tV05od8GiG7S5BNO98pVAdvzr508EIDObtHopYJeS4d60tbvVS3bR0
|
||||||
|
j6tJLp07kzQoH3jOlOrHvdPJbRzeXDLz
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh
|
||||||
|
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||||
|
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
|
||||||
|
QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT
|
||||||
|
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
|
||||||
|
b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG
|
||||||
|
9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB
|
||||||
|
CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97
|
||||||
|
nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
|
||||||
|
43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
|
||||||
|
T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4
|
||||||
|
gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO
|
||||||
|
BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR
|
||||||
|
TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw
|
||||||
|
DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr
|
||||||
|
hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg
|
||||||
|
06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF
|
||||||
|
PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls
|
||||||
|
YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
|
||||||
|
CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
28
certs/stg/private.key
Normal file
28
certs/stg/private.key
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC0VyKNSM/a/CzE
|
||||||
|
16vidZzip1p4B7+EhJVyENoofRDk7D7afDddWV33yHUvI5opsyKIEMuGFRNIROH/
|
||||||
|
ZX47vV3H2ST/5UmkXhghEVjA/xQFUqx2hUxAjI+EkHyf+D3cofcoqFBGA7DVQ9MK
|
||||||
|
qgbRmwV09IgfQmdlFlF/D3/ZROYNYhY7NC5W+9d+JdmkV45Kp2zIDEa990roDF2p
|
||||||
|
oN6Nk0WsDMNn5nhyFtGyeuFmYcWwKeCI/XlMu5roko7tJtY0oC0boKSZ8S7xiEPK
|
||||||
|
uBUxw9cWcHVbkLyeJXIr7lfIzg5xejX3A5/KA7UuKtPAc3HQh09TEOD40Rof5Mts
|
||||||
|
l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BcsHsACGndJc3AEH47Ub+btIu
|
||||||
|
oiFm5AORWwcfwJOq0lHhD1G4wqYzzh00aVSvHJgHd4ZVmhdj9duRKS89blKyObc2
|
||||||
|
2XJ82Z3viYypG8h7ERdwbIBZveuupSyBf3dz9aPzAoGBAKSN9nskGkSMfPdPlohA
|
||||||
|
BAmZGciAbob0un6db34ahExKEfkjhPA/C1AIs6LZz9QNy/OTUlXzVSx4axHMeqxo
|
||||||
|
HAb5yVRkj2VDBnWl//BEAxXKj+r1KOqESdqaKeQcYzXzAMQ36DJia7DOiej7HNSx
|
||||||
|
Y3ydXe8hO8lutgiU5rsBNVLM
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
88
certs/stg/ssl_certificate.cer
Executable file
88
certs/stg/ssl_certificate.cer
Executable file
@@ -0,0 +1,88 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIGvjCCBaagAwIBAgIQC3nVkJVbuOa1WFfJQc+IMDANBgkqhkiG9w0BAQsFADBN
|
||||||
|
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5E
|
||||||
|
aWdpQ2VydCBTSEEyIFNlY3VyZSBTZXJ2ZXIgQ0EwHhcNMTgwNTIxMDAwMDAwWhcN
|
||||||
|
MjAwNTIwMTIwMDAwWjCBhTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCElsbGlub2lz
|
||||||
|
MRAwDgYDVQQHEwdDaGljYWdvMS8wLQYDVQQKEyZCbHVlIENyb3NzIGFuZCBCbHVl
|
||||||
|
IFNoaWVsZCBBc3NvY2lhdGlvbjEgMB4GA1UEAwwXKi5kZXYuYmNic2luc3RpdHV0
|
||||||
|
ZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC0VyKNSM/a/CzE
|
||||||
|
16vidZzip1p4B7+EhJVyENoofRDk7D7afDddWV33yHUvI5opsyKIEMuGFRNIROH/
|
||||||
|
ZX47vV3H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IIBbAFqAHYApLkJkLQYWBSH
|
||||||
|
uxOizGdwCjw1mAT5G9+443fNDsgN3BAAAAFjhC1vrQAABAMARzBFAiEAjDaMTkKz
|
||||||
|
JL1M7AloHKciZwIm9PhTpRJhtDedIoV2l5oCIEyT5kke4/OXoBE9guw1TPCKwuS5
|
||||||
|
klDOeG+rlHiTHZvbAHcAb1N2rDHwMRnYmQCkURX/dxUcEdkCwQApBo2yCJo32RMA
|
||||||
|
AAFjhC1xQwAABAMASDBGAiEAzo+0zJUoqV0X0IqzaZ+9boXzWvIzZCR/OqT1qcAe
|
||||||
|
a3QCIQCdMYaIEYnhnsaOXPMsyShv+ry41lQ9UvUZ3EAvhjgCeQB3ALvZ37wfinG1
|
||||||
|
k5Qjl6qSe0c4V5UKq1LoGpCWZDaOHtGFAAABY4QtcKQAAAQDAEgwRgIhAJ4XGViz
|
||||||
|
vfkGsR3/UWlVZhX9t5rLAlyhW/t1K17vkNjJAiEAhzQycmcTPIVb1Ul1Ug5UgWQ4
|
||||||
|
eD2rp/4raewQVACs26QwDQYJKoZIhvcNAQELBQADggEBADjGzhdcyCYxemKuWoP9
|
||||||
|
Umd0jnS6gHPivwgpy2Ra4SSsFCkucHX8dRMi63MRghiKi4FPj9LsFoLpdHacfi+6
|
||||||
|
Q1lX3fZ6Mv2ZpNjMtBe/g6SATLsFxUQl+UP5bMShEXHsQduinAvSW3m8UpQZ2UxG
|
||||||
|
7L/XmNfeW8x213Mi4G2DNUJKDMjO28bO/GbCNB85HGfhnaDxj7OsQYllbE5oEDXN
|
||||||
|
Wkx1QZFrvqE3/2zoOa1ga36xymRXt0Sn3OSFr/ukZh3MCWAL5fuT4zjnSjybHDqT
|
||||||
|
2qdmV08ECgXwVNUMtbTFq9kenBN0xTrfPFR0Y0IPzqXQP5kTPktgrrYiAf+S875J
|
||||||
|
IVo=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIElDCCA3ygAwIBAgIQA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v9kuXclVzDAGySj4dzp30d8tbQk
|
||||||
|
CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
@@ -80,4 +80,7 @@ secret = "hK4Yc9jtBrxaZTr4UU2VsfX9"
|
|||||||
[blue365]
|
[blue365]
|
||||||
url = "https://api-cloud.bcbs.com/blue365deals-stg/v1/validatePrefix/"
|
url = "https://api-cloud.bcbs.com/blue365deals-stg/v1/validatePrefix/"
|
||||||
key = "jcn5xjxvarc96rtjxp25dctj"
|
key = "jcn5xjxvarc96rtjxp25dctj"
|
||||||
secret = "6XdEusG2w2PWWXsfXVyweQnY"
|
secret = "6XdEusG2w2PWWXsfXVyweQnY"
|
||||||
|
|
||||||
|
[eligibility]
|
||||||
|
url = "https://portal-api.dev.bcbsinstitute.com/v1/nemt/eligibility"
|
||||||
@@ -81,3 +81,6 @@ secret = "vFhNeWE8JdJpbDZQtcm6AHjX"
|
|||||||
url = "https://api-cloud.bcbs.com/blue365deals-stg/v1/validatePrefix/"
|
url = "https://api-cloud.bcbs.com/blue365deals-stg/v1/validatePrefix/"
|
||||||
key = "jcn5xjxvarc96rtjxp25dctj"
|
key = "jcn5xjxvarc96rtjxp25dctj"
|
||||||
secret = "6XdEusG2w2PWWXsfXVyweQnY"
|
secret = "6XdEusG2w2PWWXsfXVyweQnY"
|
||||||
|
|
||||||
|
[eligibility]
|
||||||
|
url = "https://portal-api.bcbsinstitute.com/v1/nemt/eligibility"
|
||||||
@@ -28,6 +28,8 @@ type Conn struct {
|
|||||||
notification *notificationRepo
|
notification *notificationRepo
|
||||||
profile *profileRepo
|
profile *profileRepo
|
||||||
organization *organizationRepo
|
organization *organizationRepo
|
||||||
|
zipcodes *zipcodeRepo
|
||||||
|
plan *planRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin starts a transaction
|
// Begin starts a transaction
|
||||||
@@ -80,6 +82,14 @@ func (c *Conn) Organization() contract.OrganizationRepo {
|
|||||||
return c.organization
|
return c.organization
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Conn) Zipcodes() contract.ZipcodeRepo {
|
||||||
|
return c.zipcodes
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Conn) Plans() contract.PlanRepo {
|
||||||
|
return c.plan
|
||||||
|
}
|
||||||
|
|
||||||
// Instance returns an instance of a DataManager
|
// Instance returns an instance of a DataManager
|
||||||
func Instance(cfg *config.Config) (contract.DataManager, error) {
|
func Instance(cfg *config.Config) (contract.DataManager, error) {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
@@ -111,6 +121,8 @@ func Instance(cfg *config.Config) (contract.DataManager, error) {
|
|||||||
instance.notification = newNotificationRepo(db)
|
instance.notification = newNotificationRepo(db)
|
||||||
instance.profile = newProfileRepo(db)
|
instance.profile = newProfileRepo(db)
|
||||||
instance.organization = newOrganizationRepo(db)
|
instance.organization = newOrganizationRepo(db)
|
||||||
|
instance.zipcodes = newZipcodeRepo(db)
|
||||||
|
instance.plan = newPlanRepo(db)
|
||||||
})
|
})
|
||||||
|
|
||||||
return instance, connErr
|
return instance, connErr
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ func (c *organizationRepo) getProfileQuery(user entity.User) (query string, wher
|
|||||||
if len(user.Profiles) > 0 {
|
if len(user.Profiles) > 0 {
|
||||||
for _, p := range user.Profiles {
|
for _, p := range user.Profiles {
|
||||||
switch p.Key {
|
switch p.Key {
|
||||||
|
case "VIRPT":
|
||||||
|
switch p.Organization.Type.Key {
|
||||||
|
case "provider":
|
||||||
|
return
|
||||||
|
}
|
||||||
case "AD", "BCBSIAD", "BDCAD", "PLANAD":
|
case "AD", "BCBSIAD", "BDCAD", "PLANAD":
|
||||||
switch p.Organization.Type.Key {
|
switch p.Organization.Type.Key {
|
||||||
case "techsupport", "bcbsi", "bcbsa":
|
case "techsupport", "bcbsi", "bcbsa":
|
||||||
@@ -214,7 +219,11 @@ func (c *organizationRepo) parseEntity(row scanner) (retVal entity.Organization,
|
|||||||
err = row.Scan(
|
err = row.Scan(
|
||||||
&retVal.ID, &retVal.UUID, &retVal.Type.ID, &retVal.Type.Name, &retVal.Type.Key, &retVal.Name, &retVal.Description, &retVal.ReferenceID, &retVal.ParentID, &retVal.Main, &retVal.Created, &retVal.Updated, &retVal.Active, &retVal.Suspended, &retVal.Blocked, &retVal.Author.ID, &retVal.Author.UUID, &retVal.Author.Name, &retVal.LastEditor.ID, &retVal.LastEditor.UUID, &retVal.LastEditor.Name)
|
&retVal.ID, &retVal.UUID, &retVal.Type.ID, &retVal.Type.Name, &retVal.Type.Key, &retVal.Name, &retVal.Description, &retVal.ReferenceID, &retVal.ParentID, &retVal.Main, &retVal.Created, &retVal.Updated, &retVal.Active, &retVal.Suspended, &retVal.Blocked, &retVal.Author.ID, &retVal.Author.UUID, &retVal.Author.Name, &retVal.LastEditor.ID, &retVal.LastEditor.UUID, &retVal.LastEditor.Name)
|
||||||
|
|
||||||
return retVal, errors.Wrap(err)
|
if err == sql.ErrNoRows {
|
||||||
|
return retVal, nil
|
||||||
|
} else {
|
||||||
|
return retVal, errors.Wrap(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseSet parses a result set result to an entity array
|
// parseSet parses a result set result to an entity array
|
||||||
@@ -337,7 +346,6 @@ func (c *organizationRepo) GetByUUID(organizationUUID string, user entity.User)
|
|||||||
}
|
}
|
||||||
|
|
||||||
query = c.getQuery() + query + " WHERE a.organization_uuid = ? " + where
|
query = c.getQuery() + query + " WHERE a.organization_uuid = ? " + where
|
||||||
|
|
||||||
return c.parseEntity(c.conn.QueryRow(query, organizationUUID))
|
return c.parseEntity(c.conn.QueryRow(query, organizationUUID))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,6 +360,17 @@ func (c *organizationRepo) GetByID(organizationID int64, user entity.User) (enti
|
|||||||
return c.parseEntity(c.conn.QueryRow(query, organizationID))
|
return c.parseEntity(c.conn.QueryRow(query, organizationID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *organizationRepo) GetByTypeAndReferenceID(typeKey string, referenceID int64, user entity.User) (entity.Organization, error) {
|
||||||
|
query, where, err := c.getProfileQuery(user)
|
||||||
|
if err != nil {
|
||||||
|
return entity.Organization{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
query = c.getQuery() + query + " WHERE b.organization_type_key = ? AND a.organization_reference_id = ? " + where
|
||||||
|
|
||||||
|
return c.parseEntity(c.conn.QueryRow(query, typeKey, referenceID))
|
||||||
|
}
|
||||||
|
|
||||||
func (c *organizationRepo) GetChildsByID(organizationID int64, user entity.User) ([]entity.Organization, error) {
|
func (c *organizationRepo) GetChildsByID(organizationID int64, user entity.User) ([]entity.Organization, error) {
|
||||||
query, where, err := c.getProfileQuery(user)
|
query, where, err := c.getProfileQuery(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -431,13 +450,16 @@ func (c *organizationRepo) SetOrganizationAddress(address entity.OrganizationAdd
|
|||||||
return entity.OrganizationAddress{}, errors.NewNotFoundError()
|
return entity.OrganizationAddress{}, errors.NewNotFoundError()
|
||||||
}
|
}
|
||||||
|
|
||||||
organization, err := c.GetByUUID(address.Organization.UUID, user)
|
if address.Organization.ID == 0 {
|
||||||
if err != nil {
|
organization, err := c.GetByUUID(address.Organization.UUID, user)
|
||||||
return entity.OrganizationAddress{}, err
|
if err != nil {
|
||||||
|
return entity.OrganizationAddress{}, err
|
||||||
|
}
|
||||||
|
address.Organization = &organization
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID, _ := uuid.NewV4()
|
UUID, _ := uuid.NewV4()
|
||||||
result, err := c.conn.Exec(query, UUID.String(), organization.ID, address.InternalID, address.Name, address.Address, address.Description, address.Latitude, address.Longitude, address.CreatedUser.ID, address.UpdatedUser.ID)
|
result, err := c.conn.Exec(query, UUID.String(), address.Organization.ID, address.InternalID, address.Name, address.Address, address.Description, address.Latitude, address.Longitude, address.CreatedUser.ID, address.UpdatedUser.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return entity.OrganizationAddress{}, err
|
return entity.OrganizationAddress{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
82
data/datamysql/plan.go
Normal file
82
data/datamysql/plan.go
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package datamysql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type planRepo struct {
|
||||||
|
conn executor
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPlanRepo(conn executor) *planRepo {
|
||||||
|
return &planRepo{
|
||||||
|
conn: conn,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *planRepo) getQuery() string {
|
||||||
|
const query = `SELECT
|
||||||
|
a.plan_id,
|
||||||
|
a.plan_uuid,
|
||||||
|
a.plan_name,
|
||||||
|
a.plan_internal_id,
|
||||||
|
a.plan_internal_status,
|
||||||
|
a.plan_entity_id,
|
||||||
|
a.entity_id,
|
||||||
|
a.payer_id,
|
||||||
|
a.payer_name,
|
||||||
|
a.active,
|
||||||
|
a.created,
|
||||||
|
a.updated,
|
||||||
|
b.plan_prefix_id,
|
||||||
|
b.plan_prefix_uuid,
|
||||||
|
b.alpha_prefix
|
||||||
|
FROM
|
||||||
|
tab_plan a
|
||||||
|
INNER JOIN
|
||||||
|
tab_plan_alpha_prefix b ON a.plan_id = b.plan_id `
|
||||||
|
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *planRepo) parseSet(rows *sql.Rows, err error) ([]entity.Plan, error) {
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
result := make([]entity.Plan, 0)
|
||||||
|
for rows.Next() {
|
||||||
|
entity, err := c.parseEntity(rows)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
result = append(result, entity)
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *planRepo) parseEntity(row scanner) (retVal entity.Plan, err error) {
|
||||||
|
err = row.Scan(
|
||||||
|
&retVal.ID, &retVal.UUID, &retVal.Name, &retVal.InternalID, &retVal.Status, &retVal.PlanEntityID, &retVal.EntityID, &retVal.PayerID, &retVal.PayerName,
|
||||||
|
&retVal.Active, &retVal.Created, &retVal.Updated, &retVal.PrefixID, &retVal.PrefixUUID, &retVal.AlphaPrefix)
|
||||||
|
|
||||||
|
return retVal, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *planRepo) GetByAlphaPrefix(alphaPrefix string) (entity.Plan, error) {
|
||||||
|
return c.parseEntity(c.conn.QueryRow(c.getQuery()+" WHERE b.alpha_prefix = ? ", alphaPrefix))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *planRepo) GetByUUID(planUUID string) ([]entity.Plan, error) {
|
||||||
|
return c.parseSet(c.conn.Query(c.getQuery()+" WHERE a.plan_uuid = ? ", planUUID))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *planRepo) GetByID(planID int64) ([]entity.Plan, error) {
|
||||||
|
return c.parseSet(c.conn.Query(c.getQuery()+" WHERE a.plan_id = ? ", planID))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *planRepo) GetByPrefixUUID(prefixUUID string) (entity.Plan, error) {
|
||||||
|
return c.parseEntity(c.conn.QueryRow(c.getQuery()+" WHERE b.plan_prefix_uuid = ? ", prefixUUID))
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ func (c *providerRepo) getProfileQuery(user entity.User) (query string, where st
|
|||||||
if len(user.Profiles) > 0 {
|
if len(user.Profiles) > 0 {
|
||||||
for _, p := range user.Profiles {
|
for _, p := range user.Profiles {
|
||||||
switch p.Key {
|
switch p.Key {
|
||||||
case "AD", "BCBSIAD", "BDCAD", "PLANAD":
|
case "AD", "BCBSIAD", "BDCAD", "PLANAD", "VIRPT":
|
||||||
return
|
return
|
||||||
case "SP", "SPT":
|
case "SP", "SPT":
|
||||||
switch p.Organization.Type.Key {
|
switch p.Organization.Type.Key {
|
||||||
@@ -72,44 +72,44 @@ func (c *providerRepo) getSelectQueryBaseKey() string {
|
|||||||
|
|
||||||
func (c *providerRepo) getSelectQueryBase() string {
|
func (c *providerRepo) getSelectQueryBase() string {
|
||||||
return `SELECT DISTINCT
|
return `SELECT DISTINCT
|
||||||
a.provider_id,
|
a.provider_id,
|
||||||
a.provider_uuid,
|
a.provider_uuid,
|
||||||
a.provider_internal_id,
|
a.provider_internal_id,
|
||||||
a.provider_internal_id_suffix,
|
IFNULL(a.provider_internal_id_suffix, '') provider_internal_id_suffix,
|
||||||
a.provider_muk_id,
|
IFNULL(a.provider_muk_id, '') provider_muk_id,
|
||||||
a.organization_name,
|
IFNULL(a.organization_name, '') organization_name,
|
||||||
a.gender,
|
IFNULL(a.gender, '') gender,
|
||||||
a.accept_new_patients,
|
IFNULL(a.accept_new_patients, '') accept_new_patients,
|
||||||
a.provider_name,
|
IFNULL(a.provider_name, '') provider_name,
|
||||||
a.first_name,
|
IFNULL(a.first_name, '') first_name,
|
||||||
a.last_name,
|
IFNULL(a.last_name, '') last_name,
|
||||||
a.middle_name,
|
IFNULL(a.middle_name, '') middle_name,
|
||||||
a.provider_title,
|
IFNULL(a.provider_title, '') provider_title,
|
||||||
a.street_name1,
|
IFNULL(a.street_name1, '') street_name1,
|
||||||
a.street_name2,
|
IFNULL(a.street_name2, '') street_name2,
|
||||||
a.city_name,
|
IFNULL(a.city_name, '') city_name,
|
||||||
a.state,
|
IFNULL(a.state, '') state,
|
||||||
a.zipcode,
|
IFNULL(a.zipcode, '') zipcode,
|
||||||
a.country,
|
IFNULL(a.country, '') country,
|
||||||
a.latitude,
|
IFNULL(a.latitude, 0) latitude,
|
||||||
a.longitude,
|
IFNULL(a.longitude, 0) longitude,
|
||||||
a.phone_number,
|
IFNULL(a.phone_number, '') phone_number,
|
||||||
a.create_at,
|
a.create_at,
|
||||||
a.update_at,
|
a.update_at,
|
||||||
a.active,
|
a.active,
|
||||||
a.enabled,
|
a.enabled,
|
||||||
a.created_user,
|
a.created_user,
|
||||||
(3959 * acos (
|
(3959 * acos (
|
||||||
cos ( radians(?) )
|
cos ( radians(?) )
|
||||||
* cos( radians( a.latitude ) )
|
* cos( radians( IFNULL(a.latitude, 0) ) )
|
||||||
* cos( radians( a.longitude ) - radians(?) )
|
* cos( radians( IFNULL(a.longitude, 0) ) - radians(?) )
|
||||||
+ sin ( radians(?) )
|
+ sin ( radians(?) )
|
||||||
* sin( radians( a.latitude ) )
|
* sin( radians( IFNULL(a.latitude, 0) ) )
|
||||||
)) AS distance_in_miles
|
)) AS distance_in_miles
|
||||||
FROM
|
FROM
|
||||||
tab_provider a
|
tab_provider a
|
||||||
INNER JOIN tab_provider_key b
|
INNER JOIN tab_provider_key b
|
||||||
ON a.provider_id = b.provider_id `
|
ON a.provider_id = b.provider_id `
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *providerRepo) GetAll(user entity.User) ([]entity.Provider, error) {
|
func (c *providerRepo) GetAll(user entity.User) ([]entity.Provider, error) {
|
||||||
@@ -131,6 +131,34 @@ func (c *providerRepo) GetAll(user entity.User) ([]entity.Provider, error) {
|
|||||||
return c.getKeys("", "", providers)
|
return c.getKeys("", "", providers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *providerRepo) GetByUUID(providerUUID string, user entity.User) (entity.Provider, error) {
|
||||||
|
lat := 41.886406
|
||||||
|
long := -87.624225
|
||||||
|
|
||||||
|
query, where, err := c.getProfileQuery(user)
|
||||||
|
if err != nil {
|
||||||
|
return entity.Provider{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
query = c.getSelectQueryBase() + query + " WHERE a.provider_uuid = ? " + where
|
||||||
|
|
||||||
|
return c.parseEntity(c.conn.QueryRow(query, lat, long, lat, providerUUID))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *providerRepo) GetByID(providerID int64, user entity.User) (entity.Provider, error) {
|
||||||
|
lat := 41.886406
|
||||||
|
long := -87.624225
|
||||||
|
|
||||||
|
query, where, err := c.getProfileQuery(user)
|
||||||
|
if err != nil {
|
||||||
|
return entity.Provider{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
query = c.getSelectQueryBase() + query + " WHERE a.provider_id = ? " + where
|
||||||
|
|
||||||
|
return c.parseEntity(c.conn.QueryRow(query, lat, long, lat, providerID))
|
||||||
|
}
|
||||||
|
|
||||||
func (c *providerRepo) GetByMukID(mukID string, user entity.User) (entity.Provider, error) {
|
func (c *providerRepo) GetByMukID(mukID string, user entity.User) (entity.Provider, error) {
|
||||||
lat := 41.886406
|
lat := 41.886406
|
||||||
long := -87.624225
|
long := -87.624225
|
||||||
@@ -145,6 +173,20 @@ func (c *providerRepo) GetByMukID(mukID string, user entity.User) (entity.Provid
|
|||||||
return c.parseEntity(c.conn.QueryRow(query, lat, long, lat, mukID))
|
return c.parseEntity(c.conn.QueryRow(query, lat, long, lat, mukID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *providerRepo) GetByNPI(NPI string, user entity.User) (entity.Provider, error) {
|
||||||
|
lat := 41.886406
|
||||||
|
long := -87.624225
|
||||||
|
|
||||||
|
query, where, err := c.getProfileQuery(user)
|
||||||
|
if err != nil {
|
||||||
|
return entity.Provider{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
query = c.getSelectQueryBase() + query + " WHERE a.provider_internal_id = ? " + where
|
||||||
|
|
||||||
|
return c.parseEntity(c.conn.QueryRow(query, lat, long, lat, NPI))
|
||||||
|
}
|
||||||
|
|
||||||
func (c *providerRepo) 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) {
|
func (c *providerRepo) 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) {
|
||||||
filter := " WHERE 1 = 1 "
|
filter := " WHERE 1 = 1 "
|
||||||
params := make([]interface{}, 0)
|
params := make([]interface{}, 0)
|
||||||
@@ -293,7 +335,11 @@ func (c *providerRepo) parseEntity(row scanner) (retVal entity.Provider, err err
|
|||||||
err = row.Scan(
|
err = row.Scan(
|
||||||
&retVal.ProviderID, &retVal.ProviderUUID, &retVal.InternalID, &retVal.InternalSuffixID, &retVal.MukID, &retVal.OrganizatioName, &retVal.Gender, &retVal.AcceptNewPatients, &retVal.Name, &retVal.FirstName, &retVal.LastName, &retVal.MiddleName, &retVal.Title, &retVal.Address.StreetAddress1, &retVal.Address.StreetAddress2, &retVal.Address.CityName, &retVal.Address.State, &retVal.Address.ZipCode, &retVal.Address.Country, &retVal.Address.Latitude, &retVal.Address.Longitude, &retVal.Address.PhoneNumber, &retVal.CreateDate, &retVal.UpdateDate, &retVal.Active, &retVal.Enabled, &retVal.CreatedUser.ID, &retVal.Distance)
|
&retVal.ProviderID, &retVal.ProviderUUID, &retVal.InternalID, &retVal.InternalSuffixID, &retVal.MukID, &retVal.OrganizatioName, &retVal.Gender, &retVal.AcceptNewPatients, &retVal.Name, &retVal.FirstName, &retVal.LastName, &retVal.MiddleName, &retVal.Title, &retVal.Address.StreetAddress1, &retVal.Address.StreetAddress2, &retVal.Address.CityName, &retVal.Address.State, &retVal.Address.ZipCode, &retVal.Address.Country, &retVal.Address.Latitude, &retVal.Address.Longitude, &retVal.Address.PhoneNumber, &retVal.CreateDate, &retVal.UpdateDate, &retVal.Active, &retVal.Enabled, &retVal.CreatedUser.ID, &retVal.Distance)
|
||||||
|
|
||||||
return retVal, errors.Wrap(err)
|
if err == sql.ErrNoRows {
|
||||||
|
return retVal, nil
|
||||||
|
} else {
|
||||||
|
return retVal, errors.Wrap(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *providerRepo) Save(providers []entity.ProviderResponse, user entity.User) ([]entity.Provider, error) {
|
func (c *providerRepo) Save(providers []entity.ProviderResponse, user entity.User) ([]entity.Provider, error) {
|
||||||
|
|||||||
@@ -144,13 +144,13 @@ func (c *rideRepo) getProfileQuery(user entity.User) (query string, where string
|
|||||||
switch p.Key {
|
switch p.Key {
|
||||||
case "AD", "BCBSIAD", "BDCAD", "PLANAD":
|
case "AD", "BCBSIAD", "BDCAD", "PLANAD":
|
||||||
return
|
return
|
||||||
case "SP", "SPT":
|
case "SP", "SPT", "VIRPT":
|
||||||
switch p.Organization.Type.Key {
|
switch p.Organization.Type.Key {
|
||||||
case "techsupport", "bcbsi", "bcbsa", "plan":
|
case "techsupport", "bcbsi", "bcbsa", "plan":
|
||||||
return
|
return
|
||||||
case "provider":
|
case "provider":
|
||||||
query = `INNER JOIN viw_visit_provider o ON a.ride_id = o.ride_id`
|
query = `INNER JOIN viw_visit_provider z ON a.ride_id = z.ride_id`
|
||||||
where = fmt.Sprintf(` AND (o.organization_uuid = '%s' OR o.parent_organization_uuid = '%s') `, p.Organization.UUID, p.Organization.UUID)
|
where = fmt.Sprintf(` AND (z.organization_uuid = '%s' OR z.parent_organization_uuid = '%s') `, p.Organization.UUID, p.Organization.UUID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -676,6 +676,7 @@ func (c *rideRepo) GetByUUID(uuid string, user entity.User) (entity.Ride, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
query = c.getQuery() + query + " WHERE a.ride_uuid = ? " + where
|
query = c.getQuery() + query + " WHERE a.ride_uuid = ? " + where
|
||||||
|
|
||||||
return c.parseEntity(c.conn.QueryRow(query, uuid))
|
return c.parseEntity(c.conn.QueryRow(query, uuid))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ type transaction struct {
|
|||||||
notification *notificationRepo
|
notification *notificationRepo
|
||||||
profile *profileRepo
|
profile *profileRepo
|
||||||
organization *organizationRepo
|
organization *organizationRepo
|
||||||
|
zipcodes *zipcodeRepo
|
||||||
|
plan *planRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTransaction(tx *sql.Tx) *transaction {
|
func newTransaction(tx *sql.Tx) *transaction {
|
||||||
@@ -27,6 +29,11 @@ func newTransaction(tx *sql.Tx) *transaction {
|
|||||||
t.rides = newRideRepo(tx)
|
t.rides = newRideRepo(tx)
|
||||||
t.visits = newVisitRepo(tx)
|
t.visits = newVisitRepo(tx)
|
||||||
t.provider = newProviderRepo(tx)
|
t.provider = newProviderRepo(tx)
|
||||||
|
t.notification = newNotificationRepo(tx)
|
||||||
|
t.profile = newProfileRepo(tx)
|
||||||
|
t.organization = newOrganizationRepo(tx)
|
||||||
|
t.zipcodes = newZipcodeRepo(tx)
|
||||||
|
t.plan = newPlanRepo(tx)
|
||||||
|
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
@@ -66,6 +73,14 @@ func (t transaction) Organization() contract.OrganizationRepo {
|
|||||||
return t.organization
|
return t.organization
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t transaction) Zipcodes() contract.ZipcodeRepo {
|
||||||
|
return t.zipcodes
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t transaction) Plans() contract.PlanRepo {
|
||||||
|
return t.plan
|
||||||
|
}
|
||||||
|
|
||||||
func (t *transaction) Commit() error {
|
func (t *transaction) Commit() error {
|
||||||
|
|
||||||
err := t.tx.Commit()
|
err := t.tx.Commit()
|
||||||
|
|||||||
@@ -22,6 +22,32 @@ func newUserRepo(conn executor) *userRepo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *userRepo) GetByMemberID(memberID string) (entity.User, error) {
|
||||||
|
finalQuery := c.getQuery() + " AND a.member = ? AND e.key = 'US'"
|
||||||
|
|
||||||
|
user, err := c.parseSet(c.conn.Query(finalQuery, memberID))
|
||||||
|
if err != nil {
|
||||||
|
return entity.User{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user) > 0 {
|
||||||
|
retVal := user[0]
|
||||||
|
retVal.Contacts, err = c.GetContacts(retVal.ID)
|
||||||
|
if err != nil {
|
||||||
|
return entity.User{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
retVal.Addresses = nil
|
||||||
|
retVal.Addresses, err = c.getAddressByUserID(retVal.ID)
|
||||||
|
if err != nil {
|
||||||
|
return entity.User{}, err
|
||||||
|
}
|
||||||
|
return retVal, nil
|
||||||
|
} else {
|
||||||
|
return entity.User{}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *userRepo) GetByUUID(uuid string, profile string) (entity.User, error) {
|
func (c *userRepo) GetByUUID(uuid string, profile string) (entity.User, error) {
|
||||||
params := make([]interface{}, 0)
|
params := make([]interface{}, 0)
|
||||||
params = append(params, uuid)
|
params = append(params, uuid)
|
||||||
@@ -390,6 +416,24 @@ func (c *userRepo) SaveContact(contact entity.ContactInfo) (entity.ContactInfo,
|
|||||||
return c.addContactInfo(contact)
|
return c.addContactInfo(contact)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *userRepo) UpdateLogin(user entity.User) error {
|
||||||
|
const (
|
||||||
|
query = `UPDATE tab_login a
|
||||||
|
INNER JOIN tab_user b
|
||||||
|
ON a.user_id = b.user_id
|
||||||
|
SET a.email = ?,
|
||||||
|
a.phone_number = ?
|
||||||
|
WHERE
|
||||||
|
b.user_uuid = ?`
|
||||||
|
)
|
||||||
|
|
||||||
|
if _, err := c.conn.Exec(query, user.Email, user.PhoneNumber, user.UUID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *userRepo) RemoveContact(contact entity.ContactInfo) (entity.ContactInfo, error) {
|
func (c *userRepo) RemoveContact(contact entity.ContactInfo) (entity.ContactInfo, error) {
|
||||||
const (
|
const (
|
||||||
query = `DELETE FROM tab_contact WHERE contact_uuid = ?;`
|
query = `DELETE FROM tab_contact WHERE contact_uuid = ?;`
|
||||||
@@ -561,7 +605,7 @@ func (c *userRepo) createUser(user entity.User) (int64, string, error) {
|
|||||||
|
|
||||||
func (c *userRepo) RemoveAddress(addressUUID string) error {
|
func (c *userRepo) RemoveAddress(addressUUID string) error {
|
||||||
const (
|
const (
|
||||||
query = "UPDATE tab_address SET active = 0 WHERE address_uuid = ?"
|
query = "UPDATE tab_address SET active = 0 WHERE address_uuid = ?;"
|
||||||
)
|
)
|
||||||
|
|
||||||
_, err := c.conn.Exec(query, addressUUID)
|
_, err := c.conn.Exec(query, addressUUID)
|
||||||
|
|||||||
@@ -27,14 +27,13 @@ func (c *visitRepo) getProfileQuery(user entity.User) (query string, where strin
|
|||||||
switch p.Key {
|
switch p.Key {
|
||||||
case "AD", "BCBSIAD", "BDCAD", "PLANAD":
|
case "AD", "BCBSIAD", "BDCAD", "PLANAD":
|
||||||
return
|
return
|
||||||
case "SP", "SPT":
|
case "SP", "SPT", "VIRPT":
|
||||||
switch p.Organization.Type.Key {
|
switch p.Organization.Type.Key {
|
||||||
case "techsupport", "bcbsi", "bcbsa", "plan":
|
case "techsupport", "bcbsi", "bcbsa", "plan":
|
||||||
return
|
return
|
||||||
case "provider":
|
case "provider":
|
||||||
query = ` INNER JOIN viw_visit_provider f
|
query = ` INNER JOIN viw_visit_provider AS o ON o.visit_id = a.visit_id `
|
||||||
ON f.visit_id = a.visit_id `
|
where = fmt.Sprintf(` AND ( o.organization_uuid = '%s' OR o.parent_organization_uuid = '%s' ) `, p.Organization.UUID, p.Organization.UUID)
|
||||||
where = fmt.Sprintf(` AND (f.organization_uuid = '%s' OR f.parent_organization_uuid = '%s') `, p.Organization.UUID, p.Organization.UUID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,17 +84,17 @@ func (c *visitRepo) getQuery() string {
|
|||||||
IFNULL(f.provider_muk_id, '') provider_muk_id,
|
IFNULL(f.provider_muk_id, '') provider_muk_id,
|
||||||
IFNULL(f.provider_name, '') provider_name
|
IFNULL(f.provider_name, '') provider_name
|
||||||
FROM
|
FROM
|
||||||
tab_visit a
|
tab_visit AS a
|
||||||
INNER JOIN tab_visit_status b
|
INNER JOIN tab_visit_status AS b
|
||||||
ON a.visit_status_id = b.visit_status_id
|
ON a.visit_status_id = b.visit_status_id
|
||||||
INNER JOIN tab_user c
|
INNER JOIN tab_user AS c
|
||||||
ON c.user_id = a.user_id
|
ON c.user_id = a.user_id
|
||||||
INNER JOIN tab_user d
|
INNER JOIN tab_user AS d
|
||||||
ON d.user_id = a.created_user_id
|
ON d.user_id = a.created_user_id
|
||||||
INNER JOIN tab_trip_type e
|
INNER JOIN tab_trip_type AS e
|
||||||
ON e.trip_type_id = a.trip_type_id
|
ON e.trip_type_id = a.trip_type_id
|
||||||
INNER JOIN tab_provider f
|
INNER JOIN tab_provider AS f
|
||||||
ON f.provider_id = a.provider_id `
|
ON f.provider_id = a.provider_id `
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *visitRepo) GetAll(user entity.User) ([]entity.Visit, error) {
|
func (c *visitRepo) GetAll(user entity.User) ([]entity.Visit, error) {
|
||||||
@@ -191,12 +190,13 @@ func (c *visitRepo) Create(visit entity.Visit) (entity.Visit, error) {
|
|||||||
|
|
||||||
row := c.conn.QueryRow(statusQuery, retVal.Status.Key, retVal.User.UUID, retVal.CreatedUser.UUID, retVal.TripType.Key)
|
row := c.conn.QueryRow(statusQuery, retVal.Status.Key, retVal.User.UUID, retVal.CreatedUser.UUID, retVal.TripType.Key)
|
||||||
if err := row.Scan(&retVal.Status.ID, &retVal.Status.Key, &retVal.Status.Value, &retVal.User.ID, &retVal.User.Name, &retVal.CreatedUser.ID, &retVal.CreatedUser.Name, &retVal.TripType.ID, &retVal.TripType.Key, &retVal.TripType.Value); err != nil {
|
if err := row.Scan(&retVal.Status.ID, &retVal.Status.Key, &retVal.Status.Value, &retVal.User.ID, &retVal.User.Name, &retVal.CreatedUser.ID, &retVal.CreatedUser.Name, &retVal.TripType.ID, &retVal.TripType.Key, &retVal.TripType.Value); err != nil {
|
||||||
fmt.Println("Error to get base data: ", err.Error())
|
fmt.Println("data.Visit: Error getting base data: ", err.Error())
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
|
|
||||||
results, err := c.conn.Exec(query, retVal.UUID, retVal.Status.ID, retVal.User.ID, retVal.VisitDatetime, retVal.PickupDatetime, retVal.Notes, retVal.CreatedUser.ID, toNullInt64(retVal.VisitDuration), retVal.ExternalID, returnDate, retVal.TripType.ID, retVal.Pickup.ID, retVal.PickupAddressID, retVal.DestinationAddressID, retVal.Provider.ProviderID)
|
results, err := c.conn.Exec(query, retVal.UUID, retVal.Status.ID, retVal.User.ID, retVal.VisitDatetime, retVal.PickupDatetime, retVal.Notes, retVal.CreatedUser.ID, toNullInt64(retVal.VisitDuration), retVal.ExternalID, returnDate, retVal.TripType.ID, retVal.Pickup.ID, retVal.PickupAddressID, retVal.DestinationAddressID, retVal.Provider.ProviderID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("data.Visit: Error inserting visit: ", err.Error())
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,6 +205,5 @@ func (c *visitRepo) Create(visit entity.Visit) (entity.Visit, error) {
|
|||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Visit ID: ", retVal.ID)
|
|
||||||
return retVal, nil
|
return retVal, nil
|
||||||
}
|
}
|
||||||
|
|||||||
65
data/datamysql/zipcode.go
Normal file
65
data/datamysql/zipcode.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package datamysql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// rideRepo maps methods to database
|
||||||
|
type zipcodeRepo struct {
|
||||||
|
conn executor
|
||||||
|
}
|
||||||
|
|
||||||
|
func newZipcodeRepo(conn executor) *zipcodeRepo {
|
||||||
|
return &zipcodeRepo{
|
||||||
|
conn: conn,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *zipcodeRepo) getQuery() string {
|
||||||
|
const (
|
||||||
|
query = `SELECT
|
||||||
|
a.participating_zip_code_id,
|
||||||
|
a.participating_zip_code_uuid,
|
||||||
|
a.zipcode,
|
||||||
|
(IFNULL(a.participating, b'0') = b'1') participating
|
||||||
|
FROM
|
||||||
|
tab_participating_zip_code a `
|
||||||
|
)
|
||||||
|
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseSet parses a result set result to an entity array
|
||||||
|
func (c *zipcodeRepo) parseSet(rows *sql.Rows, err error) ([]entity.Zipcode, error) {
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
result := make([]entity.Zipcode, 0)
|
||||||
|
for rows.Next() {
|
||||||
|
entity, err := c.parseEntity(rows)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
result = append(result, entity)
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseEntity parses a result to an entity
|
||||||
|
func (c *zipcodeRepo) parseEntity(row scanner) (retVal entity.Zipcode, err error) {
|
||||||
|
err = row.Scan(
|
||||||
|
&retVal.ID, &retVal.UUID, &retVal.Zipcode, &retVal.Participating)
|
||||||
|
|
||||||
|
return retVal, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *zipcodeRepo) GetAll() ([]entity.Zipcode, error) {
|
||||||
|
return c.parseSet(c.conn.Query(c.getQuery()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *zipcodeRepo) GetByParticipatingZipcode(zipcode string) (entity.Zipcode, error) {
|
||||||
|
return c.parseEntity(c.conn.QueryRow(c.getQuery()+"WHERE a.participating = 1 AND a.zipcode = ?", zipcode))
|
||||||
|
}
|
||||||
22
default.dev.conf
Normal file
22
default.dev.conf
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443;
|
||||||
|
ssl on;
|
||||||
|
ssl_certificate /opt/app/certs/ssl_certificate.cer;
|
||||||
|
ssl_certificate_key /opt/app/certs/private.key;
|
||||||
|
server_name portal-api.dev.bcbsinstitute.com;
|
||||||
|
server_tokens off;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:5100;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
default.prd.conf
Normal file
22
default.prd.conf
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443;
|
||||||
|
ssl on;
|
||||||
|
ssl_certificate /opt/app/certs/ssl_certificate.cer;
|
||||||
|
ssl_certificate_key /opt/app/certs/private.key;
|
||||||
|
server_name portal-api.bcbsinstitute.com;
|
||||||
|
server_tokens off;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:5100;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
default.stg.conf
Normal file
22
default.stg.conf
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443;
|
||||||
|
ssl on;
|
||||||
|
ssl_certificate /opt/app/certs/ssl_certificate.cer;
|
||||||
|
ssl_certificate_key /opt/app/certs/private.key;
|
||||||
|
server_name portal-api.dev.bcbsinstitute.com;
|
||||||
|
server_tokens off;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:5100;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ type repoManager interface {
|
|||||||
Notification() NotificationRepo
|
Notification() NotificationRepo
|
||||||
Profile() ProfileRepo
|
Profile() ProfileRepo
|
||||||
Organization() OrganizationRepo
|
Organization() OrganizationRepo
|
||||||
|
Zipcodes() ZipcodeRepo
|
||||||
|
Plans() PlanRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserRepo defines the data set for users
|
// UserRepo defines the data set for users
|
||||||
@@ -19,6 +21,7 @@ type UserRepo interface {
|
|||||||
GetAll() (list []entity.User, err error)
|
GetAll() (list []entity.User, err error)
|
||||||
GetByID(userID int64) (retVal entity.User, err error)
|
GetByID(userID int64) (retVal entity.User, err error)
|
||||||
GetByUUID(uuid string, profile string) (entity.User, error)
|
GetByUUID(uuid string, profile string) (entity.User, error)
|
||||||
|
GetByMemberID(memberID string) (entity.User, error)
|
||||||
Login(email string, pass string) (entity.User, error)
|
Login(email string, pass string) (entity.User, error)
|
||||||
FullLogin(loginType string, key string, pass string, profile string) (entity.User, error)
|
FullLogin(loginType string, key string, pass string, profile string) (entity.User, error)
|
||||||
Create(user entity.User) (entity.User, error)
|
Create(user entity.User) (entity.User, error)
|
||||||
@@ -29,6 +32,7 @@ type UserRepo interface {
|
|||||||
RemoveAddress(addressUUID string) error
|
RemoveAddress(addressUUID string) error
|
||||||
SaveContact(contact entity.ContactInfo) (entity.ContactInfo, error)
|
SaveContact(contact entity.ContactInfo) (entity.ContactInfo, error)
|
||||||
RemoveContact(contact entity.ContactInfo) (entity.ContactInfo, error)
|
RemoveContact(contact entity.ContactInfo) (entity.ContactInfo, error)
|
||||||
|
UpdateLogin(user entity.User) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// RideRepo defines the data set for Rides
|
// RideRepo defines the data set for Rides
|
||||||
@@ -56,6 +60,9 @@ type ProviderRepo interface {
|
|||||||
GetAll(user entity.User) ([]entity.Provider, error)
|
GetAll(user entity.User) ([]entity.Provider, error)
|
||||||
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)
|
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)
|
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)
|
||||||
|
GetByID(providerID int64, user entity.User) (entity.Provider, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotificationRepo defines the data set for Notification
|
// NotificationRepo defines the data set for Notification
|
||||||
@@ -72,6 +79,7 @@ type OrganizationRepo interface {
|
|||||||
GetAllTypes() ([]entity.OrganizationType, error)
|
GetAllTypes() ([]entity.OrganizationType, error)
|
||||||
GetByType(organizationTypeKey string, user entity.User) ([]entity.Organization, error)
|
GetByType(organizationTypeKey string, user entity.User) ([]entity.Organization, error)
|
||||||
GetByUUID(organizationUUID 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)
|
GetContactsByOrganizationUUID(organizationUUID string) ([]entity.OrganizationContact, error)
|
||||||
GetContactsByOrganizationID(organizationID int64) ([]entity.OrganizationContact, error)
|
GetContactsByOrganizationID(organizationID int64) ([]entity.OrganizationContact, error)
|
||||||
GetContactsByUUID(contactUUID string) (entity.OrganizationContact, error)
|
GetContactsByUUID(contactUUID string) (entity.OrganizationContact, error)
|
||||||
@@ -90,6 +98,13 @@ type OrganizationRepo interface {
|
|||||||
GetTypeByKey(key string) (entity.OrganizationType, error)
|
GetTypeByKey(key string) (entity.OrganizationType, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PlanRepo interface {
|
||||||
|
GetByAlphaPrefix(alphaPrefix string) (entity.Plan, error)
|
||||||
|
GetByUUID(planUUID string) ([]entity.Plan, error)
|
||||||
|
GetByID(planID int64) ([]entity.Plan, error)
|
||||||
|
GetByPrefixUUID(prefixUUID string) (entity.Plan, error)
|
||||||
|
}
|
||||||
|
|
||||||
// VisitRepo defines the data set for Rides
|
// VisitRepo defines the data set for Rides
|
||||||
type VisitRepo interface {
|
type VisitRepo interface {
|
||||||
Create(visit entity.Visit) (entity.Visit, error)
|
Create(visit entity.Visit) (entity.Visit, error)
|
||||||
@@ -104,3 +119,8 @@ type ProfileRepo interface {
|
|||||||
GetVisibles(visible bool) ([]entity.Profile, error)
|
GetVisibles(visible bool) ([]entity.Profile, error)
|
||||||
GetByOrganizationType(organizationTypeID int64) ([]entity.Profile, error)
|
GetByOrganizationType(organizationTypeID int64) ([]entity.Profile, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ZipcodeRepo interface {
|
||||||
|
GetAll() ([]entity.Zipcode, error)
|
||||||
|
GetByParticipatingZipcode(zipcode string) (entity.Zipcode, error)
|
||||||
|
}
|
||||||
|
|||||||
21
domain/entity/plan.go
Normal file
21
domain/entity/plan.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type Plan struct {
|
||||||
|
ID int64 `json:"-"`
|
||||||
|
UUID string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
InternalID string `json:"key"`
|
||||||
|
Status bool `json:"desc"`
|
||||||
|
PlanEntityID int64 `json:"plan_entity_id"`
|
||||||
|
EntityID int64 `json:"entity_id"`
|
||||||
|
PayerID int64 `json:"payer_id"`
|
||||||
|
PayerName string `json:"payer_name"`
|
||||||
|
PrefixID int64 `json:"prefix_id"`
|
||||||
|
PrefixUUID string `json:"prefix_uuid"`
|
||||||
|
AlphaPrefix string `json:"alpha_prefix"`
|
||||||
|
Created time.Time `json:"created"`
|
||||||
|
Updated time.Time `json:"updated"`
|
||||||
|
Active bool `json:"active"`
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ type Provider struct {
|
|||||||
Keys []ProviderKey `json:"keys"`
|
Keys []ProviderKey `json:"keys"`
|
||||||
Address ProviderAddress `json:"address"`
|
Address ProviderAddress `json:"address"`
|
||||||
Distance float64 `json:"distance"`
|
Distance float64 `json:"distance"`
|
||||||
|
Organization Organization `json:"organization"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProviderKey struct {
|
type ProviderKey struct {
|
||||||
|
|||||||
8
domain/entity/zipcode.go
Normal file
8
domain/entity/zipcode.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
type Zipcode struct {
|
||||||
|
ID int64 `db:"participating_zip_code_id" json:"-"`
|
||||||
|
UUID string `db:"participating_zip_code_uuid" json:"uuid"`
|
||||||
|
Zipcode string `db:"zipcode" json:"zipcode"`
|
||||||
|
Participating bool `db:"participating" json:"participating"`
|
||||||
|
}
|
||||||
@@ -28,6 +28,10 @@ func (s *organizationService) GetByName(name string, searchType string, user ent
|
|||||||
return s.svc.db.Organization().GetByName(name, searchType, user)
|
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) {
|
func (s *organizationService) GetByUUID(organizationUUID string, user entity.User) (entity.Organization, error) {
|
||||||
organization, err := s.svc.db.Organization().GetByUUID(organizationUUID, user)
|
organization, err := s.svc.db.Organization().GetByUUID(organizationUUID, user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
31
domain/service/plan.go
Normal file
31
domain/service/plan.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
type planService struct {
|
||||||
|
svc *Service
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPlanService(svc *Service) *planService {
|
||||||
|
return &planService{
|
||||||
|
svc: svc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *planService) GetByAlphaPrefix(alphaPrefix string) (entity.Plan, error) {
|
||||||
|
return s.svc.db.Plans().GetByAlphaPrefix(alphaPrefix)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *planService) GetByUUID(planUUID string) ([]entity.Plan, error) {
|
||||||
|
return s.svc.db.Plans().GetByUUID(planUUID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *planService) GetByID(planID int64) ([]entity.Plan, error) {
|
||||||
|
return s.svc.db.Plans().GetByID(planID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *planService) GetByPrefixUUID(prefixUUID string) (entity.Plan, error) {
|
||||||
|
return s.svc.db.Plans().GetByPrefixUUID(prefixUUID)
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -42,5 +45,68 @@ func (s *providerService) Get(query string, lat float64, long float64, distance
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *providerService) GetByMukID(mukID string, user entity.User) (entity.Provider, error) {
|
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) {
|
||||||
|
provider, err := s.svc.db.Provider().GetByUUID(providerUUID, user)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("providerService.GetByUUID: Provider UUID: ", providerUUID)
|
||||||
|
fmt.Println("providerService.GetByUUID: Provider Error: ", err.Error())
|
||||||
|
return provider, err
|
||||||
|
}
|
||||||
|
|
||||||
|
organization, err := s.svc.db.Organization().GetByTypeAndReferenceID("provider", provider.ProviderID, user)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("providerService.GetByUUID: OrganizationByType ProviderID : ", provider.ProviderID)
|
||||||
|
fmt.Println("providerService.GetByUUID: OrganizationByType Error: ", err.Error())
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *providerService) GetByOrganization(organizationUUID string, user entity.User) (entity.Provider, error) {
|
||||||
|
organization, err := s.svc.db.Organization().GetByUUID(organizationUUID, user)
|
||||||
|
if err != nil {
|
||||||
|
return entity.Provider{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if organization.Type.Key != "provider" {
|
||||||
|
return entity.Provider{}, errors.New("invalid organization")
|
||||||
|
}
|
||||||
|
|
||||||
|
provider, err := s.svc.db.Provider().GetByID(organization.ReferenceID, user)
|
||||||
|
if err != nil {
|
||||||
|
return entity.Provider{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return provider, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,12 @@ func (s *rideService) GetByID(id int64, user entity.User) (entity.Ride, error) {
|
|||||||
|
|
||||||
// GetByUUID return a specific ride
|
// GetByUUID return a specific ride
|
||||||
func (s *rideService) GetByUUID(uuid string, user entity.User) (entity.Ride, error) {
|
func (s *rideService) GetByUUID(uuid string, user entity.User) (entity.Ride, error) {
|
||||||
return s.svc.db.Rides().GetByUUID(uuid, user)
|
ride, err := s.svc.db.Rides().GetByUUID(uuid, user)
|
||||||
|
if err != nil {
|
||||||
|
return entity.Ride{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ride, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetByUUID return a specific ride
|
// GetByUUID return a specific ride
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ type Service struct {
|
|||||||
Notification *notificationService
|
Notification *notificationService
|
||||||
Profile *profileService
|
Profile *profileService
|
||||||
Organization *organizationService
|
Organization *organizationService
|
||||||
|
Zipcodes *zipcodeService
|
||||||
|
Plans *planService
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new domain Service instance
|
// New returns a new domain Service instance
|
||||||
@@ -39,6 +41,8 @@ func New(db contract.DataManager, cache contract.CacheManager, cfg *config.Confi
|
|||||||
instance.Notification = newNotificationService(instance)
|
instance.Notification = newNotificationService(instance)
|
||||||
instance.Profile = newProfileService(instance)
|
instance.Profile = newProfileService(instance)
|
||||||
instance.Organization = newOrganizationService(instance)
|
instance.Organization = newOrganizationService(instance)
|
||||||
|
instance.Zipcodes = newZipcodeService(instance)
|
||||||
|
instance.Plans = newPlanService(instance)
|
||||||
})
|
})
|
||||||
|
|
||||||
return instance, nil
|
return instance, nil
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ func (s *userService) GetByUUID(uuid string, profile string) (entity.User, error
|
|||||||
return s.svc.db.Users().GetByUUID(uuid, profile)
|
return s.svc.db.Users().GetByUUID(uuid, profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *userService) GetByMemberID(memberID string) (entity.User, error) {
|
||||||
|
return s.svc.db.Users().GetByMemberID(memberID)
|
||||||
|
}
|
||||||
|
|
||||||
// Login returns a specific user by email and pass
|
// Login returns a specific user by email and pass
|
||||||
func (s *userService) Login(email string, pass string) (entity.User, error) {
|
func (s *userService) Login(email string, pass string) (entity.User, error) {
|
||||||
return s.svc.db.Users().Login(email, pass)
|
return s.svc.db.Users().Login(email, pass)
|
||||||
@@ -68,6 +72,10 @@ func (s *userService) CreateBulk(users []entity.User) ([]entity.User, error) {
|
|||||||
return users, nil
|
return users, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *userService) UpdateLogin(user entity.User) error {
|
||||||
|
return s.svc.db.Users().UpdateLogin(user)
|
||||||
|
}
|
||||||
|
|
||||||
// GetUsersByProfile returns a list of users by profile
|
// GetUsersByProfile returns a list of users by profile
|
||||||
func (s *userService) GetUsersByProfile(profile string) ([]entity.User, error) {
|
func (s *userService) GetUsersByProfile(profile string) ([]entity.User, error) {
|
||||||
return s.svc.db.Users().GetUsersByProfile(profile)
|
return s.svc.db.Users().GetUsersByProfile(profile)
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ func (s *visitService) GetAll(user entity.User) ([]entity.Visit, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rides, err := s.svc.db.Rides().GetAll(user)
|
rides, _ := s.svc.db.Rides().GetAll(user)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
ridesByVisit := make(map[int64][]entity.Ride)
|
ridesByVisit := make(map[int64][]entity.Ride)
|
||||||
for _, r := range rides {
|
for _, r := range rides {
|
||||||
@@ -55,10 +55,10 @@ func (s *visitService) GetByUUID(visitUUID string, user entity.User) (entity.Vis
|
|||||||
return entity.Visit{}, errors.Wrap(err)
|
return entity.Visit{}, errors.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rides, err := s.svc.db.Rides().GetByVisitUUID(visitUUID, user)
|
rides, _ := s.svc.db.Rides().GetByVisitUUID(visitUUID, user)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return entity.Visit{}, errors.Wrap(err)
|
// return entity.Visit{}, errors.Wrap(err)
|
||||||
}
|
// }
|
||||||
visit.Rides = rides
|
visit.Rides = rides
|
||||||
|
|
||||||
return visit, nil
|
return visit, nil
|
||||||
@@ -71,10 +71,10 @@ func (s *visitService) GetByID(visitID int64, user entity.User) (entity.Visit, e
|
|||||||
return entity.Visit{}, errors.Wrap(err)
|
return entity.Visit{}, errors.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rides, err := s.svc.db.Rides().GetByVisitUUID(visit.UUID, user)
|
rides, _ := s.svc.db.Rides().GetByVisitUUID(visit.UUID, user)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return entity.Visit{}, errors.Wrap(err)
|
// return entity.Visit{}, errors.Wrap(err)
|
||||||
}
|
// }
|
||||||
visit.Rides = rides
|
visit.Rides = rides
|
||||||
|
|
||||||
return visit, nil
|
return visit, nil
|
||||||
|
|||||||
25
domain/service/zipcode.go
Normal file
25
domain/service/zipcode.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
// userService is the domain service for user operations
|
||||||
|
type zipcodeService struct {
|
||||||
|
svc *Service
|
||||||
|
}
|
||||||
|
|
||||||
|
// newUserService returns an instance of userService
|
||||||
|
func newZipcodeService(svc *Service) *zipcodeService {
|
||||||
|
return &zipcodeService{
|
||||||
|
svc: svc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *zipcodeService) GetAll() ([]entity.Zipcode, error) {
|
||||||
|
return s.svc.db.Zipcodes().GetAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *zipcodeService) GetByParticipatingZipcode(zipcode string) (entity.Zipcode, error) {
|
||||||
|
return s.svc.db.Zipcodes().GetByParticipatingZipcode(zipcode)
|
||||||
|
}
|
||||||
25
ecs.dev.json
25
ecs.dev.json
@@ -1,35 +1,26 @@
|
|||||||
{
|
{
|
||||||
"containerDefinitions": [
|
"containerDefinitions": [
|
||||||
{
|
{
|
||||||
"name": "api-development",
|
"name": "portal-api",
|
||||||
"image": "xxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/dev.nemt-portal-api:latest",
|
"image": "105690980714.dkr.ecr.us-east-2.amazonaws.com/nemt-portal-api:dev",
|
||||||
"cpu": 128,
|
"cpu": 128,
|
||||||
"memory": 128,
|
"memory": 128,
|
||||||
"essential": true,
|
"essential": true,
|
||||||
"logConfiguration": {
|
"logConfiguration": {
|
||||||
"logDriver": "awslogs",
|
"logDriver": "awslogs",
|
||||||
"options": {
|
"options": {
|
||||||
"awslogs-group": "nemt-portal-api",
|
"awslogs-group": "portal-api",
|
||||||
"awslogs-region": "sa-east-1",
|
"awslogs-region": "us-east-2",
|
||||||
"awslogs-stream-prefix": "development"
|
"awslogs-stream-prefix": "test"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"portMappings": [
|
"portMappings": [
|
||||||
{
|
{
|
||||||
"containerPort": 5100
|
"containerPort": 443,
|
||||||
}
|
"hostPort": 5100
|
||||||
],
|
|
||||||
"environment": [
|
|
||||||
{
|
|
||||||
"name": "SERVICE_5100_NAME",
|
|
||||||
"value": "portal-api"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SERVICE_5100_TAG",
|
|
||||||
"value": "api"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"family": "api-development"
|
"family": "portal-api-dev"
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
"portMappings": [
|
"portMappings": [
|
||||||
{
|
{
|
||||||
"containerPort": 5100,
|
"containerPort": 443,
|
||||||
"hostPort": 5100
|
"hostPort": 5100
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
"portMappings": [
|
"portMappings": [
|
||||||
{
|
{
|
||||||
"containerPort": 5100,
|
"containerPort": 443,
|
||||||
"hostPort": 5100
|
"hostPort": 5100
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type Config struct {
|
|||||||
Blue365 Blue365Config
|
Blue365 Blue365Config
|
||||||
Email EmailConfig
|
Email EmailConfig
|
||||||
GoogleShortener GoogleShortenerConfig
|
GoogleShortener GoogleShortenerConfig
|
||||||
|
Eligibility EligibilityConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppConfig represents the configuration values about the application.
|
// AppConfig represents the configuration values about the application.
|
||||||
@@ -137,6 +138,10 @@ type GoogleShortenerConfig struct {
|
|||||||
SecretKey string
|
SecretKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EligibilityConfig struct {
|
||||||
|
Url string
|
||||||
|
}
|
||||||
|
|
||||||
// Read returns the configuration values,
|
// Read returns the configuration values,
|
||||||
// based on the configuration files and environment variables.
|
// based on the configuration files and environment variables.
|
||||||
func Read() (*Config, error) {
|
func Read() (*Config, error) {
|
||||||
@@ -238,6 +243,9 @@ func Read() (*Config, error) {
|
|||||||
ClientID: viper.GetString("google-shortener.client-id"),
|
ClientID: viper.GetString("google-shortener.client-id"),
|
||||||
SecretKey: viper.GetString("google-shortener.secret-key"),
|
SecretKey: viper.GetString("google-shortener.secret-key"),
|
||||||
},
|
},
|
||||||
|
Eligibility : EligibilityConfig{
|
||||||
|
Url : viper.GetString("eligibility.url"),
|
||||||
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
32
nginx.conf
Normal file
32
nginx.conf
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
user nginx;
|
||||||
|
worker_processes 1;
|
||||||
|
daemon on;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log main;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
#tcp_nopush on;
|
||||||
|
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
#gzip on;
|
||||||
|
|
||||||
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
}
|
||||||
@@ -73,4 +73,4 @@ func CanCreateOrganization(user viewmodel.User, organization viewmodel.Organizat
|
|||||||
|
|
||||||
func CanUpdateOrganization(user viewmodel.User, organization viewmodel.Organization) bool{
|
func CanUpdateOrganization(user viewmodel.User, organization viewmodel.Organization) bool{
|
||||||
return CanCreateOrganization(user, organization)
|
return CanCreateOrganization(user, organization)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
package eligibilityroute
|
package eligibilityroute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
|
"math/rand"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
|
"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/third/eligibility/bcbsi"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
"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/infra/config"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
|
"googlemaps.github.io/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -37,6 +42,29 @@ func controllerInstance(cfg *config.Config, svc *applicationservice.Service) *co
|
|||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *controller) rangeIn(low, hi int) string {
|
||||||
|
result := low + rand.Intn(hi-low)
|
||||||
|
return fmt.Sprintf("%v", result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *controller) generatePassword(n int) string {
|
||||||
|
const (
|
||||||
|
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
|
)
|
||||||
|
|
||||||
|
return c.stringWithCharset(n, charset)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *controller) stringWithCharset(length int, charset string) string {
|
||||||
|
b := make([]byte, length)
|
||||||
|
var seededRand *rand.Rand = rand.New(
|
||||||
|
rand.NewSource(time.Now().UnixNano()))
|
||||||
|
for i := range b {
|
||||||
|
b[i] = charset[seededRand.Intn(len(charset))]
|
||||||
|
}
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *controller) handleEligibility(ctx echo.Context) error {
|
func (c *controller) handleEligibility(ctx echo.Context) error {
|
||||||
var eligibility viewmodel.Eligibility
|
var eligibility viewmodel.Eligibility
|
||||||
|
|
||||||
@@ -44,13 +72,45 @@ func (c *controller) handleEligibility(ctx echo.Context) error {
|
|||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
authUser, err := auth.GetUserDetail(ctx, c.cfg)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if eligibility.Provider.ProviderNPI == "" {
|
||||||
|
provider, err := c.svc.Provider.GetByOrganization(authUser.Profiles[0].Organization.UUID, authUser)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
eligibility.Provider.ProviderNPI = provider.InternalID
|
||||||
|
eligibility.Provider.ProviderName = provider.OrganizatioName
|
||||||
|
}
|
||||||
|
|
||||||
|
loc, _ := time.LoadLocation("America/Chicago")
|
||||||
|
eligibility.TrackingID = c.rangeIn(1000000, 9999999)
|
||||||
|
eligibility.ServiceInfo.DateOfService = time.Now().In(loc)
|
||||||
|
eligibility.ServiceInfo.ServiceTypeCodes = []string{"30"}
|
||||||
|
|
||||||
|
var plan viewmodel.Plan
|
||||||
|
if eligibility.Subscriber.SubscriberID != "" {
|
||||||
|
plan, err = c.svc.Plan.GetByAlphaPrefix(eligibility.Subscriber.SubscriberID[:3])
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
eligibility.Payer.PayerID = fmt.Sprintf("%v", plan.PayerID)
|
||||||
|
eligibility.Payer.PayerName = plan.PayerName
|
||||||
|
} else {
|
||||||
|
return routeutils.ResponseAPIFieldValidationError(ctx, "subscriber_id", "member # is required.")
|
||||||
|
}
|
||||||
|
|
||||||
ret, err := c.bcbsi.BXE.CheckEligibility(eligibility)
|
ret, err := c.bcbsi.BXE.CheckEligibility(eligibility)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error Here: ", err.Error())
|
fmt.Println("Error Here: ", err.Error())
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ret.QueryResult.HIPPA271.T271 != "" {
|
if ret.QueryResult.QueryResultSummary.BenefitsFound {
|
||||||
xmlString := html.UnescapeString(ret.QueryResult.HIPPA271.T271)
|
xmlString := html.UnescapeString(ret.QueryResult.HIPPA271.T271)
|
||||||
xmlReader := strings.NewReader(xmlString)
|
xmlReader := strings.NewReader(xmlString)
|
||||||
|
|
||||||
@@ -60,8 +120,138 @@ func (c *controller) handleEligibility(ctx echo.Context) error {
|
|||||||
fmt.Println("Error to unmarshal: ", err.Error())
|
fmt.Println("Error to unmarshal: ", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.JSON(200, f)
|
user, err := c.svc.Users.GetByMemberID(eligibility.Subscriber.SubscriberID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.ID == "" {
|
||||||
|
user.Pass = c.generatePassword(8)
|
||||||
|
user.BirthDate = &eligibility.Subscriber.DemographicInfo.DateOfBirth
|
||||||
|
user.Member = &eligibility.Subscriber.SubscriberID
|
||||||
|
user.Gender = &eligibility.Subscriber.DemographicInfo.Gender
|
||||||
|
user.First = eligibility.Subscriber.Name.First
|
||||||
|
user.Last = eligibility.Subscriber.Name.Last
|
||||||
|
user.Active = true
|
||||||
|
user.Type = &eligibility.Subscriber.PatientType
|
||||||
|
user.PhoneNumber = eligibility.User.PhoneNumber
|
||||||
|
user.Email = eligibility.User.Email
|
||||||
|
|
||||||
|
profile, err := c.svc.Profile.GetByKey("US")
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
user.Profiles = append(user.Profiles, profile)
|
||||||
|
|
||||||
|
if user.BirthDate == nil || user.BirthDate.IsZero() {
|
||||||
|
return routeutils.ResponseAPIAuthError(ctx, "birthdate is required", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Member == nil || len(*user.Member) == 0 {
|
||||||
|
return routeutils.ResponseAPIAuthError(ctx, "member is required", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Gender == nil || len(*user.Gender) == 0 || (*user.Gender != "M" && *user.Gender != "F" && *user.Gender != "U") {
|
||||||
|
return routeutils.ResponseAPIAuthError(ctx, "gender is required", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.Name) == 0 && len(user.First) == 0 && len(user.Last) == 0 {
|
||||||
|
return routeutils.ResponseAPIAuthError(ctx, "name is required", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.First) != 0 && len(user.Last) != 0 {
|
||||||
|
user.Name = fmt.Sprintf("%s %s", user.First, user.Last)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.PhoneNumber != nil && len(*user.PhoneNumber) == 10 && !strings.Contains(*user.PhoneNumber, "+1") {
|
||||||
|
phoneNumber := fmt.Sprintf("+1%s", *user.PhoneNumber)
|
||||||
|
user.PhoneNumber = &phoneNumber
|
||||||
|
} else {
|
||||||
|
return routeutils.ResponseAPIFieldValidationError(ctx, "phonenumber", "Phone number is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err = c.svc.Users.Create(user, authUser)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if eligibility.User.Email != nil && len(*eligibility.User.Email) > 0 {
|
||||||
|
user.Email = eligibility.User.Email
|
||||||
|
}
|
||||||
|
|
||||||
|
if eligibility.User.PhoneNumber != nil {
|
||||||
|
if len(*eligibility.User.PhoneNumber) == 10 && !strings.Contains(*eligibility.User.PhoneNumber, "+1") {
|
||||||
|
phoneNumber := fmt.Sprintf("+1%s", *eligibility.User.PhoneNumber)
|
||||||
|
eligibility.User.PhoneNumber = &phoneNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*eligibility.User.PhoneNumber) > 0 {
|
||||||
|
user.PhoneNumber = eligibility.User.PhoneNumber
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.svc.Users.UpdateLogin(user)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
address := viewmodel.Address{}
|
||||||
|
header := f.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N3_0950
|
||||||
|
body := f.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N4_0960
|
||||||
|
zipCode := strings.TrimSpace(body.N403)
|
||||||
|
|
||||||
|
address.AddressTypeName = "Home"
|
||||||
|
address.AddressType = "home"
|
||||||
|
address.Name = fmt.Sprintf("%s, %s", header.N301, body.N401)
|
||||||
|
address.Address = fmt.Sprintf("%s, %s (%s)", header.N301, body.N401, zipCode)
|
||||||
|
address.CreatedUserUUID = authUser.ID
|
||||||
|
address.User = user
|
||||||
|
address.Type = "provider"
|
||||||
|
|
||||||
|
googleMapsAPI, err := maps.NewClient(maps.WithClientIDAndSignature("gme-bluecrossandblue1", "msqgD-jdqCyR0M_1u5C1HION5iI="))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to instantiate googles api: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
r := &maps.GeocodingRequest{
|
||||||
|
Address: address.Address + " " + body.N402 + ", " + zipCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := googleMapsAPI.Geocode(context.Background(), r)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to instantiate googles api: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result) > 0 {
|
||||||
|
address.Latitude = result[0].Geometry.Location.Lat
|
||||||
|
address.Longitude = result[0].Geometry.Location.Lng
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.Addresses) > 0 {
|
||||||
|
for _, a := range user.Addresses {
|
||||||
|
if a.AddressType == "home" {
|
||||||
|
err := c.svc.Users.RemoveAddress(a.UUID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to remove old address: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
address, err = c.svc.Users.SaveAddress(address)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to save address: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
user.Addresses = append(user.Addresses, address)
|
||||||
|
|
||||||
|
return ctx.JSON(200, user)
|
||||||
} else {
|
} else {
|
||||||
return routeutils.ResponseAPIOK(ctx, ret)
|
return routeutils.ResponseAPINotEligibleWithMessageError(ctx, "No benefits found for member")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,27 +124,27 @@ func (c *controller) handleList(ctx echo.Context) error {
|
|||||||
name := ctx.QueryParam("name")
|
name := ctx.QueryParam("name")
|
||||||
searchBy := ctx.QueryParam("searchBy")
|
searchBy := ctx.QueryParam("searchBy")
|
||||||
|
|
||||||
// lat, err := routeutils.GetAndValidateFloatQueryParam(ctx, "lat", "latitude is mandatory")
|
lat, err := routeutils.GetAndValidateFloatQueryParam(ctx, "lat", "latitude is required")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return err
|
return err
|
||||||
// }
|
}
|
||||||
|
|
||||||
// long, err := routeutils.GetAndValidateFloatQueryParam(ctx, "long", "longitude is mandatory")
|
long, err := routeutils.GetAndValidateFloatQueryParam(ctx, "long", "longitude is required")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return err
|
return err
|
||||||
// }
|
}
|
||||||
|
|
||||||
distance, err := routeutils.GetAndValidateIntQueryParam(ctx, "distance", "distance is mandatory")
|
distance, err := routeutils.GetAndValidateIntQueryParam(ctx, "distance", "distance is required")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
distance = 10
|
distance = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
limit, err := routeutils.GetAndValidateIntQueryParam(ctx, "limit", "limit is mandatory")
|
limit, err := routeutils.GetAndValidateIntQueryParam(ctx, "limit", "limit is required")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
limit = 50
|
limit = 50
|
||||||
}
|
}
|
||||||
|
|
||||||
sortBy, err := routeutils.GetAndValidateStringQueryParam(ctx, "sortby", "limit is mandatory")
|
sortBy, err := routeutils.GetAndValidateStringQueryParam(ctx, "sortby", "limit is required")
|
||||||
if err != nil || (sortBy != "distance" && sortBy != "name") {
|
if err != nil || (sortBy != "distance" && sortBy != "name") {
|
||||||
sortBy = "distance"
|
sortBy = "distance"
|
||||||
}
|
}
|
||||||
@@ -152,8 +152,8 @@ func (c *controller) handleList(ctx echo.Context) error {
|
|||||||
providerParams := npdmodel.ProviderSearchParams{
|
providerParams := npdmodel.ProviderSearchParams{
|
||||||
Name: name,
|
Name: name,
|
||||||
SearchBy: searchBy,
|
SearchBy: searchBy,
|
||||||
Latitude: 41.819078,
|
Latitude: lat,
|
||||||
Longitude: -87.623129,
|
Longitude: long,
|
||||||
Distance: distance,
|
Distance: distance,
|
||||||
Limit: limit,
|
Limit: limit,
|
||||||
Offset: 0,
|
Offset: 0,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/placesroute"
|
"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/profileroute"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/providerroute"
|
"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/tncroute"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/twilioroute"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/twilioroute"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/usersroute"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/usersroute"
|
||||||
@@ -37,14 +38,16 @@ func Register(e *echo.Echo, cfg *config.Config, svc *applicationservice.Service,
|
|||||||
lyfthookroute.Register(prefixGroup.Group("/lyfthook"), cfg, svc, tnc, notification)
|
lyfthookroute.Register(prefixGroup.Group("/lyfthook"), cfg, svc, tnc, notification)
|
||||||
externalroute.Register(prefixGroup.Group("/ext"), cfg, svc, tnc, notification)
|
externalroute.Register(prefixGroup.Group("/ext"), cfg, svc, tnc, notification)
|
||||||
authenticateroute.Register(prefixGroup.Group("/authenticate"), cfg, svc)
|
authenticateroute.Register(prefixGroup.Group("/authenticate"), cfg, svc)
|
||||||
|
selfregisterroute.Register(prefixGroup.Group("/selfregister"), cfg, svc)
|
||||||
|
|
||||||
appGroup := prefixGroup.Group("/" + cfg.App.Name)
|
appGroup := prefixGroup.Group("/" + cfg.App.Name)
|
||||||
usersroute.Register(appGroup.Group("/users"), cfg, svc)
|
usersroute.Register(appGroup.Group("/users"), cfg, svc)
|
||||||
eligibilityroute.Register(appGroup.Group("/eligibility"), cfg, svc)
|
eligibilityroute.Register(appGroup.Group("/eligibility"), cfg, svc)
|
||||||
tncroute.Register(appGroup.Group("/rides"), cfg, svc, tnc, notification)
|
tncroute.Register(appGroup.Group("/rides"), cfg, svc, tnc, notification)
|
||||||
visitroute.Register(appGroup.Group("/visits"), cfg, svc)
|
visitroute.Register(appGroup.Group("/visits"), cfg, svc, tnc)
|
||||||
providerroute.Register(appGroup.Group("/provider"), cfg, svc)
|
providerroute.Register(appGroup.Group("/provider"), cfg, svc)
|
||||||
placesroute.Register(appGroup.Group("/places"), cfg, svc)
|
placesroute.Register(appGroup.Group("/places"), cfg, svc)
|
||||||
profileroute.Register(appGroup.Group("/profile"), cfg, svc)
|
profileroute.Register(appGroup.Group("/profile"), cfg, svc)
|
||||||
organizationroute.Register(appGroup.Group("/organization"), cfg, svc)
|
organizationroute.Register(appGroup.Group("/organization"), cfg, svc)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ func ResponseAPIErrorWithData(c echo.Context, status int, message string, redire
|
|||||||
Error: true,
|
Error: true,
|
||||||
Message: message,
|
Message: message,
|
||||||
Redirect: redirect,
|
Redirect: redirect,
|
||||||
Data: data,
|
Data: data,
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.JSON(status, returnValue)
|
return c.JSON(status, returnValue)
|
||||||
@@ -92,6 +92,16 @@ func ResponseAPINotFoundError(c echo.Context) error {
|
|||||||
return ResponseAPIError(c, http.StatusNotFound, "Not Found", false)
|
return ResponseAPIError(c, http.StatusNotFound, "Not Found", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ResponseAPINotEligibleError returns a standard API not eligible to the response
|
||||||
|
func ResponseAPINotEligibleError(c echo.Context) error {
|
||||||
|
return ResponseAPIError(c, http.StatusForbidden, "Member does not have active insurance coverage", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
//ResponseAPINotEligibleWithMessageError returns a standard API not eligible to the response with custom message
|
||||||
|
func ResponseAPINotEligibleWithMessageError(c echo.Context, message string) error {
|
||||||
|
return ResponseAPIError(c, http.StatusForbidden, message, false)
|
||||||
|
}
|
||||||
|
|
||||||
func ignoreDefaultWrappedErrors(c echo.Context, errorToHandle *errors.WrappedError, handler func(echo.Context, error) error) error {
|
func ignoreDefaultWrappedErrors(c echo.Context, errorToHandle *errors.WrappedError, handler func(echo.Context, error) error) error {
|
||||||
err := errorToHandle.GetOriginalError()
|
err := errorToHandle.GetOriginalError()
|
||||||
|
|
||||||
|
|||||||
143
server/router/selfregisterroute/controller.go
Normal file
143
server/router/selfregisterroute/controller.go
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
package selfregisterroute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
b64 "encoding/base64"
|
||||||
|
|
||||||
|
"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/third/npd/npdmodel"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
|
"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"
|
||||||
|
)
|
||||||
|
|
||||||
|
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 {
|
||||||
|
var user viewmodel.User
|
||||||
|
if err := ctx.Bind(&user); err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
authUser, err := c.svc.Users.GetByUUID("573c70ff-733d-11e7-ba8f-0a6ad3fcdeaa", "")
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.PhoneNumber == nil || len(*user.PhoneNumber) == 0 {
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "phonenumber is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Email == nil || len(*user.Email) == 0 {
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "email is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.Pass) == 0 {
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "password is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
pass, err := b64.StdEncoding.DecodeString(user.Pass)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "Invalid password")
|
||||||
|
}
|
||||||
|
user.Pass = string(pass)
|
||||||
|
|
||||||
|
if passwordValidationErrors := validation.ValidatePassword(&user); len(passwordValidationErrors) > 0 {
|
||||||
|
return routeutils.ResponseAPICustomValidationError(ctx, "Password not strong enough", passwordValidationErrors)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.Name) == 0 && len(user.First) == 0 && len(user.Last) == 0 {
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "name is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.First) != 0 && len(user.Last) != 0 {
|
||||||
|
user.Name = fmt.Sprintf("%s %s", user.First, user.Last)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.Provider.InternalID) == 0 || len(user.Provider.InternalID) > 10 {
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "Provider NPI is invalid")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.Provider.OrganizatioName) == 0 {
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "Provider Organization Name is invalid")
|
||||||
|
}
|
||||||
|
|
||||||
|
provider, err := c.svc.Provider.GetByNPI(user.Provider.InternalID, authUser)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to create organization", err)
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var organization viewmodel.Organization
|
||||||
|
if provider.ProviderUUID == "" {
|
||||||
|
org := viewmodel.Organization{
|
||||||
|
Author: authUser,
|
||||||
|
LastEditor: authUser,
|
||||||
|
Name: user.Provider.OrganizatioName,
|
||||||
|
Type: viewmodel.OrganizationType{
|
||||||
|
Key: "provider",
|
||||||
|
Name: "Provider",
|
||||||
|
},
|
||||||
|
Reference: npdmodel.ProviderResponse{
|
||||||
|
OrgName: user.Provider.OrganizatioName,
|
||||||
|
FivePartKeyGroups: []npdmodel.PartKeyGroup{
|
||||||
|
npdmodel.PartKeyGroup{
|
||||||
|
ProviderNum: user.Provider.InternalID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
organization, err = c.svc.Organization.AddOrganization(org, authUser)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to create organization", err)
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if organization.UUID == "" {
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "Error to create organization")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
organization = provider.Organization
|
||||||
|
}
|
||||||
|
|
||||||
|
user.Organizations = []viewmodel.Organization{organization}
|
||||||
|
user.Profiles = []viewmodel.Profile{viewmodel.Profile{
|
||||||
|
Name: "Visit Reporter",
|
||||||
|
Key: "VIRPT",
|
||||||
|
Organization: organization,
|
||||||
|
}}
|
||||||
|
|
||||||
|
user, err = c.svc.Users.Create(user, authUser)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to create user", err)
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return routeutils.ResponseAPIOK(ctx, user)
|
||||||
|
}
|
||||||
18
server/router/selfregisterroute/router.go
Normal file
18
server/router/selfregisterroute/router.go
Normal 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)
|
||||||
|
}
|
||||||
@@ -228,12 +228,9 @@ func (c *controller) handle(ctx echo.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
if user.ID == "" {
|
|
||||||
return routeutils.ResponseAPIValidationError(ctx, "User not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//Validate ride request
|
//Validate ride request
|
||||||
if validationErrors := validation.ValidateRide(&requestRide, &user) ; len(validationErrors) > 0 {
|
if validationErrors := validation.ValidateRide(&requestRide, &user); len(validationErrors) > 0 {
|
||||||
return routeutils.ResponseAPICustomValidationError(ctx, "ride validation failed", validationErrors)
|
return routeutils.ResponseAPICustomValidationError(ctx, "ride validation failed", validationErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +436,7 @@ func (c *controller) handle(ctx echo.Context) error {
|
|||||||
go func() {
|
go func() {
|
||||||
err = c.svc.Notification.SendNotification(newRide.Status, roudtripRide, newRide)
|
err = c.svc.Notification.SendNotification(newRide.Status, roudtripRide, newRide)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error to notify user: ", err.Error())
|
fmt.Println("Error notifying user: ", err.Error())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@@ -875,4 +872,4 @@ func (c *controller) handleReady(ctx echo.Context) error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
return routeutils.ResponseAPIOK(ctx, nextRide)
|
return routeutils.ResponseAPIOK(ctx, nextRide)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package usersroute
|
package usersroute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
b64 "encoding/base64"
|
b64 "encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -15,13 +19,17 @@ import (
|
|||||||
"bitbucket.org/nemt/nemt-portal-api/infra/cache"
|
"bitbucket.org/nemt/nemt-portal-api/infra/cache"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/authorization"
|
"bitbucket.org/nemt/nemt-portal-api/server/authorization"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/validation"
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/server/validation"
|
||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"googlemaps.github.io/maps"
|
"googlemaps.github.io/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
zipcodeTrimLength = 5
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
instance *controller
|
instance *controller
|
||||||
once sync.Once
|
once sync.Once
|
||||||
@@ -337,6 +345,11 @@ func (c *controller) handleMember(ctx echo.Context) error {
|
|||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Validate member
|
||||||
|
if validationErrors := validation.ValidateEligibility(&user); len(validationErrors) > 0 {
|
||||||
|
return routeutils.ResponseAPICustomValidationError(ctx, "eligibility validation failed", validationErrors)
|
||||||
|
}
|
||||||
|
|
||||||
authUser, err := auth.GetUserDetail(ctx, c.cfg)
|
authUser, err := auth.GetUserDetail(ctx, c.cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
@@ -382,11 +395,6 @@ func (c *controller) handleMember(ctx echo.Context) error {
|
|||||||
}
|
}
|
||||||
user.Profiles = append(user.Profiles, profile)
|
user.Profiles = append(user.Profiles, profile)
|
||||||
|
|
||||||
user, err = c.svc.Users.Create(user, authUser)
|
|
||||||
if err != nil {
|
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
eligibility := viewmodel.Eligibility{}
|
eligibility := viewmodel.Eligibility{}
|
||||||
eligibility.Provider.ProviderNPI = "1699849786"
|
eligibility.Provider.ProviderNPI = "1699849786"
|
||||||
eligibility.Provider.ProviderName = "LITHOLINK CORPORATION"
|
eligibility.Provider.ProviderName = "LITHOLINK CORPORATION"
|
||||||
@@ -400,44 +408,102 @@ func (c *controller) handleMember(ctx echo.Context) error {
|
|||||||
eligibility.ServiceInfo.DateOfService = time.Now()
|
eligibility.ServiceInfo.DateOfService = time.Now()
|
||||||
eligibility.ServiceInfo.ServiceTypeCodes = []string{"30"}
|
eligibility.ServiceInfo.ServiceTypeCodes = []string{"30"}
|
||||||
|
|
||||||
resp, err := c.bcbsi.BXE.Get271(eligibility)
|
/*
|
||||||
|
resp, err := c.bcbsi.BXE.Get271(eligibility)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Eligibility Not Found or Error: ", err.Error())
|
||||||
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//This part is emulating eligibility check for testing purposes
|
||||||
|
client := &http.Client{}
|
||||||
|
eligibilityJson, err := json.Marshal(eligibility)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Eligibility Not Found or Error: ", err.Error())
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
||||||
} else {
|
}
|
||||||
address := viewmodel.Address{}
|
req, _ := http.NewRequest("POST", c.cfg.Eligibility.Url, bytes.NewBuffer(eligibilityJson))
|
||||||
header := resp.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N3_0950
|
req.Header.Add("App", c.cfg.HTTP.Auth.AppKey)
|
||||||
body := resp.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N4_0960
|
req.Header.Add("Token", ctx.Request().Header.Get("Token"))
|
||||||
|
req.Header.Add("Content-Type", "application/json")
|
||||||
|
|
||||||
address.AddressTypeName = "Home"
|
resp, err := client.Do(req)
|
||||||
address.AddressType = "home"
|
if err != nil {
|
||||||
address.Name = fmt.Sprintf("%s, %s", header.N301, body.N401)
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
||||||
address.Address = fmt.Sprintf("%s, %s", header.N301, body.N401)
|
}
|
||||||
address.CreatedUserUUID = authUser.ID
|
defer resp.Body.Close()
|
||||||
address.User = user
|
|
||||||
|
|
||||||
googleMapsAPI, err := maps.NewClient(maps.WithClientIDAndSignature("gme-bluecrossandblue1", "msqgD-jdqCyR0M_1u5C1HION5iI="))
|
if resp.StatusCode < 200 || resp.StatusCode > 300 {
|
||||||
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
eligibilityResponse := viewmodel.Interchange271{}
|
||||||
|
decoder := json.NewDecoder(resp.Body)
|
||||||
|
err = decoder.Decode(&eligibilityResponse)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
||||||
|
}
|
||||||
|
//================================================================
|
||||||
|
|
||||||
|
if len(eligibilityResponse.Division.HealthCareEligibilityResponse.LoopHL0030) < 1 {
|
||||||
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
address := viewmodel.Address{}
|
||||||
|
//header := resp.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N3_0950
|
||||||
|
//body := resp.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N4_0960
|
||||||
|
header := eligibilityResponse.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N3_0950
|
||||||
|
body := eligibilityResponse.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N4_0960
|
||||||
|
|
||||||
|
address.AddressTypeName = "Home"
|
||||||
|
address.AddressType = "home"
|
||||||
|
address.Name = fmt.Sprintf("%s, %s", header.N301, body.N401)
|
||||||
|
address.Address = fmt.Sprintf("%s, %s", header.N301, body.N401)
|
||||||
|
address.CreatedUserUUID = authUser.ID
|
||||||
|
address.User = user
|
||||||
|
|
||||||
|
cleanZipcode := strings.TrimSpace(body.N403)
|
||||||
|
trimmedZipcode := cleanZipcode
|
||||||
|
if len(cleanZipcode) > zipcodeTrimLength {
|
||||||
|
trimmedZipcode = cleanZipcode[:zipcodeTrimLength]
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = c.svc.Zipcodes.GetByParticipatingZipcode(trimmedZipcode)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.ResponseAPINotEligibleWithMessageError(ctx, "Member's Home zipcode, "+trimmedZipcode+", is not currently eligible for participation in this program")
|
||||||
|
}
|
||||||
|
|
||||||
|
googleMapsAPI, err := maps.NewClient(maps.WithClientIDAndSignature("gme-bluecrossandblue1", "msqgD-jdqCyR0M_1u5C1HION5iI="))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to instantiate googles api: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
r := &maps.GeocodingRequest{
|
||||||
|
Address: address.Address + " " + body.N402 + ", " + body.N403,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := googleMapsAPI.Geocode(context.Background(), r)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to instantiate googles api: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result) > 0 {
|
||||||
|
address.Latitude = result[0].Geometry.Location.Lat
|
||||||
|
address.Longitude = result[0].Geometry.Location.Lng
|
||||||
|
|
||||||
|
_, err := c.svc.Users.SaveAddress(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error to instantiate googles api: ", err.Error())
|
fmt.Println("Error to save address: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
r := &maps.GeocodingRequest{
|
user, err = c.svc.Users.Create(user, authUser)
|
||||||
Address: address.Address + " " + body.N402 + ", " + body.N403,
|
if err != nil {
|
||||||
}
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
|
||||||
result, err := googleMapsAPI.Geocode(context.Background(), r)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error to instantiate googles api: ", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(result) > 0 {
|
|
||||||
address.Latitude = result[0].Geometry.Location.Lat
|
|
||||||
address.Longitude = result[0].Geometry.Location.Lng
|
|
||||||
|
|
||||||
_, err := c.svc.Users.SaveAddress(address)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error to save address: ", err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return routeutils.ResponseAPIOK(ctx, user)
|
return routeutils.ResponseAPIOK(ctx, user)
|
||||||
@@ -531,7 +597,7 @@ func (c *controller) handlePortal(ctx echo.Context) error {
|
|||||||
}
|
}
|
||||||
user.Pass = string(pass)
|
user.Pass = string(pass)
|
||||||
|
|
||||||
if passwordValidationErrors := validation.ValidatePassword(&user) ; len(passwordValidationErrors) > 0 {
|
if passwordValidationErrors := validation.ValidatePassword(&user); len(passwordValidationErrors) > 0 {
|
||||||
return routeutils.ResponseAPICustomValidationError(ctx, "Password not strong enough", passwordValidationErrors)
|
return routeutils.ResponseAPICustomValidationError(ctx, "Password not strong enough", passwordValidationErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,26 @@
|
|||||||
package visitroute
|
package visitroute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
b64 "encoding/base64"
|
||||||
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
|
"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/tncservice"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/auth"
|
"bitbucket.org/nemt/nemt-portal-api/infra/auth"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/server/validation"
|
||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
|
"googlemaps.github.io/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -16,33 +29,614 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type controller struct {
|
type controller struct {
|
||||||
svc *applicationservice.Service
|
svc *applicationservice.Service
|
||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
|
bcbsi *bcbsi.Service
|
||||||
|
tnc *tncservice.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func controllerInstance(svc *applicationservice.Service, cfg *config.Config) *controller {
|
func controllerInstance(svc *applicationservice.Service, cfg *config.Config, tnc *tncservice.Service) *controller {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
instance = &controller{
|
instance = &controller{
|
||||||
svc: svc,
|
svc: svc,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
|
bcbsi: bcbsi.New(cfg),
|
||||||
|
tnc: tnc,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *controller) generatePassword(n int) string {
|
||||||
|
const (
|
||||||
|
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
|
)
|
||||||
|
|
||||||
|
return c.stringWithCharset(n, charset)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *controller) stringWithCharset(length int, charset string) string {
|
||||||
|
b := make([]byte, length)
|
||||||
|
var seededRand *rand.Rand = rand.New(
|
||||||
|
rand.NewSource(time.Now().UnixNano()))
|
||||||
|
for i := range b {
|
||||||
|
b[i] = charset[seededRand.Intn(len(charset))]
|
||||||
|
}
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *controller) handleRide(ctx echo.Context) error {
|
||||||
|
var ride viewmodel.RideRequest
|
||||||
|
if err := ctx.Bind(&ride); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "invalid parameters")
|
||||||
|
}
|
||||||
|
|
||||||
|
authUser, err := auth.GetUserDetail(ctx, c.cfg)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
visit, err := c.svc.Visits.GetByUUID(ride.Visit.UUID, authUser)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
ride.Visit = visit
|
||||||
|
|
||||||
|
user, err := c.svc.Users.GetByMemberID(*visit.User.Member)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
ride.Visit.User = user
|
||||||
|
subscriber := "S"
|
||||||
|
ride.Visit.User.Type = &subscriber
|
||||||
|
|
||||||
|
var provider viewmodel.ProviderResp
|
||||||
|
provider, err = c.svc.Provider.GetByUUID(ride.Visit.Provider.ProviderUUID, authUser)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
visit.Provider = provider
|
||||||
|
|
||||||
|
eligibility := viewmodel.Eligibility{}
|
||||||
|
eligibility.Provider.ProviderNPI = provider.InternalID
|
||||||
|
eligibility.Provider.ProviderName = provider.OrganizatioName
|
||||||
|
eligibility.TrackingID = c.rangeIn(1000000, 9999999)
|
||||||
|
eligibility.Subscriber.SubscriberID = *ride.Visit.User.Member
|
||||||
|
eligibility.Subscriber.PatientType = *ride.Visit.User.Type
|
||||||
|
eligibility.Subscriber.Name.First = ride.Visit.User.First
|
||||||
|
eligibility.Subscriber.Name.Last = ride.Visit.User.Last
|
||||||
|
eligibility.Subscriber.DemographicInfo.DateOfBirth = *ride.Visit.User.BirthDate
|
||||||
|
eligibility.Subscriber.DemographicInfo.Gender = *ride.Visit.User.Gender
|
||||||
|
loc, _ := time.LoadLocation("America/Chicago")
|
||||||
|
eligibility.ServiceInfo.DateOfService = time.Now().In(loc)
|
||||||
|
eligibility.ServiceInfo.ServiceTypeCodes = []string{"30"}
|
||||||
|
|
||||||
|
resp271, err := c.bcbsi.BXE.Get271(eligibility)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
address := viewmodel.Address{}
|
||||||
|
header := resp271.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N3_0950
|
||||||
|
body := resp271.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N4_0960
|
||||||
|
zipCode := strings.TrimSpace(body.N403)
|
||||||
|
|
||||||
|
address.AddressTypeName = "Home"
|
||||||
|
address.AddressType = "home"
|
||||||
|
address.Name = fmt.Sprintf("%s, %s", header.N301, body.N401)
|
||||||
|
address.Address = fmt.Sprintf("%s, %s (%s)", header.N301, body.N401, zipCode)
|
||||||
|
address.CreatedUserUUID = authUser.ID
|
||||||
|
address.User = user
|
||||||
|
address.Type = "provider"
|
||||||
|
|
||||||
|
googleMapsAPI, err := maps.NewClient(maps.WithClientIDAndSignature("gme-bluecrossandblue1", "msqgD-jdqCyR0M_1u5C1HION5iI="))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to instantiate googles api: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
r := &maps.GeocodingRequest{
|
||||||
|
Address: address.Address + " " + body.N402 + ", " + zipCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := googleMapsAPI.Geocode(context.Background(), r)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to instantiate googles api: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result) > 0 {
|
||||||
|
address.Latitude = result[0].Geometry.Location.Lat
|
||||||
|
address.Longitude = result[0].Geometry.Location.Lng
|
||||||
|
}
|
||||||
|
|
||||||
|
if address.Latitude != 0 && address.Longitude != 0 {
|
||||||
|
if len(user.Addresses) > 0 {
|
||||||
|
for _, a := range user.Addresses {
|
||||||
|
if a.AddressType == "home" {
|
||||||
|
err := c.svc.Users.RemoveAddress(a.UUID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to remove old address: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
address, err = c.svc.Users.SaveAddress(address)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to save address: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
user.Addresses = append(user.Addresses, address)
|
||||||
|
}
|
||||||
|
|
||||||
|
homeAddress := viewmodel.Address{}
|
||||||
|
for _, a := range visit.User.Addresses {
|
||||||
|
if a.AddressType == "home" {
|
||||||
|
homeAddress = a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ride.CreateUserUUID = authUser.ID
|
||||||
|
ride.Destination = viewmodel.Location{
|
||||||
|
ID: visit.Provider.ProviderUUID,
|
||||||
|
Name: visit.Provider.OrganizatioName,
|
||||||
|
Latitude: visit.Provider.Address.Latitude,
|
||||||
|
Longitude: visit.Provider.Address.Longitude,
|
||||||
|
Address: visit.Provider.Address.StreetAddress1,
|
||||||
|
}
|
||||||
|
ride.Origin = viewmodel.Location{
|
||||||
|
ID: homeAddress.UUID,
|
||||||
|
Name: homeAddress.AddressTypeName,
|
||||||
|
Latitude: homeAddress.Latitude,
|
||||||
|
Longitude: homeAddress.Longitude,
|
||||||
|
Address: homeAddress.Address,
|
||||||
|
}
|
||||||
|
ride.Notes = ride.Notes
|
||||||
|
ride.Passenger.FirstName = visit.User.First
|
||||||
|
ride.Passenger.LastName = " "
|
||||||
|
ride.Passenger.PhoneNumber = *visit.User.PhoneNumber
|
||||||
|
ride.RideType = "lyft"
|
||||||
|
ride.VisitDate = &visit.VisitDatetime
|
||||||
|
ride.VisitTime = &visit.VisitDatetime
|
||||||
|
|
||||||
|
var resp viewmodel.RideRequest
|
||||||
|
if ride.TripType.Key != "from_visit_call" {
|
||||||
|
if ride.TripType.Key == "from_visit" {
|
||||||
|
newOrigin := ride.Origin
|
||||||
|
ride.Origin = ride.Destination
|
||||||
|
ride.Destination = newOrigin
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.cfg.LyftProd.UserUUID != authUser.ID {
|
||||||
|
resp, err = c.tnc.Lyft.RequestRide(ride)
|
||||||
|
} else {
|
||||||
|
fmt.Println("In Production")
|
||||||
|
resp, err = c.tnc.LyftProd.RequestRide(ride)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ride.TripType.Key == "from_visit" {
|
||||||
|
newOrigin := resp.Origin
|
||||||
|
resp.Origin = resp.Destination
|
||||||
|
resp.Destination = newOrigin
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.RideID = strings.Replace(resp.RideID, "s_", "", -1)
|
||||||
|
} else {
|
||||||
|
resp = ride
|
||||||
|
|
||||||
|
UUID, _ := uuid.NewV4()
|
||||||
|
resp.RideID = UUID.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.Status == "scheduled" || ride.TripType.Key == "from_visit_call" {
|
||||||
|
if ride.PickupTime == nil {
|
||||||
|
currentDate := time.Now()
|
||||||
|
ride.PickupTime = ¤tDate
|
||||||
|
}
|
||||||
|
requestMS := (ride.PickupTime.UnixNano() / int64(time.Millisecond))
|
||||||
|
generateDate := time.Now()
|
||||||
|
generateMS := (generateDate.UnixNano() / int64(time.Millisecond))
|
||||||
|
resp.RequestAt = ride.PickupTime
|
||||||
|
resp.RequestAtMS = &requestMS
|
||||||
|
resp.GeneratedAt = &generateDate
|
||||||
|
resp.GeneratedAtMS = &generateMS
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.Passenger.FirstName = visit.User.First
|
||||||
|
resp.Passenger.LastName = visit.User.Last
|
||||||
|
resp.Passenger.PhoneNumber = *visit.User.PhoneNumber
|
||||||
|
if resp.Passenger.ImageURL == nil {
|
||||||
|
imageURL := " "
|
||||||
|
resp.Passenger.ImageURL = &imageURL
|
||||||
|
}
|
||||||
|
resp.UserUUID = visit.User.ID
|
||||||
|
|
||||||
|
if ride.TripType.Key == "from_visit" {
|
||||||
|
resp.Origin.Name = ride.Destination.Name
|
||||||
|
resp.Origin.ID = ride.Destination.ID
|
||||||
|
resp.Destination.Name = ride.Origin.Name
|
||||||
|
resp.Destination.ID = ride.Origin.ID
|
||||||
|
} else {
|
||||||
|
resp.Origin.Name = ride.Origin.Name
|
||||||
|
resp.Origin.ID = ride.Origin.ID
|
||||||
|
resp.Destination.Name = ride.Destination.Name
|
||||||
|
resp.Destination.ID = ride.Destination.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.Distance = ride.Distance
|
||||||
|
resp.Duration = ride.Duration
|
||||||
|
resp.ETA = ride.ETA
|
||||||
|
resp.PickupTime = ride.PickupTime
|
||||||
|
resp.VisitDate = &ride.Visit.VisitDatetime
|
||||||
|
resp.VisitTime = &ride.Visit.VisitDatetime
|
||||||
|
resp.VisitExternalID = ride.Visit.ExternalID
|
||||||
|
resp.CreateUserUUID = authUser.ID
|
||||||
|
resp.Visit.TripType = ride.Visit.TripType
|
||||||
|
resp.Visit = visit
|
||||||
|
|
||||||
|
if resp.TripType.Key == "from_visit_call" {
|
||||||
|
resp.Status = "willCall"
|
||||||
|
resp.Passenger.UserID = &resp.UserUUID
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.TripType.Key = ride.TripType.Key
|
||||||
|
if ride.TripType.Key == "roundtrip" || ride.TripType.Key == "roundtrip_call" {
|
||||||
|
resp.TripType.Key = "to_visit"
|
||||||
|
} else if ride.TripType.Key == "from_visit_call" {
|
||||||
|
resp.TripType.Key = "from_visit_call"
|
||||||
|
}
|
||||||
|
|
||||||
|
entity, err := c.svc.Rides.Save(resp)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to save first ride: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
err = c.svc.Notification.SendNotification(resp.Status, entity, resp)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to notify user: ", err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if ride.TripType.Key == "roundtrip" || ride.TripType.Key == "roundtrip_call" {
|
||||||
|
newRide := ride
|
||||||
|
|
||||||
|
if ride.TripType.Key == "roundtrip" {
|
||||||
|
destination := newRide.Origin
|
||||||
|
newRide.Origin = newRide.Destination
|
||||||
|
newRide.Destination = destination
|
||||||
|
if ride.ReturnTime != nil {
|
||||||
|
newRide.PickupTime = ride.ReturnTime
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduledRide := make(map[string]interface{})
|
||||||
|
scheduledRide["timestamp_ms"] = ride.PickupTime.Unix()
|
||||||
|
newRide.ScheduledPickupRange = scheduledRide
|
||||||
|
|
||||||
|
newRide.Passenger.FirstName = visit.User.First
|
||||||
|
newRide.Passenger.LastName = " "
|
||||||
|
newRide.Passenger.PhoneNumber = *visit.User.PhoneNumber
|
||||||
|
|
||||||
|
if c.cfg.LyftProd.UserUUID != authUser.ID {
|
||||||
|
newRide, err = c.tnc.Lyft.RequestRide(newRide)
|
||||||
|
} else {
|
||||||
|
fmt.Println("In Production")
|
||||||
|
newRide, err = c.tnc.LyftProd.RequestRide(newRide)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
destination = newRide.Origin
|
||||||
|
newRide.Origin = newRide.Destination
|
||||||
|
newRide.Destination = destination
|
||||||
|
|
||||||
|
if newRide.Error != "" {
|
||||||
|
fmt.Println("Error to schedule a ride on lyft: ", newRide.Error, newRide.ErrorDescription)
|
||||||
|
} else {
|
||||||
|
fmt.Println("Ride Scheduled: ", newRide.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
newRide.TripType.Key = "from_visit"
|
||||||
|
} else {
|
||||||
|
newRide.TripType.Key = "from_visit_call"
|
||||||
|
newRide.Status = "willCall"
|
||||||
|
newRide.RideID = entity.UUID
|
||||||
|
}
|
||||||
|
|
||||||
|
newRide.Visit = visit
|
||||||
|
newRide.PickupTime = ride.ReturnTime
|
||||||
|
|
||||||
|
requestMS := (newRide.PickupTime.UnixNano() / int64(time.Millisecond))
|
||||||
|
generateDate := time.Now()
|
||||||
|
generateMS := (generateDate.UnixNano() / int64(time.Millisecond))
|
||||||
|
newRide.RequestAt = newRide.PickupTime
|
||||||
|
newRide.RequestAtMS = &requestMS
|
||||||
|
newRide.GeneratedAt = &generateDate
|
||||||
|
newRide.GeneratedAtMS = &generateMS
|
||||||
|
|
||||||
|
newRide.Passenger.FirstName = visit.User.First
|
||||||
|
newRide.Passenger.LastName = visit.User.Last
|
||||||
|
newRide.Passenger.PhoneNumber = *visit.User.PhoneNumber
|
||||||
|
newRide.Passenger.UserID = &ride.UserUUID
|
||||||
|
|
||||||
|
if newRide.Passenger.ImageURL == nil {
|
||||||
|
imageURL := " "
|
||||||
|
newRide.Passenger.ImageURL = &imageURL
|
||||||
|
}
|
||||||
|
|
||||||
|
newRide.UserUUID = ride.UserUUID
|
||||||
|
newRide.Origin.Name = ride.Destination.Name
|
||||||
|
newRide.Origin.ID = ride.Destination.ID
|
||||||
|
newRide.Destination.Name = ride.Origin.Name
|
||||||
|
newRide.Destination.ID = ride.Origin.ID
|
||||||
|
newRide.Distance = ride.Distance
|
||||||
|
newRide.Duration = ride.Duration
|
||||||
|
newRide.ETA = ride.ETA
|
||||||
|
newRide.VisitDate = ride.VisitDate
|
||||||
|
newRide.VisitTime = ride.VisitTime
|
||||||
|
newRide.VisitExternalID = ride.VisitExternalID
|
||||||
|
newRide.CreateUserUUID = authUser.ID
|
||||||
|
|
||||||
|
roudtripRide, err := c.svc.Rides.Save(newRide)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
err = c.svc.Notification.SendNotification(newRide.Status, roudtripRide, newRide)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to notify user: ", err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Response().Header().Set("Content-Type", "application/json")
|
||||||
|
return routeutils.ResponseAPIOK(ctx, entity)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *controller) rangeIn(low, hi int) string {
|
||||||
|
result := low + rand.Intn(hi-low)
|
||||||
|
return fmt.Sprintf("%v", result)
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
authUser, err := auth.GetUserDetail(ctx, c.cfg)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var provider viewmodel.ProviderResp
|
||||||
|
provider, err = c.svc.Provider.GetByNPI(visit.RawProvider.FivePartKeyGroups[0].ProviderNum, authUser)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if provider.ProviderUUID == "" {
|
||||||
|
org := viewmodel.Organization{
|
||||||
|
Type: viewmodel.OrganizationType{
|
||||||
|
Key: "provider",
|
||||||
|
Name: "Provider",
|
||||||
|
},
|
||||||
|
Name: visit.RawProvider.OrgName,
|
||||||
|
Description: visit.RawProvider.OrgName,
|
||||||
|
Main: false,
|
||||||
|
Author: authUser,
|
||||||
|
LastEditor: authUser,
|
||||||
|
Reference: visit.RawProvider,
|
||||||
|
}
|
||||||
|
|
||||||
|
org, err = c.svc.Organization.AddOrganization(org, authUser)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
provider, err = c.svc.Provider.GetByOrganization(org.UUID, authUser)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
visit.Provider = provider
|
||||||
|
|
||||||
|
if validationErrors := validation.ValidateVisit(&visit, &authUser); len(validationErrors) > 0 {
|
||||||
|
return routeutils.ResponseAPICustomValidationError(ctx, "visit validation failed", validationErrors)
|
||||||
|
}
|
||||||
|
|
||||||
|
// eligibility := viewmodel.Eligibility{}
|
||||||
|
// eligibility.Provider.ProviderNPI = provider.InternalID
|
||||||
|
// eligibility.Provider.ProviderName = provider.OrganizatioName
|
||||||
|
// eligibility.TrackingID = c.rangeIn(1000000, 9999999)
|
||||||
|
// 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
|
||||||
|
// loc, _ := time.LoadLocation("America/Chicago")
|
||||||
|
// eligibility.ServiceInfo.DateOfService = time.Now().In(loc)
|
||||||
|
// eligibility.ServiceInfo.ServiceTypeCodes = []string{"30"}
|
||||||
|
|
||||||
|
// resp, err := c.bcbsi.BXE.Get271(eligibility)
|
||||||
|
// if err != nil {
|
||||||
|
// fmt.Println("Error to get eligibility: ", err.Error())
|
||||||
|
// return routeutils.ResponseAPIValidationError(ctx, err.Error())
|
||||||
|
// }
|
||||||
|
|
||||||
|
user, err := c.svc.Users.GetByMemberID(*visit.User.Member)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to get user by memberID: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.ID == "" {
|
||||||
|
if len(user.Pass) == 0 {
|
||||||
|
user.Pass = c.generatePassword(8)
|
||||||
|
} else {
|
||||||
|
pass, err := b64.StdEncoding.DecodeString(user.Pass)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.ResponseAPIAuthError(ctx, "Invalid password", false)
|
||||||
|
}
|
||||||
|
user.Pass = string(pass)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.BirthDate == nil || user.BirthDate.IsZero() {
|
||||||
|
return routeutils.ResponseAPIAuthError(ctx, "birthdate is required", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Member == nil || len(*user.Member) == 0 {
|
||||||
|
return routeutils.ResponseAPIAuthError(ctx, "member is required", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Gender == nil || len(*user.Gender) == 0 || (*user.Gender != "M" && *user.Gender != "F" && *user.Gender != "U") {
|
||||||
|
return routeutils.ResponseAPIAuthError(ctx, "gender is required", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.Name) == 0 && len(user.First) == 0 && len(user.Last) == 0 {
|
||||||
|
return routeutils.ResponseAPIAuthError(ctx, "name is required", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.First) != 0 && len(user.Last) != 0 {
|
||||||
|
user.Name = fmt.Sprintf("%s %s", user.First, user.Last)
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.PhoneNumber != nil && len(*user.PhoneNumber) == 10 && !strings.Contains(*user.PhoneNumber, "+1") {
|
||||||
|
phoneNumber := fmt.Sprintf("+1%s", *user.PhoneNumber)
|
||||||
|
user.PhoneNumber = &phoneNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
profile, err := c.svc.Profile.GetByKey("US")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to get Profile: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
user.Profiles = append(user.Profiles, profile)
|
||||||
|
|
||||||
|
user, err = c.svc.Users.Create(user, authUser)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to create the user: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if visit.User.Email != nil && len(*visit.User.Email) > 0 {
|
||||||
|
user.Email = visit.User.Email
|
||||||
|
}
|
||||||
|
|
||||||
|
if visit.User.PhoneNumber != nil {
|
||||||
|
if len(*visit.User.PhoneNumber) == 10 && !strings.Contains(*visit.User.PhoneNumber, "+1") {
|
||||||
|
phoneNumber := fmt.Sprintf("+1%s", *visit.User.PhoneNumber)
|
||||||
|
visit.User.PhoneNumber = &phoneNumber
|
||||||
|
}
|
||||||
|
user.PhoneNumber = visit.User.PhoneNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.svc.Users.UpdateLogin(user)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error to update login: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// address := viewmodel.Address{}
|
||||||
|
// header := resp.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N3_0950
|
||||||
|
// body := resp.Division.HealthCareEligibilityResponse.LoopHL0030[0].HL_0460[0].HL_0890[0].NM1_0920[0].N4_0960
|
||||||
|
// zipCode := strings.TrimSpace(body.N403)
|
||||||
|
|
||||||
|
// address.AddressTypeName = "Home"
|
||||||
|
// address.AddressType = "home"
|
||||||
|
// address.Name = fmt.Sprintf("%s, %s", header.N301, body.N401)
|
||||||
|
// address.Address = fmt.Sprintf("%s, %s (%s)", header.N301, body.N401, zipCode)
|
||||||
|
// address.CreatedUserUUID = authUser.ID
|
||||||
|
// address.User = user
|
||||||
|
// address.Type = "provider"
|
||||||
|
|
||||||
|
// googleMapsAPI, err := maps.NewClient(maps.WithClientIDAndSignature("gme-bluecrossandblue1", "msqgD-jdqCyR0M_1u5C1HION5iI="))
|
||||||
|
// if err != nil {
|
||||||
|
// fmt.Println("Error to instantiate googles api: ", err.Error())
|
||||||
|
// return routeutils.HandleAPIError(ctx, err)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// r := &maps.GeocodingRequest{
|
||||||
|
// Address: address.Address + " " + body.N402 + ", " + zipCode,
|
||||||
|
// }
|
||||||
|
|
||||||
|
// result, err := googleMapsAPI.Geocode(context.Background(), r)
|
||||||
|
// if err != nil {
|
||||||
|
// fmt.Println("Error to instantiate googles api: ", err.Error())
|
||||||
|
// return routeutils.HandleAPIError(ctx, err)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if len(result) > 0 {
|
||||||
|
// address.Latitude = result[0].Geometry.Location.Lat
|
||||||
|
// address.Longitude = result[0].Geometry.Location.Lng
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if address.Latitude != 0 && address.Longitude != 0 {
|
||||||
|
// if len(user.Addresses) > 0 {
|
||||||
|
// for _, a := range user.Addresses {
|
||||||
|
// if a.AddressType == "home" {
|
||||||
|
// err := c.svc.Users.RemoveAddress(a.UUID)
|
||||||
|
// if err != nil {
|
||||||
|
// fmt.Println("Error to remove old address: ", err.Error())
|
||||||
|
// return routeutils.HandleAPIError(ctx, err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// address, err = c.svc.Users.SaveAddress(address)
|
||||||
|
// if err != nil {
|
||||||
|
// fmt.Println("Error saving address: ", err.Error())
|
||||||
|
// return routeutils.HandleAPIError(ctx, err)
|
||||||
|
// }
|
||||||
|
// user.Addresses = append(user.Addresses, address)
|
||||||
|
// }
|
||||||
|
|
||||||
|
visit.TripType = viewmodel.TripType{
|
||||||
|
Key: "no_trip",
|
||||||
|
Value: "No Trip",
|
||||||
|
}
|
||||||
|
|
||||||
|
visit.User = user
|
||||||
|
visit.CreatedUser = authUser
|
||||||
|
|
||||||
|
visit, err = c.svc.Visits.Save(visit)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error saving visit: ", err.Error())
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return routeutils.ResponseAPIOK(ctx, visit)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *controller) handleGetByID(ctx echo.Context) error {
|
func (c *controller) handleGetByID(ctx echo.Context) error {
|
||||||
visit_uuid := ctx.Param("visit_uuid")
|
visit_uuid := ctx.Param("visit_uuid")
|
||||||
if visit_uuid == "" {
|
if visit_uuid == "" {
|
||||||
return routeutils.ResponseAPIValidationError(ctx, "visit_uuid param is mandatory")
|
return routeutils.ResponseAPIValidationError(ctx, "visit_uuid param is mandatory")
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := auth.GetUserDetail(ctx, c.cfg)
|
authUser, err := auth.GetUserDetail(ctx, c.cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.svc.Visits.GetByUUID(visit_uuid, user)
|
resp, err := c.svc.Visits.GetByUUID(visit_uuid, authUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Error to get Visit: ", err.Error())
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package visitroute
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
|
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/tncservice"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
)
|
)
|
||||||
@@ -9,11 +10,15 @@ import (
|
|||||||
const (
|
const (
|
||||||
rootRoute = "/"
|
rootRoute = "/"
|
||||||
idRoute = "/:visit_uuid"
|
idRoute = "/:visit_uuid"
|
||||||
|
rideRoute = "/:visit_uuid/ride"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register registers the routes in the echo group
|
// Register registers the routes in the echo group
|
||||||
func Register(r *echo.Group, cfg *config.Config, svc *applicationservice.Service) {
|
func Register(r *echo.Group, cfg *config.Config, svc *applicationservice.Service, tnc *tncservice.Service) {
|
||||||
ctrl := controllerInstance(svc, cfg)
|
ctrl := controllerInstance(svc, cfg, tnc)
|
||||||
|
|
||||||
|
r.POST(rootRoute, ctrl.handle)
|
||||||
|
r.POST(rideRoute, ctrl.handleRide)
|
||||||
|
|
||||||
r.GET(rootRoute, ctrl.handleGetAll)
|
r.GET(rootRoute, ctrl.handleGetAll)
|
||||||
r.GET(idRoute, ctrl.handleGetByID)
|
r.GET(idRoute, ctrl.handleGetByID)
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ func authSkipper(ctx echo.Context) bool {
|
|||||||
strings.Contains(path, "/v1/ext") ||
|
strings.Contains(path, "/v1/ext") ||
|
||||||
strings.Contains(path, "/v1/notification/ws") ||
|
strings.Contains(path, "/v1/notification/ws") ||
|
||||||
strings.HasPrefix(path, "/v1/lyfthook") ||
|
strings.HasPrefix(path, "/v1/lyfthook") ||
|
||||||
strings.HasPrefix(path, "/v1/docs"))
|
strings.HasPrefix(path, "/v1/docs") ||
|
||||||
|
strings.HasPrefix(path, "/v1/selfregister"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// appSkipper is the default skipper for the application routes
|
// appSkipper is the default skipper for the application routes
|
||||||
|
|||||||
150
server/validation/eligibility.go
Normal file
150
server/validation/eligibility.go
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
package validation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
firstNameMaxLength = 50
|
||||||
|
lastNameMaxLength = 50
|
||||||
|
emailMaxLength = 150
|
||||||
|
|
||||||
|
memberNumberValidNumberOfLetters = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
formModeVisit = 1
|
||||||
|
formModeRide = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
func isAlphabetic(input string) bool {
|
||||||
|
for _, character := range input {
|
||||||
|
if !(characterIsUpperCase(character) || characterIsLowerCase(character)){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func isNumeric(input string) bool {
|
||||||
|
for _, character := range input {
|
||||||
|
if !characterIsNumber(character){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func isEmailValid (email string) bool {
|
||||||
|
validEmailRegex := regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
||||||
|
|
||||||
|
return validEmailRegex.MatchString(email)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isMemberNumberValid(input string) bool {
|
||||||
|
if len(input) < memberNumberValidNumberOfLetters {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isAlphabetic(input[:memberNumberValidNumberOfLetters]) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isNumeric(input[memberNumberValidNumberOfLetters:]){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func ValidateEligibility(user *viewmodel.User) []errors.ValidationError {
|
||||||
|
var result []errors.ValidationError
|
||||||
|
|
||||||
|
formMode:= formModeVisit // This should be red from request, not hardcoded
|
||||||
|
|
||||||
|
//First name validation
|
||||||
|
if len(user.First) < 1 {
|
||||||
|
result = append(result, errors.ValidationError{Field: "first", Message: "First Name is required"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isAlphabetic(user.First){
|
||||||
|
result = append(result, errors.ValidationError{Field: "first", Message: "First Name contains non-alphabetic characters"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.First) > firstNameMaxLength {
|
||||||
|
result = append(result, errors.ValidationError{Field: "first", Message: "First Name is too long"})
|
||||||
|
}
|
||||||
|
|
||||||
|
//Last name validation
|
||||||
|
if len(user.Last) < 1 {
|
||||||
|
result = append(result, errors.ValidationError{Field: "last", Message: "Last Name is required"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isAlphabetic(user.Last){
|
||||||
|
result = append(result, errors.ValidationError{Field: "last", Message: "Last Name contains non-alphabetic characters"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(user.Last) > lastNameMaxLength {
|
||||||
|
result = append(result, errors.ValidationError{Field: "last", Message: "Last Name is too long"})
|
||||||
|
}
|
||||||
|
|
||||||
|
//Email validation
|
||||||
|
if user.Email != nil {
|
||||||
|
if (formMode==formModeRide) && len(*user.Email) < 1 {
|
||||||
|
result = append(result, errors.ValidationError{Field: "email", Message: "Email is required"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isEmailValid(*user.Email) {
|
||||||
|
result = append(result, errors.ValidationError{Field: "email", Message: "Email is invalid"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*user.Email) > emailMaxLength {
|
||||||
|
result = append(result, errors.ValidationError{Field: "email", Message: "Email is too long"})
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if (formMode==formModeRide){
|
||||||
|
result = append(result, errors.ValidationError{Field: "email", Message: "Email is required"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Gender validation
|
||||||
|
if ((user.Gender != nil) && len(*user.Gender) < 1) || (user.Gender == nil) {
|
||||||
|
result = append(result, errors.ValidationError{Field: "gender", Message: "Member Gender is required"})
|
||||||
|
}
|
||||||
|
|
||||||
|
//Member type validation
|
||||||
|
if (user.Type != nil && len(*user.Type) < 1) || (user.Type == nil) {
|
||||||
|
result = append(result, errors.ValidationError{Field: "type", Message: "Member Type is required"})
|
||||||
|
}
|
||||||
|
|
||||||
|
//Member# validation
|
||||||
|
if !isMemberNumberValid(*user.Member){
|
||||||
|
result = append(result, errors.ValidationError{Field: "member", Message: "Member# is invalid"})
|
||||||
|
}
|
||||||
|
//Birthdate validation
|
||||||
|
if user.BirthDate == nil {
|
||||||
|
result = append(result, errors.ValidationError{Field: "birthdate", Message: "Choose a Birth Date"})
|
||||||
|
}else{
|
||||||
|
yesterday := time.Now().Add(-1*time.Hour*hoursInDay)
|
||||||
|
if user.BirthDate.After(yesterday) {
|
||||||
|
result = append(result, errors.ValidationError{Field: "birthdate", Message: "Choose a valid Birth Date"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Mobile validation
|
||||||
|
if formMode == formModeRide {
|
||||||
|
if (user.PhoneNumber != nil && len(*user.PhoneNumber) < 1) || (user.PhoneNumber == nil) {
|
||||||
|
result = append(result, errors.ValidationError{Field: "phonenumber", Message: "Phone number is required"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//User consent validation
|
||||||
|
if !user.Consent{
|
||||||
|
result = append(result, errors.ValidationError{Field: "consent", Message: "Must be 'Checked'"})
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
||||||
@@ -12,11 +13,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
tripTypeFromVisit = "From Visit"
|
tripTypeFromVisit = "from_visit"
|
||||||
tripTypeToVisit = "To Visit"
|
tripTypeToVisit = "to_visit"
|
||||||
tripTypeFromVisitWillCall = "From Visit / Will Call"
|
tripTypeFromVisitWillCall = "from_visit_call"
|
||||||
tripTypeRoundTrip = "Round Trip"
|
tripTypeRoundTrip = "roundtrip"
|
||||||
tripTypeRountTripWillCall = "Round Trip / Will Call"
|
tripTypeRountTripWillCall = "roundtrip_call"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -32,17 +33,37 @@ const (
|
|||||||
time10Minutes = 10
|
time10Minutes = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func isMixedIDValid(id string) bool {
|
||||||
|
hasUpperCase := false
|
||||||
|
hasLowerCase := false
|
||||||
|
hasNumber := false
|
||||||
|
|
||||||
|
for _, character := range (id) {
|
||||||
|
hasUpperCase = hasUpperCase || ((character >= 65) && (character <= 90))
|
||||||
|
hasLowerCase = hasLowerCase || ((character >= 97) && (character <= 122))
|
||||||
|
hasNumber = hasNumber || ((character >= 48) && (character <= 57))
|
||||||
|
}
|
||||||
|
|
||||||
|
return (hasUpperCase || hasLowerCase) && hasNumber
|
||||||
|
}
|
||||||
|
|
||||||
func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []errors.ValidationError {
|
func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []errors.ValidationError {
|
||||||
var result []errors.ValidationError
|
var result []errors.ValidationError
|
||||||
|
var validUUIDregex = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`)
|
||||||
|
|
||||||
//Step #1 validation
|
//Step #1 validation
|
||||||
|
|
||||||
if userID, err := strconv.Atoi(user.ID) ; err != nil || userID <= 0 {
|
if !validUUIDregex.MatchString(user.ID){
|
||||||
result = append(result, errors.ValidationError{Field : "user_uuid", Message : "Step #1 - Choose a Member" })
|
result = append(result, errors.ValidationError{Field : "user_uuid", Message : "Step #1 - Choose a Member" })
|
||||||
}
|
}
|
||||||
|
|
||||||
if originID, err := strconv.Atoi(requestRide.Origin.ID) ; err != nil || originID <= 0 {
|
fmt.Println("\n\n", requestRide.Origin.ID, "\n\n")
|
||||||
result = append (result, errors.ValidationError{Field : "origin.id", Message : "Step #1 - Choose a Pickup Address"})
|
if !isMixedIDValid(requestRide.Origin.ID) {
|
||||||
|
//it is not UUID or similar to UUID, let's try with just a number
|
||||||
|
if originID, err := strconv.Atoi(requestRide.Origin.ID) ; err!= nil || originID <= 0 {
|
||||||
|
//it is not a number
|
||||||
|
result = append (result, errors.ValidationError{Field : "origin.id", Message : "Step #1 - Choose a Pickup Address"})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !requestRide.UserConsent {
|
if !requestRide.UserConsent {
|
||||||
@@ -51,8 +72,12 @@ func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []er
|
|||||||
|
|
||||||
//Step #2 validation
|
//Step #2 validation
|
||||||
|
|
||||||
if destinationID, err := strconv.Atoi(requestRide.Destination.ID) ; err!= nil || destinationID <= 0 {
|
fmt.Println("\n\n", requestRide.Destination.ID, "\n\n")
|
||||||
result = append (result, errors.ValidationError{Field : "destination.id", Message : "Step #2 - Choose a Provider"})
|
if !isMixedIDValid(requestRide.Destination.ID) {
|
||||||
|
//it is not UUID or similar to UUID, let's try with just a number
|
||||||
|
if destinationID, err := strconv.Atoi(requestRide.Destination.ID) ; err!= nil || destinationID <= 0 {
|
||||||
|
result = append (result, errors.ValidationError{Field : "destination.id", Message : "Step #2 - Choose a Provider"})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Step #3 validation
|
//Step #3 validation
|
||||||
@@ -84,14 +109,12 @@ func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []er
|
|||||||
|
|
||||||
//Step #4 validation
|
//Step #4 validation
|
||||||
|
|
||||||
if requestRide.TripType.Value == "" {
|
|
||||||
result = append (result, errors.ValidationError{Field : "trip_type.value", Message : "Step #4 - Choose a Trip Type"})
|
|
||||||
}
|
|
||||||
|
|
||||||
timeWithDurationAndLoadingTime := requestRide.VisitTime.Add(-time.Duration(requestRide.Duration)*time.Second).Add(-loadingTime*time.Minute)
|
timeWithDurationAndLoadingTime := requestRide.VisitTime.Add(-time.Duration(requestRide.Duration)*time.Second).Add(-loadingTime*time.Minute)
|
||||||
after10Minutes := time.Now().Add(time.Minute*time10Minutes)
|
after10Minutes := time.Now().Add(time.Minute*time10Minutes)
|
||||||
|
|
||||||
switch requestRide.TripType.Value {
|
isTripTypeValid := true
|
||||||
|
|
||||||
|
switch requestRide.TripType.Key {
|
||||||
case tripTypeToVisit:
|
case tripTypeToVisit:
|
||||||
if requestRide.PickupTime == nil {
|
if requestRide.PickupTime == nil {
|
||||||
result = append (result, errors.ValidationError{Field : "pickup_time", Message : "Step #4 - Choose a Pickup Time"})
|
result = append (result, errors.ValidationError{Field : "pickup_time", Message : "Step #4 - Choose a Pickup Time"})
|
||||||
@@ -178,6 +201,15 @@ func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []er
|
|||||||
result = append (result, errors.ValidationError{Field : "pickup_time", Message : "Step #4 - Visit cannot occur in the past "})
|
result = append (result, errors.ValidationError{Field : "pickup_time", Message : "Step #4 - Visit cannot occur in the past "})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
isTripTypeValid = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !isTripTypeValid {
|
||||||
|
result = append (result, errors.ValidationError{Field : "trip_type.key", Message : "Step #4 - Choose a Trip Type"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
package validation
|
package validation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func characterIsUpperCase(character rune) bool {
|
func characterIsUpperCase(character rune) bool {
|
||||||
@@ -25,29 +23,31 @@ func ValidatePassword(user *viewmodel.User) []errors.ValidationError {
|
|||||||
var result []errors.ValidationError
|
var result []errors.ValidationError
|
||||||
|
|
||||||
userOrganizationName := ""
|
userOrganizationName := ""
|
||||||
if len(user.Organizations) > 0{
|
if len(user.Organizations) > 0 {
|
||||||
userOrganizationName = user.Organizations[0].Name
|
userOrganizationName = user.Organizations[0].Name
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len(user.Pass) < 8) {
|
if len(user.Pass) < 8 {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password must be at least 8 characters."})
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password must be at least 8 characters."})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strings.Contains(user.Pass, user.First)){
|
if strings.Contains(user.Pass, user.First) {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password cannot include your First Name."})
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password cannot include your First Name."})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strings.Contains(user.Pass, user.Last)){
|
if strings.Contains(user.Pass, user.Last) {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password cannot include your Last Name."})
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password cannot include your Last Name."})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strings.Contains(user.Pass, userOrganizationName)){
|
if len(userOrganizationName) > 0 {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password cannot include your Organization Name."})
|
if strings.Contains(user.Pass, userOrganizationName) {
|
||||||
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password cannot include your Organization Name."})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
containsUpperCaseLetter := false;
|
containsUpperCaseLetter := false
|
||||||
containsLowerCaseLetter := false;
|
containsLowerCaseLetter := false
|
||||||
containsNumber := false;
|
containsNumber := false
|
||||||
|
|
||||||
for _, character := range user.Pass {
|
for _, character := range user.Pass {
|
||||||
containsUpperCaseLetter = containsUpperCaseLetter || characterIsUpperCase(character)
|
containsUpperCaseLetter = containsUpperCaseLetter || characterIsUpperCase(character)
|
||||||
@@ -56,12 +56,11 @@ func ValidatePassword(user *viewmodel.User) []errors.ValidationError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !containsUpperCaseLetter || !containsLowerCaseLetter || !containsNumber {
|
if !containsUpperCaseLetter || !containsLowerCaseLetter || !containsNumber {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password must contain one of EACH :"})
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password must contain one of EACH :"})
|
||||||
result = append(result, errors.ValidationError{Field : "password-tab", Message : "an uppercase letter"})
|
result = append(result, errors.ValidationError{Field: "password-tab", Message: "an uppercase letter"})
|
||||||
result = append(result, errors.ValidationError{Field : "password-tab", Message : "a lowercase letter"})
|
result = append(result, errors.ValidationError{Field: "password-tab", Message: "a lowercase letter"})
|
||||||
result = append(result, errors.ValidationError{Field : "password-tab", Message : "a number"})
|
result = append(result, errors.ValidationError{Field: "password-tab", Message: "a number"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
36
server/validation/visit.go
Normal file
36
server/validation/visit.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package validation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ValidateVisit(visit *viewmodel.Visit, user *viewmodel.User) []errors.ValidationError {
|
||||||
|
var result []errors.ValidationError
|
||||||
|
|
||||||
|
if len(visit.User.First) == 0 {
|
||||||
|
result = append(result, errors.ValidationError{Field: "first", Message: "Step #1 - First Name is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(visit.User.Last) == 0 {
|
||||||
|
result = append(result, errors.ValidationError{Field: "last", Message: "Step #1 - Last Name is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if visit.User.Gender == nil || (*visit.User.Gender != "M" && *visit.User.Gender != "F" && *visit.User.Gender != "U") {
|
||||||
|
result = append(result, errors.ValidationError{Field: "gender", Message: "Step #1 - Gender is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if visit.User.Type == nil || (*visit.User.Type != "S" && *visit.User.Gender != "D" && *visit.User.Gender != "U") {
|
||||||
|
result = append(result, errors.ValidationError{Field: "type", Message: "Step #1 - Member Type is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if visit.User.Member == nil || len(*visit.User.Member) == 0 {
|
||||||
|
result = append(result, errors.ValidationError{Field: "member", Message: "Step #1 - Member # is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if visit.User.BirthDate == nil || visit.User.BirthDate.IsZero() {
|
||||||
|
result = append(result, errors.ValidationError{Field: "birthdate", Message: "Step #1 - Birth Date is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user