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

Add facility name to ReportTable component #7190

Merged
merged 2 commits into from
Feb 14, 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
12 changes: 10 additions & 2 deletions src/Components/Facility/Investigations/Reports/ReportTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@ const ReportTable: FC<ReportTableProps> = ({
<th
scope="col"
key={session.session_external_id}
className="bg-[#4B5563] px-6 py-3 text-center text-xs font-semibold uppercase tracking-wider text-[#F9FAFB]"
className="bg-[#4B5563] px-6 py-3 text-center text-xs font-semibold tracking-wider text-[#F9FAFB]"
>
{formatDateTime(session.session_created_date)}
<div className="flex flex-col items-center justify-center gap-1">
{formatDateTime(session.session_created_date)}
<a
className="max-w-fit font-semibold text-white hover:underline"
href={`/facility/${session.facility_id}/`}
>
{session.facility_name}
</a>
</div>
</th>
))}
<th
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Facility/Investigations/Reports/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { InvestigationValueType } from "..";
import { ConsultationModel } from "../../models";

export interface Investigation {
id: string;
group_object: any;
consultation_object: ConsultationModel;
investigation_object: {
external_id: string;
name: string;
Expand All @@ -16,12 +18,13 @@ export interface Investigation {
session_object: {
session_external_id: string;
session_created_date: string;
facility_name: string;
facility_id: string;
};
value: number | null;
notes: any;
investigation: number;
group: any;
consultation: number;
session: number;
}

Expand Down
10 changes: 7 additions & 3 deletions src/Components/Facility/Investigations/Reports/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { InvestigationResponse } from "./types";

export const transformData = _.memoize((data: InvestigationResponse) => {
const sessions = _.chain(data)
.map((value) => value.session_object)
.map((value) => {
return {
...value.session_object,
facility_name: value.consultation_object?.facility_name,
facility_id: value.consultation_object?.facility,
};
})
.uniqBy("session_external_id")
.orderBy("session_created_date", "desc")
.value();
Expand All @@ -28,7 +34,6 @@ export const transformData = _.memoize((data: InvestigationResponse) => {
}
});
const {
consultation,
group,
group_object,
id,
Expand All @@ -40,7 +45,6 @@ export const transformData = _.memoize((data: InvestigationResponse) => {
} = value[0];

return {
consultation,
group,
group_object,
id,
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ export default function PatientInfoCard(props: {
Principal Diagnosis:
</div>
<div className="flex gap-2 text-sm">
{principal_diagnosis.diagnosis_object.label}{" "}
{principal_diagnosis.diagnosis_object?.label ?? "-"}{" "}
<span className="flex items-center rounded border border-primary-500 pl-1 pr-2 text-xs font-medium text-primary-500">
<CareIcon icon="l-check" className="text-base" />
<p className="capitalize">
Expand Down
Loading