-
Notifications
You must be signed in to change notification settings - Fork 34
fix: resolve 5 bugs across controller, feed worker, and patient data handler #145
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import com.google.gson.Gson; | ||
| import com.wipro.fhir.data.healthID.BenHealthIDMapping; | ||
|
|
@@ -89,48 +90,66 @@ | |
| } | ||
|
|
||
| @Override | ||
| @Transactional(rollbackFor = FHIRException.class) | ||
| public String generatePatientProfileAMRIT_SaveTo_Mongo(String Authorization) throws FHIRException { | ||
|
Comment on lines
+93
to
94
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Transaction manager and `@EnableTransactionManagement` declarations =="
rg -n -C3 '@EnableTransactionManagement|PlatformTransactionManager|MongoTransactionManager|JpaTransactionManager|ChainedTransactionManager|transactionManagerRef' $(fd -t f '.*\.java$' src || true)
echo
echo "== Mongo config presence (templates/factories/transaction manager) =="
rg -n -C3 'MongoTemplate|MongoDatabaseFactory|MongoTransactionManager|AbstractMongoClientConfiguration' $(fd -t f '.*\.java$' src || true)
echo
echo "== savePatientProfileDataToMongo implementation and annotations =="
rg -n -C5 'savePatientProfileDataToMongo\s*\(' $(fd -t f '.*\.java$' src || true)
echo
echo "== Repository update method definition =="
rg -n -C5 'updateProcessedFlagForProfileCreated\s*\(' $(fd -t f '.*\.java$' src || true)Repository: PSMRI/FHIR-API Length of output: 11637 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== FhirApiApplication.java full content ==="
cat -n src/main/java/com/wipro/fhir/FhirApiApplication.java
echo
echo "=== Application configuration files ==="
fd -t f -e properties -e yml -e yaml src || true | head -20
rg -l 'application' . --max-depth 2 2>/dev/null | grep -E '\.(properties|yml|yaml)$' | head -20
echo
echo "=== Check application.properties for spring.data.mongodb and transaction configs ==="
fd -t f 'application.*properties' . | xargs cat 2>/dev/null | grep -i -E 'mongodb|transaction|jpa' || echo "No matches"
echo
echo "=== Check application.yml/yaml for spring.data.mongodb and transaction configs ==="
fd -t f 'application.*\.ya?ml' . | xargs cat 2>/dev/null | grep -A5 -B5 -i -E 'mongodb|transaction|jpa' || echo "No matches"
echo
echo "=== Search for `@Bean` definitions related to transaction manager ==="
rg -n '@Bean.*Transaction|TransactionManager|MongoTemplate' --type java src || echo "No additional matches"Repository: PSMRI/FHIR-API Length of output: 2853 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Find all .properties and .yml files ==="
find . -type f \( -name '*.properties' -o -name '*.yml' -o -name '*.yaml' \) 2>/dev/null | head -20
echo
echo "=== Check src/main/resources directory ==="
ls -la src/main/resources/ 2>/dev/null || echo "Directory not found"
echo
echo "=== Content of application.properties if it exists ==="
cat src/main/resources/application.properties 2>/dev/null || echo "File not found"
echo
echo "=== Content of application.yml if it exists ==="
cat src/main/resources/application.yml 2>/dev/null || echo "File not found"
echo
echo "=== Check for Spring Boot configuration in pom.xml (spring-data-mongodb vs spring-boot-starter-data-jpa) ==="
rg -A2 -B2 'spring-data-mongodb|spring-boot-starter-data-jpa|spring-boot-starter-data-rest' pom.xml 2>/dev/null || echo "Not found in pom.xml"
echo
echo "=== Check if mongoTemplate operations are wrapped in any TX manager binding ==="
rg -n 'mongoTemplate\.|transactionManager\|@Transactional.*mongodb' src --type java | head -20Repository: PSMRI/FHIR-API Length of output: 5970 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Full pom.xml search for mongodb dependency ==="
rg 'mongodb|mongo' pom.xml -i
echo
echo "=== Check environment property files for MongoDB config ==="
echo "--- common_example.properties ---"
cat src/main/environment/common_example.properties | grep -i -E 'mongo|mongodb' || echo "No MongoDB config"
echo
echo "--- common_ci.properties ---"
cat src/main/environment/common_ci.properties | grep -i -E 'mongo|mongodb' || echo "No MongoDB config"
echo
echo "--- common_docker.properties ---"
cat src/main/environment/common_docker.properties | grep -i -E 'mongo|mongodb' || echo "No MongoDB config"
echo
echo "=== Check if MongoTemplate bean in FhirApiApplication is actually used or if it fails ==="
rg -n 'MongoTemplate|mongoTemplate' src --type java | grep -v '://' | head -30Repository: PSMRI/FHIR-API Length of output: 1638 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Search for `@EnableTransactionManagement` or explicit MongoTransactionManager bean ==="
rg -n '@EnableTransactionManagement|@Bean.*MongoTransactionManager|new MongoTransactionManager' src --type java
echo
echo "=== Check savePatientProfileDataToMongo full implementation ==="
sed -n '654,670p' src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java
echo
echo "=== Check the transactional method calling savePatientProfileDataToMongo (around line 87) ==="
sed -n '70,95p' src/main/java/com/wipro/fhir/service/patient_data_handler/PatientDataGatewayServiceImpl.java
echo
echo "=== Verify if `@Transactional` on service method covers nested Mongo operations ==="
rg -B5 '@Override' src/main/java/com/wipro/fhir/service/patient_data_handler/PatientDataGatewayServiceImpl.java | grep -A5 'generatePatientProfileAMRIT_SaveTo_Mongo'Repository: PSMRI/FHIR-API Length of output: 147 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Check savePatientProfileDataToMongo full implementation ==="
sed -n '654,670p' src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java
echo
echo "=== Check the transactional method calling savePatientProfileDataToMongo (lines 70-95) ==="
sed -n '70,95p' src/main/java/com/wipro/fhir/service/patient_data_handler/PatientDataGatewayServiceImpl.java
echo
echo "=== Check PatientDataGatewayServiceImpl around the `@Transactional` method (lines 93-114) ==="
sed -n '93,114p' src/main/java/com/wipro/fhir/service/patient_data_handler/PatientDataGatewayServiceImpl.javaRepository: PSMRI/FHIR-API Length of output: 3181
These methods span Mongo writes ( No Also applies to: lines 117–119 🤖 Prompt for AI Agents |
||
|
|
||
| List<PatientDemographicModel_NDHM_Patient_Profile> ppList = new ArrayList<>(); | ||
|
|
||
| List<TRG_PatientResourceData> resultSetList = tRG_PatientResourceData_Repo | ||
| .getByProcessedOrderByCreatedDateLimit20(); | ||
| ppList = generatePatientProfileFromAMRIT(Authorization, resultSetList); | ||
|
|
||
| ppList = feedPatientProfileToMongoDB(ppList); | ||
| List<PatientDemographicModel_NDHM_Patient_Profile> savedList = feedPatientProfileToMongoDB(ppList); | ||
|
|
||
| if (ppList != null && ppList.size() > 0) { | ||
| if (savedList != null && savedList.size() > 0) { | ||
|
Check warning on line 104 in src/main/java/com/wipro/fhir/service/patient_data_handler/PatientDataGatewayServiceImpl.java
|
||
| List<Long> ids = new ArrayList<>(); | ||
| ids.add((long) 0); | ||
| for (PatientDemographicModel_NDHM_Patient_Profile pp : ppList) { | ||
| for (PatientDemographicModel_NDHM_Patient_Profile pp : savedList) { | ||
| ids.add(pp.getTriggerTableAIId()); | ||
| } | ||
| tRG_PatientResourceData_Repo.updateProcessedFlagForProfileCreated(ids); | ||
| try { | ||
| tRG_PatientResourceData_Repo.updateProcessedFlagForProfileCreated(ids); | ||
| } catch (Exception e) { | ||
| // Mongo save succeeded but MySQL update failed — stores are now inconsistent. | ||
| // Log affected IDs so ops can manually reconcile; re-throw to signal failure. | ||
| logger.error("MySQL update failed after Mongo save — inconsistent state. Affected IDs: {}. Error: {}", ids, e.getMessage()); | ||
| throw new FHIRException("Failed to update processed flag after Mongo save. " + e.getMessage()); | ||
| } | ||
| ppList = savedList; | ||
| } | ||
|
|
||
| return new Gson().toJson(ppList); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional(rollbackFor = FHIRException.class) | ||
| public String generatePatientProfileAMRIT_SaveTo_Mongo(String Authorization, | ||
| ResourceRequestHandler resourceRequestHandler) throws FHIRException { | ||
|
|
||
| List<PatientDemographicModel_NDHM_Patient_Profile> ppList = new ArrayList<>(); | ||
|
|
||
| List<TRG_PatientResourceData> resultSetList = tRG_PatientResourceData_Repo | ||
| .getByBenIdLatestRecord(resourceRequestHandler.getBeneficiaryID()); | ||
|
|
||
| ppList = generatePatientProfileFromAMRIT(Authorization, resultSetList); | ||
|
|
||
| ppList = feedPatientProfileToMongoDB(ppList); | ||
| List<PatientDemographicModel_NDHM_Patient_Profile> savedList = feedPatientProfileToMongoDB(ppList); | ||
|
|
||
| if (ppList != null && ppList.size() > 0) { | ||
| if (savedList != null && savedList.size() > 0) { | ||
|
Check warning on line 138 in src/main/java/com/wipro/fhir/service/patient_data_handler/PatientDataGatewayServiceImpl.java
|
||
| List<Long> ids = new ArrayList<>(); | ||
| ids.add((long) 0); | ||
| for (PatientDemographicModel_NDHM_Patient_Profile pp : ppList) { | ||
| for (PatientDemographicModel_NDHM_Patient_Profile pp : savedList) { | ||
| ids.add(pp.getTriggerTableAIId()); | ||
| } | ||
| tRG_PatientResourceData_Repo.updateProcessedFlagForProfileCreated(ids); | ||
| try { | ||
| tRG_PatientResourceData_Repo.updateProcessedFlagForProfileCreated(ids); | ||
| } catch (Exception e) { | ||
| // Mongo save succeeded but MySQL update failed — stores are now inconsistent. | ||
| // Log affected IDs so ops can manually reconcile; re-throw to signal failure. | ||
| logger.error("MySQL update failed after Mongo save — inconsistent state. Affected IDs: {}. Error: {}", ids, e.getMessage()); | ||
| throw new FHIRException("Failed to update processed flag after Mongo save. " + e.getMessage()); | ||
| } | ||
| ppList = savedList; | ||
| } | ||
|
|
||
| return new Gson().toJson(ppList); | ||
|
|
@@ -291,8 +310,8 @@ | |
| address.setState(pd.getI_bendemographics().getStateName()); | ||
|
|
||
| if (pd.getI_bendemographics().getAddressLine1() != null | ||
| || pd.getI_bendemographics().getAddressLine1() != null | ||
| || pd.getI_bendemographics().getAddressLine1() != null) { | ||
| || pd.getI_bendemographics().getAddressLine2() != null | ||
| || pd.getI_bendemographics().getAddressLine3() != null) { | ||
| String address1 = (pd.getI_bendemographics().getAddressLine1() != null) | ||
| ? pd.getI_bendemographics().getAddressLine1() | ||
| : ""; | ||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: PSMRI/FHIR-API
Length of output: 2734
🏁 Script executed:
Repository: PSMRI/FHIR-API
Length of output: 2005
🏁 Script executed:
Repository: PSMRI/FHIR-API
Length of output: 4217
Breaking REST API change requires external client validation.
The return type changed from
StringtoResponseEntity<String>(line 38). This is a breaking change for any external REST clients consuming this endpoint. While the underlying service layer (HealthIDService) remains unchanged, REST clients calling/healthIDRecord/mapHealthIDToBeneficiarywill receive a different response structure and must be updated accordingly. Ensure external client integrations and API documentation are updated to reflect this change.🤖 Prompt for AI Agents