-
Notifications
You must be signed in to change notification settings - Fork 19
Feature/device integration #284
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
sehjotsinghunthinkable
wants to merge
47
commits into
PSMRI:vb/trace
Choose a base branch
from
sehjotsinghunthinkable:feature/device-integration
base: vb/trace
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
47 commits
Select commit
Hold shift + click to select a range
341a34f
Enforced mandatory validation for "Reason for Refusal in section e in…
sehjotsinghunthinkable 2908c20
Added counselled flag to confirmed cases response, indicating whether…
sehjotsinghunthinkable 9396905
Align `/complete` and `/submitBulk` form response editing behavior
sehjotsinghunthinkable 9e28141
Merge branch 'vb/counselling' into vb/counselling
sehjotsinghunthinkable 105ede6
Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, pro…
sehjotsinghunthinkable 21b7187
feat(dynamic-form): add Hindi localization fields and completed benef…
sehjotsinghunthinkable fdb1a1f
feat(dynamic-form): add Hindi localization fields and completed benef…
sehjotsinghunthinkable 6d8cb0b
Merge branch 'vb/counselling' into vb/counselling
vishwab1 5f05f66
feat(beneficiary): expose GPS coordinates in getBeneficiaryData response
sehjotsinghunthinkable 6ae9ed0
Committed 82b00ccf with only the three files:
sehjotsinghunthinkable 0332e9b
Revert "Committed 82b00ccf with only the three files:"
sehjotsinghunthinkable 4123985
Committed 82b00ccf with only the three files:
sehjotsinghunthinkable b7488fe
Committed 82b00ccf with only the three files:
sehjotsinghunthinkable 78d402c
Merge branch 'vb/counselling' into vb/counselling
sehjotsinghunthinkable b92cdea
Updated isMandatory field in Section C, so changed in TbCounsellingFo…
sehjotsinghunthinkable 81e29d2
Add optional villageId and providerServiceMapId filters to getComplet…
sehjotsinghunthinkable be0d0d6
Removing section f from seeder
sehjotsinghunthinkable f6aca3a
Removing already existing check in /complete api
sehjotsinghunthinkable 41550c2
Add a CHECKBOX question type and a TB_COUNSELLING_V2 seeder with a GE…
sehjotsinghunthinkable 380014c
Seed single-checkbox questions for Sections A-D and point the Counsel…
sehjotsinghunthinkable 4aafc4b
Mark form/section status REFUSED when TB2_GI_Q1=NO on /complete, spli…
sehjotsinghunthinkable b4bc4e0
Resolved conflicts
sehjotsinghunthinkable c53b9b5
fix(stoptb): getBeneficiaryData reads anthropometry/vitals from stand…
vishwab1 c7806cf
fix(compile): rename variable 'a' to 'anthro' to avoid conflict with …
vishwab1 d8008c3
fix(stoptb): set CreatedDate on t_benvisitdetail insert to prevent NO…
vishwab1 095f0ae
fix(anc-pnc): guard CreatedDate on BenVisitDetail insert for ANC and …
vishwab1 3b3a4c5
fix(docker): set TZ=Asia/Kolkata to prevent UTC/IST date mismatch
vishwab1 b1d28ae
fix(stoptb): handle ISO 8601 Z suffix in parseDob to fix beneficiary …
vishwab1 6d92f74
fix(stoptb): fallback to i_ben_flow_outreach.ben_dob when i_beneficia…
vishwab1 7459c47
fix: use saveAndFlush to prevent FK violation in t_benchiefcomplaint
vishwab1 9fccf6f
fix(stoptb): compute age from benDetailsRMNCH_OBJ.dob instead of benD…
vishwab1 7ddde0a
fix(stoptb): scope Suspected/Confirmed getAll by facility+village ins…
vishwab1 33c4f4d
fix(stoptb): drop date filter from facility-scoped Suspected query
vishwab1 349e714
fix(stoptb): join facility-scoped query on beneficiaryID, not benefic…
vishwab1 4d6606e
Added counselled flag to confirmed cases response, indicating whether…
sehjotsinghunthinkable 33219a1
Revert "Committed 82b00ccf with only the three files:"
sehjotsinghunthinkable 6951221
Committed 82b00ccf with only the three files:
sehjotsinghunthinkable e9fd699
Merge branch 'vb/counselling' into vb/counselling
vishwab1 5df6584
Integrated diagnostic device (X-ray/CAD/Trunat) results and document …
sehjotsinghunthinkable e8e67cd
Merge branch 'vb/trace' into feature/device-integration
sehjotsinghunthinkable 078747a
feat(stoptb): return visitCode in save responses for ABDM M2 flow
vishwab1 b74654d
feat(stoptb): return visitCode in general exam/screening/OPD get resp…
vishwab1 20ed063
● Add TrueNat TB/drug-resistance classification, split XRAY/TrueNat p…
sehjotsinghunthinkable 841867e
Making changes in common_example.properties
sehjotsinghunthinkable 8b05cc3
Feature/device integration (#288)
sehjotsinghunthinkable c940bfc
Added api for listing of beneficiaries id according to diagnostic ord…
sehjotsinghunthinkable 3c9db88
Merge branch 'vb/visit' into feature/device-integration
sehjotsinghunthinkable 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
52 changes: 52 additions & 0 deletions
52
src/main/java/com/iemr/flw/controller/DiagnosticDocumentController.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,52 @@ | ||
| package com.iemr.flw.controller; | ||
|
|
||
| import com.iemr.flw.dto.DiagnosticDocumentContent; | ||
| import com.iemr.flw.masterEnum.DiagnosticDocumentType; | ||
| import com.iemr.flw.service.DiagnosticDocumentService; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| /** | ||
| * SECURITY: this endpoint carries decrypted document bytes and MUST sit behind proper | ||
| * authentication/authorization in the real deployment. Today that's this app's existing | ||
| * JwtUserIdValidationFilter (utils/JwtUserIdValidationFilter.java), which protects every | ||
| * non-whitelisted path by default - do NOT add "/documents" to security.public-paths. | ||
| */ | ||
| @RestController | ||
| @RequestMapping("/documents") | ||
| public class DiagnosticDocumentController { | ||
|
|
||
| private final Logger logger = LoggerFactory.getLogger(DiagnosticDocumentController.class); | ||
|
|
||
| private final DiagnosticDocumentService diagnosticDocumentService; | ||
|
|
||
| public DiagnosticDocumentController(DiagnosticDocumentService diagnosticDocumentService) { | ||
| this.diagnosticDocumentService = diagnosticDocumentService; | ||
| } | ||
|
|
||
| @GetMapping | ||
| @Operation(summary = "Fetch the most recent stored document for a beneficiary + document type " | ||
| + "(XRAY_CHEST, XRAY_CHEST_ANNOTATED, CAD, MTB_REPORT, MTB_PLUS_REPORT, or MDR_RIF_REPORT)") | ||
| public ResponseEntity<byte[]> getDocument(@RequestParam Long benId, @RequestParam DiagnosticDocumentType documentType) { | ||
| try { | ||
| DiagnosticDocumentContent content = diagnosticDocumentService.fetch(benId, documentType); | ||
| MediaType mediaType; | ||
| try { | ||
| mediaType = MediaType.parseMediaType(content.getContentType()); | ||
| } catch (Exception e) { | ||
| mediaType = MediaType.APPLICATION_PDF; | ||
| } | ||
| return ResponseEntity.ok().contentType(mediaType).body(content.getContent()); | ||
| } catch (Exception e) { | ||
| logger.error("Error fetching document: benId={}, documentType={}: {}", benId, documentType, e.getMessage()); | ||
| return ResponseEntity.notFound().build(); | ||
| } | ||
| } | ||
| } |
129 changes: 129 additions & 0 deletions
129
src/main/java/com/iemr/flw/controller/DiagnosticOrderController.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,129 @@ | ||
| package com.iemr.flw.controller; | ||
|
|
||
| import com.google.gson.Gson; | ||
| import com.google.gson.GsonBuilder; | ||
| import com.iemr.flw.domain.iemr.DiagnosticOrder; | ||
| import com.iemr.flw.dto.DiagnosticOrderRequestDto; | ||
| import com.iemr.flw.dto.DiagnosticOrderResultDto; | ||
| import com.iemr.flw.dto.DiagnosticOrderStatusSummaryDto; | ||
| import com.iemr.flw.masterEnum.DiagnosticOrderType; | ||
| import com.iemr.flw.service.DiagnosticOrderService; | ||
| import com.iemr.flw.utils.ApiResponse; | ||
| import com.iemr.flw.utils.response.OutputResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import jakarta.validation.Valid; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/diagnostic") | ||
| public class DiagnosticOrderController { | ||
|
|
||
| private final Logger logger = LoggerFactory.getLogger(DiagnosticOrderController.class); | ||
|
|
||
| private final DiagnosticOrderService diagnosticOrderService; | ||
|
|
||
| public DiagnosticOrderController(DiagnosticOrderService diagnosticOrderService) { | ||
| this.diagnosticOrderService = diagnosticOrderService; | ||
| } | ||
|
|
||
| @PostMapping("/order/push") | ||
| @Operation(summary = "Push a diagnostic order to the configured provider") | ||
| public String pushOrder(@RequestBody @Valid DiagnosticOrderRequestDto request) { | ||
| OutputResponse response = new OutputResponse(); | ||
| try { | ||
| DiagnosticOrder order = diagnosticOrderService.createAndPushOrder(request); | ||
| response.setResponse(new Gson().toJson(order)); | ||
| } catch (Exception e) { | ||
| logger.error("Error in pushOrder: {}", e.getMessage()); | ||
| response.setError(5000, "Error pushing diagnostic order: " + e.getMessage()); | ||
| } | ||
| return response.toString(); | ||
| } | ||
|
|
||
| @PostMapping("/order/get") | ||
| @Operation(summary = "Get the diagnostic order for a beneficiary+orderType (latest, if more than one exists)") | ||
| public String getOrder(@RequestParam Long benRegID, @RequestParam String orderType) { | ||
| OutputResponse response = new OutputResponse(); | ||
| try { | ||
| DiagnosticOrder order = diagnosticOrderService.getOrder(benRegID, orderType); | ||
| response.setResponse(new Gson().toJson(order)); | ||
| } catch (Exception e) { | ||
| logger.error("Error in getOrder: {}", e.getMessage()); | ||
| response.setError(5000, "Error fetching diagnostic order: " + e.getMessage()); | ||
| } | ||
| return response.toString(); | ||
| } | ||
|
|
||
| @PostMapping("/order/getByBen/{benRegID}") | ||
| @Operation(summary = "Get all diagnostic orders for a beneficiary") | ||
| public String getOrdersByBen(@PathVariable Long benRegID) { | ||
| OutputResponse response = new OutputResponse(); | ||
| try { | ||
| List<DiagnosticOrder> orders = diagnosticOrderService.getOrdersByBenRegId(benRegID); | ||
| response.setResponse(new Gson().toJson(orders)); | ||
| } catch (Exception e) { | ||
| logger.error("Error in getOrdersByBen: {}", e.getMessage()); | ||
| response.setError(5000, "Error fetching diagnostic orders: " + e.getMessage()); | ||
| } | ||
| return response.toString(); | ||
| } | ||
|
|
||
| @PostMapping("/order/testCompleted") | ||
| @Operation(summary = "Mark that the physical test has completed for this beneficiary+orderType, starting the poll cadence") | ||
| public String markTestCompleted(@RequestParam Long benRegID, @RequestParam String orderType) { | ||
| OutputResponse response = new OutputResponse(); | ||
| try { | ||
| DiagnosticOrder order = diagnosticOrderService.markTestCompleted(benRegID, orderType); | ||
| response.setResponse(new Gson().toJson(order)); | ||
| } catch (Exception e) { | ||
| logger.error("Error in markTestCompleted: {}", e.getMessage()); | ||
| response.setError(5000, "Error marking test completed: " + e.getMessage()); | ||
| } | ||
| return response.toString(); | ||
| } | ||
|
|
||
| @PostMapping("/order/result") | ||
| @Operation(summary = "Get the diagnostic result for benId+orderType, at whatever stage it's currently in") | ||
| public String getOrderResult(@RequestParam Long benId, @RequestParam String orderType) { | ||
| OutputResponse response = new OutputResponse(); | ||
| try { | ||
| DiagnosticOrderResultDto result = diagnosticOrderService.getOrderResult(benId, orderType); | ||
| response.setResponse(new GsonBuilder().serializeNulls().create().toJson(result)); | ||
| } catch (Exception e) { | ||
| logger.error("Error in getOrderResult: {}", e.getMessage()); | ||
| response.setError(5000, "Error fetching diagnostic result: " + e.getMessage()); | ||
| } | ||
| return response.toString(); | ||
| } | ||
|
|
||
| @PostMapping("/order/poll") | ||
| @Operation(summary = "Trigger an immediate poll for one beneficiary+orderType's diagnostic order and return the result (ops use)") | ||
| public String pollOrder(@RequestParam Long benRegID, @RequestParam String orderType) { | ||
| OutputResponse response = new OutputResponse(); | ||
| try { | ||
| DiagnosticOrderResultDto result = diagnosticOrderService.triggerManualPoll(benRegID, orderType); | ||
| response.setResponse(new GsonBuilder().serializeNulls().create().toJson(result)); | ||
| } catch (Exception e) { | ||
| logger.error("Error in pollOrder: {}", e.getMessage()); | ||
| response.setError(5000, "Error triggering poll: " + e.getMessage()); | ||
| } | ||
| return response.toString(); | ||
| } | ||
|
|
||
| @GetMapping("/order/getBeneficiariesByStatus") | ||
| @Operation(summary = "Get beneficiary IDs bucketed by diagnostic order status for the given order type, " | ||
| + "optionally filtered by village and/or provider service map") | ||
| public ResponseEntity<ApiResponse> getBeneficiariesByStatus( | ||
| @RequestParam DiagnosticOrderType orderType, | ||
| @RequestParam(required = false) Integer villageId, | ||
| @RequestParam(required = false) Integer providerServiceMapId) { | ||
| DiagnosticOrderStatusSummaryDto result = | ||
| diagnosticOrderService.getOrderStatusSummary(orderType.name(), villageId, providerServiceMapId); | ||
| return ResponseEntity.ok(new ApiResponse(true, "Diagnostic order status summary fetched successfully", result)); | ||
| } | ||
| } |
74 changes: 74 additions & 0 deletions
74
src/main/java/com/iemr/flw/domain/iemr/DiagnosticDocument.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 @@ | ||
| package com.iemr.flw.domain.iemr; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.Data; | ||
| import org.hibernate.annotations.CreationTimestamp; | ||
| import org.hibernate.annotations.UpdateTimestamp; | ||
|
|
||
| import java.sql.Timestamp; | ||
|
|
||
| @Entity | ||
| @Table(name = "tb_diagnostic_document", schema = "db_iemr", | ||
| uniqueConstraints = @UniqueConstraint(columnNames = {"ben_reg_id", "document_type"}), | ||
| indexes = { | ||
| @Index(name = "idx_diagnostic_document_ben_reg_id", columnList = "ben_reg_id"), | ||
| @Index(name = "idx_diagnostic_document_order_type", columnList = "order_type"), | ||
| @Index(name = "idx_diagnostic_document_epoch_time", columnList = "epoch_time") | ||
| }) | ||
| @Data | ||
| public class DiagnosticDocument { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(name = "diagnostic_order_id") | ||
| private Long diagnosticOrderId; | ||
|
|
||
| @Column(name = "ben_reg_id") | ||
| private Long benRegID; | ||
|
|
||
| @Column(name = "order_type", length = 20) | ||
| private String orderType; | ||
|
|
||
| @Column(name = "asset_type", length = 50) | ||
| private String assetType; | ||
|
|
||
| @Column(name = "document_type", length = 30) | ||
| private String documentType; | ||
|
|
||
| @Column(name = "epoch_time") | ||
| private Long epochTime; | ||
|
|
||
| @Column(name = "stored_file_name", length = 150) | ||
| private String storedFileName; | ||
|
|
||
| @Column(name = "stored_path", length = 255) | ||
| private String storedPath; | ||
|
|
||
| @Column(name = "sha256_hash", length = 64) | ||
| private String sha256Hash; | ||
|
|
||
| @Column(name = "content_type", length = 100) | ||
| private String contentType; | ||
|
|
||
| @Column(name = "original_file_name", length = 255) | ||
| private String originalFileName; | ||
|
|
||
| @Column(name = "created_by") | ||
| private String createdBy; | ||
|
|
||
| @CreationTimestamp | ||
| @Column(name = "created_date", updatable = false) | ||
| private Timestamp createdDate; | ||
|
|
||
| @Column(name = "modified_by") | ||
| private String modifiedBy; | ||
|
|
||
| @UpdateTimestamp | ||
| @Column(name = "last_mod_date") | ||
| private Timestamp lastModDate; | ||
|
|
||
| @Column(name = "deleted") | ||
| private Boolean deleted = 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.
Please coordinate with @sac2kadam and ensure these new variables are added in DevOps repos.
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.
Okay, i will connect with him