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