Skip to content

Commit

Permalink
Merge branch 'develop' into sainak/feat/use-managed-media-source
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Sep 18, 2024
2 parents b81047e + f7bda46 commit a347560
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 115 deletions.
2 changes: 1 addition & 1 deletion cypress/pageobject/Asset/AssetFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export class AssetFilters {
facilityName: string,
assetStatus: string,
assetClass: string,
assetLocation: string
assetLocation: string,
) {
cy.contains("Advanced Filters").click();
cy.get("input[name='Facilities']")
Expand Down
4 changes: 2 additions & 2 deletions cypress/pageobject/Asset/AssetSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class AssetSearchPage {
verifyBadgeContent(expectedText: string) {
cy.get("[data-testid='Name/Serial No./QR ID']").should(
"contain",
expectedText
expectedText,
);
}

Expand Down Expand Up @@ -54,7 +54,7 @@ export class AssetSearchPage {
verifyAssetListContains(dummyCameraText: string) {
cy.get("[data-testid='created-asset-list']").should(
"contain",
dummyCameraText
dummyCameraText,
);
}
}
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientInsurance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class PatientInsurance {
typePatientInsuranceDetail(
containerId: string,
fieldId: string,
value: string
value: string,
) {
cy.get(`#${containerId}`).within(() => {
cy.get(`#${fieldId}`).click().type(value);
Expand Down
4 changes: 2 additions & 2 deletions cypress/pageobject/Patient/PatientMedicalHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PatientMedicalHistory {
patientSymptoms4,
patientSymptoms5,
patientSymptoms6,
patientSymptoms7
patientSymptoms7,
) {
cy.get("[data-testid=patient-details]").then(($dashboard) => {
cy.url().should("include", "/facility/");
Expand All @@ -51,7 +51,7 @@ class PatientMedicalHistory {
verifyNoSymptosPresent(patientSymptoms1: string) {
cy.get("[data-testid=patient-details]").should(
"not.contain",
patientSymptoms1
patientSymptoms1,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/generate-build-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ fs.writeFile(
return console.log(err);
}
return null;
}
},
);
2 changes: 1 addition & 1 deletion src/Components/ExternalResult/ResultUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export default function UpdateResult(props: any) {
]}
value={state.form.patient_created}
onChange={handleChange}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
optionValue={(option) => option.value}
error={state.errors.patient_created}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ export const FacilityCreate = (props: FacilityProps) => {
{...field("kasp_empanelled")}
label={`Is this facility ${careConfig.kasp.string} empanelled?`}
options={[true, false]}
optionDisplay={(o) => (o ? "Yes" : "No")}
optionLabel={(o) => (o ? "Yes" : "No")}
optionValue={(o) => String(o)}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const FacilityHome = ({ facilityId }: Props) => {
<div
id="facility-coverimage"
className={
"absolute right-0 top-0 z-10 flex h-full w-full cursor-pointer flex-col items-center justify-center rounded-t-lg bg-black text-sm text-secondary-300 opacity-0 transition-opacity hover:opacity-60 md:h-[88px]"
"absolute right-0 top-0 z-10 flex h-full w-full cursor-pointer flex-col items-center justify-center rounded-lg bg-black text-sm text-secondary-300 opacity-0 transition-opacity hover:opacity-60"
}
onClick={() => setEditCoverImage(true)}
>
Expand Down
36 changes: 17 additions & 19 deletions src/Components/Facility/Investigations/InvestigationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SelectFormField } from "../../Form/FormFields/SelectFormField";
import TextFormField from "../../Form/FormFields/TextFormField";
import { classNames } from "../../../Utils/utils";
import { useState } from "react";
import { useTranslation } from "react-i18next";

const TestRow = ({ data, i, onChange, showForm, value, isChanged }: any) => {
return (
Expand Down Expand Up @@ -70,6 +71,7 @@ export const InvestigationTable = ({
handleUpdateCancel,
handleSave,
}: any) => {
const { t } = useTranslation();
const [searchFilter, setSearchFilter] = useState("");
const [showForm, setShowForm] = useState(false);
const filterTests = Object.values(data).filter((i: any) => {
Expand All @@ -84,16 +86,10 @@ export const InvestigationTable = ({
return (
<div className="m-4 p-4">
<div className="mb flex flex-col items-center justify-between sm:flex-row">
{title && <div className="text-xl font-bold">{title}</div>}
<div className="flex flex-col py-2 sm:flex-row">
<ButtonV2
variant="primary"
onClick={() => window.print()}
className="my-2 mr-2"
disabled={showForm}
>
Print Report
</ButtonV2>
{title && (
<div className="text-xl font-bold print:text-xs">{title}</div>
)}
<div className="flex flex-col py-2 sm:flex-row print:hidden">
<ButtonV2
disabled={isDischargedPatient}
variant="primary"
Expand All @@ -120,30 +116,31 @@ export const InvestigationTable = ({
<TextFormField
name="test_search"
label="Search Test"
className="mt-2"
className="mt-2 print:hidden"
placeholder="Search test"
value={searchFilter}
onChange={(e) => setSearchFilter(e.value)}
/>
<br />
<div id="section-to-print">
<div className="overflow-x-scroll border-b border-secondary-200 shadow sm:rounded-lg">
<table className="min-w-full divide-y divide-secondary-200">
<thead className="bg-secondary-50">
<div className="print:w-full">
<div className="overflow-x-scroll border-b border-secondary-200 shadow sm:rounded-lg print:overflow-visible print:border-none print:shadow-none">
<table className="min-w-full divide-y divide-secondary-200 print:min-w-0 print:divide-none">
<thead className="bg-secondary-50 print:bg-white">
<tr>
{["Name", "Value", "Unit", "Min", "Max", "Ideal"].map(
(heading) => (
<th
key={heading}
scope="col"
className="px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-secondary-800"
className="px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-secondary-800 print:text-sm print:font-normal print:tracking-normal print:text-black"
>
{heading}
</th>
),
)}
</tr>
</thead>
<tbody x-max="2">
<tbody className="print:divide-none">
{filterTests.length > 0 ? (
filterTests.map((t: any, i) => {
const value =
Expand Down Expand Up @@ -173,12 +170,13 @@ export const InvestigationTable = ({
};
handleValueChange(value, target);
}}
className="print:text-black"
/>
);
})
) : (
<tr className="text-center text-secondary-500">
No tests taken
<tr className="text-center text-secondary-500 print:text-black">
<td className="col-span-6">{t("no_tests_taken")}</td>
</tr>
)}
</tbody>
Expand Down
38 changes: 19 additions & 19 deletions src/Components/Facility/Investigations/ShowInvestigation.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import _, { set } from "lodash-es";
import { navigate } from "raviger";
import { lazy, useCallback, useReducer } from "react";
import { useTranslation } from "react-i18next";
import routes from "../../../Redux/api";
import * as Notification from "../../../Utils/Notifications.js";
import request from "../../../Utils/request/request";
import useQuery from "../../../Utils/request/useQuery";
import PageTitle from "../../Common/PageTitle";
import InvestigationTable from "./InvestigationTable";

import PrintPreview from "../../../CAREUI/misc/PrintPreview";
import { useTranslation } from "react-i18next";
const Loading = lazy(() => import("../../Common/Loading"));

const initialState = {
Expand All @@ -35,10 +34,15 @@ const updateFormReducer = (state = initialState, action: any) => {
}
};

export default function ShowInvestigation(props: any) {
interface ShowInvestigationProps {
consultationId: string;
patientId: string;
sessionId: string;
facilityId: string;
}
export default function ShowInvestigation(props: ShowInvestigationProps) {
const { consultationId, patientId, sessionId } = props;
const { t } = useTranslation();
const { consultationId, patientId, facilityId, sessionId } = props;

const [state, dispatch] = useReducer(updateFormReducer, initialState);
const { loading: investigationLoading } = useQuery(routes.getInvestigation, {
pathParams: {
Expand Down Expand Up @@ -141,27 +145,23 @@ export default function ShowInvestigation(props: any) {
if (patientLoading || investigationLoading) {
return <Loading />;
}

return (
<div className="mx-auto max-w-7xl px-4">
<PageTitle
title={t("investigations")}
className="mx-3 md:mx-4"
crumbsReplacements={{
[facilityId]: { name: patientData?.facility_object?.name },
[patientId]: { name: patientData?.name },
}}
backUrl={`/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`}
/>
<PrintPreview
title={t("investigation_report_for_{{name}}", {
name: patientData?.name,
})}
>
<InvestigationTable
title={`ID: ${sessionId}`}
title={t("investigation_report_of_{{name}}", {
name: patientData?.name,
})}
data={state.initialValues}
isDischargedPatient={!!consultation?.discharge_date}
changedFields={state.changedFields}
handleValueChange={handleValueChange}
handleUpdateCancel={handleUpdateCancel}
handleSave={handleSubmit}
/>
</div>
</PrintPreview>
);
}
69 changes: 29 additions & 40 deletions src/Components/Facility/TreatmentSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import {
formatDateTime,
formatPatientAge,
} from "../../Utils/utils";
import useAppHistory from "../../Common/hooks/useAppHistory";
import routes from "../../Redux/api";
import useQuery from "../../Utils/request/useQuery";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { ConsultationModel } from "./models";
import { useMemo } from "react";
import {
Expand All @@ -18,6 +16,8 @@ import PageHeadTitle from "../Common/PageHeadTitle";
import { useTranslation } from "react-i18next";
import { PatientModel } from "../Patient/models";
import MedicineRoutes from "../Medicine/routes";
import PrintPreview from "../../CAREUI/misc/PrintPreview";
import careConfig from "@careConfig";

export interface ITreatmentSummaryProps {
consultationId: string;
Expand All @@ -28,12 +28,9 @@ export interface ITreatmentSummaryProps {
export default function TreatmentSummary({
consultationId,
patientId,
facilityId,
}: ITreatmentSummaryProps) {
const { t } = useTranslation();
const date = new Date();
const { goBack } = useAppHistory();
const url = `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`;

const { data: patientData } = useQuery(routes.getPatient, {
pathParams: { id: patientId },
Expand All @@ -49,50 +46,42 @@ export default function TreatmentSummary({
<div>
<PageHeadTitle title={t("treatment_summary__head_title")} />
<div className="my-4">
<div className="my-4 flex flex-wrap justify-center gap-2 sm:justify-end">
<button
onClick={(_) => window.print()}
className="btn btn-primary mr-2"
>
<CareIcon icon="l-print" className="mr-2" />
{t("treatment_summary__print")}
</button>
<button onClick={(_) => goBack(url)} className="btn btn-default">
<CareIcon icon="l-times" className="mr-2" />
{t("close")}
</button>
</div>

<div id="section-to-print" className="mx-5">
<h2 className="text-center text-lg">
{consultationData?.facility_name ?? ""}
</h2>
<PrintPreview title={t("treatment_summary__head_title")}>
<div id="section-to-print" className="mx-5">
<div className="mb-3 flex items-center justify-between p-4">
<h3>{consultationData?.facility_name}</h3>
<img
className="h-10 w-auto"
src={careConfig.mainLogo?.dark}
alt="care logo"
/>
</div>
<h2 className="text-center text-lg">
{t("treatment_summary__heading")}
</h2>

<h2 className="text-center text-lg">
{t("treatment_summary__heading")}
</h2>
<div className="text-right font-bold">{formatDate(date)}</div>

<div className="text-right font-bold">{formatDate(date)}</div>
<div className="mb-5 mt-2 border border-gray-800">
<BasicDetailsSection
patientData={patientData}
consultationData={consultationData}
/>

<div className="mb-5 mt-2 border border-gray-800">
<BasicDetailsSection
patientData={patientData}
consultationData={consultationData}
/>
<ComorbiditiesSection patientData={patientData} />

<ComorbiditiesSection patientData={patientData} />
<DiagnosisSection consultationData={consultationData} />

<DiagnosisSection consultationData={consultationData} />
<InvestigationsSection consultationId={consultationId} />

<InvestigationsSection consultationId={consultationId} />
<TreatmentSection consultationData={consultationData} />

<TreatmentSection consultationData={consultationData} />
<PrescriptionsSection consultationId={consultationId} />

<PrescriptionsSection consultationId={consultationId} />

<InstructionsSection consultationData={consultationData} />
<InstructionsSection consultationData={consultationData} />
</div>
</div>
</div>
</PrintPreview>
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Form/FormFields/RadioFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";

type Props<T, V = string> = FormFieldBaseProps<V | null> & {
options: readonly T[];
optionDisplay: (option: T) => React.ReactNode;
optionLabel: (option: T) => React.ReactNode;
optionValue: (option: T) => V;
containerClassName?: string;
unselectLabel?: string;
Expand Down Expand Up @@ -47,7 +47,7 @@ const RadioFormField = <T, V extends string>(props: Props<T, V>) => {
<RadioInput
key={value}
id={`${props.name}-option-${value}`}
label={props.optionDisplay(option)}
label={props.optionLabel(option)}
name={field.name}
value={props.optionValue(option)}
checked={value === field.value}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/LogUpdate/Sections/BloodSugar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const BloodSugar = ({ log, onChange }: LogUpdateSectionProps) => {
label="Frequency"
name="insulin_intake_frequency"
options={INSULIN_INTAKE_FREQUENCY_OPTIONS}
optionDisplay={(c) => t(`INSULIN_INTAKE_FREQUENCY__${c}`)}
optionLabel={(c) => t(`INSULIN_INTAKE_FREQUENCY__${c}`)}
optionValue={(c) => c}
value={log.insulin_intake_frequency}
onChange={(c) =>
Expand Down
Loading

0 comments on commit a347560

Please sign in to comment.