Search in sources :

Example 1 with CreateDraftCertificateType

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

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateTakningNotOk.

@Test
public void testCreateDraftCertificateTakningNotOk() {
    // Given
    ResultValidator resultsValidator = new ResultValidator();
    CreateDraftCertificateType certificateType = createCertificateType();
    // When
    when(mockValidator.validate(any(Utlatande.class))).thenReturn(resultsValidator);
    when(takService.verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class))).thenReturn(new TakResult(false, Lists.newArrayList("Den angivna enheten går ej att adressera för ärendekommunikation.")));
    // Then
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    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.ERROR);
    assertEquals(ErrorIdType.APPLICATION_ERROR, response.getResult().getErrorId());
    assertEquals("Den angivna enheten går ej att adressera för ärendekommunikation.", response.getResult().getResultText());
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType) SchemaVersion(se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion) 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) TakResult(se.inera.intyg.webcert.integration.tak.model.TakResult) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 2 with CreateDraftCertificateType

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

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateValidationError.

@Test
public void testCreateDraftCertificateValidationError() {
    final String validationError = "error";
    ResultValidator resultsValidator = new ResultValidator();
    resultsValidator.addError(validationError);
    CreateDraftCertificateType certificateType = createCertificateType();
    when(mockValidator.validate(any(Utlatande.class))).thenReturn(resultsValidator);
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verifyZeroInteractions(mockUtkastService);
    verifyZeroInteractions(mockIntegreradeEnheterService);
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
    assertEquals(ErrorIdType.VALIDATION_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) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 3 with CreateDraftCertificateType

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

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateNoMIUs.

@Test
public void testCreateDraftCertificateNoMIUs() {
    WebCertUser userWithoutMiu = buildWebCertUser();
    userWithoutMiu.setVardgivare(new ArrayList<>());
    when(webcertUserDetailsService.loadUserByHsaId(USER_HSAID)).thenReturn(userWithoutMiu);
    CreateDraftCertificateType certificateType = createCertificateType();
    when(mockValidator.validate(any(Intyg.class))).thenReturn(new ResultValidator());
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verify(mockMonitoringLogService).logMissingMedarbetarUppdrag(USER_HSAID, UNIT_HSAID);
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
    assertEquals(response.getResult().getErrorId(), ErrorIdType.VALIDATION_ERROR);
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType) TypAvIntyg(se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg) Intyg(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) 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 4 with CreateDraftCertificateType

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

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateTakningNotOK.

@Test
public void testCreateDraftCertificateTakningNotOK() {
    CreateDraftCertificateType certificateType = createCertificateType();
    when(mockValidator.validate(any(Intyg.class))).thenReturn(new ResultValidator());
    when(takService.verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class))).thenReturn(new TakResult(false, Lists.newArrayList("Den angivna enheten går ej att adressera för ärendekommunikation.")));
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verify(takService).verifyTakningForCareUnit(any(String.class), eq(UTKAST_TYPE), eq(SchemaVersion.VERSION_3), any(IntygUser.class));
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
    assertEquals(response.getResult().getErrorId(), ErrorIdType.APPLICATION_ERROR);
    assertEquals("Den angivna enheten går ej att adressera för ärendekommunikation.", response.getResult().getResultText());
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType) SchemaVersion(se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion) TypAvIntyg(se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg) Intyg(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) TakResult(se.inera.intyg.webcert.integration.tak.model.TakResult) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 5 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
    TypAvIntyg utlTyp = new TypAvIntyg();
    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.setFornamn("Adam");
    patType.setMellannamn("Cesarsson");
    patType.setEfternamn("Eriksson");
    Intyg utlatande = new Intyg();
    utlatande.setTypAvIntyg(utlTyp);
    utlatande.setSkapadAv(hosPerson);
    utlatande.setPatient(patType);
    utlatande.setRef("Test-ref");
    CreateDraftCertificateType certificateType = new CreateDraftCertificateType();
    certificateType.setIntyg(utlatande);
    return certificateType;
}
Also used : HosPersonal(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.HosPersonal) Enhet(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Enhet) TypAvIntyg(se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg) PersonId(se.riv.clinicalprocess.healthcond.certificate.types.v3.PersonId) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType) TypAvIntyg(se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg) Intyg(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg) Patient(se.riv.clinicalprocess.healthcond.certificate.v3.Patient) HsaId(se.riv.clinicalprocess.healthcond.certificate.types.v3.HsaId)

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