Skip to content

Commit

Permalink
Merge branch 'develop' into useQuery-migrations/file-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Feb 14, 2024
2 parents 4e77a1e + d36c0f2 commit e26bcbc
Show file tree
Hide file tree
Showing 23 changed files with 826 additions and 921 deletions.
2 changes: 1 addition & 1 deletion src/CAREUI/display/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface TimelineEvent<TType = string> {
}

interface TimelineProps {
className: string;
className?: string;
children: React.ReactNode | React.ReactNode[];
name: string;
}
Expand Down
29 changes: 13 additions & 16 deletions src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ButtonV2, {
import CareIcon from "../icons/CareIcon";
import { classNames } from "../../Utils/utils";
import Pagination from "../../Components/Common/Pagination";
import Timeline from "../display/Timeline";

const DEFAULT_PER_PAGE_LIMIT = 14;

Expand Down Expand Up @@ -135,21 +134,19 @@ const Items = <TItem extends object>(props: ItemsProps<TItem>) => {
}

return (
<Timeline className="rounded-lg bg-white p-2 shadow" name="log update">
<ul className={props.className}>
{loading && props.shimmer
? Array.from({ length: props.shimmerCount ?? 8 }).map((_, i) => (
<li key={i} className="w-full">
{props.shimmer}
</li>
))
: items.map((item, index, items) => (
<li key={index} className="w-full">
{props.children(item, items)}
</li>
))}
</ul>
</Timeline>
<ul className={props.className}>
{loading && props.shimmer
? Array.from({ length: props.shimmerCount ?? 8 }).map((_, i) => (
<li key={i} className="w-full">
{props.shimmer}
</li>
))
: items.map((item, index, items) => (
<li key={index} className="w-full">
{props.children(item, items)}
</li>
))}
</ul>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/ConsultationDoctorNotes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
notes: [],
cPage: 1,
totalPages: 1,
facilityId: facilityId,
patientId: patientId,
};
const [state, setState] = useState(initialData);

Expand Down Expand Up @@ -113,8 +115,6 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
<PatientConsultationNotesList
state={state}
setState={setState}
patientId={patientId}
facilityId={facilityId}
reload={reload}
setReload={setReload}
/>
Expand Down
95 changes: 49 additions & 46 deletions src/Components/Facility/Consultations/DailyRoundsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import PageTitle from "../../Common/PageTitle";
import DailyRoundsFilter from "./DailyRoundsFilter";
import { ConsultationModel } from "../models";
import { useSlugs } from "../../../Common/hooks/useSlug";
import { TimelineNode } from "../../../CAREUI/display/Timeline";

import Timeline, { TimelineNode } from "../../../CAREUI/display/Timeline";
import { useState } from "react";
import { QueryParams } from "../../../Utils/request/types";

Expand Down Expand Up @@ -52,69 +53,71 @@ export default function DailyRoundsList({ consultation }: Props) {
<PaginatedList.WhenLoading>
<LoadingLogUpdateCard />
</PaginatedList.WhenLoading>
<PaginatedList.Items<DailyRoundsModel> className="flex grow flex-col gap-3">
{(item, items) => {
if (item.rounds_type === "AUTOMATED") {
<Timeline name="log update">
<PaginatedList.Items<DailyRoundsModel> className="flex grow flex-col gap-3 rounded-lg bg-white p-2 shadow">
{(item, items) => {
if (item.rounds_type === "AUTOMATED") {
return (
<TimelineNode
event={{
type: "created",
timestamp: item.taken_at?.toString() ?? "",
by: {
user_type: "",
first_name: "Virtual",
last_name: "Assistant",
username: "",
id: "",
email: "",
last_login: "",
},
icon: "l-robot",
}}
isLast={items.indexOf(item) == items.length - 1}
>
<VirtualNursingAssistantLogUpdateCard
round={item}
previousRound={items[items.indexOf(item) + 1]}
/>
</TimelineNode>
);
}

const itemUrl = ["NORMAL", "TELEMEDICINE"].includes(
item.rounds_type as string
)
? `${consultationUrl}/daily-rounds/${item.id}`
: `${consultationUrl}/daily_rounds/${item.id}`;

return (
<TimelineNode
event={{
type: "created",
timestamp: item.taken_at?.toString() ?? "",
by: {
user_type: "",
first_name: "Virtual",
last_name: "Assistant",
user_type: item.created_by?.user_type ?? "",
first_name: item.created_by?.first_name ?? "",
last_name: item.created_by?.last_name ?? "",
username: "",
id: "",
email: "",
last_login: "",
},
icon: "l-robot",
icon: "l-user-nurse",
}}
isLast={items.indexOf(item) == items.length - 1}
>
<VirtualNursingAssistantLogUpdateCard
<DefaultLogUpdateCard
round={item}
previousRound={items[items.indexOf(item) + 1]}
consultationData={consultation}
onViewDetails={() => navigate(itemUrl)}
onUpdateLog={() => navigate(`${itemUrl}/update`)}
/>
</TimelineNode>
);
}

const itemUrl = ["NORMAL", "TELEMEDICINE"].includes(
item.rounds_type
)
? `${consultationUrl}/daily-rounds/${item.id}`
: `${consultationUrl}/daily_rounds/${item.id}`;

return (
<TimelineNode
event={{
type: "created",
timestamp: item.taken_at?.toString() ?? "",
by: {
user_type: item.created_by?.user_type ?? "",
first_name: item.created_by?.first_name ?? "",
last_name: item.created_by?.last_name ?? "",
username: "",
id: "",
email: "",
last_login: "",
},
icon: "l-user-nurse",
}}
isLast={items.indexOf(item) == items.length - 1}
>
<DefaultLogUpdateCard
round={item}
consultationData={consultation}
onViewDetails={() => navigate(itemUrl)}
onUpdateLog={() => navigate(`${itemUrl}/update`)}
/>
</TimelineNode>
);
}}
</PaginatedList.Items>
}}
</PaginatedList.Items>
</Timeline>
<div className="flex w-full items-center justify-center">
<PaginatedList.Paginator hideIfSinglePage />
</div>
Expand Down
12 changes: 10 additions & 2 deletions src/Components/Facility/DoctorNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { PatientNoteStateType } from "./models";

interface DoctorNoteProps {
state: PatientNoteStateType;
setReload: any;
handleNext: () => void;
disableEdit?: boolean;
}

const DoctorNote = (props: DoctorNoteProps) => {
const { state, handleNext } = props;
const { state, handleNext, setReload, disableEdit } = props;
return (
<div
className="m-2 flex h-[390px] grow flex-col-reverse overflow-auto bg-white"
Expand All @@ -30,7 +32,13 @@ const DoctorNote = (props: DoctorNoteProps) => {
scrollableTarget="patient-notes-list"
>
{state.notes.map((note: any) => (
<PatientNoteCard note={note} key={note.id} />
<PatientNoteCard
state={state}
note={note}
key={note.id}
setReload={setReload}
disableEdit={disableEdit}
/>
))}
</InfiniteScroll>
) : (
Expand Down
16 changes: 11 additions & 5 deletions src/Components/Facility/PatientConsultationNotesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ import request from "../../Utils/request/request";
interface PatientNotesProps {
state: PatientNoteStateType;
setState: any;
patientId: string;
facilityId: string;
reload?: boolean;
setReload?: any;
disableEdit?: boolean;
}

const pageSize = RESULTS_PER_PAGE_LIMIT;

const PatientConsultationNotesList = (props: PatientNotesProps) => {
const { state, setState, reload, setReload } = props;
const { state, setState, reload, setReload, disableEdit } = props;
const consultationId = useSlug("consultation") ?? "";

const [isLoading, setIsLoading] = useState(true);
Expand All @@ -28,7 +27,7 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => {
setIsLoading(true);
const { data }: any = await request(routes.getPatientNotes, {
pathParams: {
patientId: props.patientId,
patientId: props.state.patientId,
},
query: {
consultation: consultationId,
Expand Down Expand Up @@ -81,7 +80,14 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => {
);
}

return <DoctorNote state={state} handleNext={handleNext} />;
return (
<DoctorNote
state={state}
handleNext={handleNext}
setReload={setReload}
disableEdit={disableEdit}
/>
);
};

export default PatientConsultationNotesList;
Loading

0 comments on commit e26bcbc

Please sign in to comment.