Upstream sync
This commit is contained in:
@@ -88,9 +88,14 @@ func (c *controller) handleRide(ctx echo.Context) error {
|
||||
fmt.Println(err)
|
||||
return routeutils.HandleAPIError(ctx, err)
|
||||
}
|
||||
user.PhoneNumber = ride.User.PhoneNumber
|
||||
user.Email = ride.User.Email
|
||||
|
||||
ride.Visit.User = user
|
||||
subscriber := "S"
|
||||
ride.Visit.User.Type = &subscriber
|
||||
if ride.Visit.User.Type == nil {
|
||||
subscriber := "S"
|
||||
ride.Visit.User.Type = &subscriber
|
||||
}
|
||||
|
||||
var provider viewmodel.ProviderResp
|
||||
provider, err = c.svc.Provider.GetByUUID(ride.Visit.Provider.ProviderUUID, authUser)
|
||||
@@ -189,13 +194,17 @@ func (c *controller) handleRide(ctx echo.Context) error {
|
||||
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,
|
||||
|
||||
if len(ride.Origin.ID) == 0 {
|
||||
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 = " "
|
||||
@@ -205,7 +214,7 @@ func (c *controller) handleRide(ctx echo.Context) error {
|
||||
ride.VisitTime = &visit.VisitDatetime
|
||||
ride.UserConsent = true
|
||||
|
||||
if validationErrors := validation.ValidateRide(&ride, &user); len(validationErrors) > 0 {
|
||||
if validationErrors := validation.ValidateVisitRide(&ride, &user); len(validationErrors) > 0 {
|
||||
return routeutils.ResponseAPICustomValidationError(ctx, "ride validation failed", validationErrors)
|
||||
}
|
||||
|
||||
@@ -462,25 +471,25 @@ func (c *controller) handle(ctx echo.Context) error {
|
||||
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"}
|
||||
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())
|
||||
// }
|
||||
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 {
|
||||
@@ -556,60 +565,60 @@ func (c *controller) handle(ctx echo.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
// 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 := 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"
|
||||
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)
|
||||
// }
|
||||
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,
|
||||
// }
|
||||
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)
|
||||
// }
|
||||
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(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)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
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)
|
||||
// }
|
||||
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",
|
||||
|
||||
Reference in New Issue
Block a user