|
7 | 7 | import org.ciyex.ehr.portal.repository.DocumentReviewRepository; |
8 | 8 | import org.ciyex.ehr.service.DocumentService; |
9 | 9 | import org.ciyex.ehr.service.DocumentService.DownloadResult; |
| 10 | +import org.ciyex.ehr.service.DocumentSettingsService; |
10 | 11 | import org.ciyex.ehr.service.PracticeContextService; |
11 | 12 | import org.ciyex.ehr.service.portal.PortalGenericResourceService; |
12 | 13 | import org.ciyex.ehr.service.portal.PortalNotificationService; |
@@ -48,6 +49,7 @@ public class PortalDocumentsController { |
48 | 49 | private final PortalGenericResourceService portalResourceService; |
49 | 50 | private final DocumentReviewRepository documentReviewRepo; |
50 | 51 | private final PortalNotificationService portalNotificationService; |
| 52 | + private final DocumentSettingsService documentSettingsService; |
51 | 53 |
|
52 | 54 | @GetMapping("/my") |
53 | 55 | @PreAuthorize("hasAuthority('PATIENT') or hasRole('PATIENT') or hasAuthority('SCOPE_patient/Patient.read')") |
@@ -92,6 +94,23 @@ public ApiResponse<List<DocumentDto>> getMyDocuments(Authentication authenticati |
92 | 94 | } |
93 | 95 | } |
94 | 96 |
|
| 97 | + @GetMapping("/categories") |
| 98 | + @PreAuthorize("hasAuthority('PATIENT') or hasRole('PATIENT') or hasAuthority('SCOPE_patient/Patient.read')") |
| 99 | + public ApiResponse<List<String>> getDocumentCategories() { |
| 100 | + try { |
| 101 | + var cats = documentSettingsService.getCategories(); |
| 102 | + List<String> active = cats.stream() |
| 103 | + .filter(c -> c.isActive()) |
| 104 | + .map(c -> c.getName()) |
| 105 | + .toList(); |
| 106 | + return ApiResponse.<List<String>>builder().success(true).data(active).build(); |
| 107 | + } catch (Exception e) { |
| 108 | + log.debug("Could not load categories, using defaults: {}", e.getMessage()); |
| 109 | + return ApiResponse.<List<String>>builder().success(true) |
| 110 | + .data(List.of("Clinical", "Lab", "Imaging", "Insurance", "Other")).build(); |
| 111 | + } |
| 112 | + } |
| 113 | + |
95 | 114 | @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
96 | 115 | @PreAuthorize("hasAuthority('PATIENT') or hasRole('PATIENT') or hasAuthority('SCOPE_patient/Patient.read')") |
97 | 116 | public ResponseEntity<ApiResponse<DocumentDto>> uploadDocument( |
|
0 commit comments