Skip to content

Commit

Permalink
[TECH] Supprimer la fonctionnalité pour définir la date d'envoi des r…
Browse files Browse the repository at this point in the history
…ésultats aux prescripteurs sur Pix Admin (PIX-15538).

 #10754
  • Loading branch information
pix-service-auto-merge authored Dec 9, 2024
2 parents 14fafae + f65bbfd commit 81afa8f
Show file tree
Hide file tree
Showing 20 changed files with 1 addition and 590 deletions.
5 changes: 1 addition & 4 deletions admin/app/adapters/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ export default class SessionAdapter extends ApplicationAdapter {
}

updateRecord(store, type, snapshot) {
if (snapshot.adapterOptions.flagResultsAsSentToPrescriber) {
const url = this.urlForUpdateRecord(snapshot.id, type.modelName, snapshot) + '/results-sent-to-prescriber';
return this.ajax(url, 'PUT');
} else if (snapshot.adapterOptions.updatePublishedCertifications) {
if (snapshot.adapterOptions.updatePublishedCertifications) {
let url;
if (snapshot.adapterOptions.toPublish) {
url = this.urlForUpdateRecord(snapshot.id, type.modelName, snapshot) + '/publish';
Expand Down
11 changes: 0 additions & 11 deletions admin/app/components/sessions/session-informations.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,6 @@ function getFormattedDate(param) {
>
Télécharger les attestations
</PixButton>

{{#if @sessionModel.areResultsToBeSentToPrescriber}}
<PixButton
size="small"
@triggerAction={{@tagSessionAsSentToPrescriber}}
@variant="secondary"
class="session-info__download-button"
>
Résultats transmis au prescripteur
</PixButton>
{{/if}}
</div>
</div>
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ export default class IndexController extends Controller {
return this.sessionModel.assignedCertificationOfficer.get('id') ? true : false;
}

@action
async tagSessionAsSentToPrescriber() {
await this.sessionModel.save({ adapterOptions: { flagResultsAsSentToPrescriber: true } });
}

@action
async unfinalizeSession() {
try {
Expand Down
5 changes: 0 additions & 5 deletions admin/app/models/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ export default class Session extends Model {
);
}

@computed('resultsSentToPrescriberAt', 'isFinalized')
get areResultsToBeSentToPrescriber() {
return Boolean(this.isFinalized && !this.resultsSentToPrescriberAt);
}

@computed('status')
get displayStatus() {
return statusToDisplayName[this.status];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@
margin: 0 10px;
}

&__download-button:first-child {
margin-left: 0;
}

&__published-buttons {
display: flex;
flex-direction: row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
@copyButtonText={{this.copyButtonText}}
@copyResultsDownloadLink={{this.copyResultsDownloadLink}}
@downloadPDFAttestations={{this.downloadPDFAttestations}}
@tagSessionAsSentToPrescriber={{this.tagSessionAsSentToPrescriber}}
@modalTitle={{this.modalTitle}}
@modalMessage={{this.modalMessage}}
@modalConfirmAction={{this.modalConfirmAction}}
Expand Down
6 changes: 0 additions & 6 deletions admin/mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ function routes() {
});
this.get('/admin/sessions/:id');
this.get('/admin/sessions/:id/jury-certification-summaries', getPaginatedJuryCertificationSummariesBySessionId);
this.put('/admin/sessions/:id/results-sent-to-prescriber', (schema, request) => {
const sessionId = request.params.id;
const session = schema.sessions.findBy({ id: sessionId });
session.update({ resultsSentToPrescriberAt: new Date() });
return session;
});
this.post('/admin/sessions/publish-in-batch', () => {
return new Response(200);
});
Expand Down
69 changes: 0 additions & 69 deletions admin/tests/acceptance/flag-results-sent-to-prescriptor-test.js

This file was deleted.

1 change: 0 additions & 1 deletion admin/tests/acceptance/session-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ module('Acceptance | Session pages', function (hooks) {
// then
assert.dom(screen.getByText("M'assigner la session")).exists();
assert.dom(screen.getByText('Lien de téléchargement des résultats')).exists();
assert.dom(screen.getByText('Résultats transmis au prescripteur')).exists();
});

module('copy link button', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,34 +145,6 @@ module('Integration | Component | routes/authenticated/sessions/session | inform
assert.dom(screen.queryByText('Commentaire global :')).doesNotExist();
});

module('when results have not yet been sent to prescriber', function () {
test('it should display the button to flag results as sent', async function (assert) {
// given
await authenticateAdminMemberWithRole({ isSuperAdmin: true })(server);
const session = _buildSessionWithTwoJuryCertificationSummary({ resultsSentToPrescriberAt: null }, server);

// when
const screen = await visit(`/sessions/${session.id}`);

// then
assert.dom(screen.getByRole('button', { name: 'Résultats transmis au prescripteur' })).exists();
});
});

module('when results have been sent to prescriber', function () {
test('it should not display the button to flag results as sent', async function (assert) {
// given
await authenticateAdminMemberWithRole({ isSuperAdmin: true })(server);
const session = _buildSessionWithTwoJuryCertificationSummary({ resultsSentToPrescriberAt: new Date() }, server);

// when
const screen = await visit(`/sessions/${session.id}`);

// then
assert.dom(screen.queryByRole('button', { name: 'Résultats transmis au prescripteur' })).doesNotExist();
});
});

module('when the session results have been sent to the prescriber', function () {
test('it renders the resultsSentToPrescriberAt date', async function (assert) {
// given
Expand Down Expand Up @@ -218,7 +190,6 @@ module('Integration | Component | routes/authenticated/sessions/session | inform
assert.dom(screen.queryByText("M'assigner la session")).doesNotExist();
assert.dom(screen.queryByText('Définaliser la session')).doesNotExist();
assert.dom(screen.queryByText('Lien de téléchargement des résultats')).doesNotExist();
assert.dom(screen.queryByText('Résultats transmis au prescripteur')).doesNotExist();
});
});
});
Expand All @@ -236,7 +207,6 @@ module('Integration | Component | routes/authenticated/sessions/session | inform
assert.dom(screen.getByRole('button', { name: "M'assigner la session" })).exists();
assert.dom(screen.getByRole('button', { name: 'Définaliser la session' })).exists();
assert.dom(screen.getByRole('button', { name: 'Lien de téléchargement des résultats' })).exists();
assert.dom(screen.getByRole('button', { name: 'Résultats transmis au prescripteur' })).exists();
});
});
});
Expand Down
28 changes: 0 additions & 28 deletions admin/tests/unit/models/session-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,34 +324,6 @@ module('Unit | Model | session', function (hooks) {
});
});

module('#areResultsToBeSentToPrescriber', function () {
module('when session is finalized but results were not sent to prescriber yet', function () {
test('it should return areResultsToBeSentToPrescriber with true value', function (assert) {
// given
const session = store.createRecord('session', { status: 'finalized', resultsSentToPrescriberAt: null });

// when
const areResultsToBeSentToPrescriber = session.areResultsToBeSentToPrescriber;

// then
assert.true(areResultsToBeSentToPrescriber);
});
});

module('when session is finalized and results has been sent to prescriber', function () {
test('it should return areResultsToBeSentToPrescriber with false value', function (assert) {
// given
const session = store.createRecord('session', { status: 'finalized', resultsSentToPrescriberAt: new Date() });

// when
const areResultsToBeSentToPrescriber = session.areResultsToBeSentToPrescriber;

// then
assert.false(areResultsToBeSentToPrescriber);
});
});
});

module('#displayStatus', function () {
module('when status is created', function () {
test('it should display created printable equivalent', function (assert) {
Expand Down
30 changes: 0 additions & 30 deletions api/lib/application/sessions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,36 +97,6 @@ const register = async function (server) {
tags: ['api', 'session', 'publication'],
},
},
{
method: 'PUT',
path: '/api/admin/sessions/{id}/results-sent-to-prescriber',
config: {
validate: {
params: Joi.object({
id: identifiersType.sessionId,
}),
},
pre: [
{
method: (request, h) =>
securityPreHandlers.hasAtLeastOneAccessOf([
securityPreHandlers.checkAdminMemberHasRoleSuperAdmin,
securityPreHandlers.checkAdminMemberHasRoleCertif,
securityPreHandlers.checkAdminMemberHasRoleSupport,
])(request, h),
assign: 'hasAuthorizationToAccessAdminScope',
},
],

handler: sessionController.flagResultsAsSentToPrescriber,
tags: ['api', 'sessions'],
notes: [
"- **Cette route est restreinte aux utilisateurs authentifiés ayant les droits d'accès**\n" +
'- Elle permet de marquer le fait que les résultats de la session ont été envoyés au prescripteur,\n',
'- par le biais de la sauvegarde de la date courante.',
],
},
},
]);
};

Expand Down
8 changes: 0 additions & 8 deletions api/lib/application/sessions/session-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,10 @@ const unpublish = async function (request, h, dependencies = { sessionManagement
return dependencies.sessionManagementSerializer.serialize({ session });
};

const flagResultsAsSentToPrescriber = async function (request, h, dependencies = { sessionManagementSerializer }) {
const sessionId = request.params.id;
const { resultsFlaggedAsSent, session } = await usecases.flagSessionResultsAsSentToPrescriber({ sessionId });
const serializedSession = await dependencies.sessionManagementSerializer.serialize({ session });
return resultsFlaggedAsSent ? h.response(serializedSession).created() : serializedSession;
};

const sessionController = {
getJuryCertificationSummaries,
publishInBatch,
unpublish,
flagResultsAsSentToPrescriber,
};

export { sessionController };
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import _ from 'lodash';

import { SESSION_STATUSES } from '../../../shared/domain/constants.js';
import { SESSIONS_VERSIONS } from '../../../shared/domain/models/SessionVersion.js';

Expand Down Expand Up @@ -52,10 +50,6 @@ class SessionManagement {
this.createdBy = createdBy;
}

areResultsFlaggedAsSent() {
return !_.isNil(this.resultsSentToPrescriberAt);
}

get status() {
if (this.publishedAt) {
return SESSION_STATUSES.PROCESSED;
Expand Down
Loading

0 comments on commit 81afa8f

Please sign in to comment.