Skip to content

Commit

Permalink
Add facility name to ReportTable component (#7190)
Browse files Browse the repository at this point in the history
* Add facility name to ReportTable component

* Refactor ReportTable component to remove facilityName prop
  • Loading branch information
Ashesh3 authored Feb 14, 2024
1 parent 847a5de commit 77fa4de
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
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

0 comments on commit 77fa4de

Please sign in to comment.