All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openmrs.module.rulesengine.util.Validator Maven / Gradle / Ivy

package org.openmrs.module.rulesengine.util;

import org.openmrs.module.rulesengine.service.ObservationService;

public class Validator {
    public static void validate(Double obsValue, ObservationService.ConceptRepo conceptName) throws Exception {
        if (obsValue == null) {
            throw new Exception(String.format("Please enter %s to calculate dose.", conceptName));
        }
    }

    public static void validateHeightAndWeight(Double heightObsValue, Double weightObsValue, ObservationService.ConceptRepo heightConceptName, ObservationService.ConceptRepo weightConceptName) throws Exception {
        if (heightObsValue == null && weightObsValue == null) {
            throw new Exception(String.format("Please enter %s and %s to calculate dose.", heightConceptName, weightConceptName));
        }
        validate(heightObsValue, heightConceptName);
        validate(weightObsValue, weightConceptName);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy