Source:
public Result indexPopulatedGet(int patientId) { CurrentUser currentUser = sessionService.retrieveCurrentUserSession(); ServiceResponse<List<VitalItem>> vitalServiceResponse = vitalService.retrieveAllVitalItems(); if (vitalServiceResponse.hasErrors()) { throw new RuntimeException(); } ServiceResponse<PatientEncounterItem> patientEncounterItemServiceResponse = searchService.retrieveRecentPatientEncounterItemByPatientId(patientId); if(patientEncounterItemServiceResponse.hasErrors()){ throw new RuntimeException(); } PatientEncounterItem patientEncounter = patientEncounterItemServiceResponse.getResponseObject(); ServiceResponse<PatientItem> patientItemServiceResponse = searchService.retrievePatientItemByPatientId(patientId); if (patientItemServiceResponse.hasErrors()) { throw new RuntimeException(); } PatientItem patient = patientItemServiceResponse.getResponseObject(); ServiceResponse<SettingItem> settingItemServiceResponse = searchService.retrieveSystemSettings(); if (settingItemServiceResponse.hasErrors()) { throw new RuntimeException(); } ServiceResponse<Map<String, String>> patientAgeClassificationsResponse = patientService.retrieveAgeClassifications(); if (patientAgeClassificationsResponse.hasErrors()) { throw new RuntimeException(); } IndexViewModelGet viewModelGet = new IndexViewModelGet(); viewModelGet.setSettings(settingItemServiceResponse.getResponseObject()); viewModelGet.setPatient(patient); viewModelGet.setVitalNames(vitalServiceResponse.getResponseObject()); viewModelGet.setPossibleAgeClassifications(patientAgeClassificationsResponse.getResponseObject()); if(patientEncounter.getMedicalDateOfVisit() == null){ viewModelGet.setLinkToMedical(true); } else{ viewModelGet.setLinkToMedical(false); } return ok(index.render(currentUser, viewModelGet)); }

Target:
public Result indexPopulatedGet(int patientId) { CurrentUser currentUser = sessionService.retrieveCurrentUserSession(); ServiceResponse<List<VitalItem>> vitalServiceResponse = vitalService.retrieveAllVitalItems(); if (vitalServiceResponse.hasErrors()) { throw new RuntimeException(); } ServiceResponse<PatientEncounterItem> patientEncounterItemServiceResponse = searchService.retrieveRecentPatientEncounterItemByPatientId(patientId); if(patientEncounterItemServiceResponse.hasErrors()){ throw new RuntimeException(); } PatientEncounterItem patientEncounter = patientEncounterItemServiceResponse.getResponseObject(); ServiceResponse<PatientItem> patientItemServiceResponse = searchService.retrievePatientItemByPatientId(patientId); if (patientItemServiceResponse.hasErrors()) { throw new RuntimeException(); } PatientItem patient = patientItemServiceResponse.getResponseObject(); ServiceResponse<SettingItem> settingItemServiceResponse = searchService.retrieveSystemSettings(); if (settingItemServiceResponse.hasErrors()) { throw new RuntimeException(); } ServiceResponse<Map<String, String>> patientAgeClassificationsResponse = patientService.retrieveAgeClassifications(); if (patientAgeClassificationsResponse.hasErrors()) { throw new RuntimeException(); } IndexViewModelGet viewModelGet = new IndexViewModelGet(); viewModelGet.setSettings(settingItemServiceResponse.getResponseObject()); viewModelGet.setPatient(patient); viewModelGet.setVitalNames(vitalServiceResponse.getResponseObject()); viewModelGet.setPossibleAgeClassifications(patientAgeClassificationsResponse.getResponseObject()); if(patientEncounter.getIsClosed() == false){ viewModelGet.setLinkToMedical(true); } else{ viewModelGet.setLinkToMedical(false); } return ok(index.render(currentUser, viewModelGet)); }