Search in sources :

Example 31 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygModuleApiControllerTest method testCreateRenewalCopyWithNewPatientReservnummerDefaultsToPreviousPersonnummer.

/**
 * Verify that a non-valid personnr/samordningsnummer (i.e a "reservnummer") supplied as NyttPatientPersonnummer
 * will not be applied to the new utkast.
 */
@Test
public void testCreateRenewalCopyWithNewPatientReservnummerDefaultsToPreviousPersonnummer() {
    final String personnummer = "191212121212";
    final String newIntygId = "newIntygId";
    final String efternamn = "efternamn";
    final String fornamn = "fornamn";
    final String mellannamn = "mellannamn";
    final String postadress = "postadress";
    final String postort = "postort";
    final String postnummer = "postnummer";
    final String newReservnummer = "A20090122";
    CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
    copyIntygRequest.setPatientPersonnummer(createPnr(personnummer));
    WebCertUser user = new WebCertUser();
    user.setParameters(new IntegrationParameters(null, null, newReservnummer, fornamn, mellannamn, efternamn, postadress, postnummer, postort, false, false, false, true));
    addFeatures(user, CERTIFICATE_TYPE, AuthoritiesConstants.FEATURE_FORNYA_INTYG);
    addPrivileges(user, CERTIFICATE_TYPE, AuthoritiesConstants.PRIVILEGE_FORNYA_INTYG);
    user.setOrigin("NORMAL");
    ArgumentCaptor<CreateRenewalCopyRequest> captor = ArgumentCaptor.forClass(CreateRenewalCopyRequest.class);
    when(copyUtkastService.createRenewalCopy(captor.capture())).thenReturn(new CreateRenewalCopyResponse(CERTIFICATE_TYPE, newIntygId, CERTIFICATE_ID));
    when(webcertUserService.getUser()).thenReturn(user);
    Response response = moduleApiController.createRenewal(copyIntygRequest, CERTIFICATE_TYPE, CERTIFICATE_ID);
    verify(copyUtkastService).createRenewalCopy(any());
    verifyNoMoreInteractions(copyUtkastService);
    assertEquals(newIntygId, ((CopyIntygResponse) response.getEntity()).getIntygsUtkastId());
    assertEquals(personnummer, captor.getValue().getPatient().getPersonId().getPersonnummer());
    assertEquals(fornamn, captor.getValue().getPatient().getFornamn());
    assertEquals(efternamn, captor.getValue().getPatient().getEfternamn());
    assertEquals(mellannamn, captor.getValue().getPatient().getMellannamn());
    assertEquals(postadress, captor.getValue().getPatient().getPostadress());
    assertEquals(postnummer, captor.getValue().getPatient().getPostnummer());
    assertEquals(postort, captor.getValue().getPatient().getPostort());
    assertNull(captor.getValue().getNyttPatientPersonnummer());
}
Also used : Response(javax.ws.rs.core.Response) CreateRenewalCopyResponse(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyResponse) CopyIntygResponse(se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygResponse) CreateUtkastFromTemplateResponse(se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateResponse) CreateReplacementCopyResponse(se.inera.intyg.webcert.web.service.utkast.dto.CreateReplacementCopyResponse) CreateCompletionCopyResponse(se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyResponse) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) CopyIntygRequest(se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest) CreateRenewalCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest) CreateRenewalCopyResponse(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyResponse) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 32 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygModuleApiController method createPatientFromCopyIntygRequest.

private Patient createPatientFromCopyIntygRequest(CopyIntygRequest copyRequest) {
    WebCertUser user = getWebCertUserService().getUser();
    IntegrationParameters parameters = user.getParameters();
    Patient patient = new Patient();
    patient.setPersonId(copyRequest.getPatientPersonnummer());
    if (parameters != null) {
        if (!Strings.nullToEmpty(parameters.getFornamn()).trim().isEmpty()) {
            patient.setFornamn(parameters.getFornamn());
        }
        if (!Strings.nullToEmpty(parameters.getEfternamn()).trim().isEmpty()) {
            patient.setEfternamn(parameters.getEfternamn());
        }
        if (!Strings.nullToEmpty(parameters.getMellannamn()).trim().isEmpty()) {
            patient.setMellannamn(parameters.getMellannamn());
        }
        if (!Strings.nullToEmpty(parameters.getPostadress()).trim().isEmpty()) {
            patient.setPostadress(parameters.getPostadress());
        }
        if (!Strings.nullToEmpty(parameters.getPostnummer()).trim().isEmpty()) {
            patient.setPostnummer(parameters.getPostnummer());
        }
        if (!Strings.nullToEmpty(parameters.getPostort()).trim().isEmpty()) {
            patient.setPostort(parameters.getPostort());
        }
    }
    return patient;
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) Patient(se.inera.intyg.common.support.model.common.internal.Patient) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 33 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygIntegrationController method getRedirectToIntyg.

/**
 * Fetches an certificate from IT or Webcert and then performs a redirect to the view that displays
 * the certificate.
 *
 * @param intygId The id of the certificate to view.
 */
@GET
@Path("/{certId}")
public Response getRedirectToIntyg(@Context UriInfo uriInfo, @PathParam(PARAM_CERT_ID) String intygId, @DefaultValue("") @QueryParam(PARAM_ENHET_ID) String enhetId, @DefaultValue("") @QueryParam(PARAM_PATIENT_ALTERNATE_SSN) String alternatePatientSSn, @DefaultValue("") @QueryParam(PARAM_RESPONSIBLE_HOSP_NAME) String responsibleHospName, @QueryParam(PARAM_PATIENT_FORNAMN) String fornamn, @QueryParam(PARAM_PATIENT_EFTERNAMN) String efternamn, @QueryParam(PARAM_PATIENT_MELLANNAMN) String mellannamn, @QueryParam(PARAM_PATIENT_POSTADRESS) String postadress, @QueryParam(PARAM_PATIENT_POSTNUMMER) String postnummer, @QueryParam(PARAM_PATIENT_POSTORT) String postort, @DefaultValue("false") @QueryParam(PARAM_COHERENT_JOURNALING) boolean coherentJournaling, @QueryParam(PARAM_REFERENCE) String reference, @DefaultValue("false") @QueryParam(PARAM_INACTIVE_UNIT) boolean inactiveUnit, @DefaultValue("false") @QueryParam(PARAM_PATIENT_DECEASED) boolean deceased, @DefaultValue("true") @QueryParam(PARAM_COPY_OK) boolean copyOk) {
    Map<String, Object> params = new HashMap<>();
    params.put(PARAM_CERT_ID, intygId);
    // validate the request
    validateRequest(params);
    IntegrationParameters integrationParameters = getIntegrationParameters(reference, responsibleHospName, alternatePatientSSn, fornamn, efternamn, mellannamn, postadress, postnummer, postort, coherentJournaling, inactiveUnit, deceased, copyOk);
    WebCertUser user = getWebCertUser();
    user.setParameters(integrationParameters);
    return handleRedirectToIntyg(uriInfo, null, intygId, enhetId, user);
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) HashMap(java.util.HashMap) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 34 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygServiceTest method testLoggingFetchIntygAsPdfWithSJF.

@Test
public void testLoggingFetchIntygAsPdfWithSJF() throws IOException, IntygModuleFacadeException {
    // Set up user
    IntegrationParameters parameters = new IntegrationParameters(null, null, null, null, null, null, null, null, null, true, false, false, false);
    when(webcertUser.getOrigin()).thenReturn(UserOriginType.DJUPINTEGRATION.name());
    when(webcertUser.getParameters()).thenReturn(parameters);
    final Utkast draft = getDraft(CERTIFICATE_ID);
    when(utkastRepository.findOne(CERTIFICATE_ID)).thenReturn(draft);
    Fk7263Utlatande utlatande = objectMapper.readValue(draft.getModel(), Fk7263Utlatande.class);
    when(moduleFacade.getUtlatandeFromInternalModel(anyString(), anyString())).thenReturn(utlatande);
    when(moduleFacade.convertFromInternalToPdfDocument(anyString(), anyString(), anyList(), anyBoolean())).thenReturn(buildPdfDocument());
    intygService.fetchIntygAsPdf(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
    // Verify that the isAuthorized check wasn't run (since SJF=true and DJUPINTEGRATION)
    verify(webCertUserService, times(0)).isAuthorizedForUnit(anyString(), anyString(), anyBoolean());
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Test(org.junit.Test)

Example 35 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygServiceTest method testDeceasedIsNotSetForAlivePatientDjupintegration.

@Test
public void testDeceasedIsNotSetForAlivePatientDjupintegration() {
    when(webcertUser.getOrigin()).thenReturn(UserOriginType.DJUPINTEGRATION.name());
    when(webcertUser.getParameters()).thenReturn(new IntegrationParameters("", "", "", "", "", "", "", "", "", false, false, false, true));
    IntygContentHolder intygData = intygService.fetchIntygData(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
    assertFalse(intygData.isDeceased());
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) Test(org.junit.Test)

Aggregations

IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)36 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)32 Test (org.junit.Test)25 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 CreateRenewalCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest)9 CreateRenewalCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyResponse)9 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)8 Response (javax.ws.rs.core.Response)7 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)7 Personnummer (se.inera.intyg.schemas.contract.Personnummer)6 CreateReplacementCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateReplacementCopyResponse)6 CreateCompletionCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyResponse)5 Person (se.inera.intyg.infra.integration.pu.model.Person)4 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)4 CreateUtkastFromTemplateResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateResponse)4 CopyIntygRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest)4 CopyIntygResponse (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygResponse)4 Patient (se.inera.intyg.common.support.model.common.internal.Patient)3 Privilege (se.inera.intyg.infra.security.common.model.Privilege)3 Role (se.inera.intyg.infra.security.common.model.Role)3