Search in sources :

Example 11 with ArendeConversationView

use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView in project webcert by sklintyg.

the class ArendeModuleApiController method closeAsHandled.

@PUT
@Path("/{intygsTyp}/{meddelandeId}/stang")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response closeAsHandled(@PathParam("intygsTyp") String intygsTyp, @PathParam("meddelandeId") String meddelandeId) {
    LOGGER.debug("Close arende {} as handled", meddelandeId);
    abortIfHanteraFragorNotActive(intygsTyp);
    ArendeConversationView response = arendeService.closeArendeAsHandled(meddelandeId, intygsTyp);
    return Response.ok(response).build();
}
Also used : ArendeConversationView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 12 with ArendeConversationView

use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView in project webcert by sklintyg.

the class ArendeModuleApiController method createMessage.

@POST
@Path("/{intygsTyp}/{intygsId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response createMessage(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") final String intygsId, CreateMessageParameter parameter) {
    LOGGER.debug("Create arende for {} ({})", intygsId, intygsTyp);
    abortIfHanteraFragorNotActive(intygsTyp);
    ArendeConversationView response = arendeService.createMessage(intygsId, parameter.getAmne(), parameter.getRubrik(), parameter.getMeddelande());
    return Response.ok(response).build();
}
Also used : ArendeConversationView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 13 with ArendeConversationView

use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView in project webcert by sklintyg.

the class ArendeModuleApiController method openAsUnhandled.

@PUT
@Path("/{intygsTyp}/{meddelandeId}/oppna")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response openAsUnhandled(@PathParam("intygsTyp") String intygsTyp, @PathParam("meddelandeId") String meddelandeId) {
    LOGGER.debug("Open arende {} as unhandled", meddelandeId);
    abortIfHanteraFragorNotActive(intygsTyp);
    ArendeConversationView response = arendeService.openArendeAsUnhandled(meddelandeId);
    return Response.ok(response).build();
}
Also used : ArendeConversationView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 14 with ArendeConversationView

use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView in project webcert by sklintyg.

the class ArendeModuleApiController method answer.

@PUT
@Path("/{intygsTyp}/{meddelandeId}/besvara")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response answer(@PathParam("intygsTyp") String intygsTyp, @PathParam("meddelandeId") final String meddelandeId, String svarsText) {
    LOGGER.debug("Answer arende {}", meddelandeId);
    abortIfHanteraFragorNotActive(intygsTyp);
    ArendeConversationView response = arendeService.answer(meddelandeId, svarsText);
    return Response.ok(response).build();
}
Also used : ArendeConversationView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 15 with ArendeConversationView

use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView in project webcert by sklintyg.

the class ArendeServiceTest method answerKompltQuestionAuthorizedTest.

@Test
public void answerKompltQuestionAuthorizedTest() throws CertificateSenderException {
    final String svarPaMeddelandeId = "svarPaMeddelandeId";
    Arende fraga = buildArende(svarPaMeddelandeId, ENHET_ID);
    fraga.setStatus(Status.PENDING_INTERNAL_ACTION);
    fraga.setAmne(ArendeAmne.KOMPLT);
    fraga.setPatientPersonId(PERSON_ID);
    when(arendeRepository.findOneByMeddelandeId(svarPaMeddelandeId)).thenReturn(fraga);
    when(arendeRepository.findByIntygsId(INTYG_ID)).thenReturn(ImmutableList.of(fraga));
    when(webcertUserService.isAuthorizedForUnit(anyString(), anyBoolean())).thenReturn(true);
    WebCertUser webcertUser = createUser();
    when(webcertUserService.getUser()).thenReturn(webcertUser);
    List<ArendeConversationView> result = service.answerKomplettering(INTYG_ID, "svarstext");
    assertNotNull(result.get(0).getFraga());
    assertNotNull(result.get(0).getSvar());
    verify(notificationService).sendNotificationForQAs(INTYG_ID, NotificationEvent.NEW_ANSWER_FROM_CARE);
    verify(arendeRepository, times(3)).save(any(Arende.class));
    verify(arendeDraftService).delete(INTYG_ID, svarPaMeddelandeId);
}
Also used : ArendeConversationView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) Matchers.anyString(org.mockito.Matchers.anyString) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Aggregations

ArendeConversationView (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView)19 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)14 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)14 Test (org.junit.Test)12 LocalDateTime (java.time.LocalDateTime)11 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)8 ArendeAmne (se.inera.intyg.webcert.persistence.arende.model.ArendeAmne)6 Collectors (java.util.stream.Collectors)5 Clock (java.time.Clock)4 Consumes (javax.ws.rs.Consumes)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Matchers.anyString (org.mockito.Matchers.anyString)4 AuthoritiesHelper (se.inera.intyg.infra.security.authorities.AuthoritiesHelper)4 Personnummer (se.inera.intyg.schemas.contract.Personnummer)4 ImmutableList (com.google.common.collect.ImmutableList)3 PUT (javax.ws.rs.PUT)3 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)3 FrageStallare (se.inera.intyg.webcert.web.service.fragasvar.dto.FrageStallare)3 ArendeView (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView)3