Search in sources :

Example 11 with GrundData

use of se.inera.intyg.common.support.model.common.internal.GrundData 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)

Example 12 with GrundData

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

the class IntygModuleApiControllerTest method setupCertificateData.

@BeforeClass
public static void setupCertificateData() {
    utlatande = new Fk7263Utlatande();
    utlatande.setId(CERTIFICATE_ID);
    utlatande.setTyp(CERTIFICATE_TYPE);
    GrundData grundData = new GrundData();
    patient = new Patient();
    patient.setPersonId(createPnr(PERSON_ID));
    patient.setFornamn("Fornamn");
    patient.setEfternamn("Efternamn");
    grundData.setPatient(patient);
    utlatande.setGrundData(grundData);
    List<Status> status = new ArrayList<>();
    status.add(new Status(CertificateState.RECEIVED, "HSVARD", LocalDateTime.now()));
    status.add(new Status(CertificateState.SENT, "FKASSA", LocalDateTime.now()));
}
Also used : Status(se.inera.intyg.common.support.model.Status) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) ArrayList(java.util.ArrayList) Patient(se.inera.intyg.common.support.model.common.internal.Patient) GrundData(se.inera.intyg.common.support.model.common.internal.GrundData) BeforeClass(org.junit.BeforeClass)

Example 13 with GrundData

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

the class SignaturServiceImplTest method setup.

@Before
public void setup() throws Exception {
    hoSPerson = new HoSPersonal();
    hoSPerson.setPersonId("AAA");
    hoSPerson.setFullstandigtNamn("Dr Dengroth");
    VardpersonReferens vardperson = new VardpersonReferens();
    vardperson.setHsaId(hoSPerson.getPersonId());
    vardperson.setNamn(hoSPerson.getFullstandigtNamn());
    utkast = createUtkast(INTYG_ID, 1, INTYG_TYPE, UtkastStatus.DRAFT_INCOMPLETE, INTYG_JSON, vardperson, ENHET_ID, PERSON_ID);
    completedUtkast = createUtkast(INTYG_ID, 2, INTYG_TYPE, UtkastStatus.DRAFT_COMPLETE, INTYG_JSON, vardperson, ENHET_ID, PERSON_ID);
    signedUtkast = createUtkast(INTYG_ID, 3, INTYG_TYPE, UtkastStatus.SIGNED, INTYG_JSON, vardperson, ENHET_ID, PERSON_ID);
    vardenhet = new Vardenhet(ENHET_ID, "testNamn");
    vardgivare = new Vardgivare("123", "vardgivare");
    vardgivare.setVardenheter(Collections.singletonList(vardenhet));
    user = createWebCertUser(true);
    when(webcertUserService.getUser()).thenReturn(user);
    when(moduleRegistry.getModuleApi(any())).thenReturn(moduleApi);
    when(moduleApi.updateBeforeSigning(any(), any(), any())).thenReturn(INTYG_JSON);
    Utlatande utlatande = mock(Utlatande.class);
    GrundData grunddata = new GrundData();
    grunddata.setSkapadAv(new HoSPersonal());
    when(utlatande.getGrundData()).thenReturn(grunddata);
    when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
    setTypedField(intygSignatureService, new SignaturTicketTracker());
    pagaendeSignering = mock(PagaendeSignering.class);
    when(pagaendeSignering.getInternReferens()).thenReturn(PAGAENDE_SIGN_ID);
    when(pagaendeSignering.getIntygData()).thenReturn(INTYG_JSON);
    when(pagaendeSignering.getIntygsId()).thenReturn(INTYG_ID);
    when(pagaendeSignering.getSigneradAvHsaId()).thenReturn(hoSPerson.getPersonId());
    when(pagaendeSignering.getSigneradAvNamn()).thenReturn(hoSPerson.getFullstandigtNamn());
    when(pagaendeSigneringRepository.findOne(any())).thenReturn(pagaendeSignering);
    when(pagaendeSigneringRepository.save(any(PagaendeSignering.class))).thenReturn(pagaendeSignering);
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) GrundData(se.inera.intyg.common.support.model.common.internal.GrundData) PagaendeSignering(se.inera.intyg.webcert.persistence.utkast.model.PagaendeSignering) Vardenhet(se.inera.intyg.infra.integration.hsa.model.Vardenhet) Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) Before(org.junit.Before)

Aggregations

GrundData (se.inera.intyg.common.support.model.common.internal.GrundData)13 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)11 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)10 Test (org.junit.Test)9 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)9 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)8 Personnummer (se.inera.intyg.schemas.contract.Personnummer)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Patient (se.inera.intyg.common.support.model.common.internal.Patient)4 ValidateDraftResponse (se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)4 UpdatePatientOnDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.UpdatePatientOnDraftRequest)4 ValidationMessage (se.inera.intyg.common.support.modules.support.api.dto.ValidationMessage)2 SaveDraftResponse (se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)1 Status (se.inera.intyg.common.support.model.Status)1 Relation (se.inera.intyg.common.support.model.common.internal.Relation)1