Search in sources :

Example 11 with CreateDraftCertificateType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateHsaException.

@Test
public void testCreateDraftCertificateHsaException() {
    when(webcertUserDetailsService.loadUserByHsaId(USER_HSAID)).thenThrow(new MissingMedarbetaruppdragException(USER_HSAID));
    CreateDraftCertificateType certificateType = createCertificateType();
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verifyZeroInteractions(mockUtkastService);
    verifyZeroInteractions(mockIntegreradeEnheterService);
    verify(monitoringLogService).logMissingMedarbetarUppdrag(USER_HSAID, UNIT_HSAID);
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
    assertEquals(ErrorIdType.VALIDATION_ERROR, response.getResult().getErrorId());
    assertEquals("No valid MIU was found for person SE1234567890 on unit SE0987654321, can not create draft!", response.getResult().getResultText());
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType) MissingMedarbetaruppdragException(se.inera.intyg.infra.security.exception.MissingMedarbetaruppdragException) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 12 with CreateDraftCertificateType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateHsaReturnsNoMIUs.

@Test
public void testCreateDraftCertificateHsaReturnsNoMIUs() {
    WebCertUser userWithNoMiu = buildWebCertUser();
    userWithNoMiu.setVardgivare(new ArrayList<>());
    when(webcertUserDetailsService.loadUserByHsaId(USER_HSAID)).thenReturn(userWithNoMiu);
    ResultValidator resultsValidator = new ResultValidator();
    CreateDraftCertificateType certificateType = createCertificateType();
    when(mockValidator.validate(any(Utlatande.class))).thenReturn(resultsValidator);
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verifyZeroInteractions(mockUtkastService);
    verifyZeroInteractions(mockIntegreradeEnheterService);
    verify(monitoringLogService).logMissingMedarbetarUppdrag(USER_HSAID, UNIT_HSAID);
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
    assertEquals(ErrorIdType.VALIDATION_ERROR, response.getResult().getErrorId());
    assertEquals("No valid MIU was found for person SE1234567890 on unit SE0987654321, can not create draft!", response.getResult().getResultText());
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) TypAvUtlatande(se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande) Utlatande(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 13 with CreateDraftCertificateType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImplTest method whenNewCertificateDraftSuccessResponse.

/**
 * When a new certificate draft is being created the caller
 * should get a success response returned and any stakeholder
 * should be notified with a notification message.
 */
@Test
public void whenNewCertificateDraftSuccessResponse() {
    // Given
    ResultValidator resultsValidator = new ResultValidator();
    Vardgivare vardgivare = createVardgivare();
    Vardenhet vardenhet = createVardenhet(vardgivare);
    CreateNewDraftRequest draftRequest = createCreateNewDraftRequest(vardenhet);
    CreateDraftCertificateType certificateType = createCertificateType();
    VardpersonReferens vardperson = createVardpersonReferens(certificateType.getUtlatande().getSkapadAv().getPersonalId().getRoot(), certificateType.getUtlatande().getSkapadAv().getFullstandigtNamn());
    Utkast utkast = createUtkast(UTKAST_ID, Long.parseLong(UTKAST_VERSION), UTKAST_TYPE, UtkastStatus.DRAFT_INCOMPLETE, UTKAST_JSON, vardperson);
    // When
    when(mockValidator.validate(any(Utlatande.class))).thenReturn(resultsValidator);
    when(mockRequestBuilder.buildCreateNewDraftRequest(any(Utlatande.class), any(IntygUser.class))).thenReturn(draftRequest);
    when(mockUtkastService.createNewDraft(any(CreateNewDraftRequest.class))).thenReturn(utkast);
    when(takService.verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class))).thenReturn(new TakResult(true, Lists.emptyList()));
    // Then
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verify(mockUtkastService).createNewDraft(any(CreateNewDraftRequest.class));
    verify(mockIntegreradeEnheterService).putIntegreradEnhet(any(IntegreradEnhetEntry.class), eq(true), eq(false));
    verify(takService).verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class));
    // Assert response content
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.OK);
    assertEquals(response.getUtlatandeId().getExtension(), UTKAST_ID);
}
Also used : IntegreradEnhetEntry(se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry) CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType) SchemaVersion(se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion) TakResult(se.inera.intyg.webcert.integration.tak.model.TakResult) Vardgivare(se.inera.intyg.common.support.model.common.internal.Vardgivare) Vardenhet(se.inera.intyg.common.support.model.common.internal.Vardenhet) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) TypAvUtlatande(se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande) Utlatande(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 14 with CreateDraftCertificateType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateApplicationError.

@Test
public void testCreateDraftCertificateApplicationError() {
    final String validationError = "error";
    ResultValidator resultsValidator = new ResultValidator();
    resultsValidator.addError(validationError);
    CreateDraftCertificateType certificateType = createCertificateType();
    when(mockValidator.validate(any(Utlatande.class))).thenReturn(new ResultValidator());
    when(mockValidator.validateApplicationErrors(any(Utlatande.class), any(IntygUser.class))).thenReturn(resultsValidator);
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verifyZeroInteractions(mockUtkastService);
    verifyZeroInteractions(mockIntegreradeEnheterService);
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
    assertEquals(ErrorIdType.APPLICATION_ERROR, response.getResult().getErrorId());
    assertEquals(validationError, response.getResult().getResultText());
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) TypAvUtlatande(se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande) Utlatande(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 15 with CreateDraftCertificateType

use of se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType in project webcert by sklintyg.

the class CreateDraftCertificateResponderImplTest method createCertificateType.

private CreateDraftCertificateType createCertificateType() {
    // Type
    TypAvUtlatande utlTyp = new TypAvUtlatande();
    utlTyp.setCode("fk7263");
    // HoSPerson
    HsaId userHsaId = new HsaId();
    userHsaId.setExtension(USER_HSAID);
    userHsaId.setRoot("USERHSAID");
    HsaId unitHsaId = new HsaId();
    unitHsaId.setExtension(UNIT_HSAID);
    unitHsaId.setRoot("UNITHSAID");
    Enhet hosEnhet = new Enhet();
    hosEnhet.setEnhetsId(unitHsaId);
    HosPersonal hosPerson = new HosPersonal();
    hosPerson.setFullstandigtNamn("Abel Baker");
    hosPerson.setPersonalId(userHsaId);
    hosPerson.setEnhet(hosEnhet);
    // Patient
    PersonId personId = new PersonId();
    personId.setRoot("PERSNR");
    personId.setExtension("19121212-1212");
    Patient patType = new Patient();
    patType.setPersonId(personId);
    patType.getFornamn().add("Adam");
    patType.getFornamn().add("Bertil");
    patType.getMellannamn().add("Cesarsson");
    patType.getMellannamn().add("Davidsson");
    patType.setEfternamn("Eriksson");
    Utlatande utlatande = new Utlatande();
    utlatande.setTypAvUtlatande(utlTyp);
    utlatande.setSkapadAv(hosPerson);
    utlatande.setPatient(patType);
    CreateDraftCertificateType certificateType = new CreateDraftCertificateType();
    certificateType.setUtlatande(utlatande);
    return certificateType;
}
Also used : HosPersonal(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.HosPersonal) Enhet(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Enhet) PersonId(se.riv.clinicalprocess.healthcond.certificate.types.v1.PersonId) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType) TypAvUtlatande(se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande) Utlatande(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande) Patient(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Patient) HsaId(se.riv.clinicalprocess.healthcond.certificate.types.v1.HsaId) TypAvUtlatande(se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande)

Aggregations

Test (org.junit.Test)12 BaseCreateDraftCertificateTest (se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest)12 ResultValidator (se.inera.intyg.webcert.web.integration.validators.ResultValidator)12 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)8 SchemaVersion (se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion)7 TakResult (se.inera.intyg.webcert.integration.tak.model.TakResult)7 CreateDraftCertificateType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType)7 Utlatande (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande)7 CreateDraftCertificateType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType)7 Intyg (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg)7 TypAvIntyg (se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg)7 CreateDraftCertificateResponseType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType)6 CreateDraftCertificateResponseType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType)6 TypAvUtlatande (se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande)6 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)5 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)4 IntegreradEnhetEntry (se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry)4 CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)4 Personnummer (se.inera.intyg.schemas.contract.Personnummer)2 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)2