Skip to content

Commit

Permalink
Fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mhayes2772 committed May 23, 2024
1 parent b8ac715 commit 2fabac1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions app/femr/ui/controllers/MedicalController.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,27 +266,25 @@ public Result translateGet() {
String jsonText = request().getQueryString("text");
int patientId = Integer.parseInt(request().getQueryString("patientId"));

//Harrison Shu
String toLanguage = sessionService.retrieveCurrentUserSession().getLanguageCode();

// retrieve current patient encounter encounter
int patientId = Integer.parseInt(request().getQueryString("patientId"));
ServiceResponse<PatientEncounterItem> currentEncounterByPatientId = searchService.retrieveRecentPatientEncounterItemByPatientId(patientId);
if (currentEncounterByPatientId.hasErrors()) {
throw new RuntimeException();
}
PatientEncounterItem patientEncounter = currentEncounterByPatientId.getResponseObject();
String fromLanguage = patientEncounter.getLanguageCode();
//Harrison Shu
String toLanguage = sessionService.retrieveCurrentUserSession().getLanguageCode();
String fromLanguage = currentEncounterByPatientId.getResponseObject().getLanguageCode();


// Harrison Shu: Handles the creation of the response map and figures out whether or not to translate
TranslationResponseMap responseMapObject = new TranslationResponseMap(fromLanguage, toLanguage, text);
TranslationResponseMap responseMapObject = new TranslationResponseMap(fromLanguage, toLanguage, jsonText);

return ok(responseMapObject.getResponseJson());
}


// Calls Python Script to translate
private String translate(String jsonText, String fromLanguage, String toLanguage) {
public static String translate(String jsonText, String fromLanguage, String toLanguage) {
String data = "";
try {
data = TranslationServer.makeServerRequest(jsonText, fromLanguage, toLanguage);
Expand All @@ -297,8 +295,7 @@ private String translate(String jsonText, String fromLanguage, String toLanguage
return data;
}


public String parseJsonResponse(String jsonResponse){
public static String parseJsonResponse(String jsonResponse){
try{
ObjectMapper mapper = new ObjectMapper();
TranslationJson api = mapper.readValue(jsonResponse, TranslationJson.class);
Expand Down
4 changes: 2 additions & 2 deletions app/femr/util/translation/TranslationResponseMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package femr.util.translation;
import femr.ui.controllers.BackEndControllerHelper;
import femr.ui.controllers.MedicalController;
import java.util.*;
import play.libs.Json;

Expand Down Expand Up @@ -37,7 +37,7 @@ private void populateTranslation() {
} else {
String data = "";
try {
data = BackEndControllerHelper.translate(text, fromLanguage, toLanguage);
data = MedicalController.translate(text, fromLanguage, toLanguage);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 2fabac1

Please sign in to comment.