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

Adds support specifying and filtering by ration card category for patients #7926

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1404,3 +1404,5 @@ export const PATIENT_NOTES_THREADS = {
Doctors: 10,
Nurses: 20,
} as const;

export const RATION_CARD_CATEGORY = ["BPL", "APL", "NO_CARD"] as const;
8 changes: 8 additions & 0 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export const PatientManager = () => {
qParams.date_declared_positive_before || undefined,
date_declared_positive_after:
qParams.date_declared_positive_after || undefined,
ration_card_category: qParams.ration_card_category || undefined,
last_consultation_medico_legal_case:
qParams.last_consultation_medico_legal_case || undefined,
last_consultation_encounter_date_before:
Expand Down Expand Up @@ -960,6 +961,13 @@ export const PatientManager = () => {
"Is Medico-Legal Case",
"last_consultation_medico_legal_case",
),
value(
"Ration Card Category",
"ration_card_category",
qParams.ration_card_category
? t(`ration_card__${qParams.ration_card_category}`)
: "",
),
value(
"Facility",
"facility",
Expand Down
22 changes: 22 additions & 0 deletions src/Components/Patient/PatientFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
FACILITY_TYPES,
GENDER_TYPES,
PATIENT_FILTER_CATEGORIES,
RATION_CARD_CATEGORY,
} from "../../Common/constants";
import useConfig from "../../Common/hooks/useConfig";
import useMergeState from "../../Common/hooks/useMergeState";
Expand All @@ -31,11 +32,14 @@ import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";
import request from "../../Utils/request/request";
import useAuthUser from "../../Common/hooks/useAuthUser";
import { SelectFormField } from "../Form/FormFields/SelectFormField";
import { useTranslation } from "react-i18next";

const getDate = (value: any) =>
value && dayjs(value).isValid() && dayjs(value).toDate();

export default function PatientFilter(props: any) {
const { t } = useTranslation();
const authUser = useAuthUser();
const { kasp_enabled, kasp_string } = useConfig();
const { filter, onChange, closeFilter, removeFilters } = props;
Expand All @@ -59,6 +63,7 @@ export default function PatientFilter(props: any) {
age_min: filter.age_min || null,
age_max: filter.age_max || null,
date_declared_positive: filter.date_declared_positive || null,
ration_card_category: filter.ration_card_category || null,
last_consultation_medico_legal_case:
filter.last_consultation_medico_legal_case || null,
last_consultation_encounter_date_before:
Expand Down Expand Up @@ -171,6 +176,7 @@ export default function PatientFilter(props: any) {
gender,
age_min,
age_max,
ration_card_category,
last_consultation_medico_legal_case,
last_consultation_encounter_date_before,
last_consultation_encounter_date_after,
Expand Down Expand Up @@ -214,6 +220,7 @@ export default function PatientFilter(props: any) {
created_date_after: dateQueryString(created_date_after),
modified_date_before: dateQueryString(modified_date_before),
modified_date_after: dateQueryString(modified_date_after),
ration_card_category,
last_consultation_medico_legal_case:
last_consultation_medico_legal_case || "",
last_consultation_encounter_date_before: dateQueryString(
Expand Down Expand Up @@ -467,6 +474,21 @@ export default function PatientFilter(props: any) {
}
/>
</div>
<SelectFormField
name="ration_card_category"
label="Ration Card Category"
placeholder="Select"
options={RATION_CARD_CATEGORY}
optionLabel={(o) => t(`ration_card__${o}`)}
optionValue={(o) => o}
value={filterState.ration_card_category}
onChange={(e) =>
setFilterState({
...filterState,
[e.name]: e.value,
})
}
/>
</div>
</AccordionV2>
<AccordionV2
Expand Down
27 changes: 14 additions & 13 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,22 +411,13 @@ export const PatientHome = (props: any) => {
{patientData.facility_object?.name || "-"}
</h3>
<p className="mb-7 mt-4 text-sm font-medium text-zinc-500">
{patientGender} | {patientData.blood_group || "-"}
{patientGender} | {patientData.blood_group || "-"} | Born on{" "}
{patientData.date_of_birth
? formatDate(patientData.date_of_birth)
: patientData.year_of_birth}
</p>
</div>
<div className="mb-8 mt-2 grid grid-cols-1 gap-x-4 gap-y-2 md:grid-cols-2 md:gap-y-8 lg:grid-cols-4">
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
{patientData.date_of_birth
? "Date of Birth"
: "Year of Birth"}
</div>
<div className="mt-1 text-sm font-medium leading-5">
{patientData.date_of_birth
? formatDate(patientData.date_of_birth)
: patientData.year_of_birth}
</div>
</div>
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Phone
Expand Down Expand Up @@ -537,6 +528,16 @@ export const PatientHome = (props: any) => {
{parseOccupation(patientData.meta_info?.occupation) || "-"}
</div>
</div>
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Ration Card Category
</div>
<div className="mt-1 text-sm font-medium leading-5 ">
{patientData.ration_card_category
? t(`ration_card__${patientData.ration_card_category}`)
: "-"}
</div>
</div>
</div>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
GENDER_TYPES,
MEDICAL_HISTORY_CHOICES,
OCCUPATION_TYPES,
RATION_CARD_CATEGORY,
VACCINES,
} from "../../Common/constants";
import {
Expand Down Expand Up @@ -65,6 +66,7 @@ import SelectMenuV2 from "../Form/SelectMenuV2.js";
import Checkbox from "../Common/components/CheckBox.js";
import _ from "lodash";
import { ILocalBodies } from "../ExternalResult/models.js";
import { useTranslation } from "react-i18next";

const Loading = lazy(() => import("../Common/Loading"));
const PageTitle = lazy(() => import("../Common/PageTitle"));
Expand Down Expand Up @@ -130,6 +132,7 @@ const initForm: any = {
last_vaccinated_date: null,
abha_number: null,
...medicalHistoryChoices,
ration_card_category: null,
};

const initError = Object.assign(
Expand Down Expand Up @@ -169,6 +172,7 @@ export const parseOccupationFromExt = (occupation: Occupation) => {

export const PatientRegister = (props: PatientRegisterProps) => {
const authUser = useAuthUser();
const { t } = useTranslation();
const { goBack } = useAppHistory();
const { gov_data_api_key, enable_hcx, enable_abdm } = useConfig();
const { facilityId, id } = props;
Expand Down Expand Up @@ -750,6 +754,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
blood_group: formData.blood_group ? formData.blood_group : undefined,
medical_history,
is_active: true,
ration_card_category: formData.ration_card_category,
};
const { res, data: requestData } = id
? await request(routes.updatePatient, {
Expand Down Expand Up @@ -1702,6 +1707,14 @@ export const PatientRegister = (props: PatientRegisterProps) => {
optionLabel={(o) => o.text}
optionValue={(o) => o.id}
/>
<SelectFormField
{...field("ration_card_category")}
label="Ration Card Category"
placeholder="Select"
options={RATION_CARD_CATEGORY}
optionLabel={(o) => t(`ration_card__${o}`)}
optionValue={(o) => o}
/>
</>
) : (
<div id="passport_no-div">
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Patient/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PerformedByModel } from "../HCX/misc";
import {
CONSCIOUSNESS_LEVEL,
OCCUPATION_TYPES,
RATION_CARD_CATEGORY,
RHYTHM_CHOICES,
} from "../../Common/constants";

Expand Down Expand Up @@ -101,6 +102,7 @@ export interface PatientModel {
state?: number;
nationality?: string;
passport_no?: string;
ration_card_category?: (typeof RATION_CARD_CATEGORY)[number] | null;
date_of_test?: string;
date_of_result?: string; // keeping this to avoid errors in Death report
covin_id?: string;
Expand Down
5 changes: 4 additions & 1 deletion src/Locale/en/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,8 @@
"clear_all_filters": "Clear All Filters",
"summary": "Summary",
"report": "Report",
"treating_doctor":"Treating Doctor"
"treating_doctor": "Treating Doctor",
"ration_card__NO_CARD": "Non-card holder",
"ration_card__BPL": "BPL",
"ration_card__APL": "APL"
}
Loading