Compare commits
1 Commits
ZIP-partic
...
self-regis
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54ebc056d5 |
@@ -2,6 +2,7 @@ package selfregisterroute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
const (
|
||||
phoneNumberMaxLength = 12
|
||||
)
|
||||
|
||||
var (
|
||||
instance *controller
|
||||
once sync.Once
|
||||
@@ -44,12 +49,34 @@ func controllerInstance(svc *applicationservice.Service, cfg *config.Config) *co
|
||||
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 {
|
||||
var user viewmodel.User
|
||||
if err := ctx.Bind(&user); err != nil {
|
||||
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", "")
|
||||
if err != nil {
|
||||
return routeutils.HandleAPIError(ctx, err)
|
||||
@@ -132,10 +159,14 @@ func (c *controller) handle(ctx echo.Context) error {
|
||||
|
||||
notification, err = c.svc.Notification.SendNotificationWithoutWritingToDatabase(notification)
|
||||
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
|
||||
|
||||
formatedPhoneNumber = *user.PhoneNumber
|
||||
|
||||
notification = viewmodel.Notification{
|
||||
Type: applicationservice.NOtificationTypeSMS,
|
||||
To: *user.PhoneNumber,
|
||||
@@ -144,7 +175,8 @@ func (c *controller) handle(ctx echo.Context) error {
|
||||
|
||||
notification, err = c.svc.Notification.SendNotificationWithoutWritingToDatabase(notification)
|
||||
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)
|
||||
|
||||
@@ -27,8 +27,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
zipcodeTrimLength = 5
|
||||
enableZipParticipationCheck = true
|
||||
zipcodeTrimLength = 5
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -409,6 +408,14 @@ func (c *controller) handleMember(ctx echo.Context) error {
|
||||
eligibility.ServiceInfo.DateOfService = time.Now()
|
||||
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
|
||||
client := &http.Client{}
|
||||
eligibilityJson, err := json.Marshal(eligibility)
|
||||
@@ -461,11 +468,10 @@ func (c *controller) handleMember(ctx echo.Context) error {
|
||||
trimmedZipcode = cleanZipcode[:zipcodeTrimLength]
|
||||
}
|
||||
|
||||
if enableZipParticipationCheck {
|
||||
_, 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")
|
||||
}
|
||||
_, 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="))
|
||||
|
||||
Reference in New Issue
Block a user