Compare commits
1 Commits
ZIP-partic
...
self-regis
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54ebc056d5 |
@@ -2,6 +2,7 @@ package selfregisterroute
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
b64 "encoding/base64"
|
b64 "encoding/base64"
|
||||||
@@ -22,6 +23,10 @@ const (
|
|||||||
notificationSmsBody = "You have registered as a Visit Reporter for CHM NEMT. Login: https://portal.bcbsinstitute.com Reset PW: https://portal.bcbsinstitute.com/forgot"
|
notificationSmsBody = "You have registered as a Visit Reporter for CHM NEMT. Login: https://portal.bcbsinstitute.com Reset PW: https://portal.bcbsinstitute.com/forgot"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
phoneNumberMaxLength = 12
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
instance *controller
|
instance *controller
|
||||||
once sync.Once
|
once sync.Once
|
||||||
@@ -44,12 +49,34 @@ func controllerInstance(svc *applicationservice.Service, cfg *config.Config) *co
|
|||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeNonNumberChars(input string) string {
|
||||||
|
result := ""
|
||||||
|
for _, char := range input {
|
||||||
|
if char >= '0' && char <= '9' {
|
||||||
|
result += string(char)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func (c *controller) handle(ctx echo.Context) error {
|
func (c *controller) handle(ctx echo.Context) error {
|
||||||
var user viewmodel.User
|
var user viewmodel.User
|
||||||
if err := ctx.Bind(&user); err != nil {
|
if err := ctx.Bind(&user); err != nil {
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//format phone number - max length in database is 12 chars
|
||||||
|
formatedPhoneNumber := strings.TrimSpace(*user.PhoneNumber)
|
||||||
|
formatedPhoneNumber = strings.Replace(formatedPhoneNumber, "+1", "", -1)
|
||||||
|
formatedPhoneNumber = removeNonNumberChars(formatedPhoneNumber)
|
||||||
|
|
||||||
|
if len(formatedPhoneNumber) > phoneNumberMaxLength {
|
||||||
|
formatedPhoneNumber = formatedPhoneNumber[:phoneNumberMaxLength]
|
||||||
|
}
|
||||||
|
|
||||||
|
*user.PhoneNumber = formatedPhoneNumber
|
||||||
|
|
||||||
authUser, err := c.svc.Users.GetByUUID("573c70ff-733d-11e7-ba8f-0a6ad3fcdeaa", "")
|
authUser, err := c.svc.Users.GetByUUID("573c70ff-733d-11e7-ba8f-0a6ad3fcdeaa", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
@@ -132,10 +159,14 @@ func (c *controller) handle(ctx echo.Context) error {
|
|||||||
|
|
||||||
notification, err = c.svc.Notification.SendNotificationWithoutWritingToDatabase(notification)
|
notification, err = c.svc.Notification.SendNotificationWithoutWritingToDatabase(notification)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
logger := ctx.Logger()
|
||||||
|
logger.Warnf("Application Error: Could not send email notification to user email : %s", *user.Email)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send sms notification to Authorized user
|
//Send sms notification to Authorized user
|
||||||
|
|
||||||
|
formatedPhoneNumber = *user.PhoneNumber
|
||||||
|
|
||||||
notification = viewmodel.Notification{
|
notification = viewmodel.Notification{
|
||||||
Type: applicationservice.NOtificationTypeSMS,
|
Type: applicationservice.NOtificationTypeSMS,
|
||||||
To: *user.PhoneNumber,
|
To: *user.PhoneNumber,
|
||||||
@@ -144,7 +175,8 @@ func (c *controller) handle(ctx echo.Context) error {
|
|||||||
|
|
||||||
notification, err = c.svc.Notification.SendNotificationWithoutWritingToDatabase(notification)
|
notification, err = c.svc.Notification.SendNotificationWithoutWritingToDatabase(notification)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
logger := ctx.Logger()
|
||||||
|
logger.Warnf("Application Error: Could not send sms notification to user mobile : %s", *user.PhoneNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
return routeutils.ResponseAPIOK(ctx, user)
|
return routeutils.ResponseAPIOK(ctx, user)
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
zipcodeTrimLength = 5
|
zipcodeTrimLength = 5
|
||||||
enableZipParticipationCheck = true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -409,6 +408,14 @@ 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)
|
||||||
|
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
|
//This part is emulating eligibility check for testing purposes
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
eligibilityJson, err := json.Marshal(eligibility)
|
eligibilityJson, err := json.Marshal(eligibility)
|
||||||
@@ -461,11 +468,10 @@ func (c *controller) handleMember(ctx echo.Context) error {
|
|||||||
trimmedZipcode = cleanZipcode[:zipcodeTrimLength]
|
trimmedZipcode = cleanZipcode[:zipcodeTrimLength]
|
||||||
}
|
}
|
||||||
|
|
||||||
if enableZipParticipationCheck {
|
_, err = c.svc.Zipcodes.GetByParticipatingZipcode(trimmedZipcode)
|
||||||
_, err = c.svc.Zipcodes.GetByParticipatingZipcode(trimmedZipcode)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.ResponseAPINotEligibleWithMessageError(ctx, "Member's Home zipcode, "+trimmedZipcode+", is not currently eligible for participation in this program")
|
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="))
|
googleMapsAPI, err := maps.NewClient(maps.WithClientIDAndSignature("gme-bluecrossandblue1", "msqgD-jdqCyR0M_1u5C1HION5iI="))
|
||||||
|
|||||||
Reference in New Issue
Block a user