Skip to content

Commit

Permalink
Prefill Searched Phone Number in Patient Creation form (#9643)
Browse files Browse the repository at this point in the history
Co-authored-by: Amjith Titus <amjithtitus@Amjiths-MacBook-Pro.local>
Co-authored-by: Bodhish Thomas <bodhish@gmail.com>
Co-authored-by: Rithvik Nishad <rithvikn2001@gmail.com>
  • Loading branch information
4 people authored Jan 3, 2025
1 parent 39c4c52 commit 54781a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/components/Patient/PatientIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ export default function PatientIndex({ facilityId }: { facilityId: string }) {
});

const handleCreatePatient = useCallback(() => {
navigate(`/facility/${facilityId}/patient/create`);
}, [facilityId]);
const queryParams = phoneNumber ? { phone_number: phoneNumber } : {};

navigate(`/facility/${facilityId}/patient/create`, {
query: queryParams,
});
}, [facilityId, phoneNumber]);

function AddPatientButton({ outline }: { outline?: boolean }) {
return (
Expand Down
5 changes: 3 additions & 2 deletions src/components/Patient/PatientRegistration.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import careConfig from "@careConfig";
import { useMutation, useQuery } from "@tanstack/react-query";
import { navigate } from "raviger";
import { navigate, useQueryParams } from "raviger";
import { Fragment, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

Expand Down Expand Up @@ -59,6 +59,7 @@ interface PatientRegistrationPageProps {
export default function PatientRegistration(
props: PatientRegistrationPageProps,
) {
const [{ phone_number }] = useQueryParams();
const { patientId, facilityId } = props;
const { t } = useTranslation();
const { goBack } = useAppHistory();
Expand All @@ -69,7 +70,7 @@ export default function PatientRegistration(
const [_showAutoFilledPincode, setShowAutoFilledPincode] = useState(false);
const [form, setForm] = useState<Partial<PatientModel>>({
nationality: "India",
phone_number: "+91",
phone_number: phone_number || "+91",
emergency_phone_number: "+91",
});
const [feErrors, setFeErrors] = useState<
Expand Down

0 comments on commit 54781a5

Please sign in to comment.