Search in sources :

Example 1 with PaperRecord

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

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));
    }
}
Also used : PaperRecord(org.openmrs.module.paperrecord.PaperRecord) Location(org.openmrs.Location)

Aggregations

Location (org.openmrs.Location)2 PaperRecord (org.openmrs.module.paperrecord.PaperRecord)2 Test (org.junit.Test)1 LocationTag (org.openmrs.LocationTag)1 Patient (org.openmrs.Patient)1 PatientIdentifierType (org.openmrs.PatientIdentifierType)1 PaperRecordServiceImpl (org.openmrs.module.paperrecord.PaperRecordServiceImpl)1 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 DirtiesContext (org.springframework.test.annotation.DirtiesContext)1