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

Issues/8683/lab orders old #1

Draft
wants to merge 85 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
22994f9
Add lab tests translation and sidebar navigation item
yash-learner Nov 26, 2024
e5e36d4
Add Lab Test routes and component for lab orders
yash-learner Nov 26, 2024
2f5f4d6
Get tabs working
yash-learner Nov 26, 2024
77f3368
Add @tanstack/react-table package
yash-learner Nov 27, 2024
a6868ba
Add shadcn Input and Table components
yash-learner Nov 27, 2024
8a8c6f3
WIP get table structure
yash-learner Nov 27, 2024
43b867b
WIP: get a basic structure for filtering
yash-learner Nov 28, 2024
cf8a514
Add shadcn separator
yash-learner Nov 29, 2024
a72e921
Add primary button variant styles
yash-learner Nov 29, 2024
a3a0795
Enhance TableFilter component with separators and clear filters funct…
yash-learner Nov 29, 2024
18c768e
Update OrderPlaced component layout with improved spacing
yash-learner Nov 29, 2024
60ae09c
Add shadcn Badge component
yash-learner Nov 30, 2024
d51bbff
Enhance DataTable component to support badge rendering for specific c…
yash-learner Nov 30, 2024
da56b83
Refactor OrderPlaced component to enhance filtering and add action bu…
yash-learner Nov 30, 2024
f6d6aab
Add shadcn Label and Radio Group components
yash-learner Nov 30, 2024
4c3530a
Add radio button support to TableFilter component
yash-learner Nov 30, 2024
1d08121
Add priority radio filter to OrderPlaced component and update initial…
yash-learner Nov 30, 2024
2c7b06b
WIP: support multi select
yash-learner Dec 1, 2024
9cb2081
Add shadcn Card and Collapsible components
yash-learner Dec 3, 2024
f39490c
WIP: Collect specimen page
yash-learner Dec 3, 2024
462c3ae
Add sample collection UI and refactors
yash-learner Dec 5, 2024
59e18d4
Fix layout alignment
yash-learner Dec 5, 2024
129d3fa
Add barcode SVG icon
yash-learner Dec 8, 2024
7caaa65
Add more UI elements
yash-learner Dec 8, 2024
c245b20
Add SendSpecimen route and enhance SpecimenCollected component
yash-learner Dec 8, 2024
26913b9
Rename page title from "Lab Tests" to "Lab Orders"
yash-learner Dec 8, 2024
cc466a9
Add SendSpecimen component for specimen dispatch functionality
yash-learner Dec 8, 2024
300de49
Add recieve state components
yash-learner Dec 8, 2024
6c0fecd
Remove mock labs data from ReceiveSpecimen component
yash-learner Dec 8, 2024
caf36b7
Get remote button working and move some values
yash-learner Dec 9, 2024
18653e7
Replace Cross2Icon with CrossCircledIcon
yash-learner Dec 9, 2024
8806e57
Add more UI elements in ReceiveSpecimen
yash-learner Dec 9, 2024
0bd7f74
Merge branch 'develop' into issues/8683/lab-orders
yash-learner Dec 10, 2024
4e304d6
Remove duplicate primary button variant
yash-learner Dec 10, 2024
e7ba845
Make input work with changes came from develop remote
yash-learner Dec 10, 2024
60689c9
Update sidebar icon for lab tests to use duotone microscope
yash-learner Dec 10, 2024
200c632
Add SentToLab component
yash-learner Dec 10, 2024
902cac6
Add received badge style to DataTable component
yash-learner Dec 10, 2024
af5d02d
Minor Changes
yash-learner Dec 10, 2024
b91e00e
Add basic Process speciem UI elements
yash-learner Dec 10, 2024
6a8e632
Move buttons to buttom
yash-learner Dec 10, 2024
66a6a0e
added create lab order form, lab order code select and wired them
khavinshankar Dec 10, 2024
b4eb957
Add results table
yash-learner Dec 10, 2024
5802c0a
added list service requests component
khavinshankar Dec 10, 2024
51b3484
Merge branch 'issues/8683/lab-orders' of github.com:yash-learner/care…
khavinshankar Dec 10, 2024
6b813a9
wired labs flow till results entry
khavinshankar Dec 11, 2024
f8844e7
Add static Aliquot creation component
yash-learner Dec 11, 2024
d6cc353
Add static select analyzer
yash-learner Dec 11, 2024
6da9f74
WIP: Improve the timeline styling
yash-learner Dec 13, 2024
d1b7f5b
Add clock history SVG icon
yash-learner Dec 13, 2024
2c5beff
Add static Review result page
yash-learner Dec 13, 2024
ec26c1f
Add more static UI
yash-learner Dec 13, 2024
783cf01
wired labs review flow
khavinshankar Dec 15, 2024
afcfd70
Merge branch 'develop' into issues/8683/lab-orders
yash-learner Dec 15, 2024
ec119e2
Wire note and priority
yash-learner Dec 15, 2024
a405ee4
Add utility function to map keys to Badge variants
yash-learner Dec 15, 2024
96a00f6
Implement priority badge variant mapping
yash-learner Dec 15, 2024
692ecbc
Add new badge variants
yash-learner Dec 17, 2024
13de824
Update priority variant mapping and enhance Badge styling
yash-learner Dec 17, 2024
5394951
Imrpove styling
yash-learner Dec 17, 2024
0543496
Improve styling of the specimen collection
yash-learner Dec 18, 2024
44f81b1
Add ResultTable component
yash-learner Dec 18, 2024
8df9d4b
Use extracted out ResultTable
yash-learner Dec 18, 2024
dffbb5e
Add shadcn sekeleton loading
yash-learner Dec 21, 2024
548b4cd
Add DataTableSkeleton component
yash-learner Dec 21, 2024
cb70ec5
Add table skeleton loading to all the tabs
yash-learner Dec 21, 2024
2f80f46
Add skeleton loading for ListEncounter
yash-learner Dec 22, 2024
9fec8ae
Remove @tanstack/react-table for now
yash-learner Dec 23, 2024
c14c33e
Merge branch 'develop' into issues/8683/lab-orders
yash-learner Dec 23, 2024
0c1ecef
Run npm run install-all
yash-learner Dec 23, 2024
3affc0f
Wire and UI changes
yash-learner Dec 23, 2024
65fdbb3
Wire and reduce code repetition
yash-learner Dec 24, 2024
f287897
Extract out the timeline into a component and make it dynamic
yash-learner Dec 24, 2024
229a4d0
WIP: Use extracted out timeline
yash-learner Dec 24, 2024
ad51d1d
Use dynamic ServiceRequestTimeline component in result component
yash-learner Dec 25, 2024
7087c04
WIP: Wiring remaining steps in collect
yash-learner Dec 25, 2024
64db5d3
Add empty message to DataTable component
yash-learner Dec 26, 2024
c207020
Use tanstack useQuery
yash-learner Dec 26, 2024
ba1b276
Use tanstack useMutation
yash-learner Dec 26, 2024
4eed610
Conditionally render Collapsible for consolidated report
yash-learner Dec 26, 2024
986a4fa
Extract out the Consolidated result collapsabile into a component
yash-learner Dec 27, 2024
4b74345
Refactor ReviewResult to use ConsolidatedTestResults component and re…
yash-learner Dec 27, 2024
7661154
Add note field to DiagnosticReport request type
yash-learner Dec 27, 2024
e0216e9
Fix note field rendering to handle undefined text value
yash-learner Dec 27, 2024
f4fd9d4
Slice the order id
yash-learner Dec 27, 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
685 changes: 444 additions & 241 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@
"@hello-pangea/dnd": "^17.0.0",
"@pnotify/core": "^5.2.0",
"@pnotify/mobile": "^5.2.0",
"@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-collapsible": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-label": "^2.1.1",
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-radio-group": "^1.2.1",
"@radix-ui/react-scroll-area": "^1.2.0",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-toast": "^1.2.2",
"@radix-ui/react-tooltip": "^1.1.6",
Expand Down
7 changes: 7 additions & 0 deletions public/images/barcode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions public/images/clock_history.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/images/filter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@
"is_upshift_case": "Is upshift case",
"is_vaccinated": "Whether vaccinated",
"kasp_enabled_date": "{{kasp_string}} enabled date",
"lab_tests": "Lab Tests",
"label": "Label",
"landline": "Indian landline",
"language_selection": "Language Selection",
Expand Down
2 changes: 2 additions & 0 deletions src/Routers/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { BLACKLISTED_PATHS } from "@/common/constants";
import AssetRoutes from "@/Routers/routes/AssetRoutes";
import ConsultationRoutes from "@/Routers/routes/ConsultationRoutes";
import FacilityRoutes from "@/Routers/routes/FacilityRoutes";
import LabTestRoutes from "@/Routers/routes/LabTestRoutes";
import PatientRoutes from "@/Routers/routes/PatientRoutes";
import ResourceRoutes from "@/Routers/routes/ResourceRoutes";
import ShiftingRoutes from "@/Routers/routes/ShiftingRoutes";
Expand All @@ -47,6 +48,7 @@ const Routes: AppRoutes = {

...AssetRoutes,
...ConsultationRoutes,
...LabTestRoutes,
...FacilityRoutes,
...PatientRoutes,
...ResourceRoutes,
Expand Down
29 changes: 29 additions & 0 deletions src/Routers/routes/LabTestRoutes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CollectSpecimen } from "@/components/LabTest/CollectSpecimen";
import { LabTest } from "@/components/LabTest/Index";
import { ProcessSpecimen } from "@/components/LabTest/ProcessSpecimen";
import { ReceiveSpecimen } from "@/components/LabTest/ReceiveSpecimen";
import { ReviewResult } from "@/components/LabTest/ReviewResult";
import { SendSpecimen } from "@/components/LabTest/SendSpecimen";

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

const LabTestRoutes: AppRoutes = {
"/lab_tests/process": () => <ProcessSpecimen />,
"/lab_tests/:specimenId/process": ({ specimenId }) => (
<ProcessSpecimen specimenId={specimenId} />
),
"/lab_tests/send_to_lab": () => <SendSpecimen />,
"/lab_tests/receive_at_lab": () => <ReceiveSpecimen />,
"/lab_tests/:tab": () => <LabTest />,
"/lab_tests/:specimenId/collect": ({ specimenId }) => (
<CollectSpecimen specimenId={specimenId} />
),
"/lab_tests/:diagnosticReportId/review": ({ diagnosticReportId }) => (
<ReviewResult diagnosticReportId={diagnosticReportId} />
),
"/lab_tests/:diagnosticReportId/result": ({ diagnosticReportId }) => (
<ReviewResult diagnosticReportId={diagnosticReportId} />
),
};

export default LabTestRoutes;
16 changes: 16 additions & 0 deletions src/Utils/badgeUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BadgeProps } from "@/components/ui/badge";

/**
* Dynamically maps keys to Badge variants using a provided mapping object.
*
* @param key - The key to map (e.g., "routine", "asap").
* @param mapping - The mapping object that links keys to Badge variants.
* @param defaultVariant - A fallback variant to use if the key is not found.
*/
export const mapKeyToBadgeVariant = (
key: string | undefined,
mapping: Record<string, BadgeProps["variant"]>,
defaultVariant: BadgeProps["variant"] = "default",
): BadgeProps["variant"] => {
return mapping[key?.toLowerCase() || ""] || defaultVariant;
};
163 changes: 163 additions & 0 deletions src/Utils/request/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ import {
} from "@/components/Facility/models";
import { InsurerOptionModel } from "@/components/HCX/InsurerAutocomplete";
import { HCXPolicyModel } from "@/components/HCX/models";
import {
Annotation,
Coding,
DiagnosticReport,
Observation,
ServiceRequest,
Specimen,
} from "@/components/LabTest/types";
import { MedibaseMedicine, Prescription } from "@/components/Medicine/models";
import {
NotificationData,
Expand Down Expand Up @@ -96,6 +104,19 @@ export interface LoginCredentials {
password: string;
}

export interface ValuesetExpandBody {
search?: string;
count?: number;
}

export interface ValuesetExpandResponse {
results: {
code: string;
display: string;
system: string;
}[];
}

const routes = {
// Auth Endpoints
login: {
Expand Down Expand Up @@ -1255,6 +1276,148 @@ const routes = {
},
},
},

labs: {
labOrderCodes: {
method: "POST",
path: "/api/v1/valueset/system-lab-order-code/expand/",
TBody: Type<ValuesetExpandBody>(),
TRes: Type<ValuesetExpandResponse>(),
},

serviceRequest: {
create: {
method: "POST",
path: "/api/v1/service_request/",
TBody: Type<{
code: Coding;
subject: string;
encounter: string;
priority?: ServiceRequest["priority"];
note?: Annotation[];
}>(),
TRes: Type<ServiceRequest>(),
},
list: {
method: "GET",
path: "/api/v1/service_request/",
TRes: Type<PaginatedResponse<ServiceRequest>>(),
},
},

specimen: {
list: {
method: "GET",
path: "/api/v1/specimen/",
TRes: Type<PaginatedResponse<Specimen>>(),
},
get: {
method: "GET",
path: "/api/v1/specimen/{id}/",
TRes: Type<Specimen>(),
},
collect: {
method: "POST",
path: "/api/v1/specimen/{id}/collect/",
TBody: Type<{
identifier?: string;
}>(),
TRes: Type<Specimen>(),
},
sendToLab: {
method: "POST",
path: "/api/v1/specimen/{id}/send_to_lab/",
TBody: Type<{
lab?: string;
}>(),
TRes: Type<Specimen>(),
},
ReceiveAtLab: {
method: "POST",
path: "/api/v1/specimen/{id}/receive_at_lab/",
TBody: Type<{
accession_identifier?: string;
note?: Annotation;
condition?: Coding;
}>(),
TRes: Type<Specimen>(),
},
process: {
method: "POST",
path: "/api/v1/specimen/{id}/process/",
TBody: Type<{
process: {
description?: string;
method?: Coding;
}[];
}>(),
TRes: Type<Specimen>(),
},
},

diagnosticReport: {
create: {
method: "POST",
path: "/api/v1/diagnostic_report/",
TBody: Type<{
based_on: string;
specimen: string[];
}>(),
TRes: Type<DiagnosticReport>(),
},
observations: {
method: "POST",
path: "/api/v1/diagnostic_report/{id}/observations/",
TBody: Type<{
observations: {
id: string;
status: Observation["status"];
main_code: Coding;
value: string;
subject_type: "patient";
effective_datetime: string;
data_entered_by_id: number;
note: string;
}[];
}>(),
TRes: Type<DiagnosticReport>(),
},
get: {
method: "GET",
path: "/api/v1/diagnostic_report/{id}/",
TRes: Type<DiagnosticReport>(),
},
list: {
method: "GET",
path: "/api/v1/diagnostic_report/",
TRes: Type<PaginatedResponse<DiagnosticReport>>(),
},
verify: {
method: "POST",
path: "/api/v1/diagnostic_report/{id}/verify/",
TBody: Type<{
is_approved: boolean;
}>(),
TRes: Type<DiagnosticReport>(),
},
review: {
method: "POST",
path: "/api/v1/diagnostic_report/{id}/review/",
TBody: Type<{
is_approved: boolean;
conclusion?: string;
}>(),
TRes: Type<DiagnosticReport>(),
},
},

labObservationCodes: {
method: "POST",
path: "/api/v1/valueset/system-lab-order-code/expand/", // TODO: change this to more appropriate path
TBody: Type<ValuesetExpandBody>(),
TRes: Type<ValuesetExpandResponse>(),
},
},
} as const;

export default routes;
56 changes: 56 additions & 0 deletions src/components/Common/ResultTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from "react";

import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";

interface Column {
key: string;
label: string;
headerClass?: string; // Optional
}

interface ResultTableProps {
columns: Column[];
data: Array<{ [key: string]: React.ReactNode }>;
}

export const ResultTable: React.FC<ResultTableProps> = ({ columns, data }) => {
return (
<div className="overflow-x-auto w-full rounded-md border-[1.5px] border-gray-300">
<Table className="w-full border-separate border-spacing-0 bg-white shadow-sm">
<TableHeader className="bg-gray-100 rounded-lg">
<TableRow className="divide-x-[1.5px] divide-solid divide-gray-300">
{columns.map((col) => (
<TableHead
key={col.key}
className={`${col.headerClass || "text-sm text-gray-900"}`}
>
{col.label}
</TableHead>
))}
</TableRow>
</TableHeader>
<TableBody className="bg-white">
{data.map((row, i) => (
<TableRow
key={i}
className="divide-x-[1.5px] divide-solid divide-gray-300"
>
{columns.map((col) => (
<TableCell key={col.key} className="text-sm text-gray-700">
{row[col.key]}
</TableCell>
))}
</TableRow>
))}
</TableBody>
</Table>
</div>
);
};
Loading