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 sample test type filter to sample management system #1883

Merged
merged 2 commits into from
Oct 25, 2021
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
20 changes: 10 additions & 10 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,16 @@ export const BLOOD_GROUPS = [
];

export const SAMPLE_TYPE_CHOICES = [
"UNKNOWN",
"BA/ETA",
"TS/NPS/NS",
"Blood in EDTA",
"Acute Sera",
"Covalescent sera",
"Biopsy",
"AMR",
"Communicable Diseases",
"OTHER TYPE",
{ id: 0, text: "UNKNOWN" },
{ id: 1, text: "BA/ETA" },
{ id: 2, text: "TS/NPS/NS" },
{ id: 3, text: "Blood in EDTA" },
{ id: 4, text: "Acute Sera" },
{ id: 5, text: "Covalescent sera" },
{ id: 6, text: "Biopsy" },
{ id: 7, text: "AMR" },
{ id: 8, text: "Communicable Diseases" },
{ id: 9, text: "OTHER TYPE" },
];

export const ICMR_CATEGORY = [
Expand Down
24 changes: 22 additions & 2 deletions src/Components/Patient/SampleFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useState, useEffect } from "react";
import { SelectField } from "../Common/HelperInputFields";
import { SAMPLE_TEST_STATUS, SAMPLE_TEST_RESULT } from "../../Common/constants";
import {
SAMPLE_TEST_STATUS,
SAMPLE_TEST_RESULT,
SAMPLE_TYPE_CHOICES,
} from "../../Common/constants";
import { navigate } from "raviger";
import { FacilitySelect } from "../Common/FacilitySelect";
import { FacilityModel } from "../Facility/models";
Expand All @@ -23,6 +27,7 @@ export default function UserFilter(props: any) {
result: filter.result || "",
facility: filter.facility || "",
facility_ref: filter.facility_ref || null,
sample_type: filter.sample_type || "",
});

const [isFacilityLoading, setFacilityLoading] = useState(false);
Expand All @@ -33,6 +38,7 @@ export default function UserFilter(props: any) {
result: "",
facility: "",
facility_ref: null,
sample_type: "",
};

const handleChange = (event: any) => {
Expand All @@ -45,11 +51,12 @@ export default function UserFilter(props: any) {
};

const applyFilter = () => {
const { status, result, facility } = filterState;
const { status, result, facility, sample_type } = filterState;
const data = {
status: status || "",
result: result || "",
facility: facility || "",
sample_type: sample_type || "",
};
onChange(data);
};
Expand Down Expand Up @@ -124,6 +131,19 @@ export default function UserFilter(props: any) {
/>
</div>

<div className="w-64 flex-none">
<div className="text-sm font-semibold">Sample Test Type</div>
<SelectField
name="sample_type"
variant="outlined"
margin="dense"
value={filterState.sample_type}
options={[{ id: "", text: "SELECT" }, ...SAMPLE_TYPE_CHOICES]}
onChange={handleChange}
errors=""
/>
</div>

<div className="w-64 flex-none">
<span className="text-sm font-semibold">Facility</span>
<div className="">
Expand Down
8 changes: 4 additions & 4 deletions src/Components/Patient/SampleTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import Container from "@material-ui/core/Container";
const Loading = loadable(() => import("../Common/Loading"));
const PageTitle = loadable(() => import("../Common/PageTitle"));

const sampleTestTypes = [...SAMPLE_TYPE_CHOICES];
const icmrCategories = [...ICMR_CATEGORY];
const sampleTestTypes = [...SAMPLE_TYPE_CHOICES];

const initForm: SampleTestModel = {
isFastTrack: false,
Expand All @@ -37,7 +37,7 @@ const initForm: SampleTestModel = {
has_sari: false,
is_atypical_presentation: false,
is_unusual_course: false,
sample_type: "UNKNOWN",
sample_type: "0",
icmr_category: "Cat 0",
sample_type_other: "",
};
Expand Down Expand Up @@ -144,7 +144,7 @@ export const SampleTest = (props: any) => {
}
break;
case "sample_type_other":
if (state.form.sample_type === "OTHER TYPE" && !state.form[field]) {
if (state.form.sample_type === "9" && !state.form[field]) {
errors[field] = "Please provide details of the sample type";
invalidForm = true;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ export const SampleTest = (props: any) => {
sample_type: state.form.sample_type,
icmr_category: state.form.icmr_category,
sample_type_other:
state.form.sample_type === "OTHER TYPE"
state.form.sample_type === "9"
? state.form.sample_type_other
: undefined,
};
Expand Down
14 changes: 14 additions & 0 deletions src/Components/Patient/SampleViewAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
SAMPLE_TEST_RESULT,
ROLE_STATUS_MAP,
SAMPLE_FLOW_RULES,
SAMPLE_TYPE_CHOICES,
} from "../../Common/constants";
import { statusType, useAbortableEffect } from "../../Common/utils";
import { getTestList, patchSample, getFacilityV2 } from "../../Redux/actions";
Expand Down Expand Up @@ -79,6 +80,7 @@ export default function SampleViewAdmin(props: any) {
status: qParams.status || undefined,
result: qParams.result || undefined,
facility: qParams.facility || "",
sample_type: qParams.sample_type || undefined,
})
);
if (!status.aborted) {
Expand All @@ -97,6 +99,7 @@ export default function SampleViewAdmin(props: any) {
qParams.status,
qParams.result,
qParams.facility,
qParams.sample_type,
]
);

Expand Down Expand Up @@ -510,6 +513,17 @@ export default function SampleViewAdmin(props: any) {
?.text,
"result"
)}
{badge(
"Sample Test Type",
SAMPLE_TYPE_CHOICES.find(
(type) => type.id.toString() === qParams.sample_type
)?.text,
"sample_type"
)}
{qParams.facility &&
sample[0] &&
sample[0].facility_object &&
badge("Facility", sample[0].facility_object.name, "facility")}
{badge("Facility", facilityName, "facility")}
</div>
</div>
Expand Down