Skip to content

Commit dc48289

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 377a615 + a604b0a commit dc48289

11 files changed

Lines changed: 113 additions & 96 deletions

src/components/actions/AssignQuestionnaireModal.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Loader, Modal } from '@mantine/core';
1+
import { QUESTIONNAIRE_ASSIGNMENT_QUESTIONNAIRE_NAME } from '@/constants';
2+
import { getQuestionnaireByName } from '@/utils';
3+
import { Alert, Loader, Modal } from '@mantine/core';
4+
import { normalizeErrorString } from '@medplum/core';
25
import { Questionnaire, QuestionnaireResponse } from '@medplum/fhirtypes';
36
import { QuestionnaireForm, useMedplum } from '@medplum/react';
47
import { useCallback, useEffect, useState } from 'react';
58
import { useNavigate, useParams } from 'react-router-dom';
6-
import { QUESTIONNAIRE_ASSIGNMENT_QUESTIONNAIRE_NAME } from '@/constants';
7-
import { getQuestionnaireByName } from '@/utils';
89

910
interface AssignQuestionnaireModalProps {
1011
readonly opened: boolean;
@@ -16,12 +17,13 @@ export function AssignQuestionnaireModal(props: AssignQuestionnaireModalProps):
1617
const medplum = useMedplum();
1718
const navigate = useNavigate();
1819
const [questionnaire, setQuestionnaire] = useState<Questionnaire>();
20+
const [error, setError] = useState<string>();
1921

2022
useEffect(() => {
2123
getQuestionnaireByName(medplum, QUESTIONNAIRE_ASSIGNMENT_QUESTIONNAIRE_NAME)
2224
.then(setQuestionnaire)
2325
.catch((err) => {
24-
console.error('Failed to load questionnaire:', err);
26+
setError(normalizeErrorString(err));
2527
});
2628
}, [medplum]);
2729

@@ -37,7 +39,11 @@ export function AssignQuestionnaireModal(props: AssignQuestionnaireModalProps):
3739

3840
return (
3941
<Modal size="lg" opened={props.opened} onClose={props.onClose}>
40-
{!questionnaire ? (
42+
{error ? (
43+
<Alert color="red" title="Error loading questionnaire">
44+
{error}
45+
</Alert>
46+
) : !questionnaire ? (
4147
<Loader />
4248
) : (
4349
<QuestionnaireForm

src/components/actions/AssignToRoomModal.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Loader, Modal } from '@mantine/core';
1+
import { PATIENT_BED_ASSIGNMENT_QUESTIONNAIRE_NAME } from '@/constants';
2+
import { getQuestionnaireByName } from '@/utils';
3+
import { Alert, Loader, Modal } from '@mantine/core';
4+
import { normalizeErrorString } from '@medplum/core';
25
import { Questionnaire, QuestionnaireResponse } from '@medplum/fhirtypes';
36
import { QuestionnaireForm, useMedplum } from '@medplum/react';
47
import { useCallback, useEffect, useState } from 'react';
58
import { useParams } from 'react-router-dom';
6-
import { PATIENT_BED_ASSIGNMENT_QUESTIONNAIRE_NAME } from '@/constants';
7-
import { getQuestionnaireByName } from '@/utils';
89

910
interface AssignToRoomModalProps {
1011
readonly opened: boolean;
@@ -16,12 +17,13 @@ export function AssignToRoomModal(props: AssignToRoomModalProps): JSX.Element {
1617
const { id } = useParams();
1718
const medplum = useMedplum();
1819
const [questionnaire, setQuestionnaire] = useState<Questionnaire>();
20+
const [error, setError] = useState<string>();
1921

2022
useEffect(() => {
2123
getQuestionnaireByName(medplum, PATIENT_BED_ASSIGNMENT_QUESTIONNAIRE_NAME)
2224
.then(setQuestionnaire)
2325
.catch((err) => {
24-
console.error('Failed to load questionnaire:', err);
26+
setError(normalizeErrorString(err));
2527
});
2628
}, [medplum]);
2729

@@ -39,7 +41,11 @@ export function AssignToRoomModal(props: AssignToRoomModalProps): JSX.Element {
3941

4042
return (
4143
<Modal size="lg" opened={opened} onClose={onClose}>
42-
{!questionnaire ? (
44+
{error ? (
45+
<Alert color="red" title="Error loading questionnaire">
46+
{error}
47+
</Alert>
48+
) : !questionnaire ? (
4349
<Loader />
4450
) : (
4551
<QuestionnaireForm

src/pages/CreateLocationPage.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
import { Container, Loader } from '@mantine/core';
2-
import { createReference } from '@medplum/core';
1+
import { CREATE_LOCATION_LVL_QUESTIONNAIRE_NAME, CREATE_LOCATION_ROOM_QUESTIONNAIRE_NAME } from '@/constants';
2+
import { getQuestionnaireByName } from '@/utils';
3+
import { Alert, Container, Loader } from '@mantine/core';
4+
import { createReference, normalizeErrorString } from '@medplum/core';
35
import { Questionnaire, QuestionnaireResponse, QuestionnaireResponseItem } from '@medplum/fhirtypes';
46
import { QuestionnaireForm, useMedplum, useMedplumNavigate } from '@medplum/react';
57
import { useCallback, useEffect, useState } from 'react';
68
import { useParams } from 'react-router-dom';
7-
import { CREATE_LOCATION_ROOM_QUESTIONNAIRE_NAME, CREATE_LOCATION_LVL_QUESTIONNAIRE_NAME } from '@/constants';
8-
import { getQuestionnaireByName } from '@/utils';
99

1010
export function CreateLocationPage(): JSX.Element {
1111
const navigate = useMedplumNavigate();
1212
const { id } = useParams();
1313
const medplum = useMedplum();
1414
const [questionnaire, setQuestionnaire] = useState<Questionnaire>();
15+
const [error, setError] = useState<string>();
1516

1617
useEffect(() => {
17-
const questionnaireName = id
18-
? CREATE_LOCATION_ROOM_QUESTIONNAIRE_NAME
19-
: CREATE_LOCATION_LVL_QUESTIONNAIRE_NAME;
18+
const questionnaireName = id ? CREATE_LOCATION_ROOM_QUESTIONNAIRE_NAME : CREATE_LOCATION_LVL_QUESTIONNAIRE_NAME;
2019

2120
getQuestionnaireByName(medplum, questionnaireName)
2221
.then(setQuestionnaire)
2322
.catch((err) => {
24-
console.error('Failed to load questionnaire:', err);
23+
setError(normalizeErrorString(err));
2524
});
2625
}, [id, medplum]);
2726

@@ -46,6 +45,16 @@ export function CreateLocationPage(): JSX.Element {
4645
[id, medplum, navigate]
4746
);
4847

48+
if (error) {
49+
return (
50+
<Container fluid>
51+
<Alert color="red" title="Error loading questionnaire">
52+
{error}
53+
</Alert>
54+
</Container>
55+
);
56+
}
57+
4958
if (!questionnaire) {
5059
return (
5160
<Container fluid>

src/pages/LocationPage.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { useCallback, useEffect, useMemo, useState } from 'react';
2-
import { useNavigate, useParams } from 'react-router-dom';
3-
import { Button, Container, Group, Loader, Text, Title } from '@mantine/core';
1+
import { FhirPathTable, FhirPathTableField } from '@/components/FhirPathTable/FhirPathTable';
2+
import { SAMPLE_MED_LOCATION_NAME } from '@/constants';
3+
import { Alert, Button, Container, Group, Loader, Text, Title } from '@mantine/core';
44
import { modals } from '@mantine/modals';
5-
import { PropertyType } from '@medplum/core';
5+
import { normalizeErrorString, PropertyType } from '@medplum/core';
66
import { Location } from '@medplum/fhirtypes';
77
import { useMedplum } from '@medplum/react';
8-
import { FhirPathTable, FhirPathTableField } from '@/components/FhirPathTable/FhirPathTable';
9-
import { SAMPLE_MED_LOCATION_NAME } from '@/constants';
8+
import { useCallback, useEffect, useMemo, useState } from 'react';
9+
import { useNavigate, useParams } from 'react-router-dom';
1010

1111
export function LocationsPage(): JSX.Element {
1212
const navigate = useNavigate();
@@ -15,6 +15,7 @@ export function LocationsPage(): JSX.Element {
1515
const [refresh, setRefresh] = useState(false);
1616
const medplum = useMedplum();
1717
const [rootLocation, setRootLocation] = useState<Location>();
18+
const [error, setError] = useState<string>();
1819

1920
useEffect(() => {
2021
if (!id) {
@@ -27,7 +28,7 @@ export function LocationsPage(): JSX.Element {
2728
setRootLocation(location);
2829
})
2930
.catch((err) => {
30-
console.error('Failed to load root location:', err);
31+
setError(normalizeErrorString(err));
3132
});
3233
}
3334
}, [id, medplum]);
@@ -126,7 +127,6 @@ export function LocationsPage(): JSX.Element {
126127
}`;
127128
}
128129
if (!rootLocation?.id) return '';
129-
console.log('Using root location ID:', rootLocation.id);
130130
return `{
131131
ResourceList: LocationList(partof: "Location/${rootLocation.id}", physical_type: "lvl", _sort: "name", _count: 40) {
132132
id
@@ -143,6 +143,16 @@ export function LocationsPage(): JSX.Element {
143143
navigate(id ? `/Location/${id}/new` : '/Location/new');
144144
}
145145

146+
if (error) {
147+
return (
148+
<Container fluid>
149+
<Alert color="red" title="Error loading location">
150+
{error}
151+
</Alert>
152+
</Container>
153+
);
154+
}
155+
146156
if (!id && !rootLocation) {
147157
return (
148158
<Container fluid>

src/pages/NewPatientPage.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Container, Loader } from '@mantine/core';
1+
import { Alert, Container, Loader } from '@mantine/core';
22
import { showNotification } from '@mantine/notifications';
33
import { generateId, normalizeErrorString, sleep } from '@medplum/core';
44
import { Questionnaire, QuestionnaireResponse, QuestionnaireResponseItem, ServiceRequest } from '@medplum/fhirtypes';
@@ -14,17 +14,13 @@ export function NewPatientPage(): JSX.Element {
1414
const medplum = useMedplum();
1515
const navigate = useMedplumNavigate();
1616
const [questionnaire, setQuestionnaire] = useState<Questionnaire>();
17+
const [error, setError] = useState<string>();
1718

1819
useEffect(() => {
1920
getQuestionnaireByName(medplum, PATIENT_INTAKE_QUESTIONNAIRE_NAME)
2021
.then(setQuestionnaire)
2122
.catch((err) => {
22-
showNotification({
23-
color: 'red',
24-
icon: <IconCircleOff />,
25-
title: 'Error',
26-
message: normalizeErrorString(err),
27-
});
23+
setError(normalizeErrorString(err));
2824
});
2925
}, [medplum]);
3026

@@ -88,6 +84,16 @@ export function NewPatientPage(): JSX.Element {
8884
[medplum, navigate]
8985
);
9086

87+
if (error) {
88+
return (
89+
<Container fluid>
90+
<Alert color="red" title="Error loading questionnaire">
91+
{error}
92+
</Alert>
93+
</Container>
94+
);
95+
}
96+
9197
if (!questionnaire) {
9298
return (
9399
<Container fluid>

src/pages/NewPhysicianPage.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
import { Container, Loader } from '@mantine/core';
1+
import { PHYSICIAN_ONBOARDING_QUESTIONNAIRE_NAME } from '@/constants';
2+
import { getQuestionnaireByName } from '@/utils';
3+
import { Alert, Container, Loader } from '@mantine/core';
4+
import { normalizeErrorString } from '@medplum/core';
25
import { Questionnaire, QuestionnaireResponse } from '@medplum/fhirtypes';
36
import { QuestionnaireForm, useMedplum, useMedplumNavigate } from '@medplum/react';
47
import { useCallback, useEffect, useState } from 'react';
5-
import { PHYSICIAN_ONBOARDING_QUESTIONNAIRE_NAME } from '@/constants';
6-
import { getQuestionnaireByName } from '@/utils';
78

89
export function NewPhysicianPage(): JSX.Element {
910
const medplum = useMedplum();
1011
const navigate = useMedplumNavigate();
1112
const [questionnaire, setQuestionnaire] = useState<Questionnaire>();
13+
const [error, setError] = useState<string>();
1214

1315
useEffect(() => {
1416
getQuestionnaireByName(medplum, PHYSICIAN_ONBOARDING_QUESTIONNAIRE_NAME)
1517
.then(setQuestionnaire)
1618
.catch((err) => {
17-
console.error('Failed to load questionnaire:', err);
19+
setError(normalizeErrorString(err));
1820
});
1921
}, [medplum]);
2022

@@ -30,6 +32,16 @@ export function NewPhysicianPage(): JSX.Element {
3032
[medplum, navigate]
3133
);
3234

35+
if (error) {
36+
return (
37+
<Container fluid>
38+
<Alert color="red" title="Error loading questionnaire">
39+
{error}
40+
</Alert>
41+
</Container>
42+
);
43+
}
44+
3345
if (!questionnaire) {
3446
return (
3547
<Container fluid>

src/pages/PhysiciansPage.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { FhirPathTable, FhirPathTableField } from '@/components/FhirPathTable/FhirPathTable';
22
import { ViewQuestionnaireButton } from '@/components/ViewQuestionnaireButton/ViewQuestionnaireButton';
3-
import { Button, Container, Loader, Title } from '@mantine/core';
4-
import { PropertyType } from '@medplum/core';
3+
import { SAMPLE_MED_ORG_NAME } from '@/constants';
4+
import { Alert, Button, Container, Loader, Title } from '@mantine/core';
5+
import { normalizeErrorString, PropertyType } from '@medplum/core';
56
import { Organization } from '@medplum/fhirtypes';
67
import { useMedplum } from '@medplum/react';
78
import { useEffect, useMemo, useState } from 'react';
89
import { Outlet, useNavigate } from 'react-router-dom';
9-
import { SAMPLE_MED_ORG_NAME } from '@/constants';
1010

1111
export function PhysiciansPage(): JSX.Element {
1212
const navigate = useNavigate();
1313
const medplum = useMedplum();
1414
const [organization, setOrganization] = useState<Organization>();
15+
const [error, setError] = useState<string>();
1516

1617
useEffect(() => {
1718
medplum
@@ -23,7 +24,7 @@ export function PhysiciansPage(): JSX.Element {
2324
setOrganization(org);
2425
})
2526
.catch((err) => {
26-
console.error('Failed to load organization:', err);
27+
setError(normalizeErrorString(err));
2728
});
2829
}, [medplum]);
2930

@@ -77,6 +78,16 @@ export function PhysiciansPage(): JSX.Element {
7778
[navigate]
7879
);
7980

81+
if (error) {
82+
return (
83+
<Container fluid>
84+
<Alert color="red" title="Error loading organization">
85+
{error}
86+
</Alert>
87+
</Container>
88+
);
89+
}
90+
8091
if (!organization) {
8192
return (
8293
<Container fluid>

src/pages/SignInPage.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { Title } from '@mantine/core';
22
import { Logo, SignInForm } from '@medplum/react';
33
import { useNavigate } from 'react-router-dom';
4-
import { MEDPLUM_PROJECT_ID } from '../config';
4+
import { MEDPLUM_PROJECT_ID, MEDPLUM_GOOGLE_CLIENT_ID } from '../config';
55

66
export function SignInPage(): JSX.Element {
77
const navigate = useNavigate();
88

99
return (
10-
<SignInForm projectId={MEDPLUM_PROJECT_ID} onSuccess={() => navigate('/')}>
10+
<SignInForm
11+
projectId={MEDPLUM_PROJECT_ID}
12+
googleClientId={MEDPLUM_GOOGLE_CLIENT_ID || undefined}
13+
onSuccess={() => navigate('/')}
14+
>
1115
<Logo size={32} />
1216
<Title>Sign in to SampleMed Regional Portal </Title>
1317
</SignInForm>

src/utils/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ export * from './createBloodPressureObservationComponent';
44
export * from './createBundleEntry';
55
export * from './createBundleEntryReference';
66
export * from './createObservation';
7-
export * from './location';
8-
export * from './organization';
97
export * from './questionnaire';
108
export * from './shouldShowPatientSummary';

0 commit comments

Comments
 (0)