Skip to content
Closed
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: 2 additions & 0 deletions src/main/environment/104_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@

sendSMSUrl= @env.COMMON_API_BASE_URL@sms/sendSMS
sendEmailGeneralUrl = @env.COMMON_API_BASE_URL@emailController/sendEmailGeneral

cors.allowed-origins=@CORS_ALLOWED_ORIGINS@
4 changes: 3 additions & 1 deletion src/main/environment/104_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ spring.redis.host=localhost
jwt.secret=my-32-character-ultra-secure-and-ultra-long-secret
#If both properties are set, only logging.file.name takes effect.
logging.path=logs/
logging.file.name=logs/helpline104-api.log
logging.file.name=logs/helpline104-api.log

cors.allowed-origins=http://localhost:*
28 changes: 28 additions & 0 deletions src/main/java/com/iemr/helpline104/config/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.iemr.helpline104.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Value;

@Configuration
public class CorsConfig implements WebMvcConfigurer {

@Value("${cors.allowed-origins}")
private String allowedOrigins;

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns(
Arrays.stream(allowedOrigins.split(","))
.map(String::trim)
.toArray(String[]::new))
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.exposedHeaders("Authorization", "Jwttoken")
.allowCredentials(true)
.maxAge(3600);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

import io.swagger.v3.oas.annotations.Operation;


@RequestMapping(value = "/beneficiary")
@RestController
public class IMRMMRController {
Expand All @@ -54,7 +53,6 @@ public class IMRMMRController {
@Autowired
private IMRMMRService imrmmrService;

@CrossOrigin()
@Operation(summary = "Save IMR MMR")
@PostMapping(value = "/saveIMRMMR", headers = "Authorization", produces = {
"application/json" })
Expand All @@ -78,7 +76,6 @@ public String saveIMRMMR(@RequestBody String request,
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Fetch support services")
@GetMapping(value = "/fetchimrmmrmasters", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String fetchSupportServices() {
Expand All @@ -105,7 +102,6 @@ public String fetchSupportServices() {
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Feedback request")
@PostMapping(value = "/getIMRMMRList", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String feedbackReuest(@RequestBody String request) {
Expand All @@ -123,7 +119,6 @@ public String feedbackReuest(@RequestBody String request) {
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Update IMR MMR complaint")
@PostMapping(value = "/update/ImrMmrComplaint", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String updateImrMmrComplaint(@RequestBody String request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class BalVivahController {
@Autowired
private BalVivahComplaintService balVivahComplaintService;

@CrossOrigin()
@Operation(summary = "Save bal vivah complaint")
@PostMapping(value = "/saveBalVivahComplaint", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String balVivahComplaint(@RequestBody String request, HttpServletRequest httpRequest) {
Expand All @@ -60,7 +59,6 @@ public String balVivahComplaint(@RequestBody String request, HttpServletRequest
return output.toString();
}

@CrossOrigin()
@Operation(summary = "Get bal vivah list")
@PostMapping(value = "/getBalVivahList", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String feedbackReuest(@RequestBody String request) {
Expand All @@ -79,7 +77,6 @@ public String feedbackReuest(@RequestBody String request) {
return response.toString();
}

@CrossOrigin()
@Operation(summary = "Update bal vivah complaint")
@PostMapping(value = "/update/BalVivahComplaint", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String updateBalVivahComplaint(@RequestBody String request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public void setBeneficiaryCallService(BeneficiaryCallService beneficiaryCallServ
this.beneficiaryCallService = beneficiaryCallService;
}

@CrossOrigin()
@Operation(summary = "Stores callerID to the specific beneficiary who are on call")
@PostMapping(value = "/startCall", headers = "Authorization")
public String startCall(
Expand All @@ -85,37 +84,34 @@ public String startCall(
return output.toString();
}

@CrossOrigin()
@Operation(summary = "Update beneficiary reg id to the caller id")
@PostMapping(value = "update/beneficiaryCallID", headers = "Authorization")
public String updateBeneficiaryIDInCall(
@Parameter(description = "{\"callID\":\"integer\", \"beneficiaryRegID\":\"long\"}") @RequestBody String beneficiaryCall) {
OutputResponse output = new OutputResponse();
Integer startedCall = null;
try {
BeneficiaryCall beneficiarycall = inputMapper.gson().fromJson(beneficiaryCall, BeneficiaryCall.class);
@Parameter(description = "{\"callID\":\"integer\", \"beneficiaryRegID\":\"long\"}") @RequestBody String beneficiaryCall) {

OutputResponse output = new OutputResponse();
Integer startedCall = null;
Comment on lines 88 to +93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing leading slash breaks endpoint mapping

Both paths lose the leading /, producing URLs like
/beneficiaryupdate/beneficiaryCallID instead of /beneficiary/update/….

-    @PostMapping(value = "update/beneficiaryCallID", headers = "Authorization")
+    @PostMapping(value = "/update/beneficiaryCallID", headers = "Authorization")

Do the same for set/callHistory further below:

-    @PostMapping(value = "set/callHistory", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
+    @PostMapping(value = "/set/callHistory", produces = MediaType.APPLICATION_JSON, headers = "Authorization")

Without this fix, clients will receive 404s.

πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@PostMapping(value = "update/beneficiaryCallID", headers = "Authorization")
public String updateBeneficiaryIDInCall(
@Parameter(description = "{\"callID\":\"integer\", \"beneficiaryRegID\":\"long\"}") @RequestBody String beneficiaryCall) {
OutputResponse output = new OutputResponse();
Integer startedCall = null;
try {
BeneficiaryCall beneficiarycall = inputMapper.gson().fromJson(beneficiaryCall, BeneficiaryCall.class);
@Parameter(description = "{\"callID\":\"integer\", \"beneficiaryRegID\":\"long\"}") @RequestBody String beneficiaryCall) {
OutputResponse output = new OutputResponse();
Integer startedCall = null;
@PostMapping(value = "/update/beneficiaryCallID", headers = "Authorization")
public String updateBeneficiaryIDInCall(
@Parameter(description = "{\"callID\":\"integer\", \"beneficiaryRegID\":\"long\"}") @RequestBody String beneficiaryCall) {
OutputResponse output = new OutputResponse();
Integer startedCall = null;
πŸ€– Prompt for AI Agents
In
src/main/java/com/iemr/helpline104/controller/beneficiarycall/BeneficiaryCallController.java
around lines 88 to 93, the @PostMapping path "update/beneficiaryCallID" is
missing a leading slash, causing incorrect endpoint URLs and resulting in 404
errors. Add a leading slash to the path, changing it to
"/update/beneficiaryCallID". Also, apply the same fix to the "set/callHistory"
mapping further down by adding a leading slash to ensure correct URL mapping.

try {
BeneficiaryCall beneficiarycall = inputMapper.gson().fromJson(beneficiaryCall, BeneficiaryCall.class);
if (null != beneficiarycall.getBeneficiaryRegID()) {
startedCall = beneficiaryCallService.updateBeneficiaryIDInCall(beneficiarycall.getBenCallID(),
beneficiarycall.getBeneficiaryRegID());
output.setResponse(startedCall.toString());
}else {
} else {
output.setResponse("Update skipped : BeneficiaryRegID is null");
}
logger.info("updateBeneficiaryIDInCall was called successfully");
} catch (Exception e) {
logger.error("updateBeneficiaryIDInCall failed with error " + e.getMessage(), e);
output.setError(e);
logger.info("updateBeneficiaryIDInCall was called successfully");
} catch (Exception e) {
logger.error("updateBeneficiaryIDInCall failed with error " + e.getMessage(), e);
output.setError(e);

}
}

logger.info("updateBeneficiaryIDInCall completed");
logger.info("updateBeneficiaryIDInCall completed");

return output.toString();
return output.toString();
}


@CrossOrigin
@Operation(summary = "Fetch services available in the 104 helpline")
@PostMapping(value = "/get/services", headers = "Authorization")
public String getServices(
Expand All @@ -138,7 +134,6 @@ public String getServices(
return output.toString();
}

@CrossOrigin()
@Operation(summary = "Set service history")
@PostMapping(value = "set/callHistory", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String setServiceHistory(@RequestBody String request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ public class BloodComponentController {
@Autowired
private BloodComponentService bloodComponentService;

@CrossOrigin
@Operation(summary = "Save blood component details")
@PostMapping(value = "/save/bloodComponentDetails", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public String saveBloodComponentDetails(
@Parameter(description = "{\"component\":\"String\",\"componentDesc\":\"String\",\"deleted\":\"boolean\",\"createdBy\":\"String\"}") @RequestBody String request) {
@Parameter(description = "{\"component\":\"String\",\"componentDesc\":\"String\",\"deleted\":\"boolean\",\"createdBy\":\"String\"}") @RequestBody String request) {
OutputResponse output = new OutputResponse();
try {
M_Component m_component = inputMapper.gson().fromJson(request, M_Component.class);
Expand All @@ -67,11 +66,10 @@ public String saveBloodComponentDetails(
return output.toString();
}

@CrossOrigin
@Operation(summary = "Fetch blood component details")
@PostMapping(value = "/get/bloodComponentDetails", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public String getBloodComponentDetails(
@Parameter(description = "{\"componentID\":\"Integer\"}") @RequestBody String request) {
@Parameter(description = "{\"componentID\":\"Integer\"}") @RequestBody String request) {

OutputResponse output = new OutputResponse();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public class BloodRequestController {
@Autowired
private BloodComponentTypeService componentTypeService;

@CrossOrigin
@Operation(summary = "Save blood request details")
@PostMapping(value = "/save/bloodRequestDetails", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public String saveBloodRequestDetails(@RequestBody String request) {
Expand All @@ -77,7 +76,6 @@ public String saveBloodRequestDetails(@RequestBody String request) {
return output.toString();
}

@CrossOrigin
@Operation(summary = "Get blood request details")
@PostMapping(value = "/get/bloodRequestDetails", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public String getbloodRequestDetails(
Expand All @@ -102,7 +100,6 @@ public String getbloodRequestDetails(
return output.toString();
}

@CrossOrigin
@Operation(summary = "Get blood component types")
@PostMapping(value = "/get/bloodComponentTypes", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public String getBloodComponentTypes() {
Expand All @@ -120,7 +117,6 @@ public String getBloodComponentTypes() {
return output.toString();
}

@CrossOrigin
@Operation(summary = "Get blood groups")
@PostMapping(value = "/get/bloodGroups", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public String getBloodGroups() {
Expand All @@ -138,7 +134,6 @@ public String getBloodGroups() {
return output.toString();
}

@CrossOrigin
@Operation(summary = "Get blood bank URL")
@PostMapping(value = "/get/bloodBankURL", headers = "Authorization")
public String getBloodBankURL(
Expand All @@ -163,7 +158,6 @@ public String getBloodBankURL(
return output.toString();
}

@CrossOrigin
@Operation(summary = "Save blood bank URL")
@PostMapping(value = "/save/bloodBankURL", headers = "Authorization")
public String saveBloodBankURL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class CallQAMappingController {
@Autowired
public CallqamappingService callqamappingService;

@CrossOrigin
@Operation(summary = "Save call qa mapping")
@PostMapping(value = "/save/callqamapping", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public String saveCallqamapping(@RequestBody String request) {
Expand All @@ -69,7 +68,6 @@ public String saveCallqamapping(@RequestBody String request) {
return output.toString();
}

@CrossOrigin
@Operation(summary = "Fetch questions and answers given by beneficiary")
@PostMapping(value = "/get/CDIqamapping", headers = "Authorization")
public String getCDIqamapping(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class Helpline104BeneficiaryHistoryController {
@Autowired
private H104BenHistoryService h104BenHistoryService;

@CrossOrigin
@Operation(summary = "Retrieves case record")
@PostMapping(value = "/getBenCaseSheet", headers = "Authorization")
public String getBenCaseSheet(
Expand All @@ -70,7 +69,6 @@ public String getBenCaseSheet(
return output.toString();
}

@CrossOrigin
@Operation(summary = "Stores case record")
@PostMapping(value = "/save/benCaseSheet", headers = "Authorization")
public String saveBenCaseSheet(
Expand Down Expand Up @@ -101,7 +99,6 @@ public String saveBenCaseSheet(
return output.toString();
}

@CrossOrigin
@Operation(summary = "Retrieves present case record")
@PostMapping(value = "/getPresentCaseSheet", headers = "Authorization")
public String getPresentCaseSheet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class ClinicalDecisionSupportController {
private CDSSService cDSSService;
private Logger logger = LoggerFactory.getLogger(ClinicalDecisionSupportController.class);

@CrossOrigin()
@Operation(summary = "Get symptoms")
@PostMapping(value = "/Symptoms", produces = "application/json", headers = "Authorization")
public String getSymptomsPost(@RequestBody SymptomsWrapper symptomsDetails) {
Expand All @@ -73,7 +72,6 @@ public String getSymptomsPost(@RequestBody SymptomsWrapper symptomsDetails) {

}

@CrossOrigin()
@Operation(summary = "Get questions by symptom, age and gender")
@PostMapping(value = "/getQuestions", produces = "application/json", headers = "Authorization")
public String getQuestion(@RequestBody SymptomsWrapper symptomsDetails) {
Expand All @@ -99,7 +97,6 @@ public String getQuestion(@RequestBody SymptomsWrapper symptomsDetails) {

}

@CrossOrigin()
@Operation(summary = "Get result based on compliant id")
@PostMapping(value = "/getResult", produces = "application/json", headers = "Authorization")
public String getResult(@RequestBody String userAnswer) {
Expand All @@ -125,7 +122,6 @@ public String getResult(@RequestBody String userAnswer) {

}

@CrossOrigin()
@Operation(summary = "Save symptom")
@PostMapping(value = "/saveSymptom", produces = "application/json", headers = "Authorization")
public String saveSymptom(@RequestBody String inputData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import io.swagger.v3.oas.annotations.Operation;

@CrossOrigin
@RestController
@RequestMapping(value = "/master", headers = "Authorization")

Expand All @@ -44,7 +43,7 @@ public class CovidMasterController {
@Autowired
private CovidMasterService covidMasterService;

@Operation(summary= "Master data for COVID patient")
@Operation(summary = "Master data for COVID patient")
@GetMapping(value = {
"/patient/covidDetails/{providerServiceMapID}" }, produces = MediaType.APPLICATION_JSON)
public String patientAppMasterData(@PathVariable("providerServiceMapID") Integer providerServiceMapID) {
Expand All @@ -56,8 +55,7 @@ public String patientAppMasterData(@PathVariable("providerServiceMapID") Integer
return response.toString();
}

@CrossOrigin
@Operation(summary= "Save COVID data")
@Operation(summary = "Save COVID data")
@PostMapping({ "/save/covidScreeningData" })
public String saveBenCovidDoctorData(@RequestBody String requestObj,
@RequestHeader(value = "Authorization") String Authorization) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand All @@ -50,7 +50,6 @@ public class DirectoryServicesController {
@Autowired
private DirectoryServiceService directoryServiceService;

@CrossOrigin
@Operation(summary = "Retrieve directory search history")
@RequestMapping(value = "/getdirectorySearchHistory", method = RequestMethod.POST, headers = "Authorization")
public String getBenDirectoryHistory(
Expand All @@ -72,7 +71,6 @@ public String getBenDirectoryHistory(
return output.toString();
}

@CrossOrigin
@Operation(summary = "Store directory serach history")
@RequestMapping(value = "/save/directorySearchHistory", method = RequestMethod.POST, headers = "Authorization")
public String directorySearchHistory(
Expand Down
Loading
Loading