Search in sources :

Example 1 with AnswerToFkType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType 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 AnswerToFkType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType in project webcert by sklintyg.

the class FKAnswerConverterTest method testConvertAnswer.

@Test
public void testConvertAnswer() throws Exception {
    QuestionFromFkType questionFromFK = inflateQuestionFromFK();
    AnswerToFkType referenceAnswerToFK = inflateAnswerToFK();
    // convert QuestionFromFK to FragaSvar entity
    FragaSvar fragaSvar = fragaSvarConverter.convert(questionFromFK);
    // add some data
    fragaSvar.setInternReferens(321L);
    fragaSvar.setSvarsText(fragaSvar.getFrageText());
    fragaSvar.setSvarSigneringsDatum(fragaSvar.getFrageSigneringsDatum());
    // convert FragaSvar entity to AnswerToFK
    AnswerToFkType convertedAnswerToFK = FKAnswerConverter.convert(fragaSvar);
    // compare convertedAnswerToFK to reference
    String expected = jaxbToXml(referenceAnswerToFK);
    String actual = jaxbToXml(convertedAnswerToFK);
    assertEquals(expected, actual);
}
Also used : QuestionFromFkType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType) AnswerToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Test(org.junit.Test)

Example 3 with AnswerToFkType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType in project webcert by sklintyg.

the class FKAnswerConverter method convert.

public static AnswerToFkType convert(FragaSvar fs) {
    AnswerToFkType fkAnswer = new AnswerToFkType();
    fkAnswer.setAmne(ConvertToFKTypes.toAmneTyp(fs.getAmne()));
    fkAnswer.setAdressVard(ConvertToFKTypes.toVardAdresseringsType(fs.getVardperson()));
    fkAnswer.setAvsantTidpunkt(fs.getFrageSkickadDatum());
    if (fs.getMeddelandeRubrik() != null) {
        fkAnswer.setFkMeddelanderubrik(fs.getMeddelandeRubrik());
    }
    fkAnswer.setFkReferensId(fs.getExternReferens());
    fkAnswer.setVardReferensId(fs.getInternReferens().toString());
    if (fs.getSistaDatumForSvar() != null) {
        fkAnswer.setFkSistaDatumForSvar(fs.getSistaDatumForSvar());
    }
    fkAnswer.setFraga(ConvertToFKTypes.toInnehallType(fs.getFrageText(), fs.getFrageSigneringsDatum()));
    fkAnswer.setSvar(ConvertToFKTypes.toInnehallType(fs.getSvarsText(), fs.getSvarSigneringsDatum()));
    fkAnswer.setLakarutlatande(ConvertToFKTypes.toLakarUtlatande(fs.getIntygsReferens()));
    if (fs.getKompletteringar() != null) {
        for (Komplettering komplettering : fs.getKompletteringar()) {
            KompletteringType kt = new KompletteringType();
            kt.setFalt(komplettering.getFalt());
            kt.setText(komplettering.getText());
            fkAnswer.getFkKomplettering().add(kt);
        }
    }
    return fkAnswer;
}
Also used : KompletteringType(se.inera.ifv.insuranceprocess.healthreporting.medcertqa.v1.KompletteringType) AnswerToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType) Komplettering(se.inera.intyg.webcert.persistence.fragasvar.model.Komplettering)

Example 4 with AnswerToFkType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType in project webcert by sklintyg.

the class FKAnswerConverterTest method jaxbToXml.

private String jaxbToXml(AnswerToFkType object) throws JAXBException {
    ObjectFactory objectFactory = new ObjectFactory();
    Writer writer = new StringWriter();
    // Init JAXB context
    JAXBContext jaxbContext = JAXBContext.newInstance(AnswerToFkType.class);
    Marshaller marshaller = jaxbContext.createMarshaller();
    // Create a string representation from JAXB element
    marshaller.marshal(objectFactory.createAnswer(object), writer);
    return writer.toString();
}
Also used : Marshaller(javax.xml.bind.Marshaller) ObjectFactory(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.ObjectFactory) StringWriter(java.io.StringWriter) JAXBContext(javax.xml.bind.JAXBContext) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Example 5 with AnswerToFkType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType in project webcert by sklintyg.

the class FKAnswerConverterTest method inflateAnswerToFK.

private AnswerToFkType inflateAnswerToFK() throws Exception {
    JAXBContext jaxbContext = JAXBContext.newInstance(AnswerToFkType.class);
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    return unmarshaller.unmarshal(new StreamSource(new ClassPathResource("FragaSvarConverterTest/answer_to_fk.xml").getInputStream()), AnswerToFkType.class).getValue();
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) AnswerToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) ClassPathResource(org.springframework.core.io.ClassPathResource)

Aggregations

AnswerToFkType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType)5 JAXBContext (javax.xml.bind.JAXBContext)2 SendMedicalCertificateAnswerResponseType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType)2 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 Marshaller (javax.xml.bind.Marshaller)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 StreamSource (javax.xml.transform.stream.StreamSource)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 Test (org.junit.Test)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 AttributedURIType (org.w3.wsaddressing10.AttributedURIType)1 KompletteringType (se.inera.ifv.insuranceprocess.healthreporting.medcertqa.v1.KompletteringType)1 QuestionFromFkType (se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType)1 ObjectFactory (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.ObjectFactory)1 SendMedicalCertificateAnswerType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType)1 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 SendMedicalCertificateAnswerValidator (se.inera.intyg.webcert.fkstub.validation.SendMedicalCertificateAnswerValidator)1 ValidationException (se.inera.intyg.webcert.fkstub.validation.ValidationException)1 FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)1