11import React , { useState } from 'react' ;
22
33import { Button } from '@orfium/ictinus' ;
4- import { useGetSurgeonEpisodeSummary , useGetOwnedEpisodes } from 'hooks/api/patientHooks' ;
4+ import {
5+ useGetSurgeonEpisodeSummary ,
6+ useGetOwnedEpisodes ,
7+ useGetUnlinkedPatients ,
8+ useGetPreferredHospital ,
9+ } from 'hooks/api/patientHooks' ;
510import { useHistory } from 'react-router-dom' ;
611import urls from 'routing/urls' ;
712
@@ -19,6 +24,9 @@ const LandingPage: React.FC = () => {
1924 const history = useHistory ( ) ;
2025 const { isDesktop } = useResponsiveLayout ( ) ;
2126
27+ const { data : preferredHospital , isLoading : isLoadingHospital , error : hospitalError } = useGetPreferredHospital ( ) ;
28+ const { data : unlinkedPatients = [ ] } = useGetUnlinkedPatients ( ) ;
29+
2230 // State to handle sorting
2331 const [ sortConfig , setSortConfig ] = useState < {
2432 key : keyof OwnedEpisodeAPI | 'discharged' ;
@@ -105,6 +113,53 @@ const LandingPage: React.FC = () => {
105113 < DashboardText > Loading surgeon summary...</ DashboardText >
106114 ) }
107115
116+ { /* Display unlinked patients section */ }
117+ { isLoadingHospital ? (
118+ < DashboardText > Loading preferred hospital...</ DashboardText >
119+ ) : hospitalError ? (
120+ < DashboardText style = { { color : 'red' } } >
121+ Failed to load preferred hospital: { hospitalError . message }
122+ </ DashboardText >
123+ ) : ! preferredHospital || Object . keys ( preferredHospital ) . length === 0 ? (
124+ < DashboardText style = { { color : 'red' , fontStyle : 'italic' } } >
125+ Configure your preferred hospital to view any patients missing an episode.
126+ </ DashboardText >
127+ ) : unlinkedPatients . length > 0 ? (
128+ < div style = { { marginBottom : '2rem' } } >
129+ < DashboardTextHeader >
130+ < h2 > Patients without Episodes Registered in Your Hospital</ h2 >
131+ </ DashboardTextHeader >
132+ < div style = { { maxHeight : '150px' , overflowY : 'auto' } } >
133+ < table style = { { width : '100%' , borderCollapse : 'collapse' } } >
134+ < thead >
135+ < tr >
136+ < th style = { { border : '1px solid lightgrey' , padding : '8px' } } > Patient Name</ th >
137+ < th style = { { border : '1px solid lightgrey' , padding : '8px' } } > Patient Hospital ID</ th >
138+ </ tr >
139+ </ thead >
140+ < tbody >
141+ { unlinkedPatients . map ( ( patient ) => (
142+ < tr
143+ key = { patient . id }
144+ onClick = { ( ) =>
145+ history . push ( `${ urls . patients ( ) } /${ patient . hospital_id } /${ patient . id } ` )
146+ }
147+ style = { {
148+ backgroundColor : '#fc7c7c' ,
149+ cursor : 'pointer' ,
150+ borderBottom : '1px solid lightgrey' ,
151+ } }
152+ >
153+ < td style = { { border : '1px solid lightgrey' , padding : '8px' } } > { patient . full_name } </ td >
154+ < td style = { { border : '1px solid lightgrey' , padding : '8px' } } > { patient . patient_hospital_id } </ td >
155+ </ tr >
156+ ) ) }
157+ </ tbody >
158+ </ table >
159+ </ div >
160+ </ div >
161+ ) : null }
162+
108163 { /* Render owned episodes table */ }
109164 { ownedEpisodes ? (
110165 ownedEpisodes . length > 0 ? (
0 commit comments