Skip to content

Questionnaire review#183

Open
schluebbo wants to merge 20 commits intov3.3.0from
questionnaire-review
Open

Questionnaire review#183
schluebbo wants to merge 20 commits intov3.3.0from
questionnaire-review

Conversation

@schluebbo
Copy link
Contributor

Description

This pull request introduces the new Review Feature for questionnaires in MoPat. The feature allows Editors to request a review for their questionnaires and enables Moderators and Admins to review and approve or reject those submissions.

Key Features

  • Editors can:

    • Request a review for newly created or modified questionnaires.
    • View the review status and respond to feedback.
    • Delete their own reviews.
  • Moderators and Admins can:

    • Review questionnaires assigned to them.
    • Approve or reject changes with feedback.
    • Optionally define a questionnaire as the main version of its group.
    • Directly approve or revoke questionnaires in the questionnaire list view.
    • Reassign the review to a different reviewer, if needed.
    • Delete reviews they are assigned to.
  • Admins additionally can:

    • View and manage all reviews via separate tabs (pending -> all /completed -> all).
    • Delete any review, regardless of assignment.
  • Email notifications:

    • Notifications are sent during key review steps (e.g. request, rejection, approval, new reviewer).
    • A preview option is available before sending.

Technical Changes

  • Added new database tables: review and review_message.
  • Added new fields to questionnaire:
    • approval_status (DRAFT / UNDER_REVIEW / APPROVED)
    • created_by
  • Added field main_questionnaire_id to questionnaire_version_group.
  • Extended frontend with forms, buttons, badges and tabs to support the review workflow.
  • Review visibility and actions depend on user roles (Editor, Moderator, Admin).

- Added Review and ReviewMessage entities with JPA annotations
- Introduced ReviewStatus enumeration
- Implemented ReviewDao and ReviewMessageDao with corresponding DAO implementations
- Updated persistence.xml to include Review and ReviewMessage
- Added systemClock bean in AppConfig for timestamp mocking in tests
- Implement ReviewController for managing review views
- Add ReviewService for retrieving and filtering reviews
- Create Thymeleaf templates for assigned and all reviews
- Added `ReviewController` with endpoints for listing and creating review requests.
- Introduced `CreateReviewForm` and validation via `CreateReviewValidator`.
- Updated `ReviewService` to handle review request creation and validation.
- Extended `QuestionnaireService` to fetch questionnaires by ID.
- Enhanced `UserService` to retrieve users by role.
- Modified `Questionnaire` and `QuestionnaireDTO` to include an `isApproved` field.
- Created `ConditionalValidation` annotation and `ConditionalValidatorDispatcher` for dynamic validation handling.
- Added localized messages for review-related actions.
- Created `review/create.html` for the review request form.
- Added `getEmailPreview` endpoint in `ReviewController` to generate localized email previews.
- Extended `CreateReviewForm` with `personalMessage` and `language` fields.
- Updated `ReviewService` to support email preview generation.
- Implemented email preview UI in `review/create.html`, allowing users to see the email content before sending.
- Added localized messages for email-related labels and messages.
- Added `removeReview` endpoint in `ReviewController` to allow deletion of reviews.
- Implemented `deleteReviewById` in `ReviewService` with validation for access control.
- Introduced `canModifyReview` method to check if a user has permission to delete a review.
- Extended `ValidationResult` with new error messages for invalid review ID, unauthorized access, and missing reviews.
- Added localized success and error messages for review deletion
- Added review management link to `admin.html` and `mobileAdmin.html`.
- Implemented `/review/details` endpoint to view and manage review decisions.
- Added approval, rejection, resubmission, and reviewer assignment logic.
- Introduced `ReviewDecisionForm` for review actions.
- Implemented `ReviewDecisionValidator` for input validation.
- Added support for setting a questionnaire as the main version.
- Created UI for review details, including reviewer selection and conversation history.
- Introduced `ApprovalStatus` enum for better questionnaire status handling
- Added direct approval/disapproval functionality for questionnaires (admins)
- Ensured review completion when a questionnaire is approved by an admin
- Prevented duplicate review requests for the same questionnaire
- Improved questionnaire versioning and group management
- Adjusted UI labels and messages
- Unified `/review` as base path with structured routes.
- Split pending/completed reviews into separate lists & details pages.
- Moved user detail population to DTOs (`setEditorDetails()`, `setReviewerDetails()`).
- `sendReviewActionMail()` now returns `ValidationResult` instead of `boolean`.
- Improved error handling and logging for mail failures.
- Simplified Review constructor & added missing setters.
…stionnaireServiceTest

- Added `ReviewServiceTest` to cover review creation, approval, rejection, resubmission, deletion, and permission checks.
- Introduced `CreateReviewValidatorTest` to validate review form fields.
- Expanded `QuestionnaireServiceTest` with tests for questionnaire approval, disapproval, and edit restrictions.
…& admins full access

- Added `createdBy` field to `Questionnaire` to track the creator
- Updated review logic:
  - Editors can only request reviews for their own questionnaires
  - Moderators and admins can see all unapproved questionnaires
- Extended `QuestionnaireDTOMapper` and `QuestionnaireFactory` to include `createdBy`
- Added tests for `getUnapprovedQuestionnaires()` to validate the new behavior
…e and manage questionnaires

- Moderators can now approve and disapprove questionnaires.
- Questionnaires created or imported by a moderator are now also approved by default.
…s for editors

- Modified `getAllReviewers()` in `ReviewService` to include moderators as reviewers.
- Updated `pending-details.html` to allow moderators (not just admins) to approve or reject reviews.
- Updated `getUnapprovedQuestionnaires()` to allow editors to request reviews only for questionnaires they created or modified.
- Added `isCreatedOrModifiedBy(Long userId)` to `Questionnaire` and `QuestionnaireDTO` for simpler authorization logic.
- Refactored `list.html` to ensure only authorized users can request reviews or delete questionnaires.
…fixing

- Moved `getAllReviewers()` to `UserService`.
- Improved validation in `CreateReviewValidator`:
  - Now ensures the selected reviewer is valid.
- Fixed incorrect setting of sender/receiver names in `ReviewMessageDTO.setReceiverDetails()`.
- Updated `ReviewService`:
  - Refactored `addReviewMessage()` to explicitly pass sender and receiver IDs.
  - Removed redundant validation methods (`validateUserId` and `getInitials`).
- Fixed incorrect cancel button URL in `review/create.html`.
- Improved error messages and validation messages in multiple locales.
…ml logic corrected

- Admins now see approval options in the review detail view
- Adjusted visibility logic in template (considering isAdmin flag)
- Fixed mail link generation to point to /pending/details
- Added JavaDoc comments in controller and service classes
…on logic**

- Moved questionnaire deletion logic from controller to `QuestionnaireService` (`removeQuestionnaire` method).
- Improved readability and structure of the removal process for conditions, scores, bundles, reviews, and version groups.
- Added permission checks: only the questionnaire creator or users with moderator/admin roles can delete.
- Updated frontend to show the delete button only for users with appropriate permissions.
…a fields

- Added new table `review` for managing review processes
- Added new table `review_message` for conversation between editor and reviewer
- Added `approval_status` column to `questionnaire`, defaulting to 'DRAFT'
- Set `approval_status` to 'APPROVED' for existing questionnaires
- Added `created_by` column to `questionnaire` and populated it from `changed_by`
- Added `main_questionnaire_id` column to `questionnaire_version_group`
  and initialized it with the latest version per group
- Users can no longer assign themselves as reviewers when creating a review request.
- Added missing `createdBy` assignment in FHIR import.
@schluebbo schluebbo self-assigned this Mar 25, 2025
@github-actions
Copy link

Test Results:

TestsPassed ✅Skipped ⚠️Failed
JUnit Test Report1037 ran1027 passed10 skipped0 failed

@ywarnecke ywarnecke changed the base branch from v3.2.1 to v3.3.0 July 8, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant