Upstream sync
This commit is contained in:
@@ -93,26 +93,24 @@ func (c *controller) handleRide(ctx echo.Context) error {
|
||||
ride.Visit.User.Type = &subscriber
|
||||
|
||||
var provider viewmodel.ProviderResp
|
||||
if authUser.Profiles[0].Key == "VIRPT" {
|
||||
provider, err = c.svc.Provider.GetByOrganization(authUser.Profiles[0].Organization.UUID, authUser)
|
||||
} else {
|
||||
provider, err = c.svc.Provider.GetByUUID(ride.Visit.Provider.ProviderUUID, authUser)
|
||||
}
|
||||
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 = "1234567"
|
||||
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
|
||||
eligibility.ServiceInfo.DateOfService = time.Now()
|
||||
loc, _ := time.LoadLocation("America/Chicago")
|
||||
eligibility.ServiceInfo.DateOfService = time.Now().In(loc)
|
||||
eligibility.ServiceInfo.ServiceTypeCodes = []string{"30"}
|
||||
|
||||
resp271, err := c.bcbsi.BXE.Get271(eligibility)
|
||||
@@ -155,24 +153,26 @@ func (c *controller) handleRide(ctx echo.Context) error {
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
}
|
||||
user.Addresses = append(user.Addresses, address)
|
||||
|
||||
homeAddress := viewmodel.Address{}
|
||||
for _, a := range visit.User.Addresses {
|
||||
@@ -422,41 +422,64 @@ func (c *controller) handle(ctx echo.Context) error {
|
||||
}
|
||||
|
||||
var provider viewmodel.ProviderResp
|
||||
if authUser.Profiles[0].Key == "VIRPT" {
|
||||
provider, err = c.svc.Provider.GetByOrganization(authUser.Profiles[0].Organization.UUID, authUser)
|
||||
} else {
|
||||
provider, err = c.svc.Provider.GetByUUID(visit.Provider.ProviderUUID, authUser)
|
||||
}
|
||||
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
|
||||
eligibility.ServiceInfo.DateOfService = time.Now()
|
||||
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(err)
|
||||
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 {
|
||||
fmt.Println(err)
|
||||
fmt.Println("Error to get user by memberID: ", err.Error())
|
||||
return routeutils.HandleAPIError(ctx, err)
|
||||
}
|
||||
|
||||
@@ -498,12 +521,14 @@ func (c *controller) handle(ctx echo.Context) error {
|
||||
|
||||
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 {
|
||||
@@ -521,62 +546,65 @@ func (c *controller) handle(ctx echo.Context) error {
|
||||
|
||||
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 := 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 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 to save 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",
|
||||
@@ -588,6 +616,7 @@ func (c *controller) handle(ctx echo.Context) error {
|
||||
|
||||
visit, err = c.svc.Visits.Save(visit)
|
||||
if err != nil {
|
||||
fmt.Println("Error saving visit: ", err.Error())
|
||||
return routeutils.HandleAPIError(ctx, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user