use of org.openmrs.ui.framework.fragment.action.SuccessResult in project openmrs-module-coreapps by openmrs.
the class DiagnosesFragmentController method codeDiagnosis.
public FragmentActionResult codeDiagnosis(UiUtils ui, @RequestParam("nonCodedObsId") Integer nonCodedObsId, // each string is json, like {"certainty":"PRESUMED","diagnosisOrder":"PRIMARY","diagnosis":"ConceptName:840"}
@RequestParam("diagnosis") List<String> diagnoses, @SpringBean("obsService") ObsService obsService, @SpringBean("emrDiagnosisService") DiagnosisService diagnosisService, @SpringBean("conceptService") ConceptService conceptService) throws Exception {
if (nonCodedObsId != null) {
Obs nonCodedObs = obsService.getObs(nonCodedObsId);
if (nonCodedObs != null) {
List<Diagnosis> diagnosisList = new ArrayList<Diagnosis>();
for (String diagnosisJson : diagnoses) {
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode = mapper.readTree(diagnosisJson);
Iterator<JsonNode> iterator = rootNode.iterator();
while (iterator.hasNext()) {
JsonNode next = iterator.next();
Diagnosis diagnosis = parseDiagnosisJson(next.toString(), conceptService);
diagnosisList.add(diagnosis);
}
}
List<Obs> newDiagnoses = diagnosisService.codeNonCodedDiagnosis(nonCodedObs, diagnosisList);
if ((newDiagnoses != null) && (newDiagnoses.size() > 0)) {
return new SuccessResult(ui.message("coreapps.dataManagement.codeDiagnosis.success"));
}
}
}
return new FailureResult(ui.message("coreapps.dataManagement.codeDiagnosis.failure"));
}
use of org.openmrs.ui.framework.fragment.action.SuccessResult in project openmrs-module-coreapps by openmrs.
the class VisitDetailsFragmentController method deleteEncounter.
public FragmentActionResult deleteEncounter(UiUtils ui, @RequestParam("encounterId") Encounter encounter, @SpringBean("encounterService") EncounterService encounterService, UiSessionContext sessionContext) {
if (encounter != null) {
User authenticatedUser = sessionContext.getCurrentUser();
boolean canDelete = authenticatedUser.hasPrivilege(EmrApiConstants.PRIVILEGE_DELETE_ENCOUNTER);
if (verifyIfUserHasPermissionToDeleteAnEncounter(encounter, authenticatedUser, canDelete)) {
encounterService.voidEncounter(encounter, "delete encounter");
encounterService.saveEncounter(encounter);
} else {
return new FailureResult(ui.message("coreapps.patientDashBoard.deleteEncounter.notAllowed"));
}
}
return new SuccessResult(ui.message("coreapps.patientDashBoard.deleteEncounter.successMessage"));
}
use of org.openmrs.ui.framework.fragment.action.SuccessResult in project openmrs-module-coreapps by openmrs.
the class VisitDetailsFragmentController method deleteVisit.
public FragmentActionResult deleteVisit(UiUtils ui, @RequestParam("visitId") Visit visit, @SpringBean("visitService") VisitService visitService, UiSessionContext sessionContext) {
if (visit != null) {
User authenticatedUser = sessionContext.getCurrentUser();
boolean canDeleteVisit = authenticatedUser.hasPrivilege(EmrApiConstants.PRIVILEGE_DELETE_VISIT);
if (verifyIfUserHasPermissionToDeleteVisit(visit, authenticatedUser, canDeleteVisit)) {
visitService.voidVisit(visit, "delete visit");
visitService.saveVisit(visit);
} else {
return new FailureResult(ui.message("emr.patientDashBoard.deleteVisit.notAllowed"));
}
}
return new SuccessResult(ui.message("coreapps.task.deleteVisit.successMessage"));
}
use of org.openmrs.ui.framework.fragment.action.SuccessResult in project openmrs-module-coreapps by openmrs.
the class VisitFragmentController method start.
@Transactional
public FragmentActionResult start(@SpringBean("adtService") AdtService adtService, @RequestParam("patientId") Patient patient, @RequestParam("locationId") Location location, @RequestParam(value = "stopActiveVisit", required = false) Boolean stopActive, UiUtils uiUtils, HttpServletRequest request) {
VisitDomainWrapper activeVisit = adtService.getActiveVisit(patient, location);
// if patient has an active visit close it
if (patient != null && (activeVisit != null)) {
Visit visit = activeVisit.getVisit();
if (visit != null && stopActive) {
adtService.closeAndSaveVisit(visit);
}
}
// create new visit and save it
adtService.ensureVisit(patient, new Date(), location);
request.getSession().setAttribute(AppUiConstants.SESSION_ATTRIBUTE_INFO_MESSAGE, uiUtils.message("emr.visit.createQuickVisit.successMessage", uiUtils.format(patient)));
request.getSession().setAttribute(AppUiConstants.SESSION_ATTRIBUTE_TOAST_MESSAGE, "true");
return new SuccessResult();
}
use of org.openmrs.ui.framework.fragment.action.SuccessResult in project openmrs-module-pihcore by PIH.
the class AccountFragmentController method unlock.
public FragmentActionResult unlock(@RequestParam("personId") Person person, @SpringBean("accountService") AccountService accountService, UiUtils ui) {
try {
AccountDomainWrapper account = accountService.getAccountByPerson(person);
account.unlock();
return new SuccessResult(ui.message("emr.account.unlocked.successMessage"));
} catch (Exception e) {
return new FailureResult(ui.message("emr.account.unlock.failedMessage"));
}
}
Aggregations