Skip to content

Commit

Permalink
Merge pull request #340 from noharm-ai/develop
Browse files Browse the repository at this point in the history
v3.1.20
  • Loading branch information
marceloarocha authored Jul 18, 2024
2 parents fc67c0d + be0140c commit d1c6b1b
Show file tree
Hide file tree
Showing 29 changed files with 735 additions and 407 deletions.
63 changes: 0 additions & 63 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,6 @@ on:
branches: [develop]

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11.6
env:
POSTGRES_USER: postgres
POSTGRES_DB: noharm
ports:
- 5432:5432
steps:
- name: Checkout backend
run: |
git clone --single-branch --branch develop https://github.com/noharm-ai/backend .
- uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Setup Python
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Setup PostgreSQL
run: |
git clone https://github.com/noharm-ai/database
psql -h localhost -U postgres -d noharm -a -f database/noharm-public.sql -v ON_ERROR_STOP=1
psql -h localhost -U postgres -d noharm -a -f database/noharm-create.sql -v ON_ERROR_STOP=1
psql -h localhost -U postgres -d noharm -a -f database/noharm-newuser.sql -v ON_ERROR_STOP=1
psql -h localhost -U postgres -d noharm -a -f database/noharm-triggers.sql -v ON_ERROR_STOP=1
psql -h localhost -U postgres -d noharm -a -f database/noharm-insert.sql -v ON_ERROR_STOP=1
- name: Run Backend
run: |
python mobile.py &
sleep 10
env:
MAIL_HOST: http://localhost:3000
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
env:
REACT_APP_API_URL: http://localhost:5000
REACT_APP_SITE_TITLE: ${{ secrets.REACT_APP_SITE_TITLE_DEV }}
REACT_APP_API_KEY: ${{ secrets.REACT_APP_API_KEY }}
REACT_APP_SUPPORT_EMAIL: ${{ secrets.REACT_APP_SUPPORT_EMAIL }}
REACT_APP_SUPPORT_LINK: ${{ secrets.REACT_APP_SUPPORT_LINK }}
REACT_APP_ODOO_LINK: ${{ secrets.REACT_APP_ODOO_LINK }}
REACT_APP_VERSION: ${{ steps.package-version.outputs.current-version}}
REACT_APP_URL: http://localhost:3000
TEST_USER: e2e@e2e.com
TEST_USER_PASSWORD: e2etest
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
deploy:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "noharm-app",
"version": "3.1.19",
"version": "3.1.20",
"private": true,
"dependencies": {
"@ckeditor/ckeditor5-build-classic": "^35.0.1",
Expand Down
16 changes: 10 additions & 6 deletions src/components/DrugAlertLevelTag.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Tag from "components/Tag";
export default function DrugAlertLevelTag({
levels,
count,
label,
showTooltip = true,
showDescription = false,
allergy = false,
onClick = () => {},
Expand Down Expand Up @@ -71,9 +73,11 @@ export default function DrugAlertLevelTag({
return (
<Tooltip
title={
allergy
? t("prescriptionDrugTags.alertsAllergy")
: t("prescriptionDrugTags.alerts")
showTooltip
? allergy
? t("prescriptionDrugTags.alertsAllergy")
: t("prescriptionDrugTags.alerts")
: null
}
>
<Badge dot count={allergy ? 1 : 0}>
Expand All @@ -82,13 +86,13 @@ export default function DrugAlertLevelTag({
...getAlertStyle(),
cursor: "pointer",
marginRight: 0,
width: showDescription ? "auto" : "30px",
width: showDescription || label ? "auto" : "30px",
textAlign: "center",
padding: showDescription ? "0 5px" : 0,
padding: showDescription || label ? "0 5px" : 0,
}}
onClick={() => onClick()}
>
{showDescription ? getAlertDescription() : count}
{showDescription ? getAlertDescription() : count || label}
</Tag>
</Badge>
</Tooltip>
Expand Down
1 change: 1 addition & 0 deletions src/components/Forms/Patient/Base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default function Base({ security }) {
max={99999}
value={height}
onChange={(value) => setFieldValue("height", value)}
precision={0}
/>{" "}
cm
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export default function FilterMemory({
};

const loadFilterAction = (filterData) => {
// keep compatibility between different versions
if (filterData.idSegment && !Array.isArray(filterData.idSegment)) {
filterData.idSegment = [filterData.idSegment];
}

setScreeningListFilter(filterData);
loadFilter(filterData);
};
Expand Down
104 changes: 58 additions & 46 deletions src/components/Prioritization/Filter/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useState, useCallback } from "react";
import { useSelector, useDispatch } from "react-redux";
import isEmpty from "lodash.isempty";
import dayjs from "dayjs";
import debounce from "lodash.debounce";
Expand All @@ -11,7 +12,6 @@ import {
DeleteOutlined,
} from "@ant-design/icons";

import message from "components/message";
import Heading from "components/Heading";
import { Row, Col } from "components/Grid";
import { Select, RangeDatePicker, Checkbox, Input } from "components/Inputs";
Expand All @@ -23,6 +23,8 @@ import LoadBox from "components/LoadBox";
import FilterMemory from "./components/FilterMemory";
import FieldSubstanceAutocomplete from "features/fields/FieldSubstanceAutocomplete/FieldSubstanceAutocomplete";
import FieldSubstanceClassAutocomplete from "features/fields/FieldSubstanceClassAutocomplete/FieldSubstanceClassAutocomplete";
import { getSegmentDepartments } from "features/lists/ListsSlice";
import { getUniqBy } from "utils/report";

import { Box, SearchBox } from "./Filter.style";
import "./index.css";
Expand All @@ -48,9 +50,16 @@ export default function Filter({
publicFilters,
featureService,
}) {
const dispatch = useDispatch();
const params = useParams();
const location = useLocation();
const [open, setOpen] = useState(false);
const departments = useSelector(
(state) => state.lists.getSegmentDepartments.list
);
const departmentsStatus = useSelector(
(state) => state.lists.getSegmentDepartments.status
);

const [date, setDate] = useState([dayjs(params?.startDate), null]);
const { t } = useTranslation();
Expand Down Expand Up @@ -89,7 +98,13 @@ export default function Filter({

for (const key in mixedParams) {
if (mixedParams[key] !== "all") {
finalParams[key] = mixedParams[key];
if (key === "idSegment") {
finalParams[key] = Array.isArray(mixedParams[key])
? mixedParams[key]
: [mixedParams[key]];
} else {
finalParams[key] = mixedParams[key];
}
}
}

Expand Down Expand Up @@ -127,20 +142,8 @@ export default function Filter({
);

useEffect(() => {
if (!isEmpty(segments.error)) {
message.error(segments.error.message);
}
}, [segments.error]);

useEffect(() => {
if (filter.idSegment == null) return;

if (filter.idSegment !== "all") {
fetchDepartmentsList(filter.idSegment);
} else {
resetDepartmentsLst();
}
}, [filter.idSegment, fetchDepartmentsList, resetDepartmentsLst]);
dispatch(getSegmentDepartments());
}, []); //eslint-disable-line

// update list status
const updateStatus = useCallback(() => {
Expand All @@ -162,7 +165,7 @@ export default function Filter({
getParams({ ...filterData, idDept: filterData.idDepartment })
);
if (!isEmpty(filterData.idDrug)) {
searchDrugs(filterData.idSegment, { idDrug: filterData.idDrug });
searchDrugs(null, { idDrug: filterData.idDrug });
}
setOpen(false);
};
Expand Down Expand Up @@ -215,26 +218,13 @@ export default function Filter({
setDate(dt);
};

useEffect(() => {
if (!filter.idSegment && segments.list.length) {
setScreeningListFilter({ idSegment: segments.list[0].id });
fetchPrescriptionsList(getParams({ idSegment: segments.list[0].id }));
}
}, [
segments.list,
filter.idSegment,
setScreeningListFilter,
fetchPrescriptionsList,
getParams,
]);

useEffect(() => {
if (filter.idSegment) {
fetchPrescriptionsList(getParams());
}

if (!isEmpty(filter.idDrug) && filter.idSegment) {
searchDrugs(filter.idSegment, { idDrug: filter.idDrug });
if (!isEmpty(filter.idDrug)) {
searchDrugs(null, { idDrug: filter.idDrug });
}
}, [location.pathname]); // eslint-disable-line

Expand All @@ -255,7 +245,7 @@ export default function Filter({

const reset = () => {
setScreeningListFilter({
idSegment: segments.list[0].id,
idSegment: [],
idDepartment: [],
idDrug: [],
insurance: null,
Expand Down Expand Up @@ -290,7 +280,7 @@ export default function Filter({

const searchDrugsAutocomplete = debounce((value) => {
if (value.length < 3) return;
searchDrugs(filter.idSegment, { q: value });
searchDrugs(null, { q: value });
}, 800);

const drugAttributesList = [
Expand All @@ -305,6 +295,23 @@ export default function Filter({
"dialyzable",
];

const filterDepartments = (idSegmentList, list) => {
const deps = list.filter((d) => {
if (!idSegmentList || idSegmentList.length === 0) {
return true;
}

if (Array.isArray(idSegmentList)) {
return idSegmentList.indexOf(d.idSegment) !== -1;
}

// keep compatibility
return idSegmentList === d.idSegment;
});

return getUniqBy(deps, "idDepartment");
};

const hiddenFieldCount = countHiddenFilters(filter);
return (
<SearchBox className={open ? "open" : ""}>
Expand All @@ -322,6 +329,9 @@ export default function Filter({
setScreeningListFilter({ idSegment, idDepartment: [] })
}
value={filter.idSegment}
mode="multiple"
allowClear
maxTagCount="responsive"
>
{segments.list.map(({ id, description: text }) => (
<Select.Option key={id} value={id}>
Expand Down Expand Up @@ -424,23 +434,22 @@ export default function Filter({
placeholder={t(
"screeningList.labelDepartmentPlaceholder"
)}
loading={segments.single.isFetching}
loading={departmentsStatus === "loading"}
value={filter.idDepartment}
onChange={onDepartmentChange}
autoClearSearchValue={false}
allowClear
>
{segments.single.content.departments &&
segments.single.content.departments.map(
({ idDepartment, name }) => (
<Select.Option
key={idDepartment}
value={idDepartment}
>
{name}
</Select.Option>
)
)}
{filterDepartments(filter.idSegment, departments).map(
({ idDepartment, idSegment, label }) => (
<Select.Option
key={`${idSegment}-${idDepartment}`}
value={idDepartment}
>
{label}
</Select.Option>
)
)}
</Select>
</Col>
{prioritizationType === "patient" ||
Expand Down Expand Up @@ -668,6 +677,9 @@ export default function Filter({
<Select.Option key={"maxTime"} value={"maxTime"}>
{t("drugAlertType.maxTime")}
</Select.Option>
<Select.Option key={"fasting"} value={"fasting"}>
{t("drugAlertType.fasting")}
</Select.Option>
</Select>
</Col>
</Row>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Screening/ClinicalNotes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export default function ClinicalNotes({
}
loading={isFetchingExtra === group.label}
>
Abrir evoluções ({dates[group.label].count})
Abrir evoluções ({dates[group.label]?.count})
</Button>
</div>
<div className="indicators">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,10 @@ export const DrugAlertsCollapse = styled(Collapse)`
}
}
`;

export const AlertTagsContainer = styled.div`
.ant-tag {
margin-right: 5px !important;
font-size: 14px;
}
`;
Loading

0 comments on commit d1c6b1b

Please sign in to comment.