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

Moved covid vaccination related fields to medical history section in PatientRegister #2554

Closed
wants to merge 1 commit 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
289 changes: 137 additions & 152 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ import {
GENDER_TYPES,
MEDICAL_HISTORY_CHOICES,
TEST_TYPE,
DESIGNATION_HEALTH_CARE_WORKER,
VACCINES,
} from "../../Common/constants";
import countryList from "../../Common/static/countries.json";
import statesList from "../../Common/static/states.json";
import { statusType, useAbortableEffect } from "../../Common/utils";
import {
createPatient,
Expand Down Expand Up @@ -66,10 +64,6 @@ const PageTitle = loadable(() => import("../Common/PageTitle"));
// eslint-disable-next-line @typescript-eslint/no-var-requires
const debounce = require("lodash.debounce");

const placesList = countryList.concat(
statesList.filter((i: string) => i !== "Kerala")
);

interface PatientRegisterProps extends PatientModel {
facilityId: number;
}
Expand All @@ -81,29 +75,23 @@ interface medicalHistoryModel {
}

const medicalHistoryTypes = MEDICAL_HISTORY_CHOICES.filter((i) => i.id !== 1);

const medicalHistoryChoices = medicalHistoryTypes.reduce(
(acc: Array<{ [x: string]: string }>, cur) => [
...acc,
{ [`medical_history_${cur.id}`]: "" },
],
[]
);

const genderTypes = [
{
id: 0,
text: "Select",
},
...GENDER_TYPES,
];

const diseaseStatus = [...DISEASE_STATUS];

const bloodGroups = [...BLOOD_GROUPS];

const testType = [...TEST_TYPE];
const designationOfHealthWorkers = [...DESIGNATION_HEALTH_CARE_WORKER];
const vaccines = ["Select", ...VACCINES];

const initForm: any = {
Expand Down Expand Up @@ -510,7 +498,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
let invalidForm = false;
let error_div = "";

Object.keys(state.form).forEach((field, i) => {
Object.keys(state.form).forEach((field) => {
let phoneNumber, emergency_phone_number;
switch (field) {
case "address":
Expand Down Expand Up @@ -855,13 +843,6 @@ export const PatientRegister = (props: PatientRegisterProps) => {
}
};

const handleCheckboxFieldChange = (e: any) => {
const form = { ...state.form };
const { checked, name } = e.target;
form[name] = checked;
dispatch({ type: "set_form", form });
};

const handleMedicalCheckboxChange = (e: any, id: number) => {
const form = { ...state.form };
const values = state.form.medical_history;
Expand Down Expand Up @@ -1527,138 +1508,6 @@ export const PatientRegister = (props: PatientRegisterProps) => {
</Collapse>
</div>

<div id="is_vaccinated-div">
<InputLabel
id="is_vaccinated"
htmlFor="is_vaccinated"
>
Is patient Vaccinated against COVID?
</InputLabel>
<RadioGroup
aria-label="is_vaccinated"
id="is_vaccinated"
name="is_vaccinated"
value={state.form.is_vaccinated}
onChange={handleChange}
style={{ padding: "0px 5px" }}
>
<Box display="flex" flexDirection="row">
<FormControlLabel
value="true"
control={<Radio />}
label="Yes"
/>
<FormControlLabel
value="false"
control={<Radio />}
label="No"
/>
</Box>
</RadioGroup>
</div>
<Collapse
in={String(state.form.is_vaccinated) === "true"}
timeout="auto"
unmountOnExit
className="col-span-2"
>
{
<div className="grid gap-4 xl:gap-x-20 xl:gap-y-6 grid-cols-1 md:grid-cols-2">
<div id="covin_id-div">
<InputLabel
id="covin_id-label"
htmlFor="covin_id"
>
COWIN ID
</InputLabel>
<TextInputField
id="covin_id"
name="covin_id"
variant="outlined"
margin="dense"
type="text"
value={state.form.covin_id}
onChange={handleChange}
errors={state.errors.covin_id}
/>
</div>
<div id="number_of_doses-div">
<InputLabel
id="doses-label"
htmlFor="number_of_doses"
>
Number of doses
</InputLabel>
<RadioGroup
aria-label="number_of_doses"
id="number_of_doses"
name="number_of_doses"
value={state.form.number_of_doses}
onChange={handleChange}
style={{ padding: "0px 5px" }}
>
<Box display="flex" flexDirection="row">
<FormControlLabel
value="1"
control={<Radio />}
label="1"
/>
<FormControlLabel
value="2"
control={<Radio />}
label="2"
/>
</Box>
</RadioGroup>
</div>
<div id="vaccine_name-div">
<InputLabel
id="vaccine-name-label"
htmlFor="vaccine_name"
required
>
Vaccine Name
</InputLabel>
<SelectField
labelId="vaccine_name"
name="vaccine_name"
variant="outlined"
margin="dense"
optionArray={true}
value={state.form.vaccine_name}
options={vaccines}
onChange={handleChange}
errors={state.errors.vaccine_name}
/>
</div>
<div id="last_vaccinated_date-div">
<InputLabel
id="last_vaccinated_date-label"
htmlFor="last_vaccinated_date"
required
>
Last Date of Vaccination
</InputLabel>
<DateInputField
id="last_vaccinated_date"
fullWidth={true}
value={state.form.last_vaccinated_date}
onChange={(date) =>
handleDateChange(
date,
"last_vaccinated_date"
)
}
errors={state.errors.last_vaccinated_date}
inputVariant="outlined"
margin="dense"
openTo="year"
disableFuture={true}
/>
</div>
</div>
}
</Collapse>
<div id="contact_with_confirmed_carrier-div">
<InputLabel htmlFor="contact_with_confirmed_carrier">
Contact with confirmed Covid patient?
Expand Down Expand Up @@ -1968,6 +1817,142 @@ export const PatientRegister = (props: PatientRegisterProps) => {
errors={state.errors.ongoing_medication}
/>
</div>

<div>
<div id="is_vaccinated-div">
<InputLabel
id="is_vaccinated"
htmlFor="is_vaccinated"
>
Is patient Vaccinated against COVID?
</InputLabel>
<RadioGroup
aria-label="is_vaccinated"
id="is_vaccinated"
name="is_vaccinated"
value={state.form.is_vaccinated}
onChange={handleChange}
style={{ padding: "0px 5px" }}
>
<Box display="flex" flexDirection="row">
<FormControlLabel
value="true"
control={<Radio />}
label="Yes"
/>
<FormControlLabel
value="false"
control={<Radio />}
label="No"
/>
</Box>
</RadioGroup>
</div>
<Collapse
in={String(state.form.is_vaccinated) === "true"}
timeout="auto"
unmountOnExit
className="col-span-2"
>
{
<div className="grid gap-4 xl:gap-x-20 xl:gap-y-6 grid-cols-1 md:grid-cols-2">
<div id="covin_id-div">
<InputLabel
id="covin_id-label"
htmlFor="covin_id"
>
COWIN ID
</InputLabel>
<TextInputField
id="covin_id"
name="covin_id"
variant="outlined"
margin="dense"
type="text"
value={state.form.covin_id}
onChange={handleChange}
errors={state.errors.covin_id}
/>
</div>
<div id="number_of_doses-div">
<InputLabel
id="doses-label"
htmlFor="number_of_doses"
>
Number of doses
</InputLabel>
<RadioGroup
aria-label="number_of_doses"
id="number_of_doses"
name="number_of_doses"
value={state.form.number_of_doses}
onChange={handleChange}
style={{ padding: "0px 5px" }}
>
<Box display="flex" flexDirection="row">
<FormControlLabel
value="1"
control={<Radio />}
label="1"
/>
<FormControlLabel
value="2"
control={<Radio />}
label="2"
/>
</Box>
</RadioGroup>
</div>
<div id="vaccine_name-div">
<InputLabel
id="vaccine-name-label"
htmlFor="vaccine_name"
required
>
Vaccine Name
</InputLabel>
<SelectField
labelId="vaccine_name"
name="vaccine_name"
variant="outlined"
margin="dense"
optionArray={true}
value={state.form.vaccine_name}
options={vaccines}
onChange={handleChange}
errors={state.errors.vaccine_name}
/>
</div>
<div id="last_vaccinated_date-div">
<InputLabel
id="last_vaccinated_date-label"
htmlFor="last_vaccinated_date"
required
>
Last Date of Vaccination
</InputLabel>
<DateInputField
id="last_vaccinated_date"
fullWidth={true}
value={state.form.last_vaccinated_date}
onChange={(date) =>
handleDateChange(
date,
"last_vaccinated_date"
)
}
errors={state.errors.last_vaccinated_date}
inputVariant="outlined"
margin="dense"
openTo="year"
disableFuture={true}
/>
</div>
</div>
}
</Collapse>
</div>

<div className="md:col-span-2">
<InputLabel id="med-history-label">
Any medical history? (Optional Information)
Expand Down