make sure lighthouse environment is passed to the source credential.

This commit is contained in:
Jason Kulatunga 2024-01-17 13:45:19 -08:00
parent ac950a4263
commit c88751c5b7
No known key found for this signature in database
8 changed files with 25 additions and 20 deletions

View File

@ -2,6 +2,7 @@ package _0240114092806
import (
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
sourcesPkg "github.com/fastenhealth/fasten-sources/pkg"
"github.com/google/uuid"
)
@ -14,6 +15,7 @@ type SourceCredential struct {
//New Fields
Display string `json:"display"`
LighthouseEnvType sourcesPkg.FastenLighthouseEnvType `json:"lighthouse_env_type"`
BrandID *uuid.UUID `json:"brand_id"`
PortalID *uuid.UUID `json:"portal_id"`
EndpointID uuid.UUID `json:"endpoint_id"`

View File

@ -17,6 +17,7 @@ type SourceCredential struct {
//New Fields
Display string `json:"display"`
LighthouseEnvType sourcesPkg.FastenLighthouseEnvType `json:"lighthouse_env_type"`
BrandID uuid.UUID `json:"brand_id"`
PortalID uuid.UUID `json:"portal_id"`
PlatformType sourcesPkg.PlatformType `json:"platform_type"`

View File

@ -28,6 +28,7 @@ type SourceCredential struct {
//New Fields
Display string `json:"display"`
LighthouseEnvType sourcesPkg.FastenLighthouseEnvType `json:"lighthouse_env_type"`
BrandID uuid.UUID `json:"brand_id"`
PortalID uuid.UUID `json:"portal_id"`
PlatformType sourcesPkg.PlatformType `json:"platform_type"`

View File

@ -9,7 +9,6 @@ import (
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
"github.com/fastenhealth/fasten-sources/clients/factory"
sourceModels "github.com/fastenhealth/fasten-sources/clients/models"
sourcePkg "github.com/fastenhealth/fasten-sources/pkg"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"net/http"
@ -36,7 +35,7 @@ func BackgroundJobSyncResources(
_sourceCred *models.SourceCredential,
) (sourceModels.SourceClient, sourceModels.UpsertSummary, error) {
// after creating the client, we should do a bulk import
sourceClient, err := factory.GetSourceClient(sourcePkg.GetFastenLighthouseEnv(), _backgroundJobContext, _logger, _sourceCred)
sourceClient, err := factory.GetSourceClient(_sourceCred.LighthouseEnvType, _backgroundJobContext, _logger, _sourceCred)
if err != nil {
resultErr := fmt.Errorf("an error occurred while initializing hub client using source credential: %w", err)
_logger.Errorln(resultErr)

View File

@ -151,7 +151,7 @@ func CreateManualSource(c *gin.Context) {
manualSourceCredential := models.SourceCredential{
PlatformType: sourcePkg.PlatformTypeManual,
}
tempSourceClient, err := factory.GetSourceClient(sourcePkg.GetFastenLighthouseEnv(), c, logger, &manualSourceCredential)
tempSourceClient, err := factory.GetSourceClient("", c, logger, &manualSourceCredential)
if err != nil {
logger.Errorln("An error occurred while initializing hub client using manual source without credentials", err)
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
@ -185,7 +185,7 @@ func CreateManualSource(c *gin.Context) {
_databaseRepo database.DatabaseRepository,
_sourceCred *models.SourceCredential,
) (sourceModels.SourceClient, sourceModels.UpsertSummary, error) {
manualSourceClient, err := factory.GetSourceClient(sourcePkg.GetFastenLighthouseEnv(), _backgroundJobContext, _logger, _sourceCred)
manualSourceClient, err := factory.GetSourceClient("", _backgroundJobContext, _logger, _sourceCred)
if err != nil {
resultErr := fmt.Errorf("an error occurred while initializing hub client using manual source with credential: %w", err)
logger.Errorln(resultErr)

View File

@ -6,7 +6,6 @@ import (
"github.com/fastenhealth/fasten-onprem/backend/pkg/database"
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
"github.com/fastenhealth/fasten-sources/clients/factory"
sourcePkg "github.com/fastenhealth/fasten-sources/pkg"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"net/http"
@ -46,7 +45,7 @@ func UnsafeRequestSource(c *gin.Context) {
return
}
client, err := factory.GetSourceClient(sourcePkg.GetFastenLighthouseEnv(), c, logger, foundSource)
client, err := factory.GetSourceClient("", c, logger, foundSource)
if err != nil {
logger.Errorf("Could not initialize source client %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
@ -140,7 +139,7 @@ func UnsafeSyncResourceNames(c *gin.Context) {
return
}
client, err := factory.GetSourceClient(sourcePkg.GetFastenLighthouseEnv(), c, logger, foundSource)
client, err := factory.GetSourceClient("", c, logger, foundSource)
if err != nil {
logger.Errorf("Could not initialize source client %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})

View File

@ -13,6 +13,7 @@ import {Location} from '@angular/common';
import {EventBusService} from '../../services/event-bus.service';
import {SourceState} from '../../models/fasten/source-state';
import {PatientAccessBrand} from '../../models/patient-access-brands';
import {environment} from '../../../environments/environment';
@Component({
selector: 'app-medical-sources-connected',
@ -163,6 +164,7 @@ export class MedicalSourcesConnectedComponent implements OnInit {
id: expectedSourceStateInfo.reconnect_source_id,
display: portalInfo.name,
lighthouse_env_type: environment.lighthouse_api_endpoint_base == 'https://lighthouse.fastenhealth.com/v1' ? 'prod' : 'sandbox',
brand_id: expectedSourceStateInfo.brand_id,
portal_id: expectedSourceStateInfo.portal_id,
endpoint_id: expectedSourceStateInfo.endpoint_id,

View File

@ -8,6 +8,7 @@ export class Source {
user_id?: number
display?: string
lighthouse_env_type?: 'prod' | 'sandbox'
brand_id?: string
portal_id?: string
endpoint_id: string