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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.iemr.mmu</groupId>
<artifactId>mmu-api</artifactId>
<version>3.4.1</version>
<version>3.6.0</version>
<packaging>war</packaging>

<name>MMU-API</name>
Expand Down
47 changes: 45 additions & 2 deletions src/main/java/com/iemr/mmu/controller/anc/ANCController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
package com.iemr.mmu.controller.anc;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -34,6 +37,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand All @@ -42,6 +46,13 @@

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

import java.util.ArrayList;

Check warning on line 49 in src/main/java/com/iemr/mmu/controller/anc/ANCController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this duplicated import.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZrjv3ROj0xvPBg5nyUc&open=AZrjv3ROj0xvPBg5nyUc&pullRequest=142
import java.util.HashMap;

Check warning on line 50 in src/main/java/com/iemr/mmu/controller/anc/ANCController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this duplicated import.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZrjv3ROj0xvPBg5nyUd&open=AZrjv3ROj0xvPBg5nyUd&pullRequest=142
import java.util.List;
import java.util.Map;
import com.google.gson.Gson;

Check warning on line 53 in src/main/java/com/iemr/mmu/controller/anc/ANCController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this duplicated import.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZrjv3ROj0xvPBg5nyUe&open=AZrjv3ROj0xvPBg5nyUe&pullRequest=142
import com.google.gson.JsonArray;

/**
* @Objective Saving ANC data for Nurse and Doctor.
*/
Expand Down Expand Up @@ -99,7 +110,23 @@
if (jsnOBJ != null) {
Long r = ancService.saveANCDoctorData(jsnOBJ, authorization);
if (r != null && r > 0) {
response.setResponse("Data saved successfully");
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsnOBJ.has("savedDrugIDs") && !jsnOBJ.get("savedDrugIDs").isJsonNull()) {

Check failure on line 115 in src/main/java/com/iemr/mmu/controller/anc/ANCController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "savedDrugIDs" 6 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZrjv3ROj0xvPBg5nyUb&open=AZrjv3ROj0xvPBg5nyUb&pullRequest=142
JsonArray drugIDsArray = jsnOBJ.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data saved successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setError(5000, "Unable to save data");
}
Expand Down Expand Up @@ -454,7 +481,23 @@
try {
Long result = ancService.updateANCDoctorData(jsnOBJ, authorization);
if (null != result && result > 0) {
response.setResponse("Data updated successfully");
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsnOBJ.has("savedDrugIDs") && !jsnOBJ.get("savedDrugIDs").isJsonNull()) {
JsonArray drugIDsArray = jsnOBJ.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data updated successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setError(500, "Unable to modify data");
}
Expand Down
40 changes: 38 additions & 2 deletions src/main/java/com/iemr/mmu/controller/covid19/CovidController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/
package com.iemr.mmu.controller.covid19;

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

import org.json.JSONObject;
Expand All @@ -36,6 +38,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand Down Expand Up @@ -109,7 +113,23 @@
if (jsnOBJ != null) {
Long ncdCareRes = covid19Service.saveDoctorData(jsnOBJ, authorization);
if (null != ncdCareRes && ncdCareRes > 0) {
response.setResponse("Data saved successfully");
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsnOBJ.has("savedDrugIDs") && !jsnOBJ.get("savedDrugIDs").isJsonNull()) {

Check failure on line 118 in src/main/java/com/iemr/mmu/controller/covid19/CovidController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "savedDrugIDs" 6 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZrjv3S7j0xvPBg5nyUh&open=AZrjv3S7j0xvPBg5nyUh&pullRequest=142
JsonArray drugIDsArray = jsnOBJ.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data saved successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setResponse("Unable to save data");
}
Expand Down Expand Up @@ -313,7 +333,23 @@
try {
Long result = covid19ServiceImpl.updateCovid19DoctorData(jsnOBJ, authorization);
if (null != result && result > 0) {
response.setResponse("Data updated successfully");
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsnOBJ.has("savedDrugIDs") && !jsnOBJ.get("savedDrugIDs").isJsonNull()) {
JsonArray drugIDsArray = jsnOBJ.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data updated successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setError(500, "Unable to modify data");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
*/
package com.iemr.mmu.controller.generalOPD;

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

import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -33,6 +38,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand Down Expand Up @@ -104,7 +111,23 @@
if (jsonRequest != null) {
Long genOPDRes = generalOPDServiceImpl.saveDoctorData(jsonRequest, authorization);
if (null != genOPDRes && genOPDRes > 0) {
response.setResponse("Data saved successfully");
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsonRequest.has("savedDrugIDs") && !jsonRequest.get("savedDrugIDs").isJsonNull()) {

Check failure on line 116 in src/main/java/com/iemr/mmu/controller/generalOPD/GeneralOPDController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "savedDrugIDs" 6 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZrjv3QFj0xvPBg5nyUY&open=AZrjv3QFj0xvPBg5nyUY&pullRequest=142
JsonArray drugIDsArray = jsonRequest.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data saved successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setResponse("Unable to save data");
}
Expand Down Expand Up @@ -401,7 +424,23 @@
try {
Long result = generalOPDServiceImpl.updateGeneralOPDDoctorData(jsonRequest, authorization);
if (null != result && result > 0) {
response.setResponse("Data updated successfully");
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsonRequest.has("savedDrugIDs") && !jsonRequest.get("savedDrugIDs").isJsonNull()) {
JsonArray drugIDsArray = jsonRequest.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data updated successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setError(500, "Unable to modify data");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/
package com.iemr.mmu.controller.ncdCare;

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

import org.json.JSONObject;
Expand All @@ -36,6 +38,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand Down Expand Up @@ -108,7 +112,23 @@
if (jsnOBJ != null) {
Long ncdCareRes = ncdCareServiceImpl.saveDoctorData(jsnOBJ, authorization);
if (null != ncdCareRes && ncdCareRes > 0) {
response.setResponse("Data saved successfully");
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsnOBJ.has("savedDrugIDs") && !jsnOBJ.get("savedDrugIDs").isJsonNull()) {

Check failure on line 117 in src/main/java/com/iemr/mmu/controller/ncdCare/NCDCareController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "savedDrugIDs" 6 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZrjv3SVj0xvPBg5nyUg&open=AZrjv3SVj0xvPBg5nyUg&pullRequest=142
JsonArray drugIDsArray = jsnOBJ.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data saved successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setResponse("Unable to save data");
}
Expand Down Expand Up @@ -316,7 +336,23 @@
try {
Long result = ncdCareServiceImpl.updateNCDCareDoctorData(jsnOBJ, authorization);
if (null != result && result > 0) {
response.setResponse("Data updated successfully");
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsnOBJ.has("savedDrugIDs") && !jsnOBJ.get("savedDrugIDs").isJsonNull()) {
JsonArray drugIDsArray = jsnOBJ.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data updated successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setError(500, "Unable to modify data");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
*/
package com.iemr.mmu.controller.ncdscreening;

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

import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -35,6 +40,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand Down Expand Up @@ -119,7 +126,23 @@
if (jsnOBJ != null) {
Long ncdCareRes = ncdScreeningServiceImpl.saveDoctorData(jsnOBJ, authorization);
if (null != ncdCareRes && ncdCareRes > 0) {
response.setResponse("Data saved successfully");
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsnOBJ.has("savedDrugIDs") && !jsnOBJ.get("savedDrugIDs").isJsonNull()) {

Check failure on line 131 in src/main/java/com/iemr/mmu/controller/ncdscreening/NCDController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "savedDrugIDs" 6 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-API&issues=AZrjv3R0j0xvPBg5nyUf&open=AZrjv3R0j0xvPBg5nyUf&pullRequest=142
JsonArray drugIDsArray = jsnOBJ.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data saved successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setResponse("Unable to save data");
}
Expand Down Expand Up @@ -426,10 +449,27 @@
try {
JsonObject jsnOBJ = parseJsonRequest(requestObj);
int i = ncdSCreeningDoctorService.updateDoctorData(jsnOBJ);
if (i > 0)
response.setResponse("Data updated successfully");
else
if (i > 0) {
// Extract drug IDs from JsonObject
List<Long> prescribedDrugIDs = new ArrayList<>();
if (jsnOBJ.has("savedDrugIDs") && !jsnOBJ.get("savedDrugIDs").isJsonNull()) {
JsonArray drugIDsArray = jsnOBJ.getAsJsonArray("savedDrugIDs");
for (int j = 0; j < drugIDsArray.size(); j++) {
prescribedDrugIDs.add(drugIDsArray.get(j).getAsLong());
}
}

// Create response with message and IDs
Map<String, Object> responseData = new HashMap<>();
responseData.put("message", "Data updated successfully");
responseData.put("prescribedDrugIDs", prescribedDrugIDs);

Gson gson = new Gson();
String responseJson = gson.toJson(responseData);
response.setResponse(responseJson);
} else {
response.setError(5000, "Error in data update");
}
} catch (Exception e) {
response.setError(5000, "Unable to modify data");
logger.error("Error while updating doctor data :" + e);
Expand Down
Loading
Loading