Search in sources :

Example 1 with CachedPatient

use of org.karnak.backend.cache.CachedPatient in project karnak by OsiriX-Foundation.

the class CSVDialog method readCSVPatients.

private void readCSVPatients() {
    try {
        // Read CSV line by line and use the string array as you want
        for (String[] row : allRows.subList(fromLineField.getValue().intValue() - 1, allRows.size())) {
            String issuerOfPatientID = selectValuesPositionHashMap.get(ISSUER_OF_PATIENT_ID).equals(-1) ? "" : row[selectValuesPositionHashMap.get(ISSUER_OF_PATIENT_ID)];
            final CachedPatient newPatient = new CachedPatient(row[selectValuesPositionHashMap.get(EXTERNAL_PSEUDONYM)], row[selectValuesPositionHashMap.get(PATIENT_ID)], row[selectValuesPositionHashMap.get(PATIENT_FIRST_NAME)], row[selectValuesPositionHashMap.get(PATIENT_LAST_NAME)], issuerOfPatientID, projectEntity.getId());
            patientsList.add(newPatient);
        }
    } catch (Exception e) {
        LOGGER.error("Error when reading selected columns", e);
    }
}
Also used : CachedPatient(org.karnak.backend.cache.CachedPatient) IOException(java.io.IOException)

Example 2 with CachedPatient

use of org.karnak.backend.cache.CachedPatient in project karnak by OsiriX-Foundation.

the class ExternalIDForm method getNewPatient.

public CachedPatient getNewPatient() {
    CachedPatient newPatient = new CachedPatient(externalIdField.getValue(), patientIdField.getValue(), patientFirstNameField.getValue(), patientLastNameField.getValue(), issuerOfPatientIdField.getValue(), projectEntity.getId());
    binder.validate();
    if (binder.isValid()) {
        binder.readBean(null);
        return newPatient;
    }
    return null;
}
Also used : CachedPatient(org.karnak.backend.cache.CachedPatient)

Example 3 with CachedPatient

use of org.karnak.backend.cache.CachedPatient in project karnak by OsiriX-Foundation.

the class ExternalIDGrid method readAllCacheValue.

public void readAllCacheValue() {
    if (externalIDCache != null) {
        Collection<PseudonymPatient> pseudonymPatients = externalIDCache.getAll();
        patientsListInCache = new ArrayList<>();
        for (Iterator<PseudonymPatient> iterator = pseudonymPatients.iterator(); iterator.hasNext(); ) {
            final CachedPatient patient = (CachedPatient) iterator.next();
            if (projectEntity != null && patient.getProjectID() != null && patient.getProjectID().equals(projectEntity.getId())) {
                patientsListInCache.add(patient);
            }
        }
        setItems(patientsListInCache);
    }
    refreshPaginator();
}
Also used : CachedPatient(org.karnak.backend.cache.CachedPatient) PseudonymPatient(org.karnak.backend.cache.PseudonymPatient)

Example 4 with CachedPatient

use of org.karnak.backend.cache.CachedPatient in project karnak by OsiriX-Foundation.

the class ExternalIDGridTest method should_add_patient_and_check_existence.

@Test
void should_add_patient_and_check_existence() {
    // Call constructor
    ExternalIDGrid externalIDGrid = new ExternalIDGrid();
    // Add patient
    CachedPatient patient = new CachedPatient("pseudonym", "patientId", "patientFirstName", "patientLastName", "issuerOfPatientId", 1L);
    patient.setProjectID(1L);
    // set project
    ProjectEntity projectEntity = new ProjectEntity();
    projectEntity.setId(1L);
    externalIDGrid.setProjectEntity(projectEntity);
    // Test no patient in cache
    assertFalse(externalIDGrid.patientExist(patient));
    // Add patient
    externalIDGrid.addPatient(patient);
    // Test patient in cache
    assertTrue(externalIDGrid.patientExist(patient));
}
Also used : CachedPatient(org.karnak.backend.cache.CachedPatient) ProjectEntity(org.karnak.backend.data.entity.ProjectEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with CachedPatient

use of org.karnak.backend.cache.CachedPatient in project karnak by OsiriX-Foundation.

the class MappingResultComponentTest method should_handle_result_patient_found.

@Test
void should_handle_result_patient_found() {
    // Init data
    Patient patient = new CachedPatient("pseudonym", "patientId", "patientFirstName", "patientLastName", "issuerOfPatientId", 1L);
    // Call method
    MappingResultComponent mappingResultComponent = new MappingResultComponent();
    mappingResultComponent.handleResultFindPatient(patient, "PSEUDO", "Cache");
    // Test results
    assertEquals("Cache", mappingResultComponent.getPatientFoundDetails().getSummaryText());
    assertNotNull(mappingResultComponent.getPatientFoundDetails().getContent());
}
Also used : CachedPatient(org.karnak.backend.cache.CachedPatient) CachedPatient(org.karnak.backend.cache.CachedPatient) Patient(org.karnak.backend.cache.Patient) Test(org.junit.jupiter.api.Test)

Aggregations

CachedPatient (org.karnak.backend.cache.CachedPatient)9 ProjectEntity (org.karnak.backend.data.entity.ProjectEntity)5 PseudonymPatient (org.karnak.backend.cache.PseudonymPatient)4 Test (org.junit.jupiter.api.Test)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ExternalIDCache (org.karnak.backend.cache.ExternalIDCache)2 Patient (org.karnak.backend.cache.Patient)2 PatientClient (org.karnak.backend.cache.PatientClient)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Button (com.vaadin.flow.component.button.Button)1 ButtonVariant (com.vaadin.flow.component.button.ButtonVariant)1 Grid (com.vaadin.flow.component.grid.Grid)1 HeaderRow (com.vaadin.flow.component.grid.HeaderRow)1 Editor (com.vaadin.flow.component.grid.editor.Editor)1 Div (com.vaadin.flow.component.html.Div)1 TextField (com.vaadin.flow.component.textfield.TextField)1 Binder (com.vaadin.flow.data.binder.Binder)1 StringLengthValidator (com.vaadin.flow.data.validator.StringLengthValidator)1