improvement: a flow added to create treatment plan for searched patients with no treatment history.
This commit is contained in:
@@ -684,6 +684,8 @@
|
||||
"purposeLabel": "Purpose:",
|
||||
"loadingAppointments": "Loading appointments…",
|
||||
"selectDayWithAppointment": "Search for a patient or select a visit from the day strip.",
|
||||
"noTreatmentFoundTitle": "No treatment found",
|
||||
"noTreatmentFoundBody": "There is no treatment or visit for {name} yet. You can add one with the {action} button in the rail.",
|
||||
"confirmDiscard": "You have unsaved changes. Discard them and continue?",
|
||||
"errorChooseOrg": "Choose at least one active organization to send this case.",
|
||||
"successCaseSent": "Case sent to selected organizations.",
|
||||
|
||||
@@ -685,6 +685,8 @@
|
||||
"purposeLabel": "هدف:",
|
||||
"loadingAppointments": "در حال بارگذاری نوبتها...",
|
||||
"selectDayWithAppointment": "برای بیمار جستجو کنید یا یک ویزیت را از نوار روز انتخاب کنید.",
|
||||
"noTreatmentFoundTitle": "درمانی یافت نشد",
|
||||
"noTreatmentFoundBody": "هنوز درمان یا ویزیتی برای {name} ثبت نشده است. میتوانید با دکمه {action} در نوار کناری یکی اضافه کنید.",
|
||||
"confirmDiscard": "تغییرات ذخیرهنشده دارید. آنها را کنار بگذارید و ادامه دهید؟",
|
||||
"errorChooseOrg": "حداقل یک سازمان فعال را برای ارسال این پرونده انتخاب کنید.",
|
||||
"successCaseSent": "پرونده به سازمانهای انتخاب شده ارسال شد.",
|
||||
|
||||
@@ -684,6 +684,8 @@
|
||||
"purposeLabel": "Doel:",
|
||||
"loadingAppointments": "Afspraken laden...",
|
||||
"selectDayWithAppointment": "Zoek een patiënt of kies een bezoek uit de dagstrook.",
|
||||
"noTreatmentFoundTitle": "Geen behandeling gevonden",
|
||||
"noTreatmentFoundBody": "Er is nog geen behandeling of bezoek voor {name}. U kunt er een toevoegen met de knop {action} in de zijbalk.",
|
||||
"confirmDiscard": "U heeft niet-opgeslagen wijzigingen. Wilt u deze negeren en doorgaan?",
|
||||
"errorChooseOrg": "Kies ten minste één actieve organisatie om deze case te verzenden.",
|
||||
"successCaseSent": "Case verzonden naar geselecteerde organisaties.",
|
||||
|
||||
@@ -550,6 +550,14 @@ export function TreatmentWorkspace({
|
||||
email: activePatient.email ?? null,
|
||||
}
|
||||
: null;
|
||||
const searchedWithoutLiveVisit = Boolean(searchedPatient) && !hasLiveContext;
|
||||
const showSearchedPatientLoading =
|
||||
searchedWithoutLiveVisit && (patientSearchBusy || historyLoading);
|
||||
const showNoTreatmentFound =
|
||||
searchedWithoutLiveVisit &&
|
||||
!patientSearchBusy &&
|
||||
!historyLoading &&
|
||||
history.length === 0;
|
||||
|
||||
const unreadUpdatesCount = unreadLabCases.length;
|
||||
const otherPatientsUnreadCount = useMemo(
|
||||
@@ -1570,26 +1578,51 @@ export function TreatmentWorkspace({
|
||||
return;
|
||||
}
|
||||
|
||||
const ok = await flushDraftSave();
|
||||
if (!ok) return;
|
||||
|
||||
setPatientSearchBusy(true);
|
||||
setSearchedPatient({
|
||||
id: patient.id,
|
||||
firstName: patient.firstName,
|
||||
lastName: patient.lastName,
|
||||
mobile: patient.mobile,
|
||||
email: patient.email,
|
||||
});
|
||||
try {
|
||||
const response = await treatmentsApi.listPatientHistory(patient.id, 1);
|
||||
const latest = response.data[0];
|
||||
if (latest) {
|
||||
const ok = await loadTreatmentIntoWorkspace(latest);
|
||||
if (!ok) {
|
||||
setSearchedPatient(null);
|
||||
const stripAppointment = appointments.find((row) => row.patientId === patient.id);
|
||||
const stripStandalone = standaloneTreatments.find(
|
||||
(row) => row.patientId === patient.id && !row.patient?.isWalkIn,
|
||||
);
|
||||
if (stripAppointment || stripStandalone) {
|
||||
draftHydratingRef.current = true;
|
||||
resetToLiveContext();
|
||||
setSearchedPatient(null);
|
||||
setNewTreatmentPickerOpen(false);
|
||||
setSelectionLocked(true);
|
||||
if (stripAppointment) {
|
||||
setSelectedAppointmentId(stripAppointment.id);
|
||||
setSelectedStandaloneId(null);
|
||||
} else if (stripStandalone) {
|
||||
setSelectedAppointmentId(null);
|
||||
setSelectedStandaloneId(stripStandalone.id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
await refreshHistory(patient.id);
|
||||
setSearchedPatient({
|
||||
id: patient.id,
|
||||
firstName: patient.firstName,
|
||||
lastName: patient.lastName,
|
||||
mobile: patient.mobile,
|
||||
email: patient.email,
|
||||
});
|
||||
resetToLiveContext();
|
||||
setNewTreatmentPickerOpen(false);
|
||||
setSelectedAppointmentId(null);
|
||||
setSelectedStandaloneId(null);
|
||||
setSelectionLocked(true);
|
||||
setHistory([]);
|
||||
setHistoryLoading(true);
|
||||
|
||||
const response = await treatmentsApi.listPatientHistory(patient.id, 1);
|
||||
const latest = response.data[0];
|
||||
if (latest) {
|
||||
await loadTreatmentIntoWorkspace(latest);
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
showError(getUserFacingError(error, tErrors, t('errorLoadHistory')));
|
||||
setSearchedPatient(null);
|
||||
@@ -1603,8 +1636,11 @@ export function TreatmentWorkspace({
|
||||
selectedStandalone?.patientId,
|
||||
searchedPatient?.id,
|
||||
hasLiveContext,
|
||||
flushDraftSave,
|
||||
appointments,
|
||||
standaloneTreatments,
|
||||
resetToLiveContext,
|
||||
loadTreatmentIntoWorkspace,
|
||||
refreshHistory,
|
||||
showError,
|
||||
t,
|
||||
tErrors,
|
||||
@@ -2371,6 +2407,24 @@ export function TreatmentWorkspace({
|
||||
</div>
|
||||
|
||||
<div className="space-y-3 min-w-0 w-full">
|
||||
{showSearchedPatientLoading ? (
|
||||
<div className="surface-card p-6">
|
||||
<p className="text-sm text-text-muted">{t('loading')}</p>
|
||||
</div>
|
||||
) : showNoTreatmentFound ? (
|
||||
<div className="surface-card w-full p-6 space-y-3">
|
||||
<h2 className="text-lg font-semibold text-text-primary">
|
||||
{t('noTreatmentFoundTitle')}
|
||||
</h2>
|
||||
<p className="text-sm text-text-secondary">
|
||||
{t('noTreatmentFoundBody', {
|
||||
name: activePatientName ?? '',
|
||||
action: t('newTreatment'),
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<TreatmentDetailsEditor
|
||||
details={details}
|
||||
activeDetailId={activeDetailId}
|
||||
@@ -2660,6 +2714,8 @@ export function TreatmentWorkspace({
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user