2022-08-28 11:51:58 -06:00
|
|
|
package hub
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config"
|
|
|
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/base"
|
|
|
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/cigna"
|
|
|
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2022-09-09 00:51:46 -06:00
|
|
|
func NewClient(providerId string, appConfig config.Interface, globalLogger logrus.FieldLogger, credentials models.Source, testHttpClient ...*http.Client) (base.Client, *models.Source, error) {
|
2022-08-28 11:51:58 -06:00
|
|
|
|
|
|
|
var providerClient base.Client
|
2022-09-09 00:51:46 -06:00
|
|
|
var updatedSource *models.Source
|
2022-08-28 11:51:58 -06:00
|
|
|
var err error
|
|
|
|
switch providerId {
|
|
|
|
case "anthem":
|
2022-09-09 00:51:46 -06:00
|
|
|
providerClient, updatedSource, err = cigna.NewClient(appConfig, globalLogger, credentials, testHttpClient...)
|
2022-08-28 11:51:58 -06:00
|
|
|
case "cigna":
|
2022-09-09 00:51:46 -06:00
|
|
|
providerClient, updatedSource, err = cigna.NewClient(appConfig, globalLogger, credentials, testHttpClient...)
|
2022-08-28 11:51:58 -06:00
|
|
|
default:
|
2022-09-09 00:51:46 -06:00
|
|
|
return nil, updatedSource, errors.New(fmt.Sprintf("Unknown Provider Type: %s", providerId))
|
2022-08-28 11:51:58 -06:00
|
|
|
}
|
|
|
|
|
2022-09-09 00:51:46 -06:00
|
|
|
return providerClient, updatedSource, err
|
2022-08-28 11:51:58 -06:00
|
|
|
}
|