Skip to content

Commit

Permalink
feat/adding a lab request (#4)
Browse files Browse the repository at this point in the history
* feat/adding a lab request

* fix: build

---------

Co-authored-by: jabahum <[email protected]>
  • Loading branch information
Mwanje and jabahum authored Sep 21, 2023
1 parent 908e06f commit f6223d5
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const moduleName = "@ugandaemr/openmrs-esm-laboratory-app";

export const LABORATARORY_ENCOUNTER_TYPE =
"cbf01392-ca29-11e9-a32f-2a2ae2dbcce4";
export const TEST_ORDER_ENCOUNTER_TYPE = "dca07f4a-30ab-102d-86b0-7a5022ba4115";
85 changes: 80 additions & 5 deletions src/patient-chart/laboratory-order.component.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,88 @@
import React from "react";
import React, { useMemo } from "react";
import { useTranslation } from "react-i18next";
import { EmptyStateComingSoon } from "@ohri/openmrs-esm-ohri-commons-lib";
import {
EncounterList,
EncounterListColumn,
getObsFromEncounter,
} from "@ohri/openmrs-esm-ohri-commons-lib";
import moment from "moment";
import {
moduleName,
LABORATARORY_ENCOUNTER_TYPE,
TEST_ORDER_ENCOUNTER_TYPE,
} from "../constants";

const LaboratoryOrder: React.FC = () => {
interface LaboratoryOrderOverviewProps {
patientUuid: string;
}

const LaboratoryOrder: React.FC<LaboratoryOrderOverviewProps> = ({
patientUuid,
}) => {
const { t } = useTranslation();
const headerTitle = t("laboratory", "Laboratory");

const columnsLab: EncounterListColumn[] = useMemo(
() => [
{
key: "encounterDate",
header: t("encounterDate", "Encounter Date"),
getValue: (encounter) => {
return moment(encounter.encounterDatetime).format("DD-MMM-YYYY");
},
},
{
key: "testOrders",
header: t("deliveryType", "Test Order(s)"),
getValue: (encounter) => {
return getObsFromEncounter(encounter, TEST_ORDER_ENCOUNTER_TYPE);
},
},

{
key: "actions",
header: t("actions", "Actions"),
getValue: (encounter) => {
const baseActions = [
{
form: {
name: "HMIS LAB 001:General Laboratory Test Request Form",
},
encounterUuid: encounter.uuid,
intent: "*",
label: "View Details",
mode: "view",
},
{
form: {
name: "HMIS LAB 001:General Laboratory Test Request Form",
},
encounterUuid: encounter.uuid,
intent: "*",
label: "Edit Form",
mode: "edit",
},
];
return baseActions;
},
},
],
[t]
);
const headerTitle = t("Laboratory");

return (
<EmptyStateComingSoon headerTitle={headerTitle} displayText={headerTitle} />
<EncounterList
patientUuid={patientUuid}
encounterType={LABORATARORY_ENCOUNTER_TYPE}
formList={[{ name: "HMIS LAB 001:General Laboratory Test Request Form" }]}
columns={columnsLab}
description={headerTitle}
headerTitle={headerTitle}
launchOptions={{
displayText: "Add",
moduleName: moduleName,
}}
/>
);
};

Expand Down

0 comments on commit f6223d5

Please sign in to comment.