Skip to content

Commit

Permalink
Merge branch 'develop' into issue#6976
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranshu1902 authored Feb 8, 2024
2 parents dff5a5f + 4fa0533 commit 026dd25
Show file tree
Hide file tree
Showing 30 changed files with 1,289 additions and 1,261 deletions.
27 changes: 14 additions & 13 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ describe("Facility Manage Functions", () => {
const facilityUpdatedMiddleware = "updated.coronasafe.live";
const facilityMiddlewareSuccessfullNotification =
"Facility updated successfully";
const facilityHrfidUpdateButton = "Link Health Facility";
const facilityHrfidSuccessfullNotification =
"Health Facility config updated successfully";
const facilityHrfId = uuidv4();
const facilityUpdatedHrfId = uuidv4();
const facilityHfridUpdateButton = "Link Health Facility";
const facilityHfridToastNotificationText =
/Health Facility config updated successfully|Health ID registration failed/;
const facilityHfrId = "IN180000018";
const facilityUpdatedHfrId = uuidv4();
const doctorCapacity = "5";
const doctorModifiedCapacity = "7";
const totalCapacity = "100";
Expand Down Expand Up @@ -80,28 +80,29 @@ describe("Facility Manage Functions", () => {
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
// verify mandatory field error message
facilityManage.clickButtonWithText(facilityHrfidUpdateButton);
facilityManage.clearHfrId();
facilityManage.clickButtonWithText(facilityHfridUpdateButton);
facilityManage.checkErrorMessageVisibility(
"Health Facility Id is required"
);
// add facility health ID and verify notification
facilityManage.typeHrfId(facilityHrfId);
facilityManage.clickButtonWithText(facilityHrfidUpdateButton);
facilityManage.typeHfrId(facilityHfrId);
facilityManage.clickButtonWithText(facilityHfridUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHrfidSuccessfullNotification
facilityHfridToastNotificationText
);
// update the existing middleware
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.typeHrfId(facilityUpdatedHrfId);
facilityManage.clickButtonWithText(facilityHrfidUpdateButton);
facilityManage.typeHfrId(facilityUpdatedHfrId);
facilityManage.clickButtonWithText(facilityHfridUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHrfidSuccessfullNotification
facilityHfridToastNotificationText
);
// verify its reflection
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyHrfIdValue(facilityUpdatedHrfId);
facilityManage.verifyHfrIdValue(facilityUpdatedHfrId);
});

it("Modify doctor capacity in Facility detail page", () => {
Expand Down
10 changes: 7 additions & 3 deletions cypress/pageobject/Facility/FacilityManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,23 @@ class FacilityManage {
cy.get("#middleware_address").click().clear().click().type(address);
}

typeHrfId(address) {
clearHfrId() {
cy.get("#hf_id").click().clear();
}

typeHfrId(address) {
cy.get("#hf_id").click().clear().click().type(address);
}

verifySuccessMessageVisibilityAndContent(text) {
cy.get(".pnotify-text").should("be.visible").and("contain", text);
cy.get(".pnotify-text").should("be.visible").contains(text);
}

verifyMiddlewareAddressValue(expectedValue) {
cy.get("#middleware_address").should("have.value", expectedValue);
}

verifyHrfIdValue(expectedValue) {
verifyHfrIdValue(expectedValue) {
cy.get("#hf_id").should("have.value", expectedValue);
}

Expand Down
1 change: 1 addition & 0 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class PatientConsultationPage {

clickEditConsultationButton() {
cy.get("#consultation-buttons").scrollIntoView();
cy.get("button").contains("Manage Patient").click();
cy.get("#consultation-buttons")
.contains("Edit Consultation Details")
.click();
Expand Down
3 changes: 2 additions & 1 deletion public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"kasp_full_string": "Karunya Arogya Suraksha Padhathi",
"sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx",
"sample_format_external_result_import": "/External-Results-Template.csv",
"enable_abdm": true
"enable_abdm": true,
"enable_hcx": false
}
49 changes: 16 additions & 33 deletions src/Components/ABDM/ConfigureHealthFacility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,53 +75,31 @@ export const ConfigureHealthFacility = (props: any) => {

let response = null;
let responseData = null;
if (state.form.health_facility) {
if (state.form.hf_id === state.form.health_facility?.hf_id) {
const { res, data } = await request(
routes.abha.partialUpdateHealthFacility,
routes.abha.registerHealthFacilityAsService,
{
pathParams: {
facility_id: facilityId,
},
body: {
hf_id: state.form.hf_id,
},
}
);
response = res;
responseData = data;
} else if (state.form.hf_id === state.form.health_facility?.hf_id) {
} else if (state.form.health_facility) {
const { res, data } = await request(
routes.abha.registerHealthFacilityAsService,
routes.abha.partialUpdateHealthFacility,
{
pathParams: {
facility_id: facilityId,
},
body: {
hf_id: state.form.hf_id,
},
}
);
response = res;
responseData = data;

if (response?.status === 200 && responseData) {
if (responseData?.registered) {
dispatch({
type: "set_form",
form: {
...state.form,
health_facility: {
...state.form?.health_facility,
registered: responseData.registered,
},
},
});

return;
}
}

Notification.Error({
msg: "Service registration failed, please try again later",
});
return;
} else {
const { res, data } = await request(routes.abha.createHealthFacility, {
body: {
Expand All @@ -133,17 +111,22 @@ export const ConfigureHealthFacility = (props: any) => {
responseData = data;
}

setIsLoading(false);
if (response && responseData) {
if (response?.ok && responseData?.registered) {
Notification.Success({
msg: "Health Facility config updated successfully",
});
navigate(`/facility/${facilityId}`);
} else {
if (responseData)
if (responseData?.registered === false) {
Notification.Warn({
msg: responseData?.detail || "Health ID registration failed",
});
navigate(`/facility/${facilityId}`);
} else {
Notification.Error({
msg: "Something went wrong: " + (responseData.detail || ""),
msg: responseData?.detail || "Health Facility config update failed",
});
}
}
setIsLoading(false);
};
Expand Down
12 changes: 8 additions & 4 deletions src/Components/Assets/AssetType/HL7Monitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ const HL7Monitor = (props: HL7MonitorProps) => {
};

if (isLoading) return <Loading />;

const socketUrl = `wss://${
middlewareHostname || resolvedMiddleware?.hostname
}/observations/${localipAddress}`;

return (
<div className="mx-auto flex w-full xl:mt-8">
<div className="mx-auto flex flex-col gap-4 xl:flex-row-reverse">
Expand Down Expand Up @@ -126,13 +131,12 @@ const HL7Monitor = (props: HL7MonitorProps) => {
)}

{assetType === "HL7MONITOR" && (
<HL7PatientVitalsMonitor
socketUrl={`wss://${resolvedMiddleware?.hostname}/observations/${localipAddress}`}
/>
<HL7PatientVitalsMonitor key={socketUrl} socketUrl={socketUrl} />
)}
{assetType === "VENTILATOR" && (
<VentilatorPatientVitalsMonitor
socketUrl={`wss://${resolvedMiddleware?.hostname}/observations/${localipAddress}`}
key={socketUrl}
socketUrl={socketUrl}
/>
)}
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Common/RelativeDateUserMention.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function RelativeDateUserMention(props: {
actionDate?: string;
user?: PerformedByModel;
tooltipPosition?: "top" | "bottom" | "left" | "right";
withoutSuffix?: boolean;
}) {
return (
<div className="flex flex-row flex-wrap items-center justify-center ">
Expand All @@ -15,7 +16,9 @@ function RelativeDateUserMention(props: {
>
{props.actionDate ? formatDateTime(props.actionDate) : "--:--"}
</span>
{props.actionDate ? relativeDate(props.actionDate) : "--:--"}
{props.actionDate
? relativeDate(props.actionDate, props.withoutSuffix ?? false)
: "--:--"}
</div>
{props.user && (
<div className="tooltip">
Expand Down
12 changes: 3 additions & 9 deletions src/Components/Common/components/AccordionV2.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useRef, useState } from "react";
import { classNames } from "../../../Utils/utils";

export default function AccordionV2(props: {
children: JSX.Element | JSX.Element[];
Expand Down Expand Up @@ -55,15 +54,10 @@ export default function AccordionV2(props: {
</button>
</div>
<div
className={classNames("transition-all duration-500 ease-in-out")}
className={`transition-all duration-500 ease-in-out ${
toggle ? "overflow-visible" : "h-0 overflow-hidden"
}`}
ref={contentEl}
style={
toggle
? {
overflow: "visible",
}
: { height: "0px", overflow: "hidden" }
}
>
{props.children}
</div>
Expand Down
102 changes: 102 additions & 0 deletions src/Components/Diagnosis/DiagnosesListAccordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import {
ActiveConditionVerificationStatuses,
ConditionVerificationStatus,
ConsultationDiagnosis,
} from "./types";
import { useTranslation } from "react-i18next";
import { compareBy } from "../../Utils/utils";
import { useState } from "react";
import CareIcon from "../../CAREUI/icons/CareIcon";
import ButtonV2 from "../Common/components/ButtonV2";

interface Props {
diagnoses: ConsultationDiagnosis[];
}

type GroupedDiagnoses = Record<
ConditionVerificationStatus,
ConsultationDiagnosis[]
>;

function groupDiagnoses(diagnoses: ConsultationDiagnosis[]) {
const groupedDiagnoses = {} as GroupedDiagnoses;

for (const status of ActiveConditionVerificationStatuses) {
groupedDiagnoses[status] = diagnoses
.filter((d) => d.verification_status === status)
.sort(compareBy("is_principal"));
}

return groupedDiagnoses;
}

export default function DiagnosesListAccordion(props: Props) {
const [isVisible, setIsVisible] = useState(true);
const diagnoses = groupDiagnoses(props.diagnoses);

return (
<div>
<div className="flex justify-between">
{!isVisible && (
<ButtonV2
className="text-md w-full p-0 font-semibold text-black hover:bg-gray-200"
ghost
onClick={() => {
setIsVisible((prev) => !prev);
}}
>
<CareIcon icon="l-angle-down" className="h-7" />
Expand Diagnoses
</ButtonV2>
)}
</div>
<div
className={`transition-all duration-500 ease-in-out ${
isVisible ? "overflow-visible" : "h-0 overflow-hidden"
}`}
>
<h3 className="my-2 text-lg font-semibold leading-relaxed text-gray-900">
Diagnoses
</h3>
<div className="grid grid-cols-1 items-start gap-2 lg:grid-cols-2 2xl:grid-cols-3">
{Object.entries(diagnoses).map(
([status, diagnoses]) =>
!!diagnoses.length && (
<DiagnosesOfStatus key={status} diagnoses={diagnoses} />
)
)}
</div>
<ButtonV2
className="text-md w-full rounded-lg p-0 text-gray-600 hover:bg-gray-200"
ghost
onClick={() => {
setIsVisible(false);
}}
>
<CareIcon icon="l-angle-up" className="h-7" />
Hide Diagnoses
</ButtonV2>
</div>
</div>
);
}

const DiagnosesOfStatus = ({ diagnoses }: Props) => {
const { t } = useTranslation();

return (
<div>
<h2 className="text-sm font-semibold">
{t(diagnoses[0].verification_status)} {t("diagnoses")}{" "}
<span>({t("icd11_as_recommended")})</span>
</h2>
<ul className="text-sm">
{diagnoses.map((diagnosis) => (
<li key={diagnosis.id} className="flex items-center gap-2">
<span>{diagnosis.diagnosis_object?.label}</span>
</li>
))}
</ul>
</div>
);
};
Loading

0 comments on commit 026dd25

Please sign in to comment.