Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
*/
@RestController
@RequestMapping(value = "/dataSync", headers = "Authorization")
@PreAuthorize("hasRole('DATASYNC') || hasRole('DATA_SYNC') ")
public class MMUDataSyncVanToServer {
private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,18 @@ public int callCentralAPIToGenerateBenIDAndimportToLocal(String requestOBJ, Stri
JSONObject obj = new JSONObject(response.getBody());
if (obj != null && obj.has("data") && obj.has("statusCode") && obj.getInt("statusCode") == 200) {
// Consume the response from API and call local identity api to save data
JSONObject localImportPayload = new JSONObject();
localImportPayload.put("vanID", vanID);
localImportPayload.put("benIDList", obj.get("data"));

// Inject vanID into each element since central response doesn't include it
org.json.JSONArray dataArray = obj.getJSONArray("data");
for (int k = 0; k < dataArray.length(); k++) {
dataArray.getJSONObject(k).put("vanID", vanID);
}
String localImportPayload = dataArray.toString();

logger.info("Authorization: " + Authorization);
logger.info("ServerAuthorization: " + ServerAuthorization);
logger.info("Payload to local import: " + localImportPayload.toString());

logger.info("Payload to local import: " + localImportPayload);

HttpEntity<Object> request1 = RestTemplateUtil.createRequestEntity( localImportPayload.toString(), Authorization, token);
HttpEntity<Object> request1 = RestTemplateUtil.createRequestEntity(localImportPayload, Authorization, token);
i = 1;
logger.info("Request to benImporturllocal: " + request1);
ResponseEntity<String> response1 = restTemplate.exchange(benImportUrlLocal, HttpMethod.POST, request1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ private JdbcTemplate getJdbcTemplate() {
"t_cancervitals", "t_cancersignandsymptoms", "t_cancerlymphnode", "t_canceroralexamination",
"t_cancerbreastexamination", "t_cancerabdominalexamination", "t_cancergynecologicalexamination",
"t_cancerdiagnosis", "t_cancerimageannotation", "i_beneficiaryimage", "t_stockadjustment",
"t_stocktransfer", "t_patientreturn", "t_indent", "t_indentissue", "t_indentorder", "t_saitemmapping");
"t_stocktransfer", "t_patientreturn", "t_indent", "t_indentissue", "t_indentorder", "t_saitemmapping",
"tb_screening", "tb_suspected", "tb_confirmed_cases", "tb_stoptb_diagnostics",
"tb_stoptb_general_examination", "tb_stoptb_general_opd", "tb_stoptb_visit", "i_householddetails");

private boolean isValidDatabaseIdentifierCharacter(String identifier) {
return identifier != null && identifier.matches("^[a-zA-Z_][a-zA-Z0-9_]*$");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ private boolean performGenericTableSync(SyncUploadDataDigester syncUploadDataDig


String vanSerialNo = String.valueOf(cleanRecord.get(vanAutoIncColumnName));
String vanID = String.valueOf(cleanRecord.get("VanID"));
// Column may be "vanID" (Stop TB tables) or "VanID" (standard tables) β€” check both
Object vanIDRaw = cleanRecord.get("VanID") != null ? cleanRecord.get("VanID") : cleanRecord.get("vanID");
String vanID = vanIDRaw != null ? String.valueOf(vanIDRaw) : null;
int syncFacilityID = 0;

cleanRecord.put("SyncedBy", syncUploadDataDigester.getSyncedBy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.types.Expiration;
import org.springframework.stereotype.Service;

import com.google.gson.Gson;
Expand All @@ -44,6 +50,11 @@
@Service
public class IemrMmuLoginServiceImpl implements IemrMmuLoginService {

private static final Logger logger = LoggerFactory.getLogger(IemrMmuLoginServiceImpl.class);

@Autowired
private LettuceConnectionFactory redisConnectionFactory;

private UserParkingplaceMappingRepo userParkingplaceMappingRepo;
private MasterVanRepo masterVanRepo;
private VanServicepointMappingRepo vanServicepointMappingRepo;
Expand Down Expand Up @@ -186,6 +197,24 @@
parkingPlaceLocationMap.put("blockName", obj1[6]);
}
resMap.put("UserLocDetails", parkingPlaceLocationMap);

// Store camp vanID in Redis β€” FLW-API and TM-API read this to stamp vanID on records
try {
if (objList.size() > 0 && parkingPlaceList.size() > 0) {

Check warning on line 203 in src/main/java/com/iemr/mmu/service/login/IemrMmuLoginServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use isEmpty() to check whether the collection is empty or not.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZ-NJ1m7kL2BOW0UD-y5&open=AZ-NJ1m7kL2BOW0UD-y5&pullRequest=172

Check warning on line 203 in src/main/java/com/iemr/mmu/service/login/IemrMmuLoginServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use isEmpty() to check whether the collection is empty or not.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZ-NJ1m7kL2BOW0UD-y4&open=AZ-NJ1m7kL2BOW0UD-y4&pullRequest=172
Integer campVanID = (Integer) objList.get(0)[1]; // vanID is at index 1
Integer campParkingPlaceID = (Integer) parkingPlaceList.get(0)[0]; // parkingPlaceID at index 0
RedisConnection conn = redisConnectionFactory.getConnection();
conn.set("camp:vanID".getBytes(), String.valueOf(campVanID).getBytes(),
Expiration.seconds(30L * 24 * 3600), SetOption.UPSERT);
conn.set("camp:parkingPlaceID".getBytes(), String.valueOf(campParkingPlaceID).getBytes(),
Expiration.seconds(30L * 24 * 3600), SetOption.UPSERT);
conn.close();
logger.info("Camp config stored in Redis: vanID={}, parkingPlaceID={}", campVanID, campParkingPlaceID);
}
} catch (Exception e) {
logger.warn("Failed to store camp config in Redis: " + e.getMessage());
}

// 1.1
return new Gson().toJson(resMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
|| path.startsWith(contextPath + "/user/refreshToken")
|| path.startsWith(contextPath + "/public")
|| path.equals(contextPath + "/version")
|| path.equals(contextPath + "/health")) {
|| path.equals(contextPath + "/health")
|| path.startsWith(contextPath + "/dataSync")) {
logger.info("Skipping filter for path: " + path);
filterChain.doFilter(servletRequest, servletResponse);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.requestMatchers("/user/**").permitAll()
.requestMatchers("/health").permitAll()
.requestMatchers("/version").permitAll()
.requestMatchers("/dataSync/**").permitAll()
.anyRequest().authenticated()
)
.exceptionHandling(ex -> ex
Expand Down
Loading