Search in sources :

Example 1 with BadFormDesignException

use of org.openmrs.module.htmlformentry.BadFormDesignException in project openmrs-module-coreapps by openmrs.

the class EncounterDiagnosesTagHandler method getSubstitution.

@Override
protected String getSubstitution(FormEntrySession session, FormSubmissionController controller, Map<String, String> attributes) throws BadFormDesignException {
    EncounterDiagnosesElement element = new EncounterDiagnosesElement();
    // pull from the session if available, otherwise fall back to basic ui utils
    element.setUiUtils(session.getAttribute("uiUtils") != null ? (UiUtils) session.getAttribute("uiUtils") : uiUtils);
    element.setRequired("true".equals(attributes.get("required")));
    element.setSelectedDiagnosesTarget(attributes.get("selectedDiagnosesTarget"));
    element.setEmrApiProperties(emrApiProperties);
    element.setConceptService(conceptService);
    element.setAdtService(adtService);
    /**
     *  Handle the attribute to specify loading any prior diagnoses from the most recent encounter with a specific disposition
     * (use case: prepopulating the diagonses on an admission note with the diagnoses from the consult recommending admission,
     *  ie., on our admission note: <encounterDiagnoses required="true" selectedDiagnosesTarget="#encounter-diagnoses-target" includePriorDiagnosesFromMostRecentEncounterWithDispositionOfType="ADMIT"/>)
     */
    if (attributes.containsKey(CoreAppsConstants.HTMLFORMENTRY_ENCOUNTER_DIAGNOSES_TAG_INCLUDE_PRIOR_DIAGNOSES_ATTRIBUTE_NAME)) {
        try {
            element.setDispositionTypeForPriorDiagnoses(DispositionType.valueOf(attributes.get(CoreAppsConstants.HTMLFORMENTRY_ENCOUNTER_DIAGNOSES_TAG_INCLUDE_PRIOR_DIAGNOSES_ATTRIBUTE_NAME).toUpperCase()));
        } catch (IllegalArgumentException ex) {
            throw new BadFormDesignException("Encounter Diagnoses Tag: invalid value of " + attributes.get(CoreAppsConstants.HTMLFORMENTRY_ENCOUNTER_DIAGNOSES_TAG_INCLUDE_PRIOR_DIAGNOSES_ATTRIBUTE_NAME) + " for attribute " + CoreAppsConstants.HTMLFORMENTRY_ENCOUNTER_DIAGNOSES_TAG_INCLUDE_PRIOR_DIAGNOSES_ATTRIBUTE_NAME);
        }
    }
    controller.addAction(element);
    return element.generateHtml(session.getContext());
}
Also used : BadFormDesignException(org.openmrs.module.htmlformentry.BadFormDesignException) UiUtils(org.openmrs.ui.framework.UiUtils)

Aggregations

BadFormDesignException (org.openmrs.module.htmlformentry.BadFormDesignException)1 UiUtils (org.openmrs.ui.framework.UiUtils)1