+
{translation.patients}
- {filteredActive.length >= 0 && (
-
-
{`${translation.active} (${filteredActive.length})`}
- {filteredActive.map(patient => (
-
-
{patient.name}
-
-
-
-
-
- ))}
-
- )}
- {filteredUnassigned.length >= 0 && (
-
-
{`${translation.unassigned} (${filteredUnassigned.length})`}
- {filteredUnassigned.map(patient => (
-
-
{patient.name}
-
-
-
-
-
- ))}
-
- )}
- {filteredDischarged.length >= 0 && (
-
-
{`${translation.discharged} (${filteredDischarged.length})`}
- {filteredDischarged.map(patient => (
-
- {patient.name}
-
-
- ))}
+
+
+ {filteredActive.length >= 0 && (
+
{`${translation.active} (${filteredActive.length})`}}
+ >
+ {filteredActive.map(patient => (
+
+
{patient.name}
+
+
+
+
+
+ ))}
+
+ )}
+ {filteredUnassigned.length >= 0 && (
+
{`${translation.unassigned} (${filteredUnassigned.length})`}}
+ >
+ {filteredUnassigned.map(patient => (
+
+
{patient.name}
+
+
+
+
+
+ ))}
+
+ )}
+ {filteredDischarged.length >= 0 && (
+
{`${translation.discharged} (${filteredDischarged.length})`}}
+ >
+ {filteredDischarged.map(patient => (
+
+ {patient.name}
+ { /* TODO implement when backend endpoint exists
+
+ */}
+
+ ))}
+
+ )}
- )}
+
)
}
diff --git a/tasks/mutations/patient_mutations.ts b/tasks/mutations/patient_mutations.ts
index 8a294bde..565bb1c1 100644
--- a/tasks/mutations/patient_mutations.ts
+++ b/tasks/mutations/patient_mutations.ts
@@ -10,7 +10,8 @@ import {
AssignBedRequest,
UnassignBedRequest,
GetPatientDetailsResponse,
- GetPatientAssignmentByWardRequest
+ GetPatientAssignmentByWardRequest,
+ GetPatientListRequest
} from '@helpwave/proto-ts/proto/services/task_svc/v1/patient_svc_pb'
import { patientService, getAuthenticatedGrpcMetadata } from '../utils/grpc'
import type { BedWithPatientID } from './bed_mutations'
@@ -185,24 +186,46 @@ export const usePatientAssignmentByWardQuery = (wardID: string) => {
})
}
-// TODO remove this comment
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const usePatientListQuery = (wardID: string) => {
- const queryClient = useQueryClient()
+export const usePatientListQuery = (organisationID?: string) => {
return useQuery({
queryKey: [patientsQueryKey, 'patientList'],
queryFn: async () => {
- // TODO do grpc request
+ const req = new GetPatientListRequest()
+ if (organisationID) {
+ req.setOrganisationId(organisationID)
+ }
+ const res = await patientService.getPatientList(req, getAuthenticatedGrpcMetadata())
- return queryClient.getQueryData
([patientsQueryKey, 'patientList'])
- },
- initialData: {
- active: [
- ],
- unassigned: [
- ],
- discharged: [
- ]
+ const patientList: PatientListDTO = {
+ active: res.getActiveList().map(value => {
+ const room = value.getRoom()
+ const bed = value.getBed()
+
+ if (!room) {
+ console.error('no room for active patient in PatientList')
+ }
+
+ if (!bed) {
+ console.error('no room for active patient in PatientList')
+ }
+ return ({
+ id: value.getId(),
+ name: value.getHumanReadableIdentifier(),
+ bed: { id: bed?.getId() ?? '', name: bed?.getName() ?? '' },
+ room: { id: room?.getId() ?? '', name: room?.getName() ?? '' }
+ })
+ }),
+ discharged: res.getDischargedPatientsList().map(value => ({
+ id: value.getId(),
+ name: value.getHumanReadableIdentifier(),
+ })),
+ unassigned: res.getUnassignedPatientsList().map(value => ({
+ id: value.getId(),
+ name: value.getHumanReadableIdentifier(),
+ }))
+ }
+
+ return patientList
}
})
}
@@ -226,7 +249,8 @@ export const usePatientCreateMutation = (callback: (patient: PatientDTO) => void
return patient
},
onSuccess: () => {
- queryClient.refetchQueries([roomsQueryKey]).catch(reason => console.log(reason))
+ queryClient.refetchQueries([roomsQueryKey]).catch(reason => console.error(reason))
+ queryClient.refetchQueries([patientsQueryKey]).catch(reason => console.error(reason))
}
})
}
@@ -252,26 +276,32 @@ export const usePatientUpdateMutation = (callback: (patient: PatientDTO) => void
return patient
},
onSuccess: () => {
- queryClient.refetchQueries([roomsQueryKey]).catch(reason => console.log(reason))
+ queryClient.refetchQueries([patientsQueryKey]).catch(reason => console.error(reason))
+ queryClient.refetchQueries([roomsQueryKey]).catch(reason => console.error(reason))
}
})
}
-export const usePatientDischargeMutation = (callback: () => void) => {
+export const usePatientDischargeMutation = (callback: () => void = noop) => {
const queryClient = useQueryClient()
return useMutation({
- mutationFn: async (patient: PatientDTO) => {
+ mutationFn: async (patientID: string) => {
const req = new DischargePatientRequest()
- req.setId(patient.id)
+ req.setId(patientID)
const res = await patientService.dischargePatient(req, getAuthenticatedGrpcMetadata())
- // TODO some check whether request was successful
+ if (!res.toObject()) {
+ console.error('error in PatientDischarge')
+ }
- queryClient.refetchQueries([roomsQueryKey, roomOverviewsQueryKey]).catch(reason => console.log(reason))
callback()
return res.toObject()
},
+ onSuccess: () => {
+ queryClient.refetchQueries([roomsQueryKey, roomOverviewsQueryKey]).catch(reason => console.error(reason))
+ queryClient.refetchQueries([patientsQueryKey]).catch(reason => console.error(reason))
+ }
})
}
@@ -314,9 +344,12 @@ export const useUnassignMutation = (callback: () => void) => {
console.error('assign bed request failed')
}
- queryClient.refetchQueries([roomsQueryKey, roomOverviewsQueryKey]).then()
callback()
return res.toObject()
},
+ onSuccess: () => {
+ queryClient.refetchQueries([roomsQueryKey, roomOverviewsQueryKey]).then()
+ queryClient.refetchQueries([patientsQueryKey]).then()
+ }
})
}
diff --git a/tasks/package.json b/tasks/package.json
index 3ae886cd..d587a50c 100644
--- a/tasks/package.json
+++ b/tasks/package.json
@@ -13,7 +13,7 @@
"@dnd-kit/sortable": "7.0.2",
"@headlessui/react": "1.7.16",
"@helpwave/common": "workspace:*",
- "@helpwave/proto-ts": "0.19.0-d9220d1.0",
+ "@helpwave/proto-ts": "0.20.0-673c02c.0",
"@radix-ui/react-checkbox": "1.0.4",
"@tanstack/react-query": "4.32.6",
"@tanstack/react-table": "8.9.3",