use of org.openmrs.module.paperrecord.PaperRecord 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.PaperRecord in project openmrs-module-mirebalais by PIH.
the class RequestRecordPageController method controller.
public void controller(@RequestParam("patientId") Patient patient, // hack to redirect back to the patient registration emergency workflow if that is where we've come from
@RequestParam(value = "redirectToEmergency", required = false) Boolean redirectToEmergency, @SpringBean("paperRecordService") PaperRecordService paperRecordService, PageModel pageModel, UiSessionContext uiSessionContext) {
Location currentLocation = uiSessionContext.getSessionLocation();
List<PaperRecord> paperRecords = paperRecordService.getPaperRecords(patient, currentLocation);
// only show the create paper record dialog if the patient does *not* have an existing record that is in some other state than pending creation
// and we are not currently at an archives location
boolean needToCreateRecord = !currentLocation.hasTag(PaperRecordConstants.LOCATION_TAG_ARCHIVES_LOCATION) && (paperRecords == null || paperRecords.size() == 0 || !CollectionUtils.exists(paperRecords, ANY_NOT_PENDING_CREATION));
pageModel.addAttribute("patient", patient);
pageModel.addAttribute("needToCreateRecord", needToCreateRecord);
pageModel.addAttribute("redirectToEmergency", redirectToEmergency);
if (needToCreateRecord) {
pageModel.addAttribute("associatedArchivesLocation", paperRecordService.getArchivesLocationAssociatedWith(currentLocation));
}
}
Aggregations