Search in sources :

Example 1 with SuccessResult

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"));
}
Also used : Obs(org.openmrs.Obs) FailureResult(org.openmrs.ui.framework.fragment.action.FailureResult) ArrayList(java.util.ArrayList) SuccessResult(org.openmrs.ui.framework.fragment.action.SuccessResult) JsonNode(org.codehaus.jackson.JsonNode) Diagnosis(org.openmrs.module.emrapi.diagnosis.Diagnosis) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 2 with SuccessResult

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"));
}
Also used : User(org.openmrs.User) FailureResult(org.openmrs.ui.framework.fragment.action.FailureResult) SuccessResult(org.openmrs.ui.framework.fragment.action.SuccessResult)

Example 3 with SuccessResult

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"));
}
Also used : User(org.openmrs.User) FailureResult(org.openmrs.ui.framework.fragment.action.FailureResult) SuccessResult(org.openmrs.ui.framework.fragment.action.SuccessResult)

Example 4 with SuccessResult

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();
}
Also used : Visit(org.openmrs.Visit) SuccessResult(org.openmrs.ui.framework.fragment.action.SuccessResult) VisitDomainWrapper(org.openmrs.module.emrapi.visit.VisitDomainWrapper) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with 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"));
    }
}
Also used : FailureResult(org.openmrs.ui.framework.fragment.action.FailureResult) AccountDomainWrapper(org.openmrs.module.emrapi.account.AccountDomainWrapper) SuccessResult(org.openmrs.ui.framework.fragment.action.SuccessResult)

Aggregations

SuccessResult (org.openmrs.ui.framework.fragment.action.SuccessResult)5 FailureResult (org.openmrs.ui.framework.fragment.action.FailureResult)4 User (org.openmrs.User)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 JsonNode (org.codehaus.jackson.JsonNode)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 Obs (org.openmrs.Obs)1 Visit (org.openmrs.Visit)1 AccountDomainWrapper (org.openmrs.module.emrapi.account.AccountDomainWrapper)1 Diagnosis (org.openmrs.module.emrapi.diagnosis.Diagnosis)1 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)1 Transactional (org.springframework.transaction.annotation.Transactional)1