-
Notifications
You must be signed in to change notification settings - Fork 56
AMM-1337 platform feedback module #289
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
768b3f7
fix: AMM-1677 - rendering only grievances who have consent
5Amogh 82d6408
fix: AMM-1701 callcounter issue fix
5Amogh bf2c62d
Merge branch 'release-3.5.0' of https://github.com/PSMRI/Common-API iβ¦
5Amogh 5e39ca1
feat: amm-1337 platform feedback module
5Amogh d2f44b1
feat: amm-1337 entities updated based on change in DDL
5Amogh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/com/iemr/common/controller/platform_feedback/PlatformFeedbackController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * AMRIT β Accessible Medical Records via Integrated Technology | ||
| * Integrated EHR (Electronic Health Records) Solution | ||
| * | ||
| * Copyright (C) "Piramal Swasthya Management and Research Institute" | ||
| * | ||
| * This file is part of AMRIT. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see https://www.gnu.org/licenses/. | ||
| */ | ||
| package com.iemr.common.controller; | ||
|
|
||
| import com.iemr.common.dto.*; | ||
| import com.iemr.common.service.PlatformFeedbackService; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import jakarta.validation.Valid; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Tag(name = "Platform Feedback", description = "Feedback ingestion and category listing for platform-wide feedback") | ||
| @RestController | ||
| @RequestMapping("/platform-feedback") | ||
| @Validated | ||
| public class PlatformFeedbackController { | ||
|
|
||
| private final PlatformFeedbackService service; | ||
|
|
||
| public PlatformFeedbackController(PlatformFeedbackService service) { | ||
| this.service = service; | ||
| } | ||
|
|
||
| @Operation(summary = "Submit feedback (public endpoint)", | ||
| description = "Accepts feedback (anonymous or identified). Accepts categoryId or categorySlug; slug is preferred.") | ||
| @ApiResponse(responseCode = "201", description = "Feedback accepted") | ||
| @ApiResponse(responseCode = "400", description = "Validation or business error", content = @Content) | ||
| @PostMapping | ||
| public ResponseEntity<FeedbackResponse> submit( | ||
| @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Feedback payload") | ||
| @Valid @RequestBody FeedbackRequest req) { | ||
| FeedbackResponse resp = service.submitFeedback(req); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body(resp); | ||
| } | ||
|
|
||
| @Operation(summary = "List active categories", | ||
| description = "Returns active categories. Optionally filter by serviceLine (frontend convenience).") | ||
| @ApiResponse(responseCode = "200", description = "List of categories") | ||
| @GetMapping("/categories") | ||
| public ResponseEntity<List<CategoryResponse>> list( | ||
| @Parameter(description = "Optional serviceLine to prefer scopes (1097|104|AAM|MMU|TM|ECD)") | ||
| @RequestParam(required = false) String serviceLine) { | ||
| if (serviceLine == null) serviceLine = "GLOBAL"; | ||
| List<CategoryResponse> list = service.listCategories(serviceLine); | ||
| return ResponseEntity.ok(list); | ||
| } | ||
| } |
171 changes: 171 additions & 0 deletions
171
src/main/java/com/iemr/common/data/platform_feedback/Feedback.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| /* | ||
| * AMRIT β Accessible Medical Records via Integrated Technology | ||
| * Integrated EHR (Electronic Health Records) Solution | ||
| * | ||
| * Copyright (C) "Piramal Swasthya Management and Research Institute" | ||
| * | ||
| * This file is part of AMRIT. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see https://www.gnu.org/licenses/. | ||
| */ | ||
| package com.iemr.common.model; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import jakarta.validation.constraints.Max; | ||
| import jakarta.validation.constraints.Min; | ||
| import jakarta.validation.constraints.Size; | ||
| import java.time.LocalDateTime; | ||
| import java.util.UUID; | ||
|
|
||
| @Entity | ||
| @Table(name = "m_platform_feedback") | ||
| public class Feedback { | ||
|
|
||
| @Id | ||
| @Column(name = "FeedbackID", length = 36, updatable = false, nullable = false) | ||
| private String feedbackId; | ||
|
|
||
| @Column(name = "CreatedAt", nullable = false, insertable = false, updatable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| @Column(name = "UpdatedAt", nullable = false, insertable = false, updatable = false) | ||
| private LocalDateTime updatedAt; | ||
|
|
||
| @Min(1) | ||
| @Max(5) | ||
| @Column(name = "Rating", nullable = false) | ||
| private int rating; | ||
|
|
||
| @Size(max = 2000) | ||
| @Column(name = "Comment", columnDefinition = "TEXT", nullable = true) | ||
| private String comment; | ||
|
|
||
| @Column(name = "ServiceLine", nullable = false, length = 10) | ||
| private String serviceLine; | ||
|
|
||
| @Column(name = "IsAnonymous", nullable = false) | ||
| private boolean isAnonymous = true; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
| @JoinColumn(name = "CategoryID", referencedColumnName = "CategoryID", nullable = false) | ||
| private FeedbackCategory category; | ||
|
|
||
| @Column(name = "UserID", nullable = true) | ||
| private Integer userId; | ||
|
|
||
| public Feedback() { | ||
| this.feedbackId = UUID.randomUUID().toString(); | ||
| } | ||
|
|
||
| public Feedback(int rating, String comment, String serviceLine, boolean isAnonymous, FeedbackCategory category, Integer userId) { | ||
| this(); // ensures feedbackId | ||
| this.setRating(rating); | ||
| this.setComment(comment); | ||
| this.setServiceLine(serviceLine); | ||
| this.isAnonymous = isAnonymous; | ||
| this.category = category; | ||
| this.userId = userId; | ||
| } | ||
|
|
||
| public String getFeedbackId() { | ||
| return feedbackId; | ||
| } | ||
|
|
||
| // Don't usually set feedbackId externally, but keep setter for testing/migration if needed | ||
| public void setFeedbackId(String feedbackId) { | ||
| this.feedbackId = feedbackId; | ||
| } | ||
|
|
||
| public LocalDateTime getCreatedAt() { | ||
| return createdAt; | ||
| } | ||
|
|
||
| public void setCreatedAt(LocalDateTime createdAt) { | ||
| this.createdAt = createdAt; | ||
| } | ||
|
|
||
| public LocalDateTime getUpdatedAt() { | ||
| return updatedAt; | ||
| } | ||
|
|
||
| public void setUpdatedAt(LocalDateTime updatedAt) { | ||
| this.updatedAt = updatedAt; | ||
| } | ||
|
|
||
| public int getRating() { | ||
| return rating; | ||
| } | ||
|
|
||
| public void setRating(int rating) { | ||
| if (rating < 1 || rating > 5) { | ||
| throw new IllegalArgumentException("Rating must be between 1 and 5."); | ||
| } | ||
| this.rating = rating; | ||
| } | ||
|
|
||
| public String getComment() { | ||
| return comment; | ||
| } | ||
|
|
||
| public void setComment(String comment) { | ||
| if (comment != null && comment.length() > 2000) { | ||
| throw new IllegalArgumentException("Comment cannot exceed 2000 characters"); | ||
| } | ||
| this.comment = (comment == null || comment.trim().isEmpty()) ? null : comment.trim(); | ||
| } | ||
|
|
||
| public String getServiceLine() { | ||
| return serviceLine; | ||
| } | ||
|
|
||
| public void setServiceLine(String serviceLine) { | ||
| if (serviceLine == null || serviceLine.trim().isEmpty()) { | ||
| throw new IllegalArgumentException("ServiceLine must not be null or empty."); | ||
| } | ||
| this.serviceLine = serviceLine; | ||
| } | ||
|
|
||
| public boolean isAnonymous() { | ||
| return isAnonymous; | ||
| } | ||
|
|
||
| public void setAnonymous(boolean anonymous) { | ||
| isAnonymous = anonymous; | ||
| if (anonymous) { | ||
| this.userId = null; | ||
| } | ||
| } | ||
|
|
||
| public FeedbackCategory getCategory() { | ||
| return category; | ||
| } | ||
|
|
||
| public void setCategory(FeedbackCategory category) { | ||
| if (category == null) { | ||
| throw new IllegalArgumentException("Category must not be null."); | ||
| } | ||
| this.category = category; | ||
| } | ||
|
|
||
| public Integer getUserId() { | ||
| return userId; | ||
| } | ||
|
|
||
| public void setUserId(Integer userId) { | ||
| this.userId = userId; | ||
| if (userId != null) { | ||
| this.isAnonymous = false; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the table name as m_platformfeedback, since we follow this naming standard for all table names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it matches the standards high_risk_assess, asha_profile etc, should be fine i guess