Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app,dashboard): fix temporaire des duplicatas de dossier médical #1711

Merged
merged 2 commits into from
Oct 8, 2023
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
28 changes: 26 additions & 2 deletions app/src/recoil/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const itemsGroupedByPersonSelector = selector({
const comments = get(commentsState);
const consultations = get(consultationsState);
const treatments = get(treatmentsState);
const medicalFiles = get(medicalFileState);
const medicalFiles = [...get(medicalFileState)].sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
const relsPersonPlace = get(relsPersonPlaceState);
const places = get(placesObjectSelector);
const rencontres = get(rencontresState);
Expand Down Expand Up @@ -173,7 +173,31 @@ export const itemsGroupedByPersonSelector = selector({
}
for (const medicalFile of medicalFiles) {
if (!personsObject[medicalFile.person]) continue;
personsObject[medicalFile.person].medicalFile = medicalFile;
if (personsObject[medicalFile.person].medicalFile) {
const nextDocuments = {};
const nextComments = {};
const existingMedicalFile = personsObject[medicalFile.person].medicalFile;
for (const document of medicalFile.documents || []) {
nextDocuments[document._id] = document;
}
for (const document of existingMedicalFile.documents || []) {
nextDocuments[document._id] = document;
}
for (const comment of medicalFile.comments || []) {
nextComments[comment._id] = comment;
}
for (const comment of existingMedicalFile.comments || []) {
nextComments[comment._id] = comment;
}
personsObject[medicalFile.person].medicalFile = {
...medicalFile,
...personsObject[medicalFile.person].medicalFile,
documents: Object.values(nextDocuments),
comments: Object.values(nextComments),
};
} else {
personsObject[medicalFile.person].medicalFile = medicalFile;
}
}
// we don't use passages in the app - no use, no load
// but we keep it here just to be aware of that app specificity
Expand Down
21 changes: 18 additions & 3 deletions dashboard/src/recoil/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const itemsGroupedByPersonSelector = selector({
const comments = get(commentsState);
const consultations = get(consultationsState);
const treatments = get(treatmentsState);
const medicalFiles = get(medicalFileState);
const medicalFiles = [...get(medicalFileState)].sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
const passages = get(passagesState);
const relsPersonPlace = get(relsPersonPlaceState);
const places = get(placesObjectSelector);
Expand Down Expand Up @@ -260,11 +260,26 @@ export const itemsGroupedByPersonSelector = selector({
for (const medicalFile of medicalFiles) {
if (!personsObject[medicalFile.person]) continue;
if (personsObject[medicalFile.person].medicalFile) {
const nextDocuments = {};
const nextComments = {};
const existingMedicalFile = personsObject[medicalFile.person].medicalFile;
for (const document of medicalFile.documents || []) {
nextDocuments[document._id] = document;
}
for (const document of existingMedicalFile.documents || []) {
nextDocuments[document._id] = document;
}
for (const comment of medicalFile.comments || []) {
nextComments[comment._id] = comment;
}
for (const comment of existingMedicalFile.comments || []) {
nextComments[comment._id] = comment;
}
personsObject[medicalFile.person].medicalFile = {
...medicalFile,
...personsObject[medicalFile.person].medicalFile,
documents: [...(medicalFile?.documents || []), ...(personsObject[medicalFile.person].medicalFile?.documents || [])],
comments: [...(medicalFile?.comments || []), ...(personsObject[medicalFile.person].medicalFile?.comments || [])],
documents: Object.values(nextDocuments),
comments: Object.values(nextComments),
};
} else {
personsObject[medicalFile.person].medicalFile = medicalFile;
Expand Down
2 changes: 1 addition & 1 deletion e2e/restricted-role_V2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ test("test", async ({ page }) => {
await page.getByLabel("Nom de l'action").fill("Action");

// à ne pas voir concernant les actions
await expect(page.getByLabel("Description")).not.toBeVisible();
await expect(page.getByLabel("Description", { exact: true })).not.toBeVisible();
await expect(page.getByRole("heading", { name: "Commentaires" })).not.toBeVisible();
await expect(page.getByRole("button", { name: "Supprimer" })).not.toBeVisible();
await page.getByRole("button", { name: "Sauvegarder" }).click();
Expand Down
Loading