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

O3-1710: History and Comments Section: Ordered vs Dispensed #49

Merged
merged 1 commit into from
Jan 23, 2023
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
30 changes: 0 additions & 30 deletions src/components/history-and-comments.scss

This file was deleted.

98 changes: 0 additions & 98 deletions src/components/medication-event-card.component.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions src/components/medication-event-status-tag.tsx

This file was deleted.

93 changes: 93 additions & 0 deletions src/components/medication-event.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React from "react";
import {
DosageInstruction,
MedicationDispense,
MedicationRequest,
Quantity,
} from "../types";
import styles from "./medication-event.scss";
import {
getDosageInstruction,
getQuantity,
getRefillsAllowed,
getMedicationDisplay,
getMedicationReferenceOrCodeableConcept,
} from "../utils";
import { useTranslation } from "react-i18next";

// can render MedicationRequest or MedicationDispense
const MedicationEvent: React.FC<{
medicationEvent: MedicationRequest | MedicationDispense;
status?;
}> = ({ medicationEvent, status = null }) => {
const { t } = useTranslation();
const dosageInstruction: DosageInstruction = getDosageInstruction(
medicationEvent.dosageInstruction
);
const quantity: Quantity = getQuantity(medicationEvent);
const refillsAllowed: number = getRefillsAllowed(medicationEvent);

return (
<div>
<p className={styles.medicationName}>
{status}
<strong>
{getMedicationDisplay(
getMedicationReferenceOrCodeableConcept(medicationEvent)
)}
</strong>
</p>
<p className={styles.bodyLong01}>
<span className={styles.label01}>
{t("dose", "Dose").toUpperCase()}
</span>{" "}
{dosageInstruction && (
<>
<span className={styles.dosage}>
{dosageInstruction.doseAndRate &&
dosageInstruction?.doseAndRate.map((doseAndRate, index) => {
return (
<span key={index}>
{doseAndRate?.doseQuantity?.value}{" "}
{doseAndRate?.doseQuantity?.unit}
</span>
);
})}
</span>{" "}
&mdash; {dosageInstruction?.route?.text} &mdash;{" "}
{dosageInstruction?.timing?.code?.text}{" "}
{dosageInstruction?.timing?.repeat?.duration
? "for " +
dosageInstruction?.timing?.repeat?.duration +
" " +
dosageInstruction?.timing?.repeat?.durationUnit
: " "}
</>
)}
</p>
<p className={styles.bodyLong01}>
<span className={styles.label01}>
{t("quantity", "Quantity").toUpperCase()}
</span>{" "}
{quantity && (
<span className={styles.quantity}>
{quantity.value} {quantity.unit}
</span>
)}
</p>
{(refillsAllowed || refillsAllowed === 0) && (
<p className={styles.bodyLong01}>
<span className={styles.label01}>
{t("refills", "Refills").toUpperCase()}
</span>{" "}
<span className={styles.refills}>{refillsAllowed}</span>
</p>
)}
{dosageInstruction?.text && (
<p className={styles.bodyLong01}>{dosageInstruction.text}</p>
)}
</div>
);
};

export default MedicationEvent;
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
@use '@carbon/styles/scss/type';
@import "~@openmrs/esm-styleguide/src/vars";

.medicationEventTile {
width: 100%;
margin: 2px 0 8px;
padding: 0 8px 0 8px;
background-color: #fff;
border-left: 4px solid var(--brand-03);
color: $text-02;
margin-bottom: 1rem !important;
}

.medicationName {
font-size: 15px !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import {
DataTableSkeleton,
OverflowMenu,
OverflowMenuItem,
Tag,
Tile,
} from "@carbon/react";
import { useTranslation } from "react-i18next";
import { parseDate, formatDatetime } from "@openmrs/esm-framework";
import styles from "./history-and-comments.scss";
import { usePrescriptionDetails } from "../medication-request/medication-request.resource";
import { deleteMedicationDispense } from "../medication-dispense/medication-dispense.resource";
import MedicationEventCard from "./medication-event-card.component";
import MedicationEvent from "../components/medication-event.component";
import { launchOverlay } from "../hooks/useOverlay";
import DispenseForm from "../forms/dispense-form.component";
import { MedicationDispense } from "../types";
Expand Down Expand Up @@ -87,10 +89,11 @@ const HistoryAndComments: React.FC<{
{t("dispensedMedication", "dispensed medication")} -{" "}
{formatDatetime(parseDate(dispense.whenHandedOver))}
</h5>
<MedicationEventCard
medicationEvent={dispense}
actionMenu={generateMedicationDispenseActionMenu(dispense)}
/>
<Tile className={styles.dispenseTile}>
{generateMedicationDispenseActionMenu(dispense)}
<Tag type="red">{t("dispense", "Dispense")}</Tag>
<MedicationEvent medicationEvent={dispense} />
</Tile>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clearer example of the what changed in the MedicationEventCard.... the Tile now leaves here (so we can apply custom styling) as well the action menu, and the new "Dispense" tag... the Medication Event card just displays the details of the medication event.

</div>
);
})}
Expand All @@ -109,7 +112,10 @@ const HistoryAndComments: React.FC<{
{t("orderedMedication ", "ordered medication")} -{" "}
{formatDatetime(prescriptionDate)}
</h5>
<MedicationEventCard medicationEvent={request} />
<Tile className={styles.requestTile}>
<Tag type="green">{t("order", "Order")}</Tag>
<MedicationEvent medicationEvent={request} />
</Tile>
</div>
);
})}
Expand Down
57 changes: 57 additions & 0 deletions src/history/history-and-comments.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@use '@carbon/styles/scss/spacing';
@use '@carbon/styles/scss/type';
@import "~@openmrs/esm-styleguide/src/vars";

.historyAndCommentsContainer {
max-width: 80%;

form {
display: flex;
flex-flow: row wrap;
align-items: center;
}

form input {
vertical-align: middle;
margin: 0 10px 0 0;
padding: 10px;
border: 1px solid #8d8d8d !important;
background-color: white;
}
form button {
width: 90px;
height: 20px;
min-height: 2.5rem !important;
}

form :global(.cds--btn--ghost) {
width: 8rem !important;
}

.requestTile {
width: 100%;
margin: 2px 0 8px;
padding: 0 8px 0 8px;
background-color: #fff;
border-left: 4px solid var(--brand-03);
color: $text-02;
margin-bottom: 1rem !important;
}

.dispenseTile {
width: 100%;
margin: 2px 0 8px;
padding: 0 8px 0 8px;
background-color: #fff;
border-left: 4px solid red;
color: $text-02;
margin-bottom: 1rem !important;
}

.medicationEventActionMenu {
float: right;
}

}


Loading