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

Added occupation field in patient register #2725

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
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
35 changes: 33 additions & 2 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import ExpandMoreIcon from "@material-ui/icons/ExpandMore";

const Loading = loadable(() => import("../Common/Loading"));
const PageTitle = loadable(() => import("../Common/PageTitle"));

// eslint-disable-next-line @typescript-eslint/no-var-requires
const debounce = require("lodash.debounce");

interface PatientRegisterProps extends PatientModel {
Expand Down Expand Up @@ -89,6 +89,7 @@ const genderTypes = [
},
...GENDER_TYPES,
];

const diseaseStatus = [...DISEASE_STATUS];
const bloodGroups = [...BLOOD_GROUPS];
const testType = [...TEST_TYPE];
Expand All @@ -98,6 +99,7 @@ const initForm: any = {
name: "",
age: "",
gender: "",
occupation: "",
phone_number: "",
emergency_phone_number: "",
blood_group: "",
Expand Down Expand Up @@ -306,6 +308,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
form["gender"] = res.data.gender
? parseGenderFromExt(res.data.gender, state.form.gender)
: state.form.gender;
form["occupation"] = res.data.occupation;
form["srf_id"] = res.data.srf_id ? res.data.srf_id : state.form.srf_id;

form["state"] = res.data.district_object
Expand Down Expand Up @@ -362,6 +365,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
...res.data,
nationality: res.data.nationality ? res.data.nationality : "India",
gender: res.data.gender ? res.data.gender : "",
occupation: res.data.occupation ? res.data.occupation : "",
cluster_name: res.data.cluster_name ? res.data.cluster_name : "",
state: res.data.state ? res.data.state : "",
district: res.data.district ? res.data.district : "",
Expand Down Expand Up @@ -491,7 +495,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
}
}
fetchFacilityName();
}, [dispatchAction, facilityId]);
}, [dispatchAction, facilityId, id]);

const validateForm = () => {
const errors = { ...initError };
Expand All @@ -510,6 +514,13 @@ export const PatientRegister = (props: PatientRegisterProps) => {
invalidForm = true;
}
return;
case "occupation":
if (!state.form[field]) {
errors[field] = "Field is required";
if (!error_div) error_div = field;
invalidForm = true;
}
return;
case "permanent_address":
if (!sameAddress) {
if (!state.form[field]) {
Expand Down Expand Up @@ -725,6 +736,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
name: state.form.name,
pincode: state.form.pincode ? state.form.pincode : undefined,
gender: Number(state.form.gender),
occupation: state.form.occupation,
nationality: state.form.nationality,
is_antenatal: state.form.is_antenatal,

Expand Down Expand Up @@ -1142,6 +1154,25 @@ export const PatientRegister = (props: PatientRegisterProps) => {
errors={state.errors.gender}
/>
</div>
<div data-testid="occupation" id="occupation-div">
<InputLabel
htmlFor="occupation"
id="occupation-label"
required
>
Occupation
</InputLabel>
<TextInputField
id="occupation"
name="occupation"
variant="outlined"
margin="dense"
type="text"
value={state.form.occupation}
onChange={handleChange}
errors={state.errors.occupation}
/>
</div>

<Collapse
in={String(state.form.gender) === "2"}
Expand Down