Search in sources :

Example 1 with ValidationException

use of se.inera.intyg.webcert.fkstub.validation.ValidationException in project webcert by sklintyg.

the class SendAnswerStub method sendMedicalCertificateAnswer.

@Override
public SendMedicalCertificateAnswerResponseType sendMedicalCertificateAnswer(AttributedURIType logicalAddress, SendMedicalCertificateAnswerType parameters) {
    SendMedicalCertificateAnswerResponseType response = new SendMedicalCertificateAnswerResponseType();
    if (logicalAddress == null) {
        response.setResult(ResultOfCallUtil.failResult("Ingen LogicalAddress är satt"));
    } else if (!LOGICAL_ADDRESS.equals(logicalAddress.getValue())) {
        response.setResult(ResultOfCallUtil.failResult("LogicalAddress '" + logicalAddress.getValue() + "' är inte samma som '" + LOGICAL_ADDRESS + "'"));
    } else if ("error".equalsIgnoreCase(parameters.getAnswer().getSvar().getMeddelandeText())) {
        response.setResult(ResultOfCallUtil.failResult("Du ville ju få ett fel"));
    } else {
        AnswerToFkType answerType = parameters.getAnswer();
        SendMedicalCertificateAnswerValidator validator = new SendMedicalCertificateAnswerValidator(answerType);
        try {
            validator.validateAndCorrect();
            response.setResult(ResultOfCallUtil.okResult());
        } catch (ValidationException e) {
            response.setResult(ResultOfCallUtil.failResult(e.getMessage()));
        }
        questionAnswerStore.addAnswer(parameters.getAnswer());
    }
    return response;
}
Also used : SendMedicalCertificateAnswerResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType) ValidationException(se.inera.intyg.webcert.fkstub.validation.ValidationException) SendMedicalCertificateAnswerValidator(se.inera.intyg.webcert.fkstub.validation.SendMedicalCertificateAnswerValidator) AnswerToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType)

Example 2 with ValidationException

use of se.inera.intyg.webcert.fkstub.validation.ValidationException in project webcert by sklintyg.

the class SendQuestionStub method sendMedicalCertificateQuestion.

@Override
public SendMedicalCertificateQuestionResponseType sendMedicalCertificateQuestion(AttributedURIType logicalAddress, SendMedicalCertificateQuestionType parameters) {
    SendMedicalCertificateQuestionResponseType response = new SendMedicalCertificateQuestionResponseType();
    if (logicalAddress == null) {
        response.setResult(ResultOfCallUtil.failResult("Ingen LogicalAddress är satt"));
    } else if (!LOGICAL_ADDRESS.equals(logicalAddress.getValue())) {
        response.setResult(ResultOfCallUtil.failResult("LogicalAddress '" + logicalAddress.getValue() + "' är inte samma som '" + LOGICAL_ADDRESS + "'"));
    } else if ("error".equalsIgnoreCase(parameters.getQuestion().getFraga().getMeddelandeText())) {
        response.setResult(ResultOfCallUtil.failResult("Du ville ju få ett fel"));
    } else {
        QuestionToFkType questionType = parameters.getQuestion();
        SendMedicalCertificateQuestionValidator validator = new SendMedicalCertificateQuestionValidator(questionType);
        try {
            validator.validateAndCorrect();
            response.setResult(ResultOfCallUtil.okResult());
        } catch (ValidationException e) {
            response.setResult(ResultOfCallUtil.failResult(e.getMessage()));
        }
        questionAnswerStore.addQuestion(parameters.getQuestion());
    }
    return response;
}
Also used : ValidationException(se.inera.intyg.webcert.fkstub.validation.ValidationException) SendMedicalCertificateQuestionValidator(se.inera.intyg.webcert.fkstub.validation.SendMedicalCertificateQuestionValidator) QuestionToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.QuestionToFkType) SendMedicalCertificateQuestionResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.SendMedicalCertificateQuestionResponseType)

Aggregations

ValidationException (se.inera.intyg.webcert.fkstub.validation.ValidationException)2 AnswerToFkType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType)1 SendMedicalCertificateAnswerResponseType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType)1 QuestionToFkType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.QuestionToFkType)1 SendMedicalCertificateQuestionResponseType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.SendMedicalCertificateQuestionResponseType)1 SendMedicalCertificateAnswerValidator (se.inera.intyg.webcert.fkstub.validation.SendMedicalCertificateAnswerValidator)1 SendMedicalCertificateQuestionValidator (se.inera.intyg.webcert.fkstub.validation.SendMedicalCertificateQuestionValidator)1