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