Search in sources :

Example 11 with FragaSvar

use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar 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 12 with FragaSvar

use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.

the class FKQuestionConverterTest method testConvertQuestion.

@Test
public void testConvertQuestion() throws Exception {
    QuestionFromFkType questionFromFK = inflateQuestionFromFK();
    QuestionToFkType referenceQuestionToFK = inflateQuestionToFK();
    // convert QuestionFromFK to FragaSvar entity
    FragaSvar fragaSvar = fragaSvarConverter.convert(questionFromFK);
    // add some data
    fragaSvar.setAmne(Amne.KONTAKT);
    fragaSvar.setInternReferens(321L);
    // convert fragaSvar entity to QuestionToFK
    QuestionToFkType convertedQuestionToFK = FKQuestionConverter.convert(fragaSvar);
    // compare convertedQuestionToFK to reference
    String expected = jaxbToXml(referenceQuestionToFK);
    String actual = jaxbToXml(convertedQuestionToFK);
    assertEquals(expected, actual);
}
Also used : QuestionFromFkType(se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) QuestionToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.QuestionToFkType) Test(org.junit.Test)

Example 13 with FragaSvar

use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.

the class FragaSvarResource method askQuestion.

@POST
@Path("/skickafraga/{vardgivare}/{enhet}/{intygId}/{typ}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public Response askQuestion(@PathParam("vardgivare") final String vardgivarId, @PathParam("enhet") final String enhetsId, @PathParam("intygId") final String intygId, @PathParam("typ") final String typ, CreateQuestionParameter parameter) {
    SecurityContext originalContext = SecurityContextHolder.getContext();
    SecurityContextHolder.setContext(getSecurityContext(vardgivarId, enhetsId));
    try {
        FragaSvar fragaSvarResponse = fragaSvarService.saveNewQuestion(intygId, typ, parameter.getAmne(), parameter.getFrageText());
        return Response.ok(fragaSvarResponse).build();
    } finally {
        SecurityContextHolder.setContext(originalContext);
    }
}
Also used : SecurityContext(org.springframework.security.core.context.SecurityContext) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 14 with FragaSvar

use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.

the class FragaSvarResource method deleteFragaSvarByEnhet.

@DELETE
@Path("/enhet/{enhetsId}")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteFragaSvarByEnhet(@PathParam("enhetsId") String enhetsId) {
    List<String> enhetsIds = new ArrayList<>();
    enhetsIds.add(enhetsId);
    List<FragaSvar> fragorOchSvar = fragasvarRepository.findByEnhetsId(enhetsIds);
    if (fragorOchSvar != null) {
        for (FragaSvar fragaSvar : fragorOchSvar) {
            fragasvarRepository.delete(fragaSvar);
        }
    }
    return Response.ok().build();
}
Also used : ArrayList(java.util.ArrayList) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 15 with FragaSvar

use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.

the class FragaSvarModuleApiController method createQuestion.

@POST
@Path("/{intygsTyp}/{intygsId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response createQuestion(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") final String intygsId, CreateQuestionParameter parameter) {
    authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR, AuthoritiesConstants.FEATURE_SKAPA_NYFRAGA).orThrow();
    LOG.debug("New question for cert {} with subject {}", intygsId, parameter.getAmne());
    FragaSvar fragaSvarResponse = fragaSvarService.saveNewQuestion(intygsId, intygsTyp, parameter.getAmne(), parameter.getFrageText());
    return Response.ok(fragaSvarResponse).build();
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)71 Test (org.junit.Test)42 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)14 IntygsReferens (se.inera.intyg.webcert.persistence.fragasvar.model.IntygsReferens)11 Vardperson (se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson)11 Produces (javax.ws.rs.Produces)7 AttributedURIType (org.w3.wsaddressing10.AttributedURIType)7 Path (javax.ws.rs.Path)6 Filter (se.inera.intyg.webcert.persistence.model.Filter)6 LocalDateTime (java.time.LocalDateTime)5 Consumes (javax.ws.rs.Consumes)5 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)5 ArendeListItem (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem)5 ArrayList (java.util.ArrayList)4 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 SendMedicalCertificateAnswerResponseType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType)4 SendMedicalCertificateAnswerType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType)4 SendMedicalCertificateQuestionType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.SendMedicalCertificateQuestionType)4 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)4 Amne (se.inera.intyg.webcert.persistence.fragasvar.model.Amne)4