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;
}
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);
}
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;
}
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();
}
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();
}
Aggregations