make sure lighthouse environment is passed to the source credential.
This commit is contained in:
parent
ac950a4263
commit
c88751c5b7
|
@ -2,6 +2,7 @@ package _0240114092806
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
|
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
|
||||||
|
sourcesPkg "github.com/fastenhealth/fasten-sources/pkg"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,11 +14,12 @@ type SourceCredential struct {
|
||||||
Patient string `json:"patient" gorm:"uniqueIndex:idx_user_source_patient"`
|
Patient string `json:"patient" gorm:"uniqueIndex:idx_user_source_patient"`
|
||||||
|
|
||||||
//New Fields
|
//New Fields
|
||||||
Display string `json:"display"`
|
Display string `json:"display"`
|
||||||
BrandID *uuid.UUID `json:"brand_id"`
|
LighthouseEnvType sourcesPkg.FastenLighthouseEnvType `json:"lighthouse_env_type"`
|
||||||
PortalID *uuid.UUID `json:"portal_id"`
|
BrandID *uuid.UUID `json:"brand_id"`
|
||||||
EndpointID uuid.UUID `json:"endpoint_id"`
|
PortalID *uuid.UUID `json:"portal_id"`
|
||||||
PlatformType string `json:"platform_type"`
|
EndpointID uuid.UUID `json:"endpoint_id"`
|
||||||
|
PlatformType string `json:"platform_type"`
|
||||||
|
|
||||||
LatestBackgroundJob *models.BackgroundJob `json:"latest_background_job,omitempty"`
|
LatestBackgroundJob *models.BackgroundJob `json:"latest_background_job,omitempty"`
|
||||||
LatestBackgroundJobID *uuid.UUID `json:"-"`
|
LatestBackgroundJobID *uuid.UUID `json:"-"`
|
||||||
|
|
|
@ -16,10 +16,11 @@ type SourceCredential struct {
|
||||||
EndpointID uuid.UUID `json:"endpoint_id" gorm:"uniqueIndex:idx_user_source_patient"`
|
EndpointID uuid.UUID `json:"endpoint_id" gorm:"uniqueIndex:idx_user_source_patient"`
|
||||||
|
|
||||||
//New Fields
|
//New Fields
|
||||||
Display string `json:"display"`
|
Display string `json:"display"`
|
||||||
BrandID uuid.UUID `json:"brand_id"`
|
LighthouseEnvType sourcesPkg.FastenLighthouseEnvType `json:"lighthouse_env_type"`
|
||||||
PortalID uuid.UUID `json:"portal_id"`
|
BrandID uuid.UUID `json:"brand_id"`
|
||||||
PlatformType sourcesPkg.PlatformType `json:"platform_type"`
|
PortalID uuid.UUID `json:"portal_id"`
|
||||||
|
PlatformType sourcesPkg.PlatformType `json:"platform_type"`
|
||||||
|
|
||||||
LatestBackgroundJob *models.BackgroundJob `json:"latest_background_job,omitempty"`
|
LatestBackgroundJob *models.BackgroundJob `json:"latest_background_job,omitempty"`
|
||||||
LatestBackgroundJobID *uuid.UUID `json:"-"`
|
LatestBackgroundJobID *uuid.UUID `json:"-"`
|
||||||
|
|
|
@ -27,10 +27,11 @@ type SourceCredential struct {
|
||||||
EndpointID uuid.UUID `json:"endpoint_id" gorm:"uniqueIndex:idx_user_source_patient"`
|
EndpointID uuid.UUID `json:"endpoint_id" gorm:"uniqueIndex:idx_user_source_patient"`
|
||||||
|
|
||||||
//New Fields
|
//New Fields
|
||||||
Display string `json:"display"`
|
Display string `json:"display"`
|
||||||
BrandID uuid.UUID `json:"brand_id"`
|
LighthouseEnvType sourcesPkg.FastenLighthouseEnvType `json:"lighthouse_env_type"`
|
||||||
PortalID uuid.UUID `json:"portal_id"`
|
BrandID uuid.UUID `json:"brand_id"`
|
||||||
PlatformType sourcesPkg.PlatformType `json:"platform_type"`
|
PortalID uuid.UUID `json:"portal_id"`
|
||||||
|
PlatformType sourcesPkg.PlatformType `json:"platform_type"`
|
||||||
|
|
||||||
LatestBackgroundJob *BackgroundJob `json:"latest_background_job,omitempty"`
|
LatestBackgroundJob *BackgroundJob `json:"latest_background_job,omitempty"`
|
||||||
LatestBackgroundJobID *uuid.UUID `json:"-"`
|
LatestBackgroundJobID *uuid.UUID `json:"-"`
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
|
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
|
||||||
"github.com/fastenhealth/fasten-sources/clients/factory"
|
"github.com/fastenhealth/fasten-sources/clients/factory"
|
||||||
sourceModels "github.com/fastenhealth/fasten-sources/clients/models"
|
sourceModels "github.com/fastenhealth/fasten-sources/clients/models"
|
||||||
sourcePkg "github.com/fastenhealth/fasten-sources/pkg"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -36,7 +35,7 @@ func BackgroundJobSyncResources(
|
||||||
_sourceCred *models.SourceCredential,
|
_sourceCred *models.SourceCredential,
|
||||||
) (sourceModels.SourceClient, sourceModels.UpsertSummary, error) {
|
) (sourceModels.SourceClient, sourceModels.UpsertSummary, error) {
|
||||||
// after creating the client, we should do a bulk import
|
// 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 {
|
if err != nil {
|
||||||
resultErr := fmt.Errorf("an error occurred while initializing hub client using source credential: %w", err)
|
resultErr := fmt.Errorf("an error occurred while initializing hub client using source credential: %w", err)
|
||||||
_logger.Errorln(resultErr)
|
_logger.Errorln(resultErr)
|
||||||
|
|
|
@ -151,7 +151,7 @@ func CreateManualSource(c *gin.Context) {
|
||||||
manualSourceCredential := models.SourceCredential{
|
manualSourceCredential := models.SourceCredential{
|
||||||
PlatformType: sourcePkg.PlatformTypeManual,
|
PlatformType: sourcePkg.PlatformTypeManual,
|
||||||
}
|
}
|
||||||
tempSourceClient, err := factory.GetSourceClient(sourcePkg.GetFastenLighthouseEnv(), c, logger, &manualSourceCredential)
|
tempSourceClient, err := factory.GetSourceClient("", c, logger, &manualSourceCredential)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorln("An error occurred while initializing hub client using manual source without credentials", err)
|
logger.Errorln("An error occurred while initializing hub client using manual source without credentials", err)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
||||||
|
@ -185,7 +185,7 @@ func CreateManualSource(c *gin.Context) {
|
||||||
_databaseRepo database.DatabaseRepository,
|
_databaseRepo database.DatabaseRepository,
|
||||||
_sourceCred *models.SourceCredential,
|
_sourceCred *models.SourceCredential,
|
||||||
) (sourceModels.SourceClient, sourceModels.UpsertSummary, error) {
|
) (sourceModels.SourceClient, sourceModels.UpsertSummary, error) {
|
||||||
manualSourceClient, err := factory.GetSourceClient(sourcePkg.GetFastenLighthouseEnv(), _backgroundJobContext, _logger, _sourceCred)
|
manualSourceClient, err := factory.GetSourceClient("", _backgroundJobContext, _logger, _sourceCred)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resultErr := fmt.Errorf("an error occurred while initializing hub client using manual source with credential: %w", err)
|
resultErr := fmt.Errorf("an error occurred while initializing hub client using manual source with credential: %w", err)
|
||||||
logger.Errorln(resultErr)
|
logger.Errorln(resultErr)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/fastenhealth/fasten-onprem/backend/pkg/database"
|
"github.com/fastenhealth/fasten-onprem/backend/pkg/database"
|
||||||
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
|
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
|
||||||
"github.com/fastenhealth/fasten-sources/clients/factory"
|
"github.com/fastenhealth/fasten-sources/clients/factory"
|
||||||
sourcePkg "github.com/fastenhealth/fasten-sources/pkg"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -46,7 +45,7 @@ func UnsafeRequestSource(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := factory.GetSourceClient(sourcePkg.GetFastenLighthouseEnv(), c, logger, foundSource)
|
client, err := factory.GetSourceClient("", c, logger, foundSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("Could not initialize source client %v", err)
|
logger.Errorf("Could not initialize source client %v", err)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
|
||||||
|
@ -140,7 +139,7 @@ func UnsafeSyncResourceNames(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := factory.GetSourceClient(sourcePkg.GetFastenLighthouseEnv(), c, logger, foundSource)
|
client, err := factory.GetSourceClient("", c, logger, foundSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("Could not initialize source client %v", err)
|
logger.Errorf("Could not initialize source client %v", err)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {Location} from '@angular/common';
|
||||||
import {EventBusService} from '../../services/event-bus.service';
|
import {EventBusService} from '../../services/event-bus.service';
|
||||||
import {SourceState} from '../../models/fasten/source-state';
|
import {SourceState} from '../../models/fasten/source-state';
|
||||||
import {PatientAccessBrand} from '../../models/patient-access-brands';
|
import {PatientAccessBrand} from '../../models/patient-access-brands';
|
||||||
|
import {environment} from '../../../environments/environment';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-medical-sources-connected',
|
selector: 'app-medical-sources-connected',
|
||||||
|
@ -163,6 +164,7 @@ export class MedicalSourcesConnectedComponent implements OnInit {
|
||||||
id: expectedSourceStateInfo.reconnect_source_id,
|
id: expectedSourceStateInfo.reconnect_source_id,
|
||||||
|
|
||||||
display: portalInfo.name,
|
display: portalInfo.name,
|
||||||
|
lighthouse_env_type: environment.lighthouse_api_endpoint_base == 'https://lighthouse.fastenhealth.com/v1' ? 'prod' : 'sandbox',
|
||||||
brand_id: expectedSourceStateInfo.brand_id,
|
brand_id: expectedSourceStateInfo.brand_id,
|
||||||
portal_id: expectedSourceStateInfo.portal_id,
|
portal_id: expectedSourceStateInfo.portal_id,
|
||||||
endpoint_id: expectedSourceStateInfo.endpoint_id,
|
endpoint_id: expectedSourceStateInfo.endpoint_id,
|
||||||
|
|
|
@ -8,6 +8,7 @@ export class Source {
|
||||||
user_id?: number
|
user_id?: number
|
||||||
|
|
||||||
display?: string
|
display?: string
|
||||||
|
lighthouse_env_type?: 'prod' | 'sandbox'
|
||||||
brand_id?: string
|
brand_id?: string
|
||||||
portal_id?: string
|
portal_id?: string
|
||||||
endpoint_id: string
|
endpoint_id: string
|
||||||
|
|
Loading…
Reference in New Issue