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

New Patient Search and Register UI #9400

Merged
merged 33 commits into from
Dec 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2c9c3c1
search page
shivankacker Dec 12, 2024
64168bc
midway
shivankacker Dec 13, 2024
ee20536
merge conflicts
shivankacker Dec 13, 2024
a320c84
social profile
shivankacker Dec 14, 2024
607eb07
logic
shivankacker Dec 14, 2024
42cd4e9
fix merge conflicts
shivankacker Dec 14, 2024
f146193
validations left
shivankacker Dec 14, 2024
2f8671d
complete except some stuff
shivankacker Dec 15, 2024
673cc2f
added validation checks
shivankacker Dec 15, 2024
2f917f9
Merge branch 'form-field-v1' of https://github.com/ohcnetwork/care_fe…
shivankacker Dec 15, 2024
765e657
district autofill fixed
shivankacker Dec 15, 2024
fd50078
fixed district and ward on update
shivankacker Dec 15, 2024
6d838e1
add transfer module
shivankacker Dec 15, 2024
65fd607
fix merge conflicts
shivankacker Dec 16, 2024
c6da6b8
bug fixes
shivankacker Dec 16, 2024
dd9a0cc
fix age field
shivankacker Dec 16, 2024
3ea61dd
switch to absolute imports
shivankacker Dec 17, 2024
9231ecf
fix merge conflicts
shivankacker Dec 18, 2024
fda516f
duplicate loading solved, with other coderabbit improvements
shivankacker Dec 19, 2024
4f17160
updates
shivankacker Dec 19, 2024
1e6ba61
fix merge conflicts
shivankacker Dec 21, 2024
d24c033
Changes
shivankacker Dec 21, 2024
db0d353
listing page changes made
shivankacker Dec 21, 2024
9954b1e
fixes
shivankacker Dec 21, 2024
c414be8
change component name
shivankacker Dec 22, 2024
ce8ad70
file name change
shivankacker Dec 22, 2024
80d7743
fix merge conflicts
shivankacker Dec 23, 2024
9889929
changes
shivankacker Dec 23, 2024
510049c
switch to use mutation
shivankacker Dec 23, 2024
58a5653
moved validation to seperate file
shivankacker Dec 23, 2024
611a8ee
added ward number and fixed add patient button
shivankacker Dec 24, 2024
24550a5
enhancements
shivankacker Dec 24, 2024
4c03487
Merge branch 'form-field-v1' into patient-registration
bodhish Dec 24, 2024
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
Next Next commit
search page
  • Loading branch information
shivankacker committed Dec 12, 2024
commit 2c9c3c1dc93af770694eb3cd95b1827462940762
2 changes: 2 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
@@ -311,6 +311,7 @@
"age": "Age",
"all_changes_have_been_saved": "All changes have been saved",
"all_details": "All Details",
"all_patients": "All Patients",
"allergies": "Allergies",
"allow_transfer": "Allow Transfer",
"allowed_formats_are": "Allowed formats are",
@@ -1227,6 +1228,7 @@
"search_icd11_placeholder": "Search for ICD-11 Diagnoses",
"search_investigation_placeholder": "Search Investigation & Groups",
"search_patient": "Search Patient",
"search_patients": "Search Patients",
"search_resource": "Search Resource",
"see_attachments": "See Attachments",
"select": "Select",
5 changes: 3 additions & 2 deletions src/Routers/routes/PatientRoutes.tsx
Original file line number Diff line number Diff line change
@@ -2,16 +2,17 @@ import DeathReport from "@/components/DeathReport/DeathReport";
import InvestigationReports from "@/components/Facility/Investigations/Reports";
import FileUploadPage from "@/components/Patient/FileUploadPage";
import { InsuranceDetails } from "@/components/Patient/InsuranceDetails";
import { PatientManager } from "@/components/Patient/ManagePatients";
import { patientTabs } from "@/components/Patient/PatientDetailsTab";
import { PatientHome } from "@/components/Patient/PatientHome";
import PatientIndex from "@/components/Patient/PatientIndex";
import PatientNotes from "@/components/Patient/PatientNotes";
import { PatientRegister } from "@/components/Patient/PatientRegister";

import { AppRoutes } from "@/Routers/AppRouter";

const PatientRoutes: AppRoutes = {
"/patients": () => <PatientManager />,
//"/patients": () => <PatientManager />,
shivankacker marked this conversation as resolved.
Show resolved Hide resolved
"/patients": () => <PatientIndex />,
"/patient/:id": ({ id }) => <PatientHome id={id} page="demography" />,
"/patient/:id/investigation_reports": ({ id }) => (
<InvestigationReports id={id} />
2 changes: 1 addition & 1 deletion src/components/Common/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ export default function Breadcrumbs({
<Button
asChild
variant="link"
className="p-1 font-normal text-gray-800 underline underline-offset-2 hover:text-gray-700"
className="p-0 font-normal text-gray-800 underline underline-offset-2 hover:text-gray-700"
shivankacker marked this conversation as resolved.
Show resolved Hide resolved
>
<Link href="/">Home</Link>
</Button>
3 changes: 1 addition & 2 deletions src/components/Common/SearchByMultipleFields.tsx
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ import PhoneNumberFormField from "@/components/Form/FormFields/PhoneNumberFormFi

interface SearchOption {
key: string;
label: string;
shivankacker marked this conversation as resolved.
Show resolved Hide resolved
type: "text" | "phone";
placeholder: string;
value: string;
@@ -241,7 +240,7 @@ const SearchByMultipleFields: React.FC<SearchByMultipleFieldsProps> = ({
<CareIcon icon="l-search" className="mr-2 h-4 w-4" />
<span className="flex-1">{t(option.key)}</span>
<kbd className="ml-auto text-xs text-gray-400">
{option.label.charAt(0).toUpperCase()}
{option.shortcutKey}
shivankacker marked this conversation as resolved.
Show resolved Hide resolved
</kbd>
</CommandItem>
))}
1 change: 0 additions & 1 deletion src/components/Facility/FacilityList.tsx
Original file line number Diff line number Diff line change
@@ -197,7 +197,6 @@ export const FacilityList = () => {
options={[
{
key: "facility_district_name",
label: "Facility or District Name",
type: "text" as const,
placeholder: "facility_search_placeholder",
shivankacker marked this conversation as resolved.
Show resolved Hide resolved
value: qParams.search || "",
272 changes: 271 additions & 1 deletion src/components/Patient/PatientFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import careConfig from "@careConfig";
import dayjs from "dayjs";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

import FilterBadge from "@/CAREUI/display/FilterBadge";
import CareIcon from "@/CAREUI/icons/CareIcon";
import FiltersSlideover from "@/CAREUI/interactive/FiltersSlideover";

@@ -22,10 +24,13 @@ import {
import MultiSelectMenuV2 from "@/components/Form/MultiSelectMenuV2";
import SelectMenuV2 from "@/components/Form/SelectMenuV2";
import DiagnosesFilter, {
DIAGNOSES_FILTER_LABELS,
DiagnosesFilterKey,
FILTER_BY_DIAGNOSES_KEYS,
} from "@/components/Patient/DiagnosesFilter";

import useAuthUser from "@/hooks/useAuthUser";
import useFilters from "@/hooks/useFilters";
import useMergeState from "@/hooks/useMergeState";

import {
@@ -34,14 +39,19 @@ import {
DISCHARGE_REASONS,
FACILITY_TYPES,
GENDER_TYPES,
PATIENT_CATEGORIES,
PATIENT_FILTER_CATEGORIES,
RATION_CARD_CATEGORY,
} from "@/common/constants";
import { parseOptionId } from "@/common/utils";

import routes from "@/Utils/request/api";
import request from "@/Utils/request/request";
import useQuery from "@/Utils/request/useQuery";
import { dateQueryString } from "@/Utils/utils";
import { dateQueryString, humanizeStrings } from "@/Utils/utils";

import { ICD11DiagnosisModel } from "../Diagnosis/types";
import { getDiagnosesByIds } from "../Diagnosis/utils";

const getDate = (value: any) =>
value && dayjs(value).isValid() && dayjs(value).toDate();
@@ -782,3 +792,263 @@ export default function PatientFilter(props: any) {
</FiltersSlideover>
);
}

export function PatientFilterBadges() {
const { t } = useTranslation();

const { qParams, FilterBadges, updateQuery } = useFilters({
limit: 12,
cacheBlacklist: [
"name",
"patient_no",
"phone_number",
"emergency_phone_number",
],
});

const [diagnoses, setDiagnoses] = useState<ICD11DiagnosisModel[]>([]);

const { data: districtData } = useQuery(routes.getDistrict, {
pathParams: {
id: qParams.district,
},
prefetch: !!Number(qParams.district),
});

const { data: LocalBodyData } = useQuery(routes.getLocalBody, {
pathParams: {
id: qParams.lsgBody,
},
prefetch: !!Number(qParams.lsgBody),
});

const { data: facilityData } = useQuery(routes.getAnyFacility, {
pathParams: {
id: qParams.facility,
},
prefetch: !!qParams.facility,
});
const { data: facilityAssetLocationData } = useQuery(
routes.getFacilityAssetLocation,
{
pathParams: {
facility_external_id: qParams.facility,
external_id: qParams.last_consultation_current_bed__location,
},
prefetch: !!qParams.last_consultation_current_bed__location,
},
);

const LastAdmittedToTypeBadges = () => {
const badge = (key: string, value: string | undefined, id: string) => {
return (
value && (
<FilterBadge
name={key}
value={value}
onRemove={() => {
const lcat = qParams.last_consultation_admitted_bed_type_list
.split(",")
.filter((x: string) => x != id)
.join(",");
updateQuery({
...qParams,
last_consultation_admitted_bed_type_list: lcat,
});
}}
/>
)
);
};
return qParams.last_consultation_admitted_bed_type_list
.split(",")
.map((id: string) => {
const text = ADMITTED_TO.find((obj) => obj.id == id)?.text;
return badge("Bed Type", text, id);
});
};

const HasConsentTypesBadges = () => {
const badge = (key: string, value: string | undefined, id: string) => {
return (
value && (
<FilterBadge
name={key}
value={value}
onRemove={() => {
const lcat = qParams.last_consultation__consent_types
.split(",")
.filter((x: string) => x != id)
.join(",");
updateQuery({
...qParams,
last_consultation__consent_types: lcat,
});
}}
/>
)
);
};

return qParams.last_consultation__consent_types
.split(",")
.map((id: string) => {
const text = [
...CONSENT_TYPE_CHOICES,
{ id: "None", text: "No Consents" },
].find((obj) => obj.id == id)?.text;
return badge("Has Consent", text, id);
});
};

const getTheCategoryFromId = () => {
let category_name;
if (qParams.category) {
category_name = PATIENT_CATEGORIES.find(
(item: any) => qParams.category === item.id,
)?.text;

return String(category_name);
} else {
return "";
}
};

const getDiagnosisFilterValue = (key: DiagnosesFilterKey) => {
const ids: string[] = (qParams[key] ?? "").split(",");
return ids.map((id) => diagnoses.find((obj) => obj.id == id)?.label ?? id);
};

useEffect(() => {
const ids: string[] = [];
FILTER_BY_DIAGNOSES_KEYS.forEach((key) => {
ids.push(...(qParams[key] ?? "").split(",").filter(Boolean));
});
const existing = diagnoses.filter(({ id }) => ids.includes(id));
const objIds = existing.map((o) => o.id);
const diagnosesToBeFetched = ids.filter((id) => !objIds.includes(id));
getDiagnosesByIds(diagnosesToBeFetched).then((data) => {
const retrieved = data.filter(Boolean) as ICD11DiagnosisModel[];
setDiagnoses([...existing, ...retrieved]);
});
}, [
qParams.diagnoses,
qParams.diagnoses_confirmed,
qParams.diagnoses_provisional,
qParams.diagnoses_unconfirmed,
qParams.diagnoses_differential,
]);

return (
<FilterBadges
badges={({
badge,
value,
kasp,
phoneNumber,
dateRange,
range,
ordering,
}) => [
phoneNumber("Primary number", "phone_number"),
phoneNumber("Emergency number", "emergency_phone_number"),
badge("Patient name", "name"),
badge("IP/OP number", "patient_no"),
...dateRange("Modified", "modified_date"),
...dateRange("Created", "created_date"),
...dateRange("Admitted", "last_consultation_encounter_date"),
...dateRange("Discharged", "last_consultation_discharge_date"),
// Admitted to type badges
badge("No. of vaccination doses", "number_of_doses"),
kasp(),
badge("COWIN ID", "covin_id"),
badge("Is Antenatal", "is_antenatal"),
badge("Review Missed", "review_missed"),
badge("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",
qParams.facility ? facilityData?.name || "" : "",
),
value(
"Location",
"last_consultation_current_bed__location",
qParams.last_consultation_current_bed__location
? facilityAssetLocationData?.name ||
qParams.last_consultation_current_bed__locations
: "",
),
badge("Facility Type", "facility_type"),
value(
"District",
"district",
qParams.district ? districtData?.name || "" : "",
),
ordering(),
value("Category", "category", getTheCategoryFromId()),
value(
"Respiratory Support",
"ventilator_interface",
qParams.ventilator_interface &&
t(`RESPIRATORY_SUPPORT_SHORT__${qParams.ventilator_interface}`),
),
value(
"Gender",
"gender",
parseOptionId(GENDER_TYPES, qParams.gender) || "",
),
{
name: "Admitted to",
value: ADMITTED_TO[qParams.last_consultation_admitted_to],
paramKey: "last_consultation_admitted_to",
},
...range("Age", "age"),
{
name: "LSG Body",
value: qParams.lsgBody ? LocalBodyData?.name || "" : "",
paramKey: "lsgBody",
},
...FILTER_BY_DIAGNOSES_KEYS.map((key) =>
value(
DIAGNOSES_FILTER_LABELS[key],
key,
humanizeStrings(getDiagnosisFilterValue(key)),
),
),
badge("Declared Status", "is_declared_positive"),
...dateRange("Declared positive", "date_declared_positive"),
...dateRange("Last vaccinated", "last_vaccinated_date"),
{
name: "Telemedicine",
paramKey: "last_consultation_is_telemedicine",
},
value(
"Discharge Reason",
"last_consultation__new_discharge_reason",
parseOptionId(
DISCHARGE_REASONS,
qParams.last_consultation__new_discharge_reason,
) || "",
),
]}
children={
(qParams.last_consultation_admitted_bed_type_list ||
qParams.last_consultation__consent_types) && (
<>
{qParams.last_consultation_admitted_bed_type_list &&
LastAdmittedToTypeBadges()}
{qParams.last_consultation__consent_types &&
HasConsentTypesBadges()}
</>
)
}
/>
);
}
Loading
Loading