Skip to content

Commit

Permalink
Merge branch 'develop' into Fix-ohcnetwork#7244-1
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafMd-1 authored May 1, 2024
2 parents 2e81525 + 4568e5f commit 381e085
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 38 deletions.
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,33 @@ Authenticate to staging API with any of the following credentials

#### 🧪 Run cypress tests

Ensure that the development server is running and then run the cypress tests in either of the ways described below.
To run cypress tests locally, you'll need to setup the backend to run locally and load dummy data required for cypress to the database. See [docs](https://github.com/coronasafe/care#self-hosting).

Once backend is running locally, you'll have to ensure your local front-end is connected to local backend, by setting the `CARE_API` env.

```env
#.env
CARE_API=http://127.0.0.1:9000
```

Once done, start the development server by running

```sh
npm run dev
```

Once development server is running, then run the cypress tests in either of the ways described below.

```sh
npm run cypress:run # To run all tests in headless mode.
```

```sh
npm run cypress:run:gui # To run all tests in headed mode.
```

```sh
$ npm run cypress:run # To run all tests in headless mode.
$ npm run cypress:run:gui # To run all tests in headed mode.
$ npm run cypress:open # To debug and run tests individually.
npm run cypress:open # To debug and run tests individually.
```

- Failed test screenshots are saved in `cypress/screenshots`
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ExternalResult/ResultList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default function ResultList() {
});
}

if (loading) {
if (loading || !data) {
manageResults = (
<tr className="bg-white">
<td colSpan={5}>
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import ConfirmDialog from "../Common/ConfirmDialog.js";
import request from "../../Utils/request/request.js";
import routes from "../../Redux/api.js";
import useQuery from "../../Utils/request/useQuery.js";
import { t } from "i18next";

const Loading = lazy(() => import("../Common/Loading"));
const PageTitle = lazy(() => import("../Common/PageTitle"));
Expand Down Expand Up @@ -1477,7 +1478,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
>
<UserAutocompleteFormField
name={"treating_physician"}
label="Treating Physician"
label={t("treating_doctor")}
placeholder="Attending Doctors Name and Designation"
required
value={
Expand Down
25 changes: 17 additions & 8 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import CircularProgress from "../Common/components/CircularProgress";
import { FacilitySelect } from "../Common/FacilitySelect";
import { FacilityModel } from "./models";
import dayjs from "../../Utils/dayjs";
import { FieldError } from "../Form/FieldValidators";

interface PreDischargeFormInterface {
new_discharge_reason: number | null;
Expand Down Expand Up @@ -121,15 +122,22 @@ const DischargeModal = ({

if (
preDischargeForm.new_discharge_reason ==
DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id &&
!preDischargeForm.discharge_notes.trim()
DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id
) {
setErrors({
...errors,
discharge_notes: "Please enter the cause of death",
});
setIsSendingDischargeApi(false);
return;
const newErrors: Record<string, FieldError> = {};

if (!preDischargeForm.discharge_notes.trim()) {
newErrors["discharge_notes"] = "Please enter the cause of death";
}
if (!preDischargeForm.death_confirmed_doctor?.trim()) {
newErrors["death_confirmed_doctor"] = "Field is required";
}

if (Object.entries(newErrors).length) {
setErrors({ ...errors, ...newErrors });
setIsSendingDischargeApi(false);
return;
}
}

const dischargeDetails = {
Expand Down Expand Up @@ -310,6 +318,7 @@ const DischargeModal = ({
<TextFormField
name="death_confirmed_by"
label="Confirmed By"
error={errors.death_confirmed_doctor}
value={preDischargeForm.death_confirmed_doctor ?? ""}
onChange={(e) => {
setPreDischargeForm((form) => {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Medicine/CreatePrescriptionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function CreatePrescriptionForm(props: {
optionValue={(key) => key}
/>
{field("dosage_type").value === "TITRATED" ? (
<div className="flex w-full gap-4">
<div className="flex w-full flex-[2] gap-4">
<DosageFormField
className="flex-1"
label={t("start_dosage")}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Medicine/EditPrescriptionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function EditPrescriptionForm(props: Props) {
optionValue={(key) => key}
/>
{field("dosage_type").value === "TITRATED" ? (
<div className="flex w-full gap-4">
<div className="flex w-full flex-[2] gap-4">
<DosageFormField
className="flex-1"
label={t("start_dosage")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default function MedicineAdministrationTableRow({
<span>{t("edit_caution_note")}</span>
</div>
}
className="w-full max-w-3xl lg:min-w-[600px]"
className="w-full max-w-4xl lg:min-w-[768px]"
>
<EditPrescriptionForm
initial={prescription}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Medicine/PrescriptionBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function PrescriptionBuilder({
<span>{t("modification_caution_note")}</span>
</div>
}
className="w-full max-w-3xl lg:min-w-[600px]"
className="w-full max-w-4xl lg:min-w-[768px]"
>
<CreatePrescriptionForm
prescription={
Expand Down
14 changes: 8 additions & 6 deletions src/Components/Medicine/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const PRESCRIPTION_COMPARE_FIELDS: (keyof Prescription)[] = [
"medicine",
"days",
"discontinued",
"target_dosage",
"base_dosage",
"frequency",
"indicator",
Expand Down Expand Up @@ -77,11 +78,12 @@ export const AdministrationDosageValidator = (
if (value?.split(" ")[1] !== base_dosage?.split(" ")[1])
return "Unit must be the same as start and target dosage's unit";

if (
baseDosage &&
targetDosage &&
(valueDosage < baseDosage || valueDosage > targetDosage)
)
return "Dosage should be between start and target dosage";
if (baseDosage && targetDosage) {
const [min, max] = [baseDosage, targetDosage].sort((a, b) => a - b);

if (!(min <= valueDosage && valueDosage <= max)) {
return "Dosage should be between start and target dosage";
}
}
};
};
2 changes: 1 addition & 1 deletion src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export default function PatientInfoCard(props: {
consultation?.deprecated_verified_by) && (
<div className="text-sm" id="treating-physician">
<span className="font-semibold leading-relaxed">
Treating Physician:{" "}
{t("treating_doctor")}:{" "}
</span>
{consultation?.treating_physician_object
? `${consultation?.treating_physician_object.first_name} ${consultation?.treating_physician_object.last_name}`
Expand Down
33 changes: 21 additions & 12 deletions src/Components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export default function ManageUsers() {
open={expandFacilityList}
setOpen={setExpandFacilityList}
slideFrom="right"
title={t("facilities")}
title={t("linked_facilities")}
dialogClass="md:w-[400px]"
>
<UserFacilities user={selectedUser} />
Expand Down Expand Up @@ -728,6 +728,7 @@ export function UserFacilities(props: { user: any }) {
handleOk={handleUnlinkFacilitySubmit}
/>
)}

<div className="mb-4 flex items-stretch gap-2">
<FacilitySelect
multiple={false}
Expand All @@ -749,6 +750,8 @@ export function UserFacilities(props: { user: any }) {
{t("add")}
</ButtonV2>
</div>
<hr className="my-2 border-gray-300" />

{isLoading || userFacilitiesLoading ? (
<div className="flex items-center justify-center">
<CircularProgress />
Expand All @@ -757,13 +760,23 @@ export function UserFacilities(props: { user: any }) {
<div className="flex flex-col">
{/* Home Facility section */}
{user?.home_facility_object && (
<div className="mt-2" id="home-facility">
<div className="mb-2 ml-2 text-lg font-bold">
{t("home_facility")}
</div>
<div className="py-2" id="home-facility">
<div className="relative rounded p-2 transition hover:bg-gray-200 focus:bg-gray-200 md:rounded-lg">
<div className="flex items-center justify-between">
<span>{user?.home_facility_object?.name}</span>
<div className="flex items-center justify-between gap-2">
<div className="flex content-center items-center justify-center gap-2">
<span>{user?.home_facility_object?.name}</span>{" "}
<span
className={
"flex items-center justify-center rounded-xl bg-green-600 px-2 py-0.5 text-sm font-medium text-white"
}
>
<CareIcon
icon="l-estate"
className="mr-1 pt-[1px] text-lg"
/>
Home Facility
</span>
</div>
<div className="flex items-center gap-2">
<button
className="tooltip text-lg text-red-600"
Expand All @@ -784,16 +797,12 @@ export function UserFacilities(props: { user: any }) {
</div>
</div>
</div>
<hr className="my-2 border-gray-300" />
</div>
)}

{/* Linked Facilities section */}
{!!userFacilities?.results.length && (
<div className="mt-2" id="linked-facility-list">
<div className="mb-2 ml-2 text-lg font-bold">
{t("linked_facilities")}
</div>
<div id="linked-facility-list">
<div className="flex flex-col">
{userFacilities.results.map(
(facility: FacilityModel, i: number) => {
Expand Down
3 changes: 2 additions & 1 deletion src/Locale/en/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,6 @@
"DD/MM/YYYY": "DD/MM/YYYY",
"clear_all_filters": "Clear All Filters",
"summary": "Summary",
"report": "Report"
"report": "Report",
"treating_doctor":"Treating Doctor"
}

0 comments on commit 381e085

Please sign in to comment.