feat(COG-148): Add bulk lab order import from external reference lab - #19
Open
devin-ai-integration[bot] wants to merge 3 commits into
Open
devin-ai-integration[bot] wants to merge 3 commits into
devin-ai-integration[bot] wants to merge 3 commits into
Conversation
- Add HL7 v2.5.1 ORU^R01 parser using HAPI library - Add flexible CSV parser with column alias support - Add import service with auto-matching to pending lab orders - Add REST endpoint POST /v1/lab-results/import - Add Flyway migration V3 for lab_result_imports and unmatched_lab_results tables - Add domain entities, repositories, and DTOs - Add unmatched results queue for manual review - Add async provider notifications on result match - Add audit logging via @AuditAccess - Add 23 unit tests for parsers and import service Co-Authored-By: Stephen Cornwell <stephen@cognition.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…ons-io dep - Add @transactional(readOnly=true) at class level on LabResultImportService following PatientService pattern - Remove unused commons-io dependency from pom.xml - Add getUnmatchedCount convenience method Co-Authored-By: Stephen Cornwell <stephen@cognition.ai>
- Replace Page<UnmatchedLabResult> with Page<UnmatchedLabResultDTO> in controller to avoid LazyInitializationException from ManyToOne relationship - Add deterministic ORDER BY orderDateTime DESC to MRN+testCode fallback query so most recent pending order is matched first - Create UnmatchedLabResultDTO to flatten entity for API response Co-Authored-By: Stephen Cornwell <stephen@cognition.ai>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a new bulk lab result import feature that accepts HL7 v2.5.1 ORU^R01 files (
.hl7) or CSV files (.csv) from external reference labs (Quest, LabCorp, etc.), auto-matches results to pending lab orders, and queues unmatched results for manual review.New files (20 changed):
POST /v1/lab-results/import(multipart file upload), plus GET endpoints for import status, history, and unmatched resultsHL7ResultParser(HAPI v2.5.1) andCsvResultParser(flexible header aliases)LabResultImportService— orchestrates parsing, matching (by order number, then MRN+test code fallback), result creation, and provider notificationLabResultImport,UnmatchedLabResultentities with enums (ImportStatus,ReviewStatus)LabResultImportResponse,ParsedLabResult,UnmatchedLabResultDTOLabOrderRepository,LabResultRepository,LabResultImportRepository,UnmatchedLabResultRepositoryV3__lab_result_import.sql— createslab_result_importsandunmatched_lab_resultstableshapi-structures-v251Updates since last revision
Page<UnmatchedLabResult>withPage<UnmatchedLabResultDTO>in controller/service to avoidLazyInitializationExceptionfrom the@ManyToOnerelationship toLabResultImportORDER BY lo.orderDateTime DESCto MRN+testCode fallback query so the most recent pending order is matched first@Transactional(readOnly = true)at class level onLabResultImportService(followsPatientServicepattern)commons-iodependencyReview & Testing Checklist for Human
@PreAuthorizeor role-based access control on any of the import endpoints. Consistent with existing controllers, but verify this is acceptable given HIPAA requirements for importing external lab data.BIGSERIAL/IDENTITYfor ID generation, enum column string widths, nullable constraints). No integration tests validate this.importFile()runs synchronously in the request thread within a single@Transactional. Large files could cause request timeouts and long-held DB locks. Notifications are@Async, but the import itself is not.orderDateTime DESCand the service picks the first (most recent). Verify this is the desired behavior vs. routing to unmatched queue when ambiguous.Recommended test plan: Deploy to a dev environment, run the Flyway migration against the actual DB, then upload a sample
.hl7file and a sample.csvfile via thePOST /v1/lab-results/importendpoint. Verify matched results appear on the correct lab orders, unmatched results are queued and returned as DTOs via/import/unmatched, and the import history/status endpoints return correct data.Notes
yyyyMMddHHmmssandyyyyMMddHHmmformats only; other HL7 timestamp variants (timezone offsets, fractional seconds) will silently result in nullresultDateTime.Link to Devin session: https://app.devin.ai/sessions/18dc2cfa1fe546ba9a3fb2495f448e6c
Requested by: @stephencornwell