Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "noharm-app",
"private": true,
"version": "6.2.10",
"version": "6.2.11",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
10 changes: 10 additions & 0 deletions src/components/ChartCreator/ChartCreator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function ChartCreator({ data, initialCharts, onChartsChange, readOnly }:
const [newReferenceLine, setNewReferenceLine] = useState<ReferenceLine | undefined>(undefined);
const [newShowTitle, setNewShowTitle] = useState(true);
const [newColorPalette, setNewColorPalette] = useState<ColorPalette>("default");
const [newStacked, setNewStacked] = useState(false);

// State for EDITING chart form (Modal)
const [editTitle, setEditTitle] = useState("");
Expand All @@ -47,6 +48,7 @@ export function ChartCreator({ data, initialCharts, onChartsChange, readOnly }:
const [editReferenceLine, setEditReferenceLine] = useState<ReferenceLine | undefined>(undefined);
const [editShowTitle, setEditShowTitle] = useState(true);
const [editColorPalette, setEditColorPalette] = useState<ColorPalette>("default");
const [editStacked, setEditStacked] = useState(false);
const [editingChartId, setEditingChartId] = useState<string | null>(null);

const keys = useMemo(() => {
Expand Down Expand Up @@ -86,6 +88,7 @@ export function ChartCreator({ data, initialCharts, onChartsChange, readOnly }:
referenceLine: newReferenceLine,
showTitle: newShowTitle,
colorPalette: newColorPalette,
stacked: newStacked,
},
]);
setNewTitle("");
Expand All @@ -104,6 +107,7 @@ export function ChartCreator({ data, initialCharts, onChartsChange, readOnly }:
setNewReferenceLine(undefined);
setNewShowTitle(true);
setNewColorPalette("default");
setNewStacked(false);
}
};

Expand All @@ -125,6 +129,7 @@ export function ChartCreator({ data, initialCharts, onChartsChange, readOnly }:
setEditReferenceLine(chart.referenceLine);
setEditShowTitle(chart.showTitle ?? true);
setEditColorPalette(chart.colorPalette ?? "default");
setEditStacked(chart.stacked ?? false);
}, []);

const saveEdit = () => {
Expand All @@ -150,6 +155,7 @@ export function ChartCreator({ data, initialCharts, onChartsChange, readOnly }:
referenceLine: editReferenceLine,
showTitle: editShowTitle,
colorPalette: editColorPalette,
stacked: editStacked,
}
: c,
),
Expand Down Expand Up @@ -228,6 +234,8 @@ export function ChartCreator({ data, initialCharts, onChartsChange, readOnly }:
setShowTitle={setNewShowTitle}
colorPalette={newColorPalette}
setColorPalette={setNewColorPalette}
stacked={newStacked}
setStacked={setNewStacked}
keys={keys}
/>
</Card>
Expand Down Expand Up @@ -286,6 +294,8 @@ export function ChartCreator({ data, initialCharts, onChartsChange, readOnly }:
setShowTitle={setEditShowTitle}
colorPalette={editColorPalette}
setColorPalette={setEditColorPalette}
stacked={editStacked}
setStacked={setEditStacked}
keys={keys}
/>
</Modal>
Expand Down
20 changes: 19 additions & 1 deletion src/components/ChartCreator/ChartFormFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ interface ChartFormFieldsProps {
setShowTitle: (val: boolean) => void;
colorPalette: ColorPalette;
setColorPalette: (val: ColorPalette) => void;
stacked: boolean;
setStacked: (val: boolean) => void;
keys: string[];
}

Expand Down Expand Up @@ -121,6 +123,8 @@ export const ChartFormFields = ({
setShowTitle,
colorPalette,
setColorPalette,
stacked,
setStacked,
keys,
}: ChartFormFieldsProps) => {
const allYOptions = keys.map((k) => ({ label: k, value: k }));
Expand Down Expand Up @@ -359,7 +363,7 @@ export const ChartFormFields = ({
</Col>
</Row>

{/* Show labels + X label rotation */}
{/* Show labels + Stacked */}
<Row gutter={8} align="middle">
<Col
span={12}
Expand All @@ -373,6 +377,20 @@ export const ChartFormFields = ({
Rótulos nos dados
</label>
</Col>
{(type === "bar" || type === "hbar") && (
<Col
span={12}
style={{ display: "flex", alignItems: "center", gap: 8 }}
>
<Switch checked={stacked} onChange={setStacked} size="small" />
<label
style={{ cursor: "pointer" }}
onClick={() => setStacked(!stacked)}
>
Barras empilhadas
</label>
</Col>
)}
</Row>

{/* Reference line */}
Expand Down
1 change: 1 addition & 0 deletions src/components/ChartCreator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface ChartConfig {
referenceLine?: ReferenceLine;
showTitle?: boolean;
colorPalette?: ColorPalette;
stacked?: boolean;
}

export interface ChartCreatorProps {
Expand Down
5 changes: 4 additions & 1 deletion src/components/ChartCreator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,10 @@ export const getChartOption = (data: any[], config: ChartConfig) => {
}

const isHBar = config.type === "hbar";
const isStacked = !!config.stacked && (config.type === "bar" || config.type === "hbar");
const label = {
show: showLabels,
position: isHBar ? "right" as const : "top" as const,
position: isStacked ? "inside" as const : (isHBar ? "right" as const : "top" as const),
formatter: isCountPct
? (params: any) => `${params.data.rawCount} (${params.value}%)`
: "{c}",
Expand Down Expand Up @@ -276,6 +277,7 @@ export const getChartOption = (data: any[], config: ChartConfig) => {
type: echartsType,
label,
markLine,
...(isStacked ? { stack: "total" } : {}),
},
]
: config.yKeys
Expand All @@ -287,6 +289,7 @@ export const getChartOption = (data: any[], config: ChartConfig) => {
label,
// Only attach markLine to the first series to avoid duplication
...(idx === 0 && markLine ? { markLine } : {}),
...(isStacked ? { stack: "total" } : {}),
}));

const legendData = isCount
Expand Down
107 changes: 87 additions & 20 deletions src/components/Forms/ClinicalNotes/Base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
SettingOutlined,
DownloadOutlined,
CopyOutlined,
LeftOutlined,
RightOutlined,
} from "@ant-design/icons";
import { formatDate } from "utils/date";

Expand All @@ -24,9 +26,10 @@ import {
import notification from "components/notification";
import { getErrorMessage } from "utils/errorHandler";

import Modal from "components/Modal";
import MemoryText from "containers/MemoryText";
import MemoryDraft from "features/memory/MemoryDraft/MemoryDraft";
import { getUserLastClinicalNotes } from "features/serverActions/ServerActionsSlice";
import { getUserLastClinicalNotesList } from "features/serverActions/ServerActionsSlice";

import getInterventionTemplate from "./util/getInterventionTemplate";
import { EditorBox } from "../Form.style";
Expand All @@ -37,6 +40,9 @@ export default function Base({ prescription, account, signature, action }) {
const { t } = useTranslation();
const { values, setFieldValue, errors, touched } = useFormikContext();
const [loadingCopy, setLoadingCopy] = useState(false);
const [lastNotesList, setLastNotesList] = useState([]);
const [lastNotesModalOpen, setLastNotesModalOpen] = useState(false);
const [currentNoteIndex, setCurrentNoteIndex] = useState(0);
const { notes, concilia, date, notesType } = values;

const clinicalNotesTypeOptions = (
Expand All @@ -49,7 +55,7 @@ export default function Base({ prescription, account, signature, action }) {
const loadDefaultText = () => {
setFieldValue(
"notes",
getInterventionTemplate(prescription, account, signature, concilia)
getInterventionTemplate(prescription, account, signature, concilia),
);
};

Expand All @@ -68,36 +74,37 @@ export default function Base({ prescription, account, signature, action }) {
prescription,
clinicalNote,
{ signature, account },
t
)
t,
),
);
};

const applyLastNote = (item) => {
setFieldValue(
"notes",
`---Cópia do dia: ${formatDate(item.date)}\n\n${item.text}`,
);
setLastNotesModalOpen(false);
notification.success({ message: "Evolução copiada com sucesso" });
};

const loadLastNote = () => {
setLoadingCopy(true);
dispatch(
getUserLastClinicalNotes({
getUserLastClinicalNotesList({
admissionNumber: values.admissionNumber,
})
}),
).then((response) => {
setLoadingCopy(false);

if (response.error) {
notification.error({
message: getErrorMessage(response, t),
});
notification.error({ message: getErrorMessage(response, t) });
} else {
if (response.payload.data) {
setFieldValue(
"notes",
`---Cópia do dia: ${formatDate(response.payload.data?.date)}\n\n${
response.payload.data?.text
}`
);

notification.success({
message: "Última evolução copiada com sucesso",
});
const list = response.payload?.data;
if (list && list.length > 0) {
setLastNotesList(list);
setCurrentNoteIndex(0);
setLastNotesModalOpen(true);
} else {
notification.error({
message: "Não encontramos evolução para este atendimento",
Expand Down Expand Up @@ -275,6 +282,66 @@ export default function Base({ prescription, account, signature, action }) {
</EditorBox>
</div>
</div>
<Modal
title={`Selecionar evolução (${currentNoteIndex + 1} / ${lastNotesList.length})`}
open={lastNotesModalOpen}
onCancel={() => setLastNotesModalOpen(false)}
footer={
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}}
>
<Button
icon={<LeftOutlined />}
onClick={() => setCurrentNoteIndex((i) => i - 1)}
disabled={currentNoteIndex === 0}
>
Anterior
</Button>
<Button
type="primary"
icon={<CopyOutlined />}
onClick={() => applyLastNote(lastNotesList[currentNoteIndex])}
>
Copiar
</Button>
<Button
onClick={() => setCurrentNoteIndex((i) => i + 1)}
disabled={currentNoteIndex === lastNotesList.length - 1}
>
Próxima
<RightOutlined />
</Button>
</div>
}
width={660}
>
<p style={{ marginBottom: "16px", color: "#666" }}>
Navegue pelas evoluções anteriores e selecione a que deseja copiar
para o campo de evolução.
</p>
{lastNotesList[currentNoteIndex] && (
<>
<strong>{formatDate(lastNotesList[currentNoteIndex].date)}</strong>
<div
style={{
marginTop: "8px",
maxHeight: "50vh",
overflowY: "auto",
whiteSpace: "pre-wrap",
padding: "12px",
background: "#f5f5f5",
borderRadius: "6px",
}}
>
{lastNotesList[currentNoteIndex].text}
</div>
</>
)}
</Modal>
</>
);
}
8 changes: 6 additions & 2 deletions src/components/Forms/ClinicalNotes/util/customTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,15 @@ export const getCustomClinicalNote = (
.replaceAll("{{alertas}}", alerts || "Nenhum alerta registrado")
.replaceAll(
"{{medicamentos_conciliados}}",
conciliationDrugsWithRelation || "--",
prescription.data.concilia
? conciliationDrugsWithRelation || "--"
: "Lista de conciliação só está disponível em prescrições de conciliação",
)
.replaceAll(
"{{medicamentos_nao_conciliados}}",
conciliationDrugsWithoutRelation || "--",
prescription.data.concilia
? conciliationDrugsWithoutRelation || "--"
: "Lista de conciliação só está disponível em prescrições de conciliação",
)
.replaceAll(
"{{antimicrobianos}}",
Expand Down
Loading
Loading