Search in sources :

Example 1 with PaperRecordServiceImpl

use of org.openmrs.module.paperrecord.PaperRecordServiceImpl in project openmrs-module-mirebalais by PIH.

the class PaperRecordServiceIT method shouldCreateTwoDifferentDossierNumbers.

@Test
@DirtiesContext
public void shouldCreateTwoDifferentDossierNumbers() throws Exception {
    authenticate();
    PatientIdentifierType patientIdentifierType = Context.getPatientService().getPatientIdentifierTypeByUuid("e66645eb-03a8-4991-b4ce-e87318e37566");
    when(paperRecordProperties.getPaperRecordIdentifierType()).thenReturn(patientIdentifierType);
    Location location = new Location(15);
    LocationTag locationTag = new LocationTag(15);
    locationTag.setName("tag");
    location.addTag(locationTag);
    when(paperRecordProperties.getMedicalRecordLocationLocationTag()).thenReturn(locationTag);
    PaperRecord paperRecord1 = ((PaperRecordServiceImpl) paperRecordService).createPaperRecord(new Patient(), location);
    assertTrue(paperRecord1.getPatientIdentifier().getIdentifier().matches("A\\d{6}"));
    PaperRecord paperRecord2 = ((PaperRecordServiceImpl) paperRecordService).createPaperRecord(new Patient(), location);
    assertTrue(paperRecord2.getPatientIdentifier().getIdentifier().matches("A\\d{6}"));
    assertThat(paperRecord1.getPatientIdentifier().getIdentifier(), not(paperRecord2.getPatientIdentifier().getIdentifier()));
}
Also used : LocationTag(org.openmrs.LocationTag) PaperRecord(org.openmrs.module.paperrecord.PaperRecord) Patient(org.openmrs.Patient) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location) PaperRecordServiceImpl(org.openmrs.module.paperrecord.PaperRecordServiceImpl) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 2 with PaperRecordServiceImpl

use of org.openmrs.module.paperrecord.PaperRecordServiceImpl in project openmrs-module-mirebalais by PIH.

the class PaperRecordServiceIT method setUp.

@Before
public void setUp() {
    paperRecordService = new PaperRecordServiceImpl();
    patientService = mock(PatientService.class);
    administrationService = mock(AdministrationService.class);
    paperRecordProperties = mock(PaperRecordProperties.class);
    paperRecordDAO = mock(PaperRecordDAO.class);
    ((PaperRecordServiceImpl) paperRecordService).setIdentifierSourceService(identifierSourceService);
    ((PaperRecordServiceImpl) paperRecordService).setPatientService(patientService);
    ((PaperRecordServiceImpl) paperRecordService).setPaperRecordProperties(paperRecordProperties);
    ((PaperRecordServiceImpl) paperRecordService).setPaperRecordDAO(paperRecordDAO);
    // so we handle the hack in PaperRecordServiceImpl where internal methods are fetched via Context.getService
    mockStatic(Context.class);
    when(Context.getService(PaperRecordService.class)).thenReturn(paperRecordService);
}
Also used : PaperRecordDAO(org.openmrs.module.paperrecord.db.PaperRecordDAO) AdministrationService(org.openmrs.api.AdministrationService) PatientService(org.openmrs.api.PatientService) PaperRecordProperties(org.openmrs.module.paperrecord.PaperRecordProperties) PaperRecordServiceImpl(org.openmrs.module.paperrecord.PaperRecordServiceImpl) Before(org.junit.Before)

Aggregations

PaperRecordServiceImpl (org.openmrs.module.paperrecord.PaperRecordServiceImpl)2 Before (org.junit.Before)1 Test (org.junit.Test)1 Location (org.openmrs.Location)1 LocationTag (org.openmrs.LocationTag)1 Patient (org.openmrs.Patient)1 PatientIdentifierType (org.openmrs.PatientIdentifierType)1 AdministrationService (org.openmrs.api.AdministrationService)1 PatientService (org.openmrs.api.PatientService)1 PaperRecord (org.openmrs.module.paperrecord.PaperRecord)1 PaperRecordProperties (org.openmrs.module.paperrecord.PaperRecordProperties)1 PaperRecordDAO (org.openmrs.module.paperrecord.db.PaperRecordDAO)1 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 DirtiesContext (org.springframework.test.annotation.DirtiesContext)1