Search in sources :

Example 1 with GetPrivatePractitionerResponseType

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

the class GetPrivatePractitionerResponderStub method getGetPrivatePractitionerResponseTypeForPnr.

private GetPrivatePractitionerResponseType getGetPrivatePractitionerResponseTypeForPnr(GetPrivatePractitionerType parameters) {
    String id = parameters.getPersonalIdentityNumber();
    Personnummer personnummer = Personnummer.createPersonnummer(id).orElse(null);
    GetPrivatePractitionerResponseType response = new GetPrivatePractitionerResponseType();
    // if matching -- create error response
    if (PERSONNUMMER_ERROR_RESPONSE.equals(id)) {
        response.setHoSPerson(null);
        response.setResultCode(ResultCodeEnum.ERROR);
        response.setResultText("FAILURE: an error occured while trying to get private practitioner with personal identity number: " + Personnummer.getPersonnummerHashSafe(personnummer) + " exists.");
        return response;
    }
    // if matching -- throw exception
    if (PERSONNUMMER_THROW_EXCEPTION.equals(id)) {
        throw new SOAPFaultException(createSOAPFault());
    }
    HoSPersonType person = personStub.get(id);
    if (person == null) {
        response.setResultCode(ResultCodeEnum.INFO);
        response.setResultText("No private practitioner with personal identity number: " + Personnummer.getPersonnummerHashSafe(personnummer) + " exists.");
    } else {
        response.setHoSPerson(person);
        response.setResultCode(ResultCodeEnum.OK);
    }
    return response;
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) GetPrivatePractitionerResponseType(se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerResponseType) HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException)

Example 2 with GetPrivatePractitionerResponseType

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

the class GetPrivatePractitionerResponderStub method getGetPrivatePractitionerResponseTypeForHsaid.

private GetPrivatePractitionerResponseType getGetPrivatePractitionerResponseTypeForHsaid(GetPrivatePractitionerType parameters) {
    String hsa = parameters.getPersonHsaId();
    GetPrivatePractitionerResponseType response = new GetPrivatePractitionerResponseType();
    // if matching -- create error response
    if (PERSONNUMMER_ERROR_RESPONSE.equals(hsa)) {
        response.setHoSPerson(null);
        response.setResultCode(ResultCodeEnum.ERROR);
        response.setResultText("FAILURE: an error occured while trying to get private practitioner with hsa id: " + hsa + " exists.");
        return response;
    }
    // if matching -- throw exception
    if (PERSONNUMMER_THROW_EXCEPTION.equals(hsa)) {
        throw new SOAPFaultException(createSOAPFault());
    }
    HoSPersonType person = personStub.getByHsaId(hsa);
    if (person == null) {
        response.setResultCode(ResultCodeEnum.INFO);
        response.setResultText("No private practitioner with hsa id: " + hsa + " exists.");
    } else {
        response.setHoSPerson(person);
        response.setResultCode(ResultCodeEnum.OK);
    }
    return response;
}
Also used : GetPrivatePractitionerResponseType(se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerResponseType) HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException)

Example 3 with GetPrivatePractitionerResponseType

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

the class GetPrivatePractitionerResponderTest method verifyExistingPerson.

@Test
public void verifyExistingPerson() {
    // Given
    ObjectCreator objectCreator = new ObjectCreator();
    HoSPersonType hoSPersonType = objectCreator.getHoSPersonType();
    GetPrivatePractitionerType request = defaultRequest();
    GetPrivatePractitionerResponseType expected = new GetPrivatePractitionerResponseType();
    expected.setResultCode(ResultCodeEnum.OK);
    expected.setHoSPerson(hoSPersonType);
    // When
    when(personStub.get(PERSONNUMMER)).thenReturn(hoSPersonType);
    // Call web service
    GetPrivatePractitionerResponseType actual = ws.getPrivatePractitioner("address", request);
    // Then
    assertTrue(ResultCodeEnum.OK == actual.getResultCode());
    assertEquals(HSAID, actual.getHoSPerson().getHsaId().getExtension());
    assertEquals(PERSONNUMMER, actual.getHoSPerson().getPersonId().getExtension());
    verify(personStub, times(1)).get(PERSONNUMMER);
}
Also used : GetPrivatePractitionerResponseType(se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerResponseType) HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) GetPrivatePractitionerType(se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerType) ObjectCreator(se.inera.intyg.webcert.integration.pp.util.ObjectCreator) Test(org.junit.Test)

Example 4 with GetPrivatePractitionerResponseType

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

the class GetPrivatePractitionerResponderTest method verifyNonExistingPerson.

@Test
public void verifyNonExistingPerson() {
    // Given
    GetPrivatePractitionerType request = defaultRequest();
    request.setPersonalIdentityNumber("1901010101-0101");
    // When
    when(personStub.get("1901010101-0101")).thenReturn(null);
    // Call web service
    GetPrivatePractitionerResponseType actual = ws.getPrivatePractitioner("address", request);
    // Then
    assertTrue(ResultCodeEnum.INFO == actual.getResultCode());
    assertNull(actual.getHoSPerson());
    verify(personStub, times(1)).get("1901010101-0101");
}
Also used : GetPrivatePractitionerResponseType(se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerResponseType) GetPrivatePractitionerType(se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerType) Test(org.junit.Test)

Aggregations

GetPrivatePractitionerResponseType (se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerResponseType)4 HoSPersonType (se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 Test (org.junit.Test)2 GetPrivatePractitionerType (se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerType)2 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1 ObjectCreator (se.inera.intyg.webcert.integration.pp.util.ObjectCreator)1