Skip to content

Commit 2115fb2

Browse files
committed
Encounter list and patient dashboard done
1 parent f221346 commit 2115fb2

6 files changed

Lines changed: 162 additions & 13 deletions

File tree

src/containers/EncountersUberList/index.tsx

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import { PlusOutlined } from '@ant-design/icons';
22
import { t, Trans } from '@lingui/macro';
3-
import { Encounter } from 'fhir/r4b';
3+
import { Encounter, Reference } from 'fhir/r4b';
44

55
import { questionnaireAction, navigationAction, ResourceListPage } from '@beda.software/emr/components';
66
import { SearchBarColumnType } from '@beda.software/emr/dist/components/SearchBar/types';
7-
import { formatPeriodDateTime } from '@beda.software/emr/utils';
7+
import { compileAsFirst, formatPeriodDateTime } from '@beda.software/emr/utils';
8+
9+
export const getPractitioner = compileAsFirst<Encounter,Reference>("Encounter.participant.individual.where(resourceType='Practitioner').individual");
10+
export const getPatient= compileAsFirst<Encounter, Reference>("Encounter.subject");
11+
export const getOrganization = compileAsFirst<Encounter,Reference>("Encounter.serviceProvider");
812

913
export function EncountersUberList() {
1014
return (
1115
<ResourceListPage<Encounter>
1216
headerTitle="Encounters"
1317
resourceType="Encounter"
1418
getTableColumns={() => [
15-
{
16-
title: 'Practitioner',
17-
dataIndex: 'practitioner',
18-
key: 'practitioner',
19-
render: (_text: any, { resource }) => resource.participant?.[0]?.individual?.display,
20-
},
2119
{
2220
title: 'Status',
2321
dataIndex: 'status',
@@ -33,6 +31,42 @@ export function EncountersUberList() {
3331
width: 250,
3432
render: (_text: any, { resource }) => formatPeriodDateTime(resource.period),
3533
},
34+
{
35+
title: 'Practitioner',
36+
dataIndex: 'practitioner',
37+
key: 'practitioner',
38+
render: (_text: any, { resource }) => {
39+
const reference = getPractitioner(resource);
40+
if(reference){
41+
return reference.display ?? reference.reference;
42+
43+
}
44+
},
45+
},
46+
{
47+
title: 'Patient',
48+
dataIndex: 'patient',
49+
key: 'patient',
50+
render: (_text: any, { resource }) => {
51+
const reference = getPatient(resource);
52+
if (reference) {
53+
return reference.display ?? reference.reference;
54+
55+
}
56+
},
57+
},
58+
{
59+
title: 'Organization',
60+
dataIndex: 'organization',
61+
key: 'organization',
62+
render: (_text: any, { resource }) => {
63+
const reference = getOrganization(resource);
64+
if (reference) {
65+
return reference.display ?? reference.reference;
66+
67+
}
68+
},
69+
},
3670
]}
3771
getFilters={() => [
3872
{
@@ -68,7 +102,6 @@ export function EncountersUberList() {
68102
placement: ['table', 'search-bar'],
69103
},
70104
]}
71-
getRecordActions={(record) => [navigationAction('Open', `/`)]}
72105
getHeaderActions={() => [
73106
questionnaireAction(<Trans>Create encounter</Trans>, 'encounter-create-connectathon', {
74107
icon: <PlusOutlined />,

src/containers/ImmunizationsUberList /index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function ImmunizationsUberList() {
5555
placement: ['table', 'search-bar'],
5656
},
5757
]}
58-
getRecordActions={(record) => [navigationAction('Open', `/`)]}
58+
getRecordActions={(_record) => [navigationAction('Open', `/`)]}
5959
getHeaderActions={() => [
6060
questionnaireAction(<Trans>Create immunization</Trans>, 'immunization-create-connectathon', {
6161
icon: <PlusOutlined />,
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import type { Dashboard, DashboardInstance } from '@beda.software/emr/dist/components/Dashboard/types';
2+
import { OverviewCard } from '@beda.software/emr/dist/containers/PatientDetails/PatientOverviewDynamic/components/StandardCard/types';
3+
import { StandardCardContainerFabric } from '@beda.software/emr/dist/containers/PatientDetails/PatientOverviewDynamic/containers/StandardCardContainerFabric/index';
4+
import { Bundle, Encounter, Patient } from 'fhir/r4b';
5+
import { getOrganization, getPractitioner } from '../EncountersUberList';
6+
import { formatPeriodDateTime } from '@beda.software/emr/utils';
7+
8+
function prepareEncounter(
9+
resources: Encounter[],
10+
bundle: Bundle<Encounter>,
11+
): OverviewCard<Encounter> {
12+
13+
return {
14+
title: 'Encounters',
15+
key: 'ecnounter',
16+
icon: <h2></h2>,
17+
data: resources,
18+
total: bundle.total ?? 0,
19+
getKey: (r) => r.id!,
20+
columns: [
21+
{
22+
title: 'Status',
23+
key: 'status',
24+
render: (resource) => {
25+
return resource.status;
26+
},
27+
},
28+
{
29+
title: 'Date',
30+
key: 'date',
31+
width: 250,
32+
render: (resource) => formatPeriodDateTime(resource.period),
33+
},
34+
{
35+
title: 'Practitioner',
36+
key: 'practitioner',
37+
render: (resource) => {
38+
const reference = getPractitioner(resource);
39+
if (reference) {
40+
return reference.display ?? reference.reference;
41+
42+
}
43+
},
44+
},
45+
{
46+
title: 'Organization',
47+
key: 'organization',
48+
render: (resource) => {
49+
const reference = getOrganization(resource);
50+
if (reference) {
51+
return reference.display ?? reference.reference;
52+
53+
}
54+
},
55+
},
56+
]
57+
,
58+
};
59+
}
60+
61+
const patientDashboardConfig: DashboardInstance = {
62+
top: [
63+
{
64+
query: {
65+
resourceType: 'Encounter',
66+
search: (patient: Patient) => ({
67+
patient: patient.id,
68+
_count: 7,
69+
}),
70+
},
71+
widget: StandardCardContainerFabric(prepareEncounter),
72+
},
73+
74+
],
75+
left: [],
76+
right: [],
77+
bottom: [],
78+
}
79+
80+
export const dashboard: Dashboard = {
81+
default: patientDashboardConfig,
82+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Patient } from 'fhir/r4b';
2+
3+
import { PatientDashboardProvider } from '@beda.software/emr/dist/components/Dashboard/contexts';
4+
import { PatientOverview } from '@beda.software/emr/dist/containers/PatientDetails/PatientOverviewDynamic/index';
5+
import { ResourceDetailPage, Tab } from '@beda.software/emr/dist/uberComponents/ResourceDetailPage/index';
6+
import { compileAsFirst } from '@beda.software/emr/dist/utils/index';
7+
8+
import { dashboard } from './dashboard';
9+
10+
11+
const getName = compileAsFirst<Patient, string>("Patient.name.given.first() + ' ' + Patient.name.family");
12+
13+
14+
const tabs: Array<Tab<Patient>> = [
15+
{
16+
path: '',
17+
label: 'Overview',
18+
component: ({ resource }) => <PatientOverview patient={resource} />,
19+
}
20+
];
21+
22+
export function PatientDetails() {
23+
return (
24+
<PatientDashboardProvider dashboard={dashboard}>
25+
<ResourceDetailPage<Patient>
26+
resourceType="Patient"
27+
getSearchParams={({ id }) => ({ _id: id })}
28+
getTitle={({ resource, bundle }) => getName(resource, { bundle })!}
29+
tabs={tabs}
30+
/>
31+
</PatientDashboardProvider>
32+
);
33+
}
34+

src/containers/PatientsUberList/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ export function PatientUberList() {
8686
},
8787
]}
8888
getRecordActions={(record) => [
89-
navigationAction('Open', `/patients/${record.resource.id}`),
90-
questionnaireAction('Edit', 'patient-edit'),
91-
customAction(<S.LinkButton type="link">Custom action</S.LinkButton>),
89+
navigationAction('Open', `/patients-ph/${record.resource.id}`),
9290
]}
9391
getHeaderActions={() => [
9492
questionnaireAction(<Trans>Add patient</Trans>, 'patient-create-connectathon', {

src/main.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { PatientUberList } from './containers/PatientsUberList';
4545
import { PractitionersUberList } from './containers/PractitionersUberList ';
4646
import { ProceduresUberList } from './containers/ProceduresUberList';
4747
import { dynamicActivate, getCurrentLocale } from './services/i18n';
48+
import { PatientDetails } from './containers/PatientsUberList/detail';
4849

4950
async function expandEMRValueSet(answerValueSet: string | undefined, searchText: string): Promise<Coding[]> {
5051
if (!answerValueSet) {
@@ -101,6 +102,7 @@ export const AppWithContext = () => {
101102
authenticatedRoutes={
102103
<>
103104
<Route path="/patients-ph" element={<PatientUberList />} />
105+
<Route path="/patients-ph/:id" element={<PatientDetails />} />
104106
<Route path="/encounters-ph" element={<EncountersUberList />} />
105107
<Route path="/practitioners-ph" element={<PractitionersUberList />} />
106108
<Route path="/organizations-ph" element={<OrganizationsUberList />} />

0 commit comments

Comments
 (0)