Search in sources :

Example 26 with HoSPersonal

use of se.inera.intyg.common.support.model.common.internal.HoSPersonal in project webcert by sklintyg.

the class UtkastIntygDecoratorTest method setup.

@Before
public void setup() {
    HoSPersonal person = buildHosPerson();
    VardpersonReferens vardperson = buildVardpersonReferens(person);
    signedUtkast = buildUtkast(INTYG_ID, INTYG_TYPE, UtkastStatus.SIGNED, INTYG_JSON, vardperson);
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) Before(org.junit.Before)

Example 27 with HoSPersonal

use of se.inera.intyg.common.support.model.common.internal.HoSPersonal in project webcert by sklintyg.

the class UtkastIntygDecoratorTest method buildHosPerson.

private HoSPersonal buildHosPerson() {
    HoSPersonal person = new HoSPersonal();
    person.setPersonId("AAA");
    person.setFullstandigtNamn("Dr Dengroth");
    return person;
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal)

Example 28 with HoSPersonal

use of se.inera.intyg.common.support.model.common.internal.HoSPersonal in project webcert by sklintyg.

the class UtkastServiceImplTest method testUpdatePatientOnDraft.

@Test
public void testUpdatePatientOnDraft() throws Exception {
    utkast.setEnhetsId(UTKAST_ENHETS_ID);
    Patient newPatient = getUpdatedPatient();
    UpdatePatientOnDraftRequest request = new UpdatePatientOnDraftRequest(newPatient.getPersonId(), utkast.getIntygsId(), utkast.getVersion());
    WebCertUser user = createUser();
    Utlatande utlatande = mock(Utlatande.class);
    GrundData grunddata = new GrundData();
    grunddata.setPatient(defaultPatient);
    grunddata.setSkapadAv(new HoSPersonal());
    String expectedPatientId = defaultPatient.getPersonId().getPersonnummer();
    when(utlatande.getGrundData()).thenReturn(grunddata);
    // Make a spy out of the utkast so we can verify invocations on the setters with proper names further down.
    utkast = spy(utkast);
    when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(utkast);
    when(moduleRegistry.getModuleApi(INTYG_TYPE)).thenReturn(mockModuleApi);
    when(mockModuleApi.updateBeforeSave(anyString(), any(Patient.class))).thenReturn("{}");
    when(mockModuleApi.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
    when(mockUtkastRepository.save(utkast)).thenReturn(utkast);
    when(userService.getUser()).thenReturn(user);
    when(mockModuleApi.updateBeforeSave(anyString(), any(HoSPersonal.class))).thenReturn("{}");
    draftService.updatePatientOnDraft(request);
    verify(mockUtkastRepository).save(any(Utkast.class));
    verify(notificationService).sendNotificationForDraftChanged(any(Utkast.class));
    verify(utkast).setPatientPersonnummer(any(Personnummer.class));
    assertEquals(expectedPatientId, user.getParameters().getBeforeAlternateSsn());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Patient(se.inera.intyg.common.support.model.common.internal.Patient) GrundData(se.inera.intyg.common.support.model.common.internal.GrundData) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) UpdatePatientOnDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.UpdatePatientOnDraftRequest) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 29 with HoSPersonal

use of se.inera.intyg.common.support.model.common.internal.HoSPersonal in project webcert by sklintyg.

the class UtkastServiceImplTest method setup.

@Before
public void setup() {
    hoSPerson = new HoSPersonal();
    hoSPerson.setPersonId("AAA");
    hoSPerson.setFullstandigtNamn("Dr Dengroth");
    hoSPerson.getBefattningar().add("Befattning");
    hoSPerson.getSpecialiteter().add("Ortoped");
    defaultPatient = new Patient();
    defaultPatient.setPersonId(PERSONNUMMER);
    defaultPatient.setFornamn("fornamn");
    defaultPatient.setMellannamn("mellannamn");
    defaultPatient.setPostadress("pa1");
    defaultPatient.setPostnummer("0000");
    defaultPatient.setPostort("ort");
    se.inera.intyg.common.support.model.common.internal.Vardgivare vardgivare = new se.inera.intyg.common.support.model.common.internal.Vardgivare();
    vardgivare.setVardgivarid("SE234234");
    vardgivare.setVardgivarnamn("Vårdgivaren");
    se.inera.intyg.common.support.model.common.internal.Vardenhet vardenhet = new se.inera.intyg.common.support.model.common.internal.Vardenhet();
    vardenhet.setArbetsplatsKod("00000");
    vardenhet.setEnhetsnamn("Vårdenheten");
    vardenhet.setEnhetsid("SE234897348");
    vardenhet.setPostadress("Sjukvägen 1");
    vardenhet.setPostnummer("12345");
    vardenhet.setPostort("Testberga");
    vardenhet.setTelefonnummer("0123-456789");
    vardenhet.setEpost("ingen@ingen.se");
    vardenhet.setVardgivare(vardgivare);
    VardpersonReferens vardperson = new VardpersonReferens();
    vardperson.setHsaId(hoSPerson.getPersonId());
    vardperson.setNamn(hoSPerson.getFullstandigtNamn());
    hoSPerson.setVardenhet(vardenhet);
    utkast = createUtkast(INTYG_ID, UTKAST_VERSION, INTYG_TYPE, UtkastStatus.DRAFT_INCOMPLETE, INTYG_JSON, vardperson, PERSONNUMMER);
    signedUtkast = createUtkast(INTYG_ID, INTYG_VERSION, INTYG_TYPE, UtkastStatus.SIGNED, INTYG_JSON, vardperson, PERSONNUMMER);
}
Also used : Patient(se.inera.intyg.common.support.model.common.internal.Patient) Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) Vardenhet(se.inera.intyg.infra.integration.hsa.model.Vardenhet) HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) ValidateDraftResponse(se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse) SaveDraftResponse(se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) Before(org.junit.Before)

Example 30 with HoSPersonal

use of se.inera.intyg.common.support.model.common.internal.HoSPersonal in project webcert by sklintyg.

the class UtkastServiceImplTest method testUpdatePatientOnDraftEmptyPatientId.

@Test
public void testUpdatePatientOnDraftEmptyPatientId() throws Exception {
    utkast.setEnhetsId(UTKAST_ENHETS_ID);
    UpdatePatientOnDraftRequest request = new UpdatePatientOnDraftRequest(null, utkast.getIntygsId(), utkast.getVersion());
    WebCertUser user = createUser();
    Utlatande utlatande = mock(Utlatande.class);
    GrundData grunddata = new GrundData();
    grunddata.setPatient(defaultPatient);
    grunddata.setSkapadAv(new HoSPersonal());
    when(utlatande.getGrundData()).thenReturn(grunddata);
    // Make a spy out of the utkast so we can verify invocations on the setters with proper names further down.
    utkast = spy(utkast);
    when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(utkast);
    when(moduleRegistry.getModuleApi(INTYG_TYPE)).thenReturn(mockModuleApi);
    when(mockModuleApi.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
    when(userService.getUser()).thenReturn(user);
    draftService.updatePatientOnDraft(request);
    verify(mockUtkastRepository, never()).save(any(Utkast.class));
    verify(notificationService, never()).sendNotificationForDraftChanged(any(Utkast.class));
    verify(utkast, never()).setPatientPersonnummer(any(Personnummer.class));
    assertEquals(defaultPatient.getPersonId().getPersonnummer(), user.getParameters().getBeforeAlternateSsn());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) GrundData(se.inera.intyg.common.support.model.common.internal.GrundData) UpdatePatientOnDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.UpdatePatientOnDraftRequest) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Aggregations

HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)38 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)15 Test (org.junit.Test)13 Patient (se.inera.intyg.common.support.model.common.internal.Patient)11 GrundData (se.inera.intyg.common.support.model.common.internal.GrundData)10 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)10 Before (org.junit.Before)8 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)7 Vardenhet (se.inera.intyg.common.support.model.common.internal.Vardenhet)5 Vardgivare (se.inera.intyg.common.support.model.common.internal.Vardgivare)5 ValidateDraftResponse (se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)5 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)5 Personnummer (se.inera.intyg.schemas.contract.Personnummer)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)4 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)4 CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)4 UpdatePatientOnDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.UpdatePatientOnDraftRequest)4 AbstractVardenhet (se.inera.intyg.infra.integration.hsa.model.AbstractVardenhet)3 SaveDraftResponse (se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse)3