Skip to content

Commit 6470bac

Browse files
committed
Externalize FHIR server config for production
1 parent 72c7a74 commit 6470bac

6 files changed

Lines changed: 47 additions & 15 deletions

File tree

angular.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
"configurations": {
7474
"production": {
7575
"baseHref": "https://ihtsdo.github.io/sct-implementation-demonstrator/",
76+
"fileReplacements": [
77+
{
78+
"replace": "src/environments/environment.ts",
79+
"with": "src/environments/environment.prod.ts"
80+
}
81+
],
7682
"budgets": [
7783
{
7884
"type": "initial",

src/app/app.component.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import { LicenseAgreementComponent } from './license-agreement/license-agreement
1010
import { CookieConsentComponent } from './cookie-consent/cookie-consent.component';
1111
import { CookieService } from './services/cookie.service';
1212
import { GoogleAnalyticsService } from './services/google-analytics.service';
13-
import { catchError, of, skip, Subject, switchMap, tap } from 'rxjs';
13+
import { catchError, filter, of, skip, Subject, switchMap, tap } from 'rxjs';
1414
import { HttpClient } from '@angular/common/http';
15+
import { environment } from '../environments/environment';
16+
import { FhirServer } from '../environments/fhir-server.interface';
1517

1618
@Component({
1719
selector: 'app-root',
@@ -34,18 +36,8 @@ export class AppComponent {
3436
selectedLanRefsetConcept: any = null;
3537
selectedLanguageContext: any = null;
3638
selectedLanguageDisplayLabel = 'Language';
37-
fhirServers = [
38-
{ name: "SNOMED Dev IS", url: "https://dev-is-browser.ihtsdotools.org/fhir"},
39-
{ name: "SNOMED Public", url: "https://snowstorm.ihtsdotools.org/fhir"},
40-
{ name: "SNOMED Dev 2", url: "https://snowstorm-temp.kaicode.io/fhir"},
41-
{ name: "SNOMED Lite Demo", url: "https://implementation-demo.snomedtools.org/snowstorm-lite/fhir"},
42-
{ name: "LOINC Ontology Server", url: "https://browser.loincsnomed.org/fhir"},
43-
{ name: "Ontoserver", url: "https://r4.ontoserver.csiro.au/fhir"},
44-
{ name: "SNOMED Dev 1", url: "https://dev-browser.ihtsdotools.org/fhir"},
45-
{ name: "Implementation Demo", url: "https://implementation-demo.snomedtools.org/fhir"},
46-
// { name: "SNOMED International Next", url: "https://snomedbrowser.org/fhir"},
47-
];
48-
selectedServer = this.fhirServers[1];
39+
fhirServers: FhirServer[] = environment.fhirServers;
40+
selectedServer: FhirServer = this.fhirServers[environment.defaultFhirServerIndex];
4941
embeddedMode: boolean = false;
5042
demos: any[] = [];
5143

@@ -188,7 +180,7 @@ export class AppComponent {
188180
}
189181
});
190182

191-
this.terminologyService.snowstormFhirBase$.subscribe(url => {
183+
this.terminologyService.snowstormFhirBase$.pipe(filter(url => !!url)).subscribe(url => {
192184
if (this.fhirServers?.length > 0) {
193185
this.fhirServers.forEach(loopServer => {
194186
if (loopServer.url === url) {

src/app/services/terminology.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface CodeDisplay {
3232
export class TerminologyService {
3333

3434

35-
snowstormFhirBase = 'https://snowstorm.ihtsdotools.org/fhir';
35+
snowstormFhirBase = '';
3636
defaultFhirUrlParam = 'http://snomed.info/sct'; // 'http://snomed.info/sct/11000221109/version/20211130'
3737
fhirUrlParam = this.defaultFhirUrlParam;
3838
lang = 'en';
@@ -228,6 +228,7 @@ export class TerminologyService {
228228
}
229229

230230
getCodeSystems() {
231+
if (!this.snowstormFhirBase) return of({});
231232
let requestUrl = `${this.snowstormFhirBase}/CodeSystem`;
232233
if (this.isOntoserver()) {
233234
requestUrl += `?system=http://snomed.info/sct`;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { FhirServer } from './fhir-server.interface';
2+
3+
export const environment = {
4+
production: true,
5+
fhirServers: [
6+
{ name: 'SNOMED Dev IS', url: 'https://dev-is-browser.ihtsdotools.org/fhir' },
7+
{ name: 'SNOMED Public', url: 'https://snowstorm.ihtsdotools.org/fhir' },
8+
{ name: 'SNOMED Dev 2', url: 'https://snowstorm-temp.kaicode.io/fhir' },
9+
{ name: 'SNOMED Lite Demo', url: 'https://implementation-demo.snomedtools.org/snowstorm-lite/fhir' },
10+
{ name: 'LOINC Ontology Server', url: 'https://browser.loincsnomed.org/fhir' },
11+
{ name: 'Ontoserver', url: 'https://r4.ontoserver.csiro.au/fhir' },
12+
{ name: 'SNOMED Dev 1', url: 'https://dev-browser.ihtsdotools.org/fhir' },
13+
{ name: 'Implementation Demo', url: 'https://implementation-demo.snomedtools.org/fhir' },
14+
] as FhirServer[],
15+
defaultFhirServerIndex: 1,
16+
};

src/environments/environment.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { FhirServer } from './fhir-server.interface';
2+
3+
export const environment = {
4+
production: false,
5+
fhirServers: [
6+
{ name: 'SNOMED Public Snowstorm', url: 'https://snowstorm.ihtsdotools.org/fhir' },
7+
{ name: 'Snowstorm Lite Demo', url: 'https://implementation-demo.snomedtools.org/snowstorm-lite/fhir' },
8+
{ name: 'LOINC Ontology Snowstorm', url: 'https://browser.loincsnomed.org/fhir' },
9+
{ name: 'Ontoserver R4 Demo', url: 'https://r4.ontoserver.csiro.au/fhir' },
10+
{ name: 'Implementation Demo SnowstormX', url: 'https://implementation-demo.snomedtools.org/fhir' },
11+
] as FhirServer[],
12+
defaultFhirServerIndex: 1,
13+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface FhirServer {
2+
name: string;
3+
url: string;
4+
}

0 commit comments

Comments
 (0)