Skip to content

Commit

Permalink
Merge pull request #345 from noharm-ai/develop
Browse files Browse the repository at this point in the history
v3.2.2
  • Loading branch information
marceloarocha authored Aug 7, 2024
2 parents c71bfa8 + b54d682 commit 247e04e
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 4 deletions.
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.2.1",
"version": "3.2.2",
"private": true,
"dependencies": {
"@ckeditor/ckeditor5-build-classic": "^35.0.1",
Expand Down
30 changes: 30 additions & 0 deletions src/components/Prioritization/Filter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default function Filter({
substanceClasses: filter.substanceClasses,
patientStatus: filter.patientStatus,
patientReviewType: filter.patientReviewType,
idPatient: filter.idPatient,
};
const mixedParams = { ...params, ...forceParams };
const finalParams = {};
Expand Down Expand Up @@ -136,6 +137,7 @@ export default function Filter({
filter.substances,
filter.substanceClasses,
filter.patientReviewType,
filter.idPatient,
prioritizationType,
date,
]
Expand Down Expand Up @@ -259,6 +261,7 @@ export default function Filter({
substanceClasses: [],
patientStatus: null,
patientReviewType: null,
idPatient: [],
});
setDate([dayjs(), null]);
};
Expand Down Expand Up @@ -783,6 +786,33 @@ export default function Filter({
</Row>
)}

<Row gutter={0} style={{ marginTop: "10px" }}>
<Col md={24}>
<Box>
<Row gutter={0} style={{ width: "100%" }}>
<Col md={19}>
<Heading as="label" htmlFor="indicators" size="14px">
ID Paciente:
</Heading>
<Select
id="idPatient"
mode="tags"
placeholder="Digite o ID do paciente e pressione enter"
tokenSeparators={[","]}
style={{ width: "100%" }}
value={filter.idPatient}
onChange={(value) =>
setScreeningListFilter({ idPatient: value })
}
notFoundContent="Digite o ID do paciente e pressione enter. Mais de um ID pode ser informado."
allowClear
></Select>
</Col>
</Row>
</Box>
</Col>
</Row>

<Row gutter={[20, 0]} style={{ marginTop: "20px" }}>
<Col>
<Box flexDirection="row" alignItems="center">
Expand Down
3 changes: 2 additions & 1 deletion src/store/ducks/prescriptions/thunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const fetchPrescriptionsListThunk =
error,
} = await api.getPrescriptions(access_token, params).catch(errorHandler);

if (!isEmpty(error)) {
if (!isEmpty(error) || !data) {
dispatch(prescriptionsFetchListError(error));
return;
}
Expand All @@ -88,6 +88,7 @@ export const fetchPrescriptionsListThunk =
access_token,
requestConfig
);

const listAddedPatientName = data.map(({ idPatient, ...item }) => ({
...item,
idPatient,
Expand Down
7 changes: 7 additions & 0 deletions src/utils/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ export const formatDateTime = (isoDate) => {

return dayjs(isoDate).format("DD/MM/YYYY HH:mm");
};

export const isDate = (value) => {
return (
dayjs(value, "YYYY-MM-DD", true).isValid() ||
dayjs(value, "YYYY-MM-DDTHH:mm:ss").isValid()
);
};
19 changes: 19 additions & 0 deletions src/utils/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,22 @@ export function formatCurrency(value, precision = 2) {
export function formatNumber(value, precision = 2) {
return formatCurrency(value, precision);
}

export function isNumber(value) {
try {
Big(value);

return true;
} catch {
return false;
}
}

export function isInt(value) {
return (
!isNaN(value) &&
parseInt(Number(value)) == value && //eslint-disable-line
!isNaN(parseInt(value, 10)) &&
`${value}`.indexOf(".") === -1
);
}
10 changes: 10 additions & 0 deletions src/utils/report.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { uniq, uniqBy, isEmpty } from "utils/lodash";
import dayjs from "dayjs";
import humanizeDuration from "humanize-duration";
import { isNumber, formatNumber, isInt } from "./number";
import { isDate, formatDateTime } from "./date";

export const getUniqList = (datasource, attr) => {
if (!datasource.length) return [];
Expand Down Expand Up @@ -83,6 +85,14 @@ export const exportCSV = (datasource, t, namespace = "reportcsv") => {
return `"${JSON.stringify(value, replacer).replaceAll('"', "")}"`;
}

if (isNumber(value) && !isInt(value)) {
return JSON.stringify(formatNumber(value, 6));
}

if (isDate(value)) {
return JSON.stringify(formatDateTime(value), replacer);
}

return JSON.stringify(value, replacer);
};
const header = Object.keys(datasource[0]);
Expand Down
9 changes: 7 additions & 2 deletions src/utils/transformers/prescriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,13 @@ export const transformPrescription = ({
};
};

export const transformPrescriptions = (prescriptions) =>
prescriptions.map(transformPrescription);
export const transformPrescriptions = (prescriptions) => {
if (!prescriptions) {
return [];
}

return prescriptions.map(transformPrescription);
};

export const transformExams = (exams) =>
Object.keys(exams).map((key) => {
Expand Down

0 comments on commit 247e04e

Please sign in to comment.