Skip to content

Commit e2f522f

Browse files
Merge branch 'main' into rob/505-add-backend-logic-for-adding-valuesets
2 parents 2a4a3d9 + 2129c24 commit e2f522f

File tree

4 files changed

+47
-22
lines changed

4 files changed

+47
-22
lines changed

src/app/(pages)/query/components/searchForm/SearchForm.tsx

+18-9
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,24 @@ const SearchForm: React.FC<SearchFormProps> = function SearchForm({
6161
const [autofilled, setAutofilled] = useState(false); // boolean indicating if the form was autofilled, changes color if true
6262

6363
// Fills fields with sample data based on the selected
64-
const fillFields = useCallback((highlightAutofilled = true) => {
65-
setFirstName(hyperUnluckyPatient.FirstName);
66-
setLastName(hyperUnluckyPatient.LastName);
67-
setDOB(hyperUnluckyPatient.DOB);
68-
setMRN(hyperUnluckyPatient.MRN);
69-
setPhone(hyperUnluckyPatient.Phone);
70-
setFhirServer(hyperUnluckyPatient.FhirServer as string);
71-
setAutofilled(highlightAutofilled);
72-
}, []);
64+
const fillFields = useCallback(
65+
(highlightAutofilled = true) => {
66+
const defaultFhirServer = fhirServers.includes(
67+
hyperUnluckyPatient.FhirServer,
68+
)
69+
? hyperUnluckyPatient.FhirServer
70+
: fhirServers[0];
71+
72+
setFirstName(hyperUnluckyPatient.FirstName);
73+
setLastName(hyperUnluckyPatient.LastName);
74+
setDOB(hyperUnluckyPatient.DOB);
75+
setMRN(hyperUnluckyPatient.MRN);
76+
setPhone(hyperUnluckyPatient.Phone);
77+
setFhirServer(defaultFhirServer);
78+
setAutofilled(highlightAutofilled);
79+
},
80+
[fhirServers],
81+
);
7382

7483
const nameRegex = "^[A-Za-z\u00C0-\u024F\u1E00-\u1EFF\\-'. ]+$";
7584
const nameRuleHint =

src/app/backend/dbServices/fhir-servers.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,33 @@ class FhirServerConfigService extends FhirServerConfigServiceInternal {
320320
}
321321
}
322322

323-
static async prepareFhirClient(fhirServer: string) {
323+
static async prepareFhirClient(serverName: string) {
324324
if (FhirServerConfigService.cachedFhirServerConfigs === null) {
325325
FhirServerConfigService.cachedFhirServerConfigs =
326326
await super.getFhirServerConfigs();
327327
}
328328

329-
return new FHIRClient(
330-
fhirServer,
331-
FhirServerConfigService.cachedFhirServerConfigs,
329+
let config = FhirServerConfigService.cachedFhirServerConfigs.find(
330+
(c) => c.name === serverName,
332331
);
332+
333+
if (!config) {
334+
// fallback retry in case we have a cache miss
335+
FhirServerConfigService.cachedFhirServerConfigs =
336+
await super.getFhirServerConfigs();
337+
const followupConfig =
338+
FhirServerConfigService.cachedFhirServerConfigs.find(
339+
(c) => c.name === serverName,
340+
);
341+
342+
if (!followupConfig)
343+
throw Error(`No server config found for ${serverName}`);
344+
else {
345+
config = followupConfig;
346+
}
347+
}
348+
349+
return new FHIRClient(config);
333350
}
334351
}
335352

src/app/shared/fhirClient.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { AuthData } from "../backend/dbServices/fhir-servers";
44
import { createSmartJwt } from "../backend/dbServices/smartOnFhir/lib";
55
import { updateFhirServer } from "../backend/dbServices/fhir-servers";
66
import { fetchWithoutSSL } from "./utils";
7+
import dbService from "../backend/dbServices/db-service";
78
/**
89
* A client for querying a FHIR server.
910
* @param server The FHIR server to query.
@@ -15,14 +16,7 @@ class FHIRClient {
1516
private serverConfig: FhirServerConfig;
1617
private fetch: (url: string, options?: RequestInit) => Promise<Response>;
1718

18-
constructor(server: string, configurations: FhirServerConfig[]) {
19-
// Find the configuration for the given server
20-
const config = configurations.find((c) => c.name === server);
21-
22-
if (!config) {
23-
throw new Error(`No configuration found for server: ${server}`);
24-
}
25-
19+
constructor(config: FhirServerConfig) {
2620
this.serverConfig = config;
2721
this.hostname = config.hostname;
2822

@@ -36,6 +30,10 @@ class FHIRClient {
3630
};
3731
}
3832

33+
static async refreshFhirServerConfig() {
34+
dbService.query;
35+
}
36+
3937
/**
4038
* Creates a temporary client for testing a connection
4139
* @param url The FHIR server URL
@@ -79,7 +77,7 @@ class FHIRClient {
7977
}
8078

8179
// Create a client with a configurations array containing only the test config
82-
const client = new FHIRClient("test", [testConfig]);
80+
const client = new FHIRClient(testConfig);
8381
return client;
8482
}
8583

terraform/modules/oidc/_data.tf

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ data "aws_iam_policy_document" "github_assume_role" {
2828

2929
# tfstate and storage policy
3030
# trivy:ignore:AVD-AWS-0057
31+
# trivy:ignore:AVD-AWS-0345
3132
data "aws_iam_policy_document" "storage" {
3233
statement {
3334
actions = [

0 commit comments

Comments
 (0)