Skip to content

Commit

Permalink
Merge branch 'develop' into jwt-api
Browse files Browse the repository at this point in the history
  • Loading branch information
indraniBan authored Feb 3, 2025
2 parents 2edae7e + 7fe11c4 commit 1abf855
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 36 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/checkstyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Call Checkstyle

on:
pull_request:
branches: ["master", "develop"]
paths:
- '**/*.java'

jobs:
style-check:
uses: PSMRI/.github/.github/workflows/checkstyle.yml@main
with:
java-version: '17'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/out-tsc
/target
/logs
command_output.log

# dependencies
/node_modules
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ Detailed information on API endpoints can be found in the [API Guide](https://pi

## Usage
All features have been exposed as REST endpoints. Refer to the SWAGGER API specification for details.

## Filing Issues

If you encounter any issues, bugs, or have feature requests, please file them in the [main AMRIT repository](https://github.com/PSMRI/AMRIT/issues). Centralizing all feedback helps us streamline improvements and address concerns efficiently.

## Join Our Community

We’d love to have you join our community discussions and get real-time support!
Join our [Discord server](https://discord.gg/FVQWsf5ENS) to connect with contributors, ask questions, and stay updated.
65 changes: 65 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
<property name="severity" value="warning" />
<property name="fileExtensions" value="java" />

<!-- Checks for Size Violations -->
<module name="FileLength">
<property name="max" value="500" />
</module>
<module name="LineLength">
<property name="max" value="120" />
</module>

<module name="TreeWalker">
<!-- Checks for Naming Conventions -->
<module name="MethodName" />
<module name="PackageName" />
<module name="TypeName" />
<module name="ParameterName" />
<module name="LocalVariableName" />
<module name="MemberName" />

<!-- Checks for imports -->
<module name="AvoidStarImport" />
<module name="IllegalImport" />
<module name="RedundantImport" />
<module name="UnusedImports" />

<!-- Checks for Size Violations -->
<module name="MethodLength">
<property name="max" value="50" />
</module>

<!-- Checks for whitespace -->
<module name="EmptyLineSeparator" />
<module name="GenericWhitespace" />
<module name="MethodParamPad" />
<module name="NoWhitespaceAfter" />
<module name="NoWhitespaceBefore" />
<module name="ParenPad" />
<module name="TypecastParenPad" />
<module name="WhitespaceAfter" />
<module name="WhitespaceAround" />

<!-- Modifier Checks -->
<module name="ModifierOrder" />
<module name="RedundantModifier" />

<!-- Checks for blocks -->
<module name="EmptyBlock" />
<module name="LeftCurly" />
<module name="RightCurly" />
<module name="NeedBraces" />

<!-- Checks for common coding problems -->
<module name="EmptyStatement" />
<module name="EqualsHashCode" />
<module name="IllegalInstantiation" />
<module name="MissingSwitchDefault" />
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
</module>
</module>
30 changes: 28 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,35 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.1</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.12.7</version>
</dependency>
</dependencies>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>
<dependencyManagement>
<dependencies>
Expand Down
21 changes: 11 additions & 10 deletions src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
benSearchByBenIDURL=http://localhost:8080/commonapi-v1.0/beneficiary/searchUserByID
userAuthURL=http://localhost:8080/commonapi-v1.0/user/userAuthenticate
server.port=8093

benSearchByBenIDURL=http://localhost:8083/beneficiary/searchUserByID
userAuthURL=http://localhost:8083/user/userAuthenticate
# E-aushadhi
eaushadhiStoreStockDetailsUrl=https://uatbiharsso.dcservices.in/eAushadhi_BIHAR/rest/storeStockDetailsService/
eaushadhiStoreStockAckUrl=https://uatbiharsso.dcservices.in/eAushadhi_BIHAR/rest/AcknowledgeStoreStockService/
Expand All @@ -9,18 +10,18 @@ fhirUserName=<Enter FHIR username here>
fhirPassword=<Enter FHIR password here>

# DB Connections (MySQL)
spring.datasource.url=<Enter AMRIT DB_IEMR URL here>
spring.datasource.username=<Enter your AMRIT DB_IEMR username>
spring.datasource.password=<Enter your AMRIT DB_IEMR password>
spring.datasource.url=jdbc:mysql://localhost:3306/db_iemr
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

# DB Connection (Mongo DB)
spring.data.mongodb.host=<Enter Mongo DB host ip address>
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.authentication-database=<Enter MongoDB authentication database name>
spring.data.mongodb.database=<Enter MongoDB database name>
spring.data.mongodb.username=<Enter MongoDB username>
spring.data.mongodb.password=<Enter MongoDB password>
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.database=amrit
spring.data.mongodb.username=root
spring.data.mongodb.password=1234

atomsFeedStartPage=1
parentUrl=https://demo.mybahmni.org
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@Data
public class SaveFacilityIdForVisit {

String facilityId;
String abdmFacilityId;
BigInteger visitCode;

}
49 changes: 35 additions & 14 deletions src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -59,7 +58,6 @@
import com.wipro.fhir.data.mongo.care_context.NDHMResponse;
import com.wipro.fhir.data.mongo.care_context.Notification;
import com.wipro.fhir.data.mongo.care_context.PatientCareContexts;
import com.wipro.fhir.data.mongo.care_context.PatientCareContextsStringOBJ;
import com.wipro.fhir.data.mongo.care_context.SMSNotify;
import com.wipro.fhir.data.patient.PatientDemographic;
import com.wipro.fhir.data.patient_data_handler.PatientDemographicModel_NDHM_Patient_Profile;
Expand Down Expand Up @@ -104,10 +102,12 @@ public class CommonServiceImpl implements CommonService {
private static String authKey;
private UUID uuid;


// public static String NDHM_AUTH_TOKEN;
// public static Long NDHM_TOKEN_EXP;
// public static String NDHM_OTP_TOKEN;


@Value("${clientID}")
private String clientID;

Expand Down Expand Up @@ -215,6 +215,8 @@ public String processResourceOperation() throws FHIRException {
// 3. prescription Bundle
int k = prescriptionBundle.processPrescriptionRecordBundle(resourceRequestHandler, p);

logger.info("The value of i: " + i + " The value of j: " + j + " The value of k: " + k);

if (i > 0 && j > 0 && k > 0) {

// update the processed flag in trigger table
Expand Down Expand Up @@ -291,12 +293,12 @@ public String getUUID() {

// 31-03-2021
// @Override
public int addCareContextToMongo(PatientDemographic pDemo, PatientEligibleForResourceCreation pVisit)
public void addCareContextToMongo(PatientDemographic pDemo, PatientEligibleForResourceCreation pVisit)
throws FHIRException {
int response = 0;

if (pDemo != null && pVisit != null) {


// JsonObject jsnOBJ = new JsonObject();
// JsonParser jsnParser = new JsonParser();
// JsonElement jsnElmnt = jsnParser.parse(requestObj);
Expand Down Expand Up @@ -327,6 +329,7 @@ public int addCareContextToMongo(PatientDemographic pDemo, PatientEligibleForRes
// if (benRegID != null)
// benID = benHealthIDMappingRepo.getBenID(benRegID);


// fetch abdm facility id
logger.info("********t_benvisistData fetch request pvisit data :", pVisit);

Expand All @@ -348,20 +351,42 @@ public int addCareContextToMongo(PatientDemographic pDemo, PatientEligibleForRes
cc.setCareContextLinkedDate(resData[1] != null ? resData[1].toString() : null);
}


logger.info("********data to be saved in mongo :", cc);
PatientCareContexts pcc;
PatientCareContexts resultSet = null;


logger.info("********data to be saved in mongo :", cc);
PatientCareContexts pcc;

if (pDemo.getBeneficiaryID() != null) {
pcc = patientCareContextsMongoRepo.findByIdentifier(pDemo.getBeneficiaryID().toString());

if (pcc != null && pcc.getIdentifier() != null) {
ccList = pcc.getCareContextsList();
ccList.add(cc);
pcc.setCareContextsList(ccList);
resultSet = patientCareContextsMongoRepo.save(pcc);

// Get the existing careContextsList
if (pcc.getCareContextsList() != null && pcc.getCareContextsList().size() > 0) {
ccList = pcc.getCareContextsList();

// Check if the visitCode is already in the careContextsList
for (CareContexts existingContext : ccList) {
if (existingContext.getReferenceNumber() != null
&& existingContext.getReferenceNumber().equals(pVisit.getVisitCode().toString())) {
logger.info("Visit code already Exisit in Mongo for benId:" + pDemo.getBeneficiaryID().toString() + "and visit code : " + pVisit.getVisitCode() );
return;
}
}
ccList.add(cc);
pcc.setCareContextsList(ccList);
patientCareContextsMongoRepo.save(pcc);
}
// }
// if (pcc != null && pcc.getIdentifier() != null) {
// ccList = pcc.getCareContextsList();
// ccList.add(cc);
// pcc.setCareContextsList(ccList);
// resultSet = patientCareContextsMongoRepo.save(pcc);
//
} else {
pcc = new PatientCareContexts();
pcc.setCaseReferenceNumber(pDemo.getBeneficiaryID().toString());
Expand Down Expand Up @@ -396,15 +421,11 @@ public int addCareContextToMongo(PatientDemographic pDemo, PatientEligibleForRes
ccList.add(cc);
pcc.setCareContextsList(ccList);
// save carecontext back to mongo
resultSet = patientCareContextsMongoRepo.save(pcc);
patientCareContextsMongoRepo.save(pcc);
}

if (resultSet != null && resultSet.get_id() != null)
response = 1;
}

}
return response;
}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -16,7 +15,6 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.wipro.fhir.data.mongo.care_context.AddCareContextRequest;
import com.wipro.fhir.data.mongo.care_context.SaveFacilityIdForVisit;
import com.wipro.fhir.repo.healthID.BenHealthIDMappingRepo;
import com.wipro.fhir.service.ndhm.Common_NDHMService;
Expand Down Expand Up @@ -88,10 +86,10 @@ public String saveAbdmFacilityId(String reqObj) throws FHIRException {
String res = null;
try {
SaveFacilityIdForVisit requestObj = InputMapper.gson().fromJson(reqObj, SaveFacilityIdForVisit.class);
if(requestObj.getFacilityId() == null || requestObj.getFacilityId() == "") {
requestObj.setFacilityId(abdmFacilityId);
if(requestObj.getAbdmFacilityId() == null || requestObj.getAbdmFacilityId() == "") {
requestObj.setAbdmFacilityId(abdmFacilityId);
}
Integer response = benHealthIDMappingRepo.updateFacilityIdForVisit(requestObj.getVisitCode(), requestObj.getFacilityId());
Integer response = benHealthIDMappingRepo.updateFacilityIdForVisit(requestObj.getVisitCode(), requestObj.getAbdmFacilityId());
if(response > 0 ) {
res = "ABDM Facility ID updated successfully";
} else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.web.client.RestTemplate;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.wipro.fhir.data.healthID.HealthIDResponse;
Expand Down Expand Up @@ -431,8 +432,16 @@ public String getAbhaCardPrinted(String reqObj) throws FHIRException {

private void constructHealthIdResponse(HealthIDResponse healthIDResp, JsonObject profile) throws ParseException {
healthIDResp.setHealthIdNumber(profile.get("ABHANumber").getAsString());
String abhaAddress = profile.get("phrAddress").getAsString().replace("[", "").replace("]", "");
healthIDResp.setHealthId(abhaAddress);
JsonArray phrAddressArray = profile.getAsJsonArray("phrAddress");
StringBuilder abhaAddressBuilder = new StringBuilder();

for (int i = 0; i < phrAddressArray.size(); i++) {
abhaAddressBuilder.append(phrAddressArray.get(i).getAsString());
if (i < phrAddressArray.size() - 1) {
abhaAddressBuilder.append(", ");
}
}
healthIDResp.setHealthId(abhaAddressBuilder.toString());
healthIDResp.setName(
healthIDResp.getFirstName() + " " + healthIDResp.getMiddleName() + " " + healthIDResp.getLastName());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy");
Expand All @@ -444,5 +453,5 @@ private void constructHealthIdResponse(HealthIDResponse healthIDResp, JsonObject
healthIDResp.setMonthOfBirth(month.format(date));
healthIDResp.setDayOfBirth(day.format(date));
}

}
Loading

0 comments on commit 1abf855

Please sign in to comment.