Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6263 suggest next date from vax card #6302

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
include next suggested date in next encounter modal
  • Loading branch information
lache-melvin committed Jan 28, 2025
commit 18510e5d1892731a67d5e58ff549145b288f215f
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
Loading