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