Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/environment/common_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ generateHealthCard=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/health/facility/getPngCa
generateHealthIDCard=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/account/getPngCard

## Generate Notify SMS once episode completed
generateABDM_NotifySMS=@env.ABDM_BASE_URL@/gateway/v1/patients/sms/notify2
generateABDM_NotifySMS=@env.ABDM_HIECM_BASE_URL@/api/hiecm/hip/v3/link/patient/links/sms/notify2

##verifyBio
abdmVerifyBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/verifyBio
Expand Down
3 changes: 2 additions & 1 deletion src/main/environment/common_docker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ generateHealthCard=${ABDM_HEALTH_ID_BASE_URL}/api/v1/health/facility/getPngCard
generateHealthIDCard=${ABDM_HEALTH_ID_BASE_URL}/api/v1/account/getPngCard

## Generate Notify SMS once episode completed
generateABDM_NotifySMS=${ABDM_BASE_URL}/gateway/v1/patients/sms/notify2
generateABDM_NotifySMS=${ABDM_HIECM_BASE_URL}/api/hiecm/hip/v3/link/patient/links/sms/notify2


##verifyBio
abdmVerifyBio=${ABDM_HEALTH_ID_BASE_URL}/api/v1/registration/aadhaar/verifyBio
Expand Down
2 changes: 1 addition & 1 deletion src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ generateHealthCard=https://healthidsbx.abdm.gov.in/api/v1/health/facility/getPng
generateHealthIDCard=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/account/getPngCard

## Generate Notify SMS once episode completed
generateABDM_NotifySMS=https://dev.abdm.gov.in/gateway/v1/patients/sms/notify2
generateABDM_NotifySMS=@env.ABDM_HIECM_BASE_URL@/api/hiecm/hip/v3/link/patient/links/sms/notify2

##verifyBio
abdmVerifyBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/verifyBio
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/wipro/fhir/data/healthID/BenHealthIDMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,16 @@ public class BenHealthIDMapping {
@Transient
private boolean isNewAbha;

@Expose
@Transient
private String name;

@Expose
@Transient
private String gender;

@Expose
@Transient
private String yearOfBirth;

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class CareContextLinkTokenRequest {
private String abhaAddress;
private String name;
private String gender;
private int yearOfBirth;
private Integer yearOfBirth;
private String abdmFacilityId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class GenerateCareContextTokenRequest {
private String abhaAddress;
private String name;
private String gender;
private int yearOfBirth;
private Integer yearOfBirth;

}
79 changes: 57 additions & 22 deletions src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import com.wipro.fhir.service.ndhm.Common_NDHMService;
import com.wipro.fhir.service.ndhm.GenerateSession_NDHMService;
import com.wipro.fhir.service.patient_data_handler.PatientDataGatewayService;
import com.wipro.fhir.service.v3.abha.GenerateAuthSessionService;
import com.wipro.fhir.utils.exception.FHIRException;
import com.wipro.fhir.utils.http.HttpUtils;

Expand Down Expand Up @@ -151,6 +152,10 @@

@Autowired
private GenerateSession_NDHMService generateSession_NDHM;

@Autowired
private GenerateAuthSessionService generateAuthSessionService;

private static int ACCEPTED = 202;
@Autowired
private PatientDemographic patientDemographic;
Expand Down Expand Up @@ -232,56 +237,86 @@
// 1. OP consult resource bundle
if (p.getVisitCategory().equalsIgnoreCase("General OPD")
|| p.getVisitCategory().equalsIgnoreCase("General OPD (QC)")) {
int opConsult = oPConsultResourceBundle.processOpConsultRecordBundle(resourceRequestHandler, p);
if (opConsult <= 0)
try {

Check warning on line 240 in src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested try block into a separate method.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FHIR-API&issues=AZ79X-5Xl0lRn_2PsJX6&open=AZ79X-5Xl0lRn_2PsJX6&pullRequest=146
int opConsult = oPConsultResourceBundle.processOpConsultRecordBundle(resourceRequestHandler, p);
if (opConsult <= 0)
processed = false;
logger.info(" The value of opConsult proceesed: " + processed);
} catch (Exception e) {
processed = false;
logger.info(" The value of opConsult proceesed: " + processed);
logger.error("Op Consult FHIR Resource Bundle failed with error - " + e.getMessage());
}
}

// 2. diagnostic report record bundle
int hasLabTests = careContextRepo.hasLabtestsDone(p.getVisitCode().toString());
if (hasLabTests > 0) {
int diagReport = diagnosticReportResourceBundle
.processDiagnosticReportRecordBundle(resourceRequestHandler, p);
if (diagReport <= 0)
try {

Check warning on line 254 in src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested try block into a separate method.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FHIR-API&issues=AZ79X-5Xl0lRn_2PsJX7&open=AZ79X-5Xl0lRn_2PsJX7&pullRequest=146
int diagReport = diagnosticReportResourceBundle
.processDiagnosticReportRecordBundle(resourceRequestHandler, p);
if (diagReport <= 0)
processed = false;
logger.info(" The value of diagReport proceesed: " + processed);
} catch (Exception e) {
processed = false;
logger.info(" The value of diagReport proceesed: " + processed);
logger.error("Diagnostic Report FHIR Resource Bundle failed with error - " + e.getMessage());
}
}

// 3. prescription Bundle
int hasPrescription = careContextRepo.hasPrescribedDrugs(p.getVisitCode().toString());
if (hasPrescription > 0) {
int presp = prescriptionResourceBundle.processPrescriptionRecordBundle(resourceRequestHandler, p);
if (presp <= 0)
try {

Check warning on line 269 in src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested try block into a separate method.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FHIR-API&issues=AZ79X-5Xl0lRn_2PsJX8&open=AZ79X-5Xl0lRn_2PsJX8&pullRequest=146
int presp = prescriptionResourceBundle.processPrescriptionRecordBundle(resourceRequestHandler, p);
if (presp <= 0)
processed = false;
logger.info(" The value of presp proceesed: " + processed);
} catch (Exception e) {
processed = false;
logger.info(" The value of presp proceesed: " + processed);
logger.error("Prescription FHIR Resource Bundle failed with error - " + e.getMessage());
}
}

// 4. wellness Bundle
int hasPhyVitals = careContextRepo.hasPhyVitals(p.getVisitCode().toString());
if (hasPhyVitals > 0) {
int wellness = wellnessRecordResourceBundle.processWellnessRecordBundle(resourceRequestHandler, p);
if (wellness <= 0)
try {

Check warning on line 283 in src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested try block into a separate method.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FHIR-API&issues=AZ79X-5Xl0lRn_2PsJX9&open=AZ79X-5Xl0lRn_2PsJX9&pullRequest=146
int wellness = wellnessRecordResourceBundle.processWellnessRecordBundle(resourceRequestHandler, p);
if (wellness <= 0)
processed = false;
logger.info(" The value of wellness proceesed: " + processed);
} catch (Exception e) {
processed = false;
logger.info(" The value of wellness proceesed: " + processed);
logger.error("Wellness FHIR Resource Bundle failed with error - " + e.getMessage());
}
}

// 5. Immunization record
int hasVaccineDetails = careContextRepo.hasVaccineDetails(p.getVisitCode().toString());
if (hasVaccineDetails > 0) {
int immunization = immunizationRecordResourceBundle
.processImmunizationRecordBundle(resourceRequestHandler, p);
if (immunization <= 0)
try {

Check warning on line 297 in src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested try block into a separate method.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FHIR-API&issues=AZ79X-5Xl0lRn_2PsJX-&open=AZ79X-5Xl0lRn_2PsJX-&pullRequest=146
int immunization = immunizationRecordResourceBundle
.processImmunizationRecordBundle(resourceRequestHandler, p);
if (immunization <= 0)
processed = false;
logger.info(" The value of immunization proceesed: " + processed);
} catch (Exception e) {
processed = false;
logger.info(" The value of immunization proceesed: " + processed);
logger.error("Immunization FHIR Resource Bundle failed with error - " + e.getMessage());
}
}

// 6. Discharge Summary
int dischargeSummary = dischargeSummaryResourceBundle
.processDischargeSummaryRecordBundle(resourceRequestHandler, p);
if (dischargeSummary <= 0)
try {

Check warning on line 310 in src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested try block into a separate method.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FHIR-API&issues=AZ79X-5Xl0lRn_2PsJX_&open=AZ79X-5Xl0lRn_2PsJX_&pullRequest=146
int dischargeSummary = dischargeSummaryResourceBundle
.processDischargeSummaryRecordBundle(resourceRequestHandler, p);
if (dischargeSummary <= 0)
processed = false;
logger.info(" The value of dischargeSummary proceesed: " + processed);
} catch (Exception e) {
processed = false;
logger.info(" The value of dischargeSummary proceesed: " + processed);
logger.error("Discharge Summary FHIR Resource Bundle failed with error - " + e.getMessage());
}

logger.info(" The value of final proceesed: " + processed);

Expand Down Expand Up @@ -714,7 +749,7 @@
*/
public void sendAbdmAdvSMS(String phone) throws FHIRException {
try {
String ndhmAuthToken = generateSession_NDHM.getNDHMAuthToken();
String ndhmAuthToken = generateAuthSessionService.getAbhaAuthToken();
HIP hip = new HIP("Piramal Swasthya", clientID);
NDHMRequest obj = common_NDHMService.getRequestIDAndTimeStamp();
Notification notification = new Notification(phone, hip);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ public String saveAbdmFacilityId(String reqObj) throws FHIRException {
String res = null;
try {
SaveFacilityIdForVisit requestObj = InputMapper.gson().fromJson(reqObj, SaveFacilityIdForVisit.class);
if(requestObj.getAbdmFacilityId() == null || requestObj.getAbdmFacilityId() == "") {
if (requestObj.getAbdmFacilityId() == null || requestObj.getAbdmFacilityId().trim().isEmpty()) {
requestObj.setAbdmFacilityId(abdmFacilityId);
}
if (requestObj.getAbdmFacilityId() == null || requestObj.getAbdmFacilityId().trim().isEmpty()) {
return "ABDM Facility ID is not configured. Please map the facility before proceeding.";
}
Integer response = benHealthIDMappingRepo.updateFacilityIdForVisit(requestObj.getVisitCode(), requestObj.getAbdmFacilityId());
if(response > 0 ) {
res = "ABDM Facility ID updated successfully";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
return new Gson().toJson(health);
}

public String getBenHealthID(Long benRegID) {

Check failure on line 179 in src/main/java/com/wipro/fhir/service/healthID/HealthIDServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FHIR-API&issues=AZ79X-1cl0lRn_2PsJX2&open=AZ79X-1cl0lRn_2PsJX2&pullRequest=146
List<BenHealthIDMapping> healthDetailsList = benHealthIDMappingRepo.getHealthDetails(benRegID);

List<String> healthIdNumbers = healthDetailsList.stream()
Expand All @@ -185,18 +185,34 @@
.collect(Collectors.toList());

Map<String, Boolean> abhaMap = new HashMap<>();
Map<String, HealthIDResponse> healthIdDetailsMap = new HashMap<>();
if (!healthIdNumbers.isEmpty()) {
List<Object[]> abhaResults = benHealthIDMappingRepo.getIsNewAbhaBatch(healthIdNumbers);
for (Object[] row : abhaResults) {
String healthIdNumber = (String) row[0];
Boolean isNewAbha = (Boolean) row[1];
abhaMap.put(healthIdNumber, isNewAbha);
}
for (String hIdNumber : healthIdNumbers) {
ArrayList<HealthIDResponse> details = healthIDRepo.getHealthIDDetailsUsingHealthNumber(hIdNumber);
if (details != null && !details.isEmpty()) {
healthIdDetailsMap.put(hIdNumber, details.get(0));
}
}
}

for (BenHealthIDMapping healthDetails : healthDetailsList) {
Boolean isNew = abhaMap.get(healthDetails.getHealthIdNumber());
healthDetails.setNewAbha(Boolean.TRUE.equals(isNew));
HealthIDResponse hdResponse = healthIdDetailsMap.get(healthDetails.getHealthIdNumber());
if (hdResponse != null) {
healthDetails.setName(hdResponse.getName());
healthDetails.setGender(hdResponse.getGender());
healthDetails.setYearOfBirth(hdResponse.getYearOfBirth());
if (hdResponse.getHealthId() != null && !hdResponse.getHealthId().isEmpty()) {
healthDetails.setHealthId(hdResponse.getHealthId());
}
}
}

Map<String, Object> responseMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,22 @@
JsonParser jsnParser = new JsonParser();
JsonElement jsnElmnt = jsnParser.parse(addCareContextResponse);
jsnOBJ = jsnElmnt.getAsJsonObject();
try {
if (jsnOBJ.get("Acknowledgement") != null
&& jsnOBJ.getAsJsonObject("Acknowledgement").get("Status") != null)
successResponse = jsnOBJ.getAsJsonObject("Acknowledgement").get("Status").getAsString();
else
throw new FHIRException(
"NDHM_FHIR " + jsnOBJ.getAsJsonObject("Error").get("Message").getAsString());
} catch (Exception e) {
// v0.5 callback: {"Acknowledgement":{"Status":"SUCCESS"}}

Check warning on line 271 in src/main/java/com/wipro/fhir/service/ndhm/LinkCareContext_NDHMServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FHIR-API&issues=AZ8D3cgBxZ2CqG1pxsog&open=AZ8D3cgBxZ2CqG1pxsog&pullRequest=146
// v3 callback: {"status":"Successfully Linked care context","response":{...}}
if (jsnOBJ.get("Acknowledgement") != null
&& jsnOBJ.getAsJsonObject("Acknowledgement").get("Status") != null) {
successResponse = jsnOBJ.getAsJsonObject("Acknowledgement").get("Status").getAsString();
} else if (jsnOBJ.get("status") != null) {
successResponse = jsnOBJ.get("status").getAsString();
} else if (jsnOBJ.get("Error") != null
&& jsnOBJ.getAsJsonObject("Error").get("Message") != null) {
throw new FHIRException(
"NDHM_FHIR " + jsnOBJ.getAsJsonObject("Error").get("Message").getAsString());
} else {
throw new FHIRException("NDHM_FHIR Unexpected care context response: " + addCareContextResponse);
}

if (successResponse.equalsIgnoreCase("success")) {
if (successResponse != null && successResponse.toLowerCase().contains("success")) {
response = "Care Context added successfully";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
package com.wipro.fhir.service.resource_model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -83,53 +82,43 @@ private List<DiagnosticReport> generateDiagnosticReportResource(Patient patient,

List<DiagnosticReport> diagnosticReportList = new ArrayList<>();

Map<Integer, Boolean> testMap = new HashMap<Integer, Boolean>();

CodeableConcept cc;
Reference observationRef;
List<Reference> observationListRef;

for (DiagnosticReportDataModel d : diagnosticList) {
if (d.getProcedureID() != null && testMap != null && !testMap.containsKey(d.getProcedureID())) {

diagnosticReport = new DiagnosticReport();
UUID = commonService.getUUID();
diagnosticReport.setId("DiagnosticReport/" + UUID);

DateTimeType dtt = new DateTimeType(d.getCreatedDate());
diagnosticReport.setEffective(dtt);

diagnosticReport.setStatus(DiagnosticReportStatus.FINAL);

cc = new CodeableConcept();
cc.setText(d.getProcedureName());

diagnosticReport.setCode(cc);

// referance - patient
diagnosticReport.setSubject(new Reference(patient.getIdElement().getValue()));

if (observationMap != null && observationMap.size() > 0) {
List<Observation> observationList = observationMap.get(d.getProcedureID());

if (observationList != null && observationList.size() > 0) {
observationListRef = new ArrayList<>();
for (Observation o : observationList) {
observationRef = new Reference(o.getIdElement().getValue());
observationListRef.add(observationRef);
}

diagnosticReport.setResult(observationListRef);
// Collect all observation references across all procedures into one report.
// Previously one DiagnosticReport was created per procedure, causing the ABHA
// app to render both the DiagnosticReport (name only, no value) and each
// Observation (name + value) β€” producing duplicate entries when the procedure
// name matched the component name.
List<Reference> allObservationRefs = new ArrayList<>();
if (observationMap != null) {
for (List<Observation> obsList : observationMap.values()) {
if (obsList != null) {
for (Observation o : obsList) {
allObservationRefs.add(new Reference(o.getIdElement().getValue()));
}
}
}
}

if (!allObservationRefs.isEmpty()) {
diagnosticReport = new DiagnosticReport();
UUID = commonService.getUUID();
diagnosticReport.setId("DiagnosticReport/" + UUID);
diagnosticReport.setStatus(DiagnosticReportStatus.FINAL);

diagnosticReport.setConclusion("");
CodeableConcept cc = new CodeableConcept();
cc.setText("Laboratory Report");
diagnosticReport.setCode(cc);

diagnosticReportList.add(diagnosticReport);
diagnosticReport.setSubject(new Reference(patient.getIdElement().getValue()));

testMap.put(d.getProcedureID(), true);
if (!diagnosticList.isEmpty() && diagnosticList.get(0).getCreatedDate() != null) {
diagnosticReport.setEffective(new DateTimeType(diagnosticList.get(0).getCreatedDate()));
}

diagnosticReport.setResult(allObservationRefs);
diagnosticReport.setConclusion("");
diagnosticReportList.add(diagnosticReport);
}

return diagnosticReportList;

}
Expand Down
Loading
Loading