Skip to content

Commit

Permalink
include next suggested date in next encounter modal
Browse files Browse the repository at this point in the history
  • Loading branch information
lache-melvin committed Jan 28, 2025
1 parent 269884d commit 18510e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions client/packages/system/src/Encounter/DetailView/DetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import { getLogicalStatus } from '../utils';
import { PatientTabValue } from '../../Patient/PatientView/PatientView';
import { VaccinationCard } from '../../Vaccination/Components/VaccinationCard';
import { ScheduleNextEncounterModal } from './ScheduleNextEncounterModal';
import { usePatientVaccineCard } from '../../Vaccination/api/usePatientVaccineCard';
import { getNextVaccinationEncounterDate } from './helpers';

const getPatientBreadcrumbSuffix = (
encounter: EncounterFragment,
Expand Down Expand Up @@ -166,6 +168,15 @@ export const DetailView: FC = () => {
isError,
} = useEncounter.document.byId(id);

// If this is a vaccination encounter, we want to use the suggested
// next vaccination dates for the next encounter
const {
query: { data: vaccineCard },
} = usePatientVaccineCard(encounter?.programEnrolment?.id ?? '');
const suggestedNextEncounterDate = getNextVaccinationEncounterDate(
vaccineCard?.items ?? []
);

const handleSave = useEncounter.document.upsertDocument(
encounter?.patient.id ?? '',
encounter?.type ?? ''
Expand Down Expand Up @@ -363,6 +374,7 @@ export const DetailView: FC = () => {
encounterConfig={encounter.document.documentRegistry}
onClose={nextEncounterModal.toggleOff}
patientId={encounter.patient.id ?? ''}
suggestedDate={suggestedNextEncounterDate}
/>
)}
<Toolbar onChange={updateEncounter} encounter={encounter} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ export const ScheduleNextEncounterModal = ({
patientId,
encounterConfig,
onClose,
suggestedDate,
}: {
patientId: string;
encounterConfig: DocumentRegistryFragment;
onClose: () => void;
suggestedDate: Date | null;
}) => {
const { user, storeId } = useAuthContext();
const t = useTranslation();
const [draft, setDraft] = useState<EncounterSchema>({
createdDatetime: new Date().toISOString(),
startDatetime: suggestedDate?.toISOString(),
createdBy: { id: user?.id ?? '', username: user?.name ?? '' },
status: EncounterNodeStatus.Pending,
location: {
Expand Down

0 comments on commit 18510e5

Please sign in to comment.