Skip to content

Commit

Permalink
add button anon fill , correction problem popover selectransfersyntax
Browse files Browse the repository at this point in the history
  • Loading branch information
SophieLab committed Oct 15, 2024
1 parent f815077 commit aa83604
Show file tree
Hide file tree
Showing 12 changed files with 275 additions and 128 deletions.
153 changes: 93 additions & 60 deletions src/anonymize/AnonymizeRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,103 +5,136 @@ import PatientTable from "./PatientTable";
import StudyTable from "./StudyTable";
import { RootState } from "../store";
import { useMemo, useState } from "react";
import { flushAnonymizeList, removeStudyFromAnonymizeList, updateAnonymizationProfile, updateAnonymizePatientValue, updateAnonymizeStudyValue } from "../reducers/AnonymizeSlice";
import {
flushAnonymizeList,
removeStudyFromAnonymizeList,
updateAnonymizationProfile,
updateAnonymizePatientValue,
updateAnonymizeStudyValue,
} from "../reducers/AnonymizeSlice";
import { Anon, Empty } from "../icons";

import AutoFill from "../icons/AutofIll";
const profileOptions = [
{ value : 'default', label: 'Default' },
{value : 'full', label: 'Full' },
]
{ value: "default", label: "Default" },
{ value: "full", label: "Full" },
];

const AnonymizeRoot = () => {
const dispatch = useDispatch();
const anonList = useSelector((state: RootState) => state.anonymize);
const [selectedPatientId, setSelectedPatientId] = useState<string | null>(null)

const [selectedPatientId, setSelectedPatientId] = useState<string | null>(
null
);

const patients = useMemo(() => {
return Object.values(anonList.patients);
}, [anonList]);
const patients = useMemo(() => Object.values(anonList.patients), [anonList]);

const studies = useMemo(() => {
if (!selectedPatientId) return []
return Object.values(anonList.studies).filter(study => study.originalStudy.parentPatient === selectedPatientId);
if (!selectedPatientId) return [];
return Object.values(anonList.studies).filter(
(study) => study.originalStudy.parentPatient === selectedPatientId
);
}, [anonList, selectedPatientId]);

const handlePatientSelect = (patientId :string) => {
setSelectedPatientId(patientId)
}
const handleRemovePatient = (patientId: string) => {
const studiesIds = studies
.filter((study) => study.originalStudy.parentPatient === patientId)
.map((study) => study.originalStudy.id);
for (const studyId of studiesIds) {
dispatch(removeStudyFromAnonymizeList({ studyId }));
}
};

const handleRemoveStudy = (studyId: string) => {
dispatch(removeStudyFromAnonymizeList({ studyId }));
};

const handleChangeStudy = (studyId: string, newStudyDescription: string) => {
dispatch(updateAnonymizeStudyValue({ newStudyDescription, studyId }));
};

const handleChangePatient = (patientId: string, key: 'newPatientId' | 'newPatientName', value: string) => {
dispatch(updateAnonymizePatientValue({ patientId, [key]: value }));
}
const handleAutoFill = () => {
patients.forEach((patient) => {
dispatch(
updateAnonymizePatientValue({
patientId: patient.originalPatient.id,
newPatientName: `Patient_${patient.originalPatient.id}`,
newPatientId: `ID_${patient.originalPatient.id}`,
})
);
});

const handleClearList = () => {
dispatch(flushAnonymizeList());
studies.forEach((study) => {
dispatch(
updateAnonymizeStudyValue({
studyId: study.originalStudy.id,
newStudyDescription: `Study_${study.originalStudy.id}`,
newAccessionNumber: `Acc_${study.originalStudy.id}`,
})
);
});
};

const handleProfileChange = (option) =>{
dispatch(updateAnonymizationProfile({anonymizationProfile: option.value}))
}

return (
<Card>
<CardHeader
color={Colors.primary}
>
<CardHeader color={Colors.primary}>
<div className="flex items-center w-full">
<div className="w-4/5 text-lg font-bold text-center">Anonymize Ressources</div>
<div className="w-4/5 text-lg font-bold text-center">
Anonymiser les ressources
</div>
<div className="flex justify-end w-1/5 gap-3 p-3">
<Button
onClick={handleClearList}
onClick={() => dispatch(flushAnonymizeList())}
color={Colors.light}
className="rounded-lg hover:bg-secondary group">
<Empty
className="text-xl text-bol text-primary group-hover:text-white" />
className="rounded-lg hover:bg-secondary group"
>
<Empty className="text-xl text-primary group-hover:text-white" />
</Button>
<Button
onClick={handleAutoFill}
color={Colors.light}
className="rounded-lg hover:bg-secondary group"
>
<AutoFill className="text-xl text-primary group-hover:text-white" />
</Button>
</div>
</div>
</CardHeader>
<CardBody color={Colors.almond}>
<div className="flex flex-row w-full gap-4">
<div className="flex-1 overflow-auto">
<PatientTable patients={patients} onClickRow={handlePatientSelect} onChangePatient={handleChangePatient} onRemovePatient={handleRemovePatient} />
<PatientTable
patients={patients}
onClickRow={setSelectedPatientId}
onChangePatient={(patientId, key, value) =>
dispatch(
updateAnonymizePatientValue({ patientId, [key]: value })
)
}
onRemovePatient={(patientId) =>
studies
.filter(
(study) => study.originalStudy.parentPatient === patientId
)
.forEach((study) =>
dispatch(
removeStudyFromAnonymizeList({ studyId: study.originalStudy.id })
)
)
}
/>
</div>
<div className="flex-1 overflow-auto">
<StudyTable studies={studies} onChangeStudy={handleChangeStudy} onRemoveStudy={handleRemoveStudy} />
<StudyTable
studies={studies}
onChangeStudy={(studyId, key, value) =>
dispatch(
updateAnonymizeStudyValue({ studyId, [key]: value })
)
}
onRemoveStudy={(studyId) =>
dispatch(removeStudyFromAnonymizeList({ studyId }))
}
/>
</div>
</div>
</CardBody>
<CardFooter color={Colors.light} className="flex justify-center gap-3">
<Button
className="flex items-center gap-2 px-3 py-1 color"
color={Colors.blueCustom}>
<Anon/>
Anonymize
<Button className="flex items-center gap-2 px-3 py-1" color={Colors.blueCustom}>
<Anon />
Anonymiser
</Button>
<SelectInput
placeholder="Select option"
value={anonList.anonymizationProfile}
placeholder="Sélectionner une option"
value={anonList.anonymizationProfile}
options={profileOptions}
onChange={handleProfileChange}
onChange={(option) =>
dispatch(updateAnonymizationProfile({ anonymizationProfile: option.value }))
}
/>
</CardFooter>

</Card>
);
};
Expand Down
5 changes: 4 additions & 1 deletion src/anonymize/PatientTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const PatientTable = ({
onChangePatient,
onRowSelectionChange,
}: PatientTableProps) => {
console.log(patients)
const columns: ColumnDef<AnonPatient>[] = useMemo(() => [
{
id: "id",
Expand All @@ -37,11 +38,13 @@ const PatientTable = ({
},
{
id: "newPatientId",
accessorKey: "newPatientId",
header: "New Patient ID",
isEditable: true
},
{
id: "newPatientName",
accessorKey: "newPatientName",
header: "New Patient Name",
isEditable: true
},
Expand Down Expand Up @@ -76,9 +79,9 @@ const PatientTable = ({
onRowClick={(row) => onClickRow(row.originalPatient.id)}
onCellEdit={onChangePatient}
getRowClasses={getRowClasses}
enableRowSelection={true}
selectedRow={selectedRows}
onRowSelectionChange={onRowSelectionChange}
getRowId={(row) => row.originalPatient.id}
/>
);
};
Expand Down
23 changes: 7 additions & 16 deletions src/anonymize/StudyTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AnonStudy } from "../utils/types";

type StudyTableProps = {
studies: AnonStudy[];
onChangeStudy: (studyId: string, studyDescription: string) => void;
onChangeStudy: (studyId: string, key:string, value: string) => void;
onRemoveStudy: (studyId: string) => void;
};

Expand All @@ -25,22 +25,10 @@ const StudyTable = ({ studies, onChangeStudy, onRemoveStudy }: StudyTableProps)
header: "Study Description",
},
{
id : "newStudyDescription",
accessorKey: "newStudyDescription",
header: "New Study Description",
cell: ({ row }) => {
return (
<Input
key={row.original.originalStudy.id}
value={row.original.newStudyDescription ?? ""}
onChange={(event) =>
onChangeStudy(
row.original.originalStudy.id,
event.target.value
)
}
/>
);
},
isEditable: true,
},
{
header: "Remove",
Expand All @@ -61,9 +49,12 @@ const StudyTable = ({ studies, onChangeStudy, onRemoveStudy }: StudyTableProps)

return <Table
columns={columns}
data={studies} columnVisibility={{ id: false }}
data={studies}
columnVisibility={{ id: false }}
headerTextSize="xs"
className="text-xs"
onCellEdit={onChangeStudy}
getRowId={(row) => row.originalStudy.id}

/>;

Expand Down
24 changes: 19 additions & 5 deletions src/export/ExportRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ const ExportRoot = () => {
<Empty
className="text-xl text-bol text-primary group-hover:text-white" />
</Button>
<SelectTransferSyntax value={transferSyntax} onChange={(value) => setTrasferSyntax(value)} />
<SelectTransferSyntax
value={transferSyntax}
onChange={(value) => setTrasferSyntax(value)}
/>

</div>

Expand All @@ -196,12 +199,23 @@ const ExportRoot = () => {
</CardBody>
<CardFooter color={Colors.light} className="flex justify-center flex-grow gap-3">
<div className="flex justify-center w-4/5 gap-3">
<DropdownButton row={null} buttonText="Download" options={downloadOptions} />
<DropdownButton row={null} buttonText="Send To Modality" options={modalitiesOptions} />
<DropdownButton
row={null}
buttonText="Download"
options={downloadOptions} />
<DropdownButton
row={null}
buttonText="Send To Modality"
options={modalitiesOptions} />
{storeJobId && <ProgressJobs size={50} jobId={storeJobId} />}
<DropdownButton row={null} buttonText="Send To Peer" options={peersOptions} />
<DropdownButton
row={null}
buttonText="Send To Peer"
options={peersOptions} />
{sendPeerJobId && <ProgressJobs size={50} jobId={sendPeerJobId} />}
<Button color={Colors.blueCustom} className="text-white bg-cyan-700" disabled>
<Button
color={Colors.blueCustom}
className="text-white bg-cyan-700" disabled>
Send to <GaeloIcon className="ml-1" />
</Button>
</div>
Expand Down
Loading

0 comments on commit aa83604

Please sign in to comment.