Skip to content

Commit

Permalink
Merge branch 'develop' into fix#6771
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevildude authored Feb 15, 2024
2 parents ac487c5 + d36c0f2 commit 96f3f5d
Show file tree
Hide file tree
Showing 78 changed files with 2,404 additions and 2,443 deletions.
2 changes: 0 additions & 2 deletions cypress/e2e/assets_spec/asset_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ describe("Asset Tab", () => {
it("Filter Asset", () => {
assetFilters.filterAssets(
"Dummy Facility 40",
"INTERNAL",
"ACTIVE",
"ONVIF Camera",
"Camera Loc"
);
assetFilters.clickadvancefilter();
assetFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters
assetFilters.assertFacilityText("Dummy Facility 40");
assetFilters.assertAssetTypeText("INTERNAL");
assetFilters.assertAssetClassText("ONVIF");
assetFilters.assertStatusText("ACTIVE");
assetFilters.assertLocationText("Camera Loc");
Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/assets_spec/assets_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe("Asset", () => {
assetPage.clickCreateAsset();

assetPage.verifyEmptyAssetNameError();
assetPage.verifyEmptyAssetTypeError();
assetPage.verifyEmptyLocationError();
assetPage.verifyEmptyStatusError();
assetPage.verifyEmptyPhoneError();
Expand All @@ -41,7 +40,6 @@ describe("Asset", () => {
assetPage.createAsset();
assetPage.selectFacility("Dummy Facility 40");
assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("ONVIF Camera");

const qr_id_1 = uuidv4();
Expand All @@ -68,7 +66,6 @@ describe("Asset", () => {
const qr_id_2 = uuidv4();

assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("ONVIF Camera");
assetPage.enterAssetDetails(
"New Test Asset 2",
Expand Down Expand Up @@ -141,7 +138,6 @@ describe("Asset", () => {
assetPage.createAsset();
assetPage.selectFacility("Dummy Facility 40");
assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("HL7 Vitals Monitor");

const qr_id_1 = uuidv4();
Expand Down
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
7 changes: 0 additions & 7 deletions cypress/e2e/sample_test_spec/filter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ describe("Sample Filter", () => {
.click();
});

it("Filter by Asset Type", () => {
cy.get("#result").click();
cy.get("li[role='option']")
.contains(/^POSITIVE$/)
.click();
});

it("Filter by sample type", () => {
cy.get("#sample_type").click();
cy.get("li[role='option']")
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("User Creation", () => {
}
return result;
};
const username = makeid(25);
const username = makeid(8);
const alreadylinkedusersviews = [
"devdoctor",
"devstaff2",
Expand Down
15 changes: 0 additions & 15 deletions cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ export class AssetPage {
});
}

selectAssetType(assetType: string) {
cy.get("[data-testid=asset-type-input] button")
.click()
.then(() => {
cy.get("[role='option']").contains(assetType).click();
});
}

selectAssetClass(assetClass: string) {
cy.get("[data-testid=asset-class-input] button")
.click()
Expand Down Expand Up @@ -205,13 +197,6 @@ export class AssetPage {
);
}

verifyEmptyAssetTypeError() {
cy.get("[data-testid=asset-type-input] span").should(
"contain",
"Select an asset type"
);
}

verifyEmptyStatusError() {
cy.get("[data-testid=asset-working-status-input] span").should(
"contain",
Expand Down
9 changes: 0 additions & 9 deletions cypress/pageobject/Asset/AssetFilters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export class AssetFilters {
filterAssets(
facilityName: string,
assetType: string,
assetStatus: string,
assetClass: string,
assetLocation: string
Expand All @@ -13,11 +12,6 @@ export class AssetFilters {
.then(() => {
cy.get("[role='option']").contains(facilityName).click();
});
cy.get("#asset-type")
.click()
.then(() => {
cy.get("[role='option']").contains(assetType).click();
});
cy.get("#asset-status")
.click()
.then(() => {
Expand Down Expand Up @@ -65,9 +59,6 @@ export class AssetFilters {
assertFacilityText(text) {
cy.get("[data-testid=Facility]").should("contain", text);
}
assertAssetTypeText(text) {
cy.get("[data-testid='Asset Type']").should("contain", text);
}
assertAssetClassText(text) {
cy.get("[data-testid='Asset Class']").should("contain", text);
}
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 @@ -22,5 +22,6 @@
"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_hcx": false
"enable_hcx": false,
"min_encounter_date": "2020-01-01"
}
2 changes: 1 addition & 1 deletion src/CAREUI/display/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface TimelineEvent<TType = string> {
}

interface TimelineProps {
className: string;
className?: string;
children: React.ReactNode | React.ReactNode[];
name: string;
}
Expand Down
29 changes: 13 additions & 16 deletions src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ButtonV2, {
import CareIcon from "../icons/CareIcon";
import { classNames } from "../../Utils/utils";
import Pagination from "../../Components/Common/Pagination";
import Timeline from "../display/Timeline";

const DEFAULT_PER_PAGE_LIMIT = 14;

Expand Down Expand Up @@ -135,21 +134,19 @@ const Items = <TItem extends object>(props: ItemsProps<TItem>) => {
}

return (
<Timeline className="rounded-lg bg-white p-2 shadow" name="log update">
<ul className={props.className}>
{loading && props.shimmer
? Array.from({ length: props.shimmerCount ?? 8 }).map((_, i) => (
<li key={i} className="w-full">
{props.shimmer}
</li>
))
: items.map((item, index, items) => (
<li key={index} className="w-full">
{props.children(item, items)}
</li>
))}
</ul>
</Timeline>
<ul className={props.className}>
{loading && props.shimmer
? Array.from({ length: props.shimmerCount ?? 8 }).map((_, i) => (
<li key={i} className="w-full">
{props.shimmer}
</li>
))
: items.map((item, index, items) => (
<li key={index} className="w-full">
{props.children(item, items)}
</li>
))}
</ul>
);
};

Expand Down
5 changes: 5 additions & 0 deletions src/Common/hooks/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ export interface IConfig {
*/
wartime_shifting: boolean;
jwt_token_refresh_interval?: number;

/*
* Minimum date for a possible consultation encounter.
*/
min_encounter_date: string;
}

const useConfig = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Common/validation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const validateName = (name: string) => {
};

export const validateUsername = (username: string) => {
const pattern = /^[\w.@+-]+[^.@+_-]$/;
const pattern = /^(?!.*[._-]{2})[a-z0-9](?:[a-z0-9._-]{2,14}[a-z0-9])$/s;
return pattern.test(username);
};

Expand Down
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
Loading

0 comments on commit 96f3f5d

Please sign in to comment.