-
Notifications
You must be signed in to change notification settings - Fork 571
feat(#3490): Analyzer Manual QC Recording - Spring Boot backend #3499
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
Open
karansahani78
wants to merge
8
commits into
DIGI-UW:develop
Choose a base branch
from
karansahani78:feature/analyzer-manual-qc
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
be8f2ea
feat(#3490): add analyzer manual QC recording backend
karansahani78 91ee108
fix(#3490): add missing analyzer qc config changes and enums
karansahani78 fb6a380
fix(#3490): address PR review feedback
karansahani78 f38f0c1
refactor(#3490): remove unnecessary comments from AnalyzerQcRestContr…
karansahani78 36d4cf4
refactor(#3490): remove unnecessary comments from AnalyzerQcRun
karansahani78 e328708
refactor(#3490): remove unnecessary comments from AnalyzerQcServiceImpl
karansahani78 4c28f16
Merge branch 'develop' into feature/analyzer-manual-qc
karansahani78 65248cc
Merge branch 'develop' into feature/analyzer-manual-qc
karansahani78 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
7 changes: 7 additions & 0 deletions
7
src/main/java/org/openelisglobal/analyzer/valueholder/QcFrequencyType.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,7 @@ | ||
| package org.openelisglobal.analyzer.valueholder; | ||
|
|
||
| public enum QcFrequencyType { | ||
| DAILY, | ||
| PER_SHIFT, | ||
| CUSTOM_HOURS | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/org/openelisglobal/analyzer/valueholder/QcStatus.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,9 @@ | ||
| package org.openelisglobal.analyzer.valueholder; | ||
|
|
||
|
|
||
| public enum QcStatus { | ||
| PASS, | ||
| OVERDUE, | ||
| FAILED, | ||
| NOT_RUN | ||
| } |
93 changes: 93 additions & 0 deletions
93
src/main/java/org/openelisglobal/analyzerqc/controller/AnalyzerQcRestController.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,93 @@ | ||
| package org.openelisglobal.analyzerqc.controller; | ||
|
|
||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import java.util.List; | ||
| import org.openelisglobal.analyzerqc.form.QcRunForm; | ||
| import org.openelisglobal.analyzerqc.service.AnalyzerQcService; | ||
| import org.openelisglobal.analyzerqc.valueholder.AnalyzerQcRun; | ||
| import org.openelisglobal.analyzerqc.valueholder.AnalyzerQcStatus; | ||
| import org.openelisglobal.common.log.LogEvent; | ||
| import org.openelisglobal.login.valueholder.UserSessionData; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.access.prepost.PreAuthorize; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| /** | ||
| * REST endpoints for Analyzer Manual QC Recording (Issue #3490). | ||
| */ | ||
| @RestController | ||
| @RequestMapping("/rest/analyzer") | ||
| public class AnalyzerQcRestController { | ||
|
|
||
| @Autowired | ||
| private AnalyzerQcService analyzerQcService; | ||
|
|
||
| @GetMapping( | ||
| value = "/{id}/qc-status", | ||
| produces = MediaType.APPLICATION_JSON_VALUE) | ||
| @PreAuthorize("hasRole('ANALYZER_VIEW')") | ||
| public ResponseEntity<AnalyzerQcStatus> getQcStatus(@PathVariable String id) { | ||
| try { | ||
| return ResponseEntity.ok(analyzerQcService.getQcStatus(id)); | ||
| } catch (org.openelisglobal.common.exception.LIMSRuntimeException e) { | ||
| LogEvent.logWarn(getClass().getName(), "getQcStatus", | ||
| "Analyzer not found: " + id); | ||
| return ResponseEntity.notFound().build(); | ||
| } catch (Exception e) { | ||
| LogEvent.logError(getClass().getName(), "getQcStatus", e.getMessage()); | ||
| return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); | ||
| } | ||
|
karansahani78 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| @PostMapping( | ||
| value = "/{id}/qc-runs", | ||
| consumes = MediaType.APPLICATION_JSON_VALUE, | ||
| produces = MediaType.APPLICATION_JSON_VALUE) | ||
| @PreAuthorize("hasRole('QC_RESULT_ENTER')") | ||
| public ResponseEntity<AnalyzerQcStatus> recordQcRun( | ||
| @PathVariable String id, | ||
| @RequestBody QcRunForm form, | ||
| HttpServletRequest request) { | ||
| try { | ||
| analyzerQcService.recordQcRun(id, form, getSysUserId(request)); | ||
| return ResponseEntity | ||
| .status(HttpStatus.CREATED) | ||
| .body(analyzerQcService.getQcStatus(id)); | ||
| } catch (IllegalArgumentException e) { | ||
| LogEvent.logWarn(getClass().getName(), "recordQcRun", e.getMessage()); | ||
| return ResponseEntity.badRequest().build(); | ||
| } catch (Exception e) { | ||
| LogEvent.logError(getClass().getName(), "recordQcRun", e.getMessage()); | ||
| return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); | ||
| } | ||
|
karansahani78 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| @GetMapping( | ||
| value = "/{id}/qc-runs", | ||
| produces = MediaType.APPLICATION_JSON_VALUE) | ||
| @PreAuthorize("hasRole('QC_HISTORY_VIEW')") | ||
| public ResponseEntity<List<AnalyzerQcRun>> getQcHistory(@PathVariable String id) { | ||
| try { | ||
| return ResponseEntity.ok(analyzerQcService.getQcHistory(id)); | ||
| } catch (Exception e) { | ||
| LogEvent.logError(getClass().getName(), "getQcHistory", e.getMessage()); | ||
| return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); | ||
| } | ||
|
karansahani78 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| private String getSysUserId(HttpServletRequest request) { | ||
| UserSessionData sessionData = (UserSessionData) | ||
| request.getSession().getAttribute("userSessionData"); | ||
| return sessionData != null | ||
| ? String.valueOf(sessionData.getSystemUserId()) | ||
| : null; | ||
| } | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
src/main/java/org/openelisglobal/analyzerqc/dao/AnalyzerQcRunDAO.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,33 @@ | ||
| package org.openelisglobal.analyzerqc.dao; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import org.openelisglobal.analyzerqc.valueholder.AnalyzerQcRun; | ||
| import org.openelisglobal.common.dao.BaseDAO; | ||
|
|
||
| /** | ||
| * Persistence operations for AnalyzerQcRun. | ||
| * | ||
| * Extends BaseDAO following the same pattern as AnalyzerQcRuleDAO, | ||
| * with additional query methods needed for QC status evaluation. | ||
| */ | ||
| public interface AnalyzerQcRunDAO extends BaseDAO<AnalyzerQcRun, String> { | ||
|
|
||
| /** | ||
| * Returns the most recent PASS run for an analyzer. | ||
| * Used by status evaluation to determine if QC is still valid. | ||
| */ | ||
| Optional<AnalyzerQcRun> getLastPassForAnalyzer(String analyzerId); | ||
|
|
||
| /** | ||
| * Returns the most recent run of any result for an analyzer. | ||
| * Used to display "last run" info in the UI status panel. | ||
| */ | ||
| Optional<AnalyzerQcRun> getLastRunForAnalyzer(String analyzerId); | ||
|
|
||
| /** | ||
| * Returns all runs for an analyzer, most recent first. | ||
| * Used by the history endpoint. | ||
| */ | ||
| List<AnalyzerQcRun> getAllRunsForAnalyzer(String analyzerId); | ||
| } |
85 changes: 85 additions & 0 deletions
85
src/main/java/org/openelisglobal/analyzerqc/daoimpl/AnalyzerQcRunDAOImpl.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,85 @@ | ||
| package org.openelisglobal.analyzerqc.daoimpl; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import org.openelisglobal.analyzerqc.dao.AnalyzerQcRunDAO; | ||
| import org.openelisglobal.analyzerqc.valueholder.AnalyzerQcRun; | ||
| import org.openelisglobal.common.daoimpl.BaseDAOImpl; | ||
| import org.openelisglobal.common.exception.LIMSRuntimeException; | ||
| import org.openelisglobal.common.log.LogEvent; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| /** | ||
| * Hibernate-backed DAO for AnalyzerQcRun. | ||
| * Extends BaseDAOImpl — same pattern as AnalyzerExperimentDAOImpl. | ||
| * | ||
| * Note: schemaName omitted in JPQL because analyzer_qc_run table | ||
| * has no schema prefix (matches analyzer_qc_rule pattern). | ||
| */ | ||
| @Component | ||
| @Transactional | ||
| public class AnalyzerQcRunDAOImpl | ||
| extends BaseDAOImpl<AnalyzerQcRun, String> | ||
| implements AnalyzerQcRunDAO { | ||
|
|
||
| public AnalyzerQcRunDAOImpl() { | ||
| super(AnalyzerQcRun.class); | ||
| } | ||
|
|
||
| @Override | ||
| public Optional<AnalyzerQcRun> getLastPassForAnalyzer(String analyzerId) { | ||
| try { | ||
| List<AnalyzerQcRun> results = entityManager | ||
| .createQuery( | ||
| "FROM AnalyzerQcRun r " + | ||
| "WHERE r.analyzer.id = :analyzerId " + | ||
| " AND r.result = 'PASS' " + | ||
| "ORDER BY r.runDate DESC", | ||
| AnalyzerQcRun.class) | ||
| .setParameter("analyzerId", analyzerId) | ||
| .setMaxResults(1) | ||
| .getResultList(); | ||
| return results.isEmpty() ? Optional.empty() : Optional.of(results.get(0)); | ||
| } catch (Exception e) { | ||
| LogEvent.logError(getClass().getName(), "getLastPassForAnalyzer", e.getMessage()); | ||
| throw new LIMSRuntimeException("Error in AnalyzerQcRunDAO.getLastPassForAnalyzer", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Optional<AnalyzerQcRun> getLastRunForAnalyzer(String analyzerId) { | ||
| try { | ||
| List<AnalyzerQcRun> results = entityManager | ||
| .createQuery( | ||
| "FROM AnalyzerQcRun r " + | ||
| "WHERE r.analyzer.id = :analyzerId " + | ||
| "ORDER BY r.runDate DESC", | ||
| AnalyzerQcRun.class) | ||
| .setParameter("analyzerId", analyzerId) | ||
| .setMaxResults(1) | ||
| .getResultList(); | ||
| return results.isEmpty() ? Optional.empty() : Optional.of(results.get(0)); | ||
| } catch (Exception e) { | ||
| LogEvent.logError(getClass().getName(), "getLastRunForAnalyzer", e.getMessage()); | ||
| throw new LIMSRuntimeException("Error in AnalyzerQcRunDAO.getLastRunForAnalyzer", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public List<AnalyzerQcRun> getAllRunsForAnalyzer(String analyzerId) { | ||
| try { | ||
| return entityManager | ||
| .createQuery( | ||
| "FROM AnalyzerQcRun r " + | ||
| "WHERE r.analyzer.id = :analyzerId " + | ||
| "ORDER BY r.runDate DESC", | ||
| AnalyzerQcRun.class) | ||
| .setParameter("analyzerId", analyzerId) | ||
| .getResultList(); | ||
| } catch (Exception e) { | ||
| LogEvent.logError(getClass().getName(), "getAllRunsForAnalyzer", e.getMessage()); | ||
| throw new LIMSRuntimeException("Error in AnalyzerQcRunDAO.getAllRunsForAnalyzer", e); | ||
| } | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/openelisglobal/analyzerqc/form/QcRunForm.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,39 @@ | ||
| package org.openelisglobal.analyzerqc.form; | ||
|
|
||
| import java.sql.Timestamp; | ||
|
|
||
| /** | ||
| * Request body for POST /rest/analyzers/{id}/qc-runs. | ||
| * | ||
| * Fields: | ||
| * result — required: "PASS" or "FAIL" | ||
| * value — optional: numeric or freetext measurement | ||
| * runDate — optional: defaults to now() if null | ||
| * performedByUserId — optional: defaults to session user if null | ||
| * source — required: "ANALYZER_IMPORT" | "ANALYZER_LIST" | ||
| */ | ||
| public class QcRunForm { | ||
|
|
||
| private String result; | ||
| private String value; | ||
| private Timestamp runDate; | ||
| private String performedByUserId; | ||
| private String source; | ||
|
|
||
| public String getResult() { return result; } | ||
| public void setResult(String result) { this.result = result; } | ||
|
|
||
| public String getValue() { return value; } | ||
| public void setValue(String value) { this.value = value; } | ||
|
|
||
| public Timestamp getRunDate() { return runDate; } | ||
| public void setRunDate(Timestamp runDate) { this.runDate = runDate; } | ||
|
|
||
| public String getPerformedByUserId() { return performedByUserId; } | ||
| public void setPerformedByUserId(String performedByUserId) { | ||
| this.performedByUserId = performedByUserId; | ||
| } | ||
|
|
||
| public String getSource() { return source; } | ||
| public void setSource(String source) { this.source = source; } | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/main/java/org/openelisglobal/analyzerqc/service/AnalyzerQcService.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,35 @@ | ||
| package org.openelisglobal.analyzerqc.service; | ||
|
|
||
| import java.util.List; | ||
| import org.openelisglobal.analyzerqc.form.QcRunForm; | ||
| import org.openelisglobal.analyzerqc.valueholder.AnalyzerQcRun; | ||
| import org.openelisglobal.analyzerqc.valueholder.AnalyzerQcStatus; | ||
|
|
||
| /** | ||
| * Business logic for Analyzer Manual QC Recording (Issue #3490). | ||
| */ | ||
| public interface AnalyzerQcService { | ||
|
|
||
| /** | ||
| * Returns the current QC validity status for an analyzer. | ||
| * Implements BR-AQC-001, BR-AQC-002, BR-AQC-004. | ||
| * | ||
| * @param analyzerId the analyzer's String ID | ||
| */ | ||
| AnalyzerQcStatus getQcStatus(String analyzerId); | ||
|
|
||
| /** | ||
| * Records a new manual QC run. | ||
| * Implements FR-AQC-012, BR-AQC-006. | ||
| * | ||
| * @param analyzerId the analyzer's String ID | ||
| * @param form request body | ||
| * @param currentUserId the authenticated user's sysUserId | ||
| */ | ||
| void recordQcRun(String analyzerId, QcRunForm form, String currentUserId); | ||
|
|
||
| /** | ||
| * Returns all QC runs for an analyzer, newest first. | ||
| */ | ||
| List<AnalyzerQcRun> getQcHistory(String analyzerId); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.