Search in sources :

Example 26 with ProfileElementEntity

use of org.karnak.backend.data.entity.ProfileElementEntity in project karnak by OsiriX-Foundation.

the class ProfileTest method propagationInSequence3.

@Test
void propagationInSequence3() {
    final Attributes dataset1 = new Attributes();
    final Attributes dataset2 = new Attributes();
    dataset1.setString(Tag.StudyInstanceUID, VR.UI, "12345");
    dataset1.setString(Tag.PatientID, VR.LO, "10987654321");
    dataset1.setString(Tag.PatientName, VR.PN, "toto");
    dataset1.setString(Tag.PatientBirthDate, VR.DA, "20200101");
    dataset1.setString(Tag.PatientSex, VR.CS, "M");
    dataset1.setString(Tag.IssuerOfPatientID, VR.LO, "12345678910");
    dataset1.setString(Tag.PatientAge, VR.AS, "075Y");
    Sequence dicomElemSeq1 = dataset1.newSequence(Tag.CTExposureSequence, 1);
    final Attributes datasetSeq1 = new Attributes();
    datasetSeq1.setDouble(Tag.EstimatedDoseSaving, VR.FD, 0d);
    datasetSeq1.setDouble(Tag.ExposureTimeInms, VR.FD, 2.099d);
    datasetSeq1.setDouble(Tag.XRayTubeCurrentInmA, VR.FD, 381d);
    datasetSeq1.setDouble(Tag.ExposureInmAs, VR.FD, 800d);
    datasetSeq1.setDouble(Tag.CTDIvol, VR.FD, 47d);
    dicomElemSeq1.add(datasetSeq1);
    dataset2.setString(Tag.StudyInstanceUID, VR.UI, "12345");
    dataset2.setString(Tag.PatientID, VR.LO, "10987654321");
    dataset2.setString(Tag.PatientName, VR.PN, "toto");
    dataset2.setString(Tag.PatientBirthDate, VR.DA, "20190101");
    dataset2.setString(Tag.PatientSex, VR.CS, "M");
    dataset2.setString(Tag.IssuerOfPatientID, VR.LO, "12345678910");
    dataset2.setString(Tag.PatientAge, VR.AS, "076Y");
    Sequence dicomElemSeq2 = dataset2.newSequence(Tag.CTExposureSequence, 1);
    final Attributes datasetSeq2 = new Attributes();
    datasetSeq2.setDouble(Tag.EstimatedDoseSaving, VR.FD, 0d);
    datasetSeq2.remove(Tag.EstimatedDoseSaving);
    datasetSeq2.setDouble(Tag.ExposureTimeInms, VR.FD, 2.099d);
    datasetSeq2.setDouble(Tag.XRayTubeCurrentInmA, VR.FD, 381d);
    datasetSeq2.setDouble(Tag.ExposureInmAs, VR.FD, 800d);
    datasetSeq2.setDouble(Tag.CTDIvol, VR.FD, 47d);
    dicomElemSeq2.add(datasetSeq2);
    final ProfileEntity profileEntity = new ProfileEntity("TEST", "0.9.1", "0.9.1", "DPA");
    final ProfileElementEntity profileElementEntity1 = new ProfileElementEntity("Shift Date with argumentEntities", "action.on.dates", null, null, "shift", 0, profileEntity);
    profileElementEntity1.addIncludedTag(new IncludedTagEntity("(xxxx,xxxx)", profileElementEntity1));
    profileElementEntity1.addArgument(new ArgumentEntity("seconds", "60", profileElementEntity1));
    profileElementEntity1.addArgument(new ArgumentEntity("days", "365", profileElementEntity1));
    final ProfileElementEntity profileElementEntity2 = new ProfileElementEntity("Remove tag", "action.on.specific.tags", null, "X", null, 1, profileEntity);
    profileElementEntity2.addIncludedTag(new IncludedTagEntity("(0018,9324)", profileElementEntity2));
    final ProfileElementEntity profileElementEntity3 = new ProfileElementEntity("Keep tag", "action.on.specific.tags", null, "K", null, 2, profileEntity);
    profileElementEntity3.addIncludedTag(new IncludedTagEntity("(0018,9321)", profileElementEntity3));
    final ProfileElementEntity profileElementEntity4 = new ProfileElementEntity("Replace null", "action.on.specific.tags", null, "Z", null, 3, profileEntity);
    profileElementEntity4.addIncludedTag(new IncludedTagEntity("(0018,9330)", profileElementEntity2));
    profileEntity.addProfilePipe(profileElementEntity1);
    profileEntity.addProfilePipe(profileElementEntity2);
    profileEntity.addProfilePipe(profileElementEntity3);
    profileEntity.addProfilePipe(profileElementEntity4);
    Profile profile = new Profile(profileEntity);
    profile.applyAction(dataset1, dataset1, defaultHMAC, null, null, null);
    assertTrue(DicomObjectTools.dicomObjectEquals(dataset2, dataset1));
}
Also used : IncludedTagEntity(org.karnak.backend.data.entity.IncludedTagEntity) ArgumentEntity(org.karnak.backend.data.entity.ArgumentEntity) ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) Attributes(org.dcm4che3.data.Attributes) Sequence(org.dcm4che3.data.Sequence) ProfileEntity(org.karnak.backend.data.entity.ProfileEntity) Profile(org.karnak.backend.service.profilepipe.Profile) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 27 with ProfileElementEntity

use of org.karnak.backend.data.entity.ProfileElementEntity in project karnak by OsiriX-Foundation.

the class TagRepoTest method shouldFindAllRecords.

/**
 * Test find all.
 */
@Test
void shouldFindAllRecords() {
    // Create an entity to save
    // Profile
    ProfileEntity profileEntity = new ProfileEntity();
    profileEntity.setName("name");
    profileEntity = profileRepo.saveAndFlush(profileEntity);
    // Profile element
    ProfileElementEntity profileElementEntity = new ProfileElementEntity();
    profileElementEntity.setName("name");
    profileElementEntity.setProfileEntity(profileEntity);
    profileElementEntity = profileElementRepo.saveAndFlush(profileElementEntity);
    // IncludedTagEntity
    IncludedTagEntity entity = new IncludedTagEntity();
    entity.setTagValue("Name");
    entity.setProfileElementEntity(profileElementEntity);
    // Save the entity
    LOGGER.info("Saving entity with name [{}]", entity.getTagValue());
    repository.saveAndFlush(entity);
    // Find all
    List<TagEntity> all = repository.findAll();
    // Test find all
    assertNotNull(all);
    assertTrue(all.size() > 0);
    assertEquals(1, all.size());
    LOGGER.info("Number of entities found [{}]", all.size());
}
Also used : IncludedTagEntity(org.karnak.backend.data.entity.IncludedTagEntity) ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) IncludedTagEntity(org.karnak.backend.data.entity.IncludedTagEntity) TagEntity(org.karnak.backend.data.entity.TagEntity) ProfileEntity(org.karnak.backend.data.entity.ProfileEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 28 with ProfileElementEntity

use of org.karnak.backend.data.entity.ProfileElementEntity in project karnak by OsiriX-Foundation.

the class ProfileTest method should_evaluate_condition_clean_pixel_case_no_condition.

@Test
void should_evaluate_condition_clean_pixel_case_no_condition() {
    // Init data
    ProfileEntity profileEntity = new ProfileEntity();
    Attributes attributes = new Attributes();
    Set<ProfileElementEntity> profileElementEntities = new HashSet<>();
    ProfileElementEntity profileElementEntityCleanPixelData = new ProfileElementEntity();
    profileElementEntityCleanPixelData.setCodename("clean.pixel.data");
    profileElementEntityCleanPixelData.setName("nameCleanPixel");
    profileElementEntityCleanPixelData.setAction("ReplaceNull");
    profileElementEntityCleanPixelData.setCondition(null);
    profileElementEntities.add(profileElementEntityCleanPixelData);
    profileEntity.setProfileElementEntities(profileElementEntities);
    Profile profile = new Profile(profileEntity);
    // Evaluate condition
    boolean evaluation = profile.evaluateConditionCleanPixelData(attributes);
    // Test results
    assertTrue(evaluation);
}
Also used : ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) Attributes(org.dcm4che3.data.Attributes) ProfileEntity(org.karnak.backend.data.entity.ProfileEntity) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 29 with ProfileElementEntity

use of org.karnak.backend.data.entity.ProfileElementEntity in project karnak by OsiriX-Foundation.

the class ProfileTest method propagationInSequence1.

@Test
void propagationInSequence1() {
    final Attributes dataset1 = new Attributes();
    final Attributes dataset2 = new Attributes();
    dataset1.setString(Tag.PatientAge, VR.AS, "075Y");
    dataset1.setString(Tag.StudyInstanceUID, VR.UI, "12345");
    dataset1.setString(Tag.PatientID, VR.LO, "10987654321");
    dataset1.setString(Tag.PatientName, VR.PN, "toto");
    dataset1.setString(Tag.PatientBirthDate, VR.DA, "20200101");
    dataset1.setString(Tag.PatientSex, VR.CS, "M");
    dataset1.setString(Tag.IssuerOfPatientID, VR.LO, "12345678910");
    Sequence dicomElemSeq1 = dataset1.newSequence(Tag.GroupOfPatientsIdentificationSequence, 1);
    final Attributes datasetSeq1 = new Attributes();
    datasetSeq1.setString(Tag.PatientID, VR.LO, "12345");
    Sequence dicomElemSeq12 = datasetSeq1.newSequence(Tag.IssuerOfPatientIDQualifiersSequence, 1);
    final Attributes datasetSeq12 = new Attributes();
    datasetSeq12.setString(Tag.UniversalEntityID, VR.UT, "UT");
    dicomElemSeq12.add(datasetSeq12);
    dicomElemSeq1.add(datasetSeq1);
    dataset2.setString(Tag.PatientAge, VR.AS, "075Y");
    dataset2.setString(Tag.StudyInstanceUID, VR.UI, "12345");
    dataset2.setString(Tag.PatientID, VR.LO, "10987654321");
    dataset2.setString(Tag.PatientName, VR.PN, "toto");
    dataset2.setString(Tag.PatientBirthDate, VR.DA, "20200101");
    dataset2.setString(Tag.PatientSex, VR.CS, "M");
    dataset2.setString(Tag.IssuerOfPatientID, VR.LO, "12345678910");
    dataset2.remove(Tag.PatientAge);
    dataset2.remove(Tag.StudyInstanceUID);
    dataset2.remove(Tag.PatientID);
    dataset2.remove(Tag.PatientName);
    dataset2.remove(Tag.PatientBirthDate);
    dataset2.remove(Tag.PatientSex);
    dataset2.remove(Tag.IssuerOfPatientID);
    Sequence dicomElemSeq2 = dataset2.newSequence(Tag.GroupOfPatientsIdentificationSequence, 1);
    final Attributes datasetSeq2 = new Attributes();
    datasetSeq2.setString(Tag.PatientID, VR.LO, "12345");
    Sequence dicomElemSeq22 = datasetSeq2.newSequence(Tag.IssuerOfPatientIDQualifiersSequence, 1);
    final Attributes datasetSeq22 = new Attributes();
    datasetSeq22.setString(Tag.UniversalEntityID, VR.UT, "UT");
    dicomElemSeq22.add(datasetSeq22);
    dicomElemSeq2.add(datasetSeq2);
    final ProfileEntity profileEntity = new ProfileEntity("TEST", "0.9.1", "0.9.1", "DPA");
    final ProfileElementEntity profileElementEntity1 = new ProfileElementEntity("Remove tag", "action.on.specific.tags", null, "X", null, 0, profileEntity);
    profileElementEntity1.addIncludedTag(new IncludedTagEntity("(0010,1010)", profileElementEntity1));
    final ProfileElementEntity profileElementEntity2 = new ProfileElementEntity("Keep tag", "action.on.specific.tags", null, "K", null, 1, profileEntity);
    profileElementEntity2.addIncludedTag(new IncludedTagEntity("(0010,0027)", profileElementEntity2));
    final ProfileElementEntity profileElementEntity3 = new ProfileElementEntity("Remove tag", "action.on.specific.tags", null, "X", null, 2, profileEntity);
    profileElementEntity3.addIncludedTag(new IncludedTagEntity("(xxxx,xxxx)", profileElementEntity3));
    profileEntity.addProfilePipe(profileElementEntity1);
    profileEntity.addProfilePipe(profileElementEntity2);
    profileEntity.addProfilePipe(profileElementEntity3);
    Profile profile = new Profile(profileEntity);
    profile.applyAction(dataset1, dataset1, defaultHMAC, null, null, null);
    assertTrue(DicomObjectTools.dicomObjectEquals(dataset2, dataset1));
}
Also used : IncludedTagEntity(org.karnak.backend.data.entity.IncludedTagEntity) ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) Attributes(org.dcm4che3.data.Attributes) Sequence(org.dcm4che3.data.Sequence) ProfileEntity(org.karnak.backend.data.entity.ProfileEntity) Profile(org.karnak.backend.service.profilepipe.Profile) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 30 with ProfileElementEntity

use of org.karnak.backend.data.entity.ProfileElementEntity in project karnak by OsiriX-Foundation.

the class ProfileElementRepoTest method shouldModifyRecord.

/**
 * Test modification of a record.
 */
@Test
void shouldModifyRecord() {
    String initialText = "InitialText";
    String modifiedText = "ModifiedText";
    // Create an entity to save
    ProfileElementEntity entity = new ProfileElementEntity();
    entity.setName(initialText);
    // Save the entity
    LOGGER.info("Saving entity with name [{}]", entity.getName());
    entity = repository.save(entity);
    LOGGER.info("Id of the entity with name [{}]", entity.getId());
    // Test Save
    assertNotNull(entity);
    assertEquals(initialText, entity.getName());
    // Modify the record
    entity.setName(modifiedText);
    LOGGER.info("Modify entity name [{}] to [{}]", initialText, modifiedText);
    ProfileElementEntity entityModified = repository.save(entity);
    // Test Modify
    assertNotNull(entityModified);
    assertEquals(entity.getId(), entityModified.getId());
    assertEquals(modifiedText, entityModified.getName());
    LOGGER.info("Name of the entity with id [{}]: [{}]", entityModified.getId(), entityModified.getName());
}
Also used : ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Aggregations

ProfileElementEntity (org.karnak.backend.data.entity.ProfileElementEntity)31 Test (org.junit.jupiter.api.Test)24 ProfileEntity (org.karnak.backend.data.entity.ProfileEntity)24 Attributes (org.dcm4che3.data.Attributes)18 IncludedTagEntity (org.karnak.backend.data.entity.IncludedTagEntity)14 Profile (org.karnak.backend.service.profilepipe.Profile)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 HashSet (java.util.HashSet)7 Sequence (org.dcm4che3.data.Sequence)7 ArgumentEntity (org.karnak.backend.data.entity.ArgumentEntity)6 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)6 ProjectEntity (org.karnak.backend.data.entity.ProjectEntity)3 ProfileItemType (org.karnak.backend.enums.ProfileItemType)3 H2 (com.vaadin.flow.component.html.H2)2 ArrayList (java.util.ArrayList)2 MaskEntity (org.karnak.backend.data.entity.MaskEntity)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 Div (com.vaadin.flow.component.html.Div)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1