Search in sources :

Example 1 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class ValidatePrivatePractitionerResponderStub method validatePrivatePractitioner.

@Override
public ValidatePrivatePractitionerResponseType validatePrivatePractitioner(String logicalAddress, ValidatePrivatePractitionerType parameters) {
    // Do validation of parameters object
    validate(parameters);
    String id = parameters.getPersonalIdentityNumber();
    Personnummer personnummer = Personnummer.createPersonnummer(id).orElse(null);
    ValidatePrivatePractitionerResponseType response = new ValidatePrivatePractitionerResponseType();
    HoSPersonType person = personStub.get(id);
    if (person == null) {
        response.setResultCode(ResultCodeEnum.ERROR);
        response.setResultText("No private practitioner with personal identity number: " + Personnummer.getPersonnummerHashSafe(personnummer) + " exists.");
    } else if (person.isGodkandAnvandare()) {
        response.setResultCode(ResultCodeEnum.OK);
    } else {
        response.setResultCode(ResultCodeEnum.ERROR);
        response.setResultText("Private practitioner with personal identity number: " + Personnummer.getPersonnummerHashSafe(personnummer) + " is not authorized to use webcert.");
    }
    return response;
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ValidatePrivatePractitionerResponseType(se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType) HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType)

Example 2 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class PPServiceTest method checkExistingPerson.

@Test
public void checkExistingPerson() {
    HoSPersonType hoSPersonType = service.getPrivatePractitioner("address", null, GetPrivatePractitionerResponderStub.PERSONNUMMER_EXISTING);
    assertNotNull(hoSPersonType);
    assertEquals(hoSPersonType.getPersonId().getExtension(), GetPrivatePractitionerResponderStub.PERSONNUMMER_EXISTING);
}
Also used : HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) Test(org.junit.Test)

Example 3 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class PPServiceTest method whenServiceResultCodeIsErrorThenExpectNullResponse.

@Test
public void whenServiceResultCodeIsErrorThenExpectNullResponse() {
    HoSPersonType hoSPersonType = service.getPrivatePractitioner("address", null, GetPrivatePractitionerResponderStub.PERSONNUMMER_ERROR_RESPONSE);
    assertNull(hoSPersonType);
}
Also used : HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) Test(org.junit.Test)

Example 4 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class ElegWebCertUserDetailsService method decorateWebCertUserWithBefattningar.

private void decorateWebCertUserWithBefattningar(HoSPersonType hosPerson, WebCertUser webCertUser) {
    List<String> befattningar = new ArrayList<>();
    for (BefattningType bt : hosPerson.getBefattning()) {
        befattningar.add(bt.getNamn());
    }
    webCertUser.setBefattningar(befattningar);
}
Also used : ArrayList(java.util.ArrayList) BefattningType(se.riv.infrastructure.directory.privatepractitioner.v1.BefattningType)

Example 5 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class MailNotificationServiceImplTest method testSendMailForIncomingQuestionMailIsSentToPrivatePractitioner.

@Test
public void testSendMailForIncomingQuestionMailIsSentToPrivatePractitioner() throws Exception {
    // Given
    HoSPersonType hoSPersonType = new HoSPersonType();
    EnhetType enhet = new EnhetType();
    String epost = "test@test.se";
    enhet.setEpost(epost);
    enhet.setEnhetsnamn("TestEnhet");
    hoSPersonType.setEnhet(enhet);
    doReturn(hoSPersonType).when(ppService).getPrivatePractitioner(anyString(), isNull(), isNull());
    MailNotification mailNotification = mailNotification("intygsId", MailNotificationServiceImpl.PRIVATE_PRACTITIONER_HSAID_PREFIX + "1234");
    // When
    mailNotificationService.sendMailForIncomingQuestion(mailNotification);
    // Then
    verify(mailSender, times(1)).send(mimeCaptor.capture());
    MimeMessage mimeMessage = mimeCaptor.getValue();
    Address[] allRecipients = mimeMessage.getAllRecipients();
    assertEquals(1, allRecipients.length);
    assertEquals(epost, allRecipients[0].toString());
}
Also used : Address(javax.mail.Address) MimeMessage(javax.mail.internet.MimeMessage) HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) EnhetType(se.riv.infrastructure.directory.privatepractitioner.v1.EnhetType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

HoSPersonType (se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType)16 Test (org.junit.Test)9 EnhetType (se.riv.infrastructure.directory.privatepractitioner.v1.EnhetType)6 ArrayList (java.util.ArrayList)3 GetPrivatePractitionerResponseType (se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerResponseType)3 Address (javax.mail.Address)2 MimeMessage (javax.mail.internet.MimeMessage)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Personnummer (se.inera.intyg.schemas.contract.Personnummer)2 ObjectCreator (se.inera.intyg.webcert.integration.pp.util.ObjectCreator)2 ValidatePrivatePractitionerResponseType (se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType)2 MessagingException (javax.mail.MessagingException)1 WebServiceException (javax.xml.ws.WebServiceException)1 MailSendException (org.springframework.mail.MailSendException)1 HsaServiceCallException (se.inera.intyg.infra.integration.hsa.exception.HsaServiceCallException)1 Role (se.inera.intyg.infra.security.common.model.Role)1 GetPrivatePractitionerType (se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerType)1 HsaId (se.riv.infrastructure.directory.privatepractitioner.types.v1.HsaId)1 PersonId (se.riv.infrastructure.directory.privatepractitioner.types.v1.PersonId)1