Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit a02c4e56 authored by luc chatty's avatar luc chatty

PATREG-33 | add domain

parent 7b7e43c7
Pipeline #137265 failed with stages
in 19 minutes and 10 seconds
......@@ -2,6 +2,7 @@ package net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.serv
import net.ihe.gazelle.app.patientregistryapi.business.PatientSearchCriterionKey;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.EntityManagerProducer;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.HierarchicDesignatorDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.PatientDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.PatientIdentifierDB;
import net.ihe.gazelle.lib.searchjpadao.adapter.SearchCriterionJPAMappingService;
......@@ -43,6 +44,7 @@ public class PatientSearchCriterionJPAMappingService implements SearchCriterionJ
PatientSearchCriterionKey patientSearchCriterionKey = castToPatientKey(searchCriterionKey);
Metamodel metamodel = entityManager.getMetamodel();
EntityType<PatientDB> entityType = metamodel.entity(PatientDB.class);
EntityType<PatientIdentifierDB> entityTypeIdentifier = metamodel.entity(PatientIdentifierDB.class);
if (PatientSearchCriterionKey.UUID.equals(patientSearchCriterionKey)) {
return from;
} else if (PatientSearchCriterionKey.IDENTIFIER.equals(patientSearchCriterionKey)) {
......@@ -52,6 +54,19 @@ public class PatientSearchCriterionJPAMappingService implements SearchCriterionJ
JoinType.LEFT.equals(((Join) p).getJoinType()))
.findAny().orElse(null);
return from2 != null ? from : from.join(entityType.getList("patientIdentifiers", PatientIdentifierDB.class), JoinType.LEFT);
} else if (PatientSearchCriterionKey.DOMAIN.equals(patientSearchCriterionKey)) {
From from2 = (From) from.getJoins().stream()
.filter(p ->
((Join) p).getAttribute().getName().equals("patientIdentifiers") &&
JoinType.LEFT.equals(((Join) p).getJoinType()))
.findAny().orElse(null);
from2 = from2 != null ? from2 : from.join(entityType.getList("patientIdentifiers", PatientIdentifierDB.class), JoinType.LEFT);
From from3 = (From) from2.getJoins().stream()
.filter(p ->
((Join) p).getAttribute().getName().equals("domain") &&
JoinType.LEFT.equals(((Join) p).getJoinType()))
.findAny().orElse(null);
return from3 != null ? from3 : from2.join(entityTypeIdentifier.getSingularAttribute("domain", HierarchicDesignatorDB.class), JoinType.LEFT);
} else {
throw new IllegalArgumentException("Unsupported test key : " + patientSearchCriterionKey);
}
......@@ -67,6 +82,8 @@ public class PatientSearchCriterionJPAMappingService implements SearchCriterionJ
return "uuid";
} else if (PatientSearchCriterionKey.IDENTIFIER.equals(patientSearchCriterionKey)) {
return "identifier";
} else if (PatientSearchCriterionKey.DOMAIN.equals(patientSearchCriterionKey)) {
return "universalID";
} else {
throw new IllegalArgumentException("Unsupported test key : " + patientSearchCriterionKey);
}
......
......@@ -141,6 +141,9 @@ public class SearchExecutionStepDefinition {
} else if (searchCriteriaName.equals("identifier.value")) {
this.searchCriteria.addSearchCriterion(createStringSearchCriterion(PatientSearchCriterionKey.IDENTIFIER,
getStringSearchCriterionOperator(searchCriteriaVerbText), searchCriteriaValue));
} else if (searchCriteriaName.equals("identifier.systemIdentifier")) {
this.searchCriteria.addSearchCriterion(createStringSearchCriterion(PatientSearchCriterionKey.DOMAIN,
getStringSearchCriterionOperator(searchCriteriaVerbText), searchCriteriaValue));
} else {
fail(String.format("Unsupported criteria %s", searchCriteriaName));
}
......@@ -215,6 +218,12 @@ public class SearchExecutionStepDefinition {
patient.getIdentifiers().forEach(identifier -> identifierList.add(identifier.getValue()));
checkStringListWithOperator(verb, value, identifierList);
});
} else if (parameter.equals("identifier.systemIdentifier")) {
searchedPatients.forEach((Patient patient) -> {
List<String> identifierList = new ArrayList<>();
patient.getIdentifiers().forEach(identifier -> identifierList.add(identifier.getSystemIdentifier()));
checkStringListWithOperator(verb, value, identifierList);
});
} else {
fail(String.format("Unsupported criteria %s", parameter));
}
......
......@@ -205,6 +205,9 @@ public class SearchExecutionStepDefinition {
} else if (searchCriteriaName.equals("identifier.value")) {
this.searchCriteria.addSearchCriterion(createStringSearchCriterion(PatientSearchCriterionKey.IDENTIFIER,
getStringSearchCriterionOperator(searchCriteriaVerbText), searchCriteriaValue));
} else if (searchCriteriaName.equals("identifier.systemIdentifier")) {
this.searchCriteria.addSearchCriterion(createStringSearchCriterion(PatientSearchCriterionKey.DOMAIN,
getStringSearchCriterionOperator(searchCriteriaVerbText), searchCriteriaValue));
} else {
fail(String.format("Unsupported criteria %s", searchCriteriaName));
}
......@@ -279,6 +282,12 @@ public class SearchExecutionStepDefinition {
patient.getIdentifiers().forEach(identifier -> identifierList.add(identifier.getValue()));
checkStringListWithOperator(verb, value, identifierList);
});
} else if (parameter.equals("identifier.systemIdentifier")) {
searchedPatients.forEach((Patient patient) -> {
List<String> identifierList = new ArrayList<>();
patient.getIdentifiers().forEach(identifier -> identifierList.add(identifier.getSystemIdentifier()));
checkStringListWithOperator(verb, value, identifierList);
});
} else {
fail(String.format("Unsupported criteria %s", parameter));
}
......
......@@ -13,7 +13,7 @@ Feature: Search Patient information
| tmpuuid0 | urn:oid:5.6.7.8 | identifier0 | system0 | PI |
| tmpuuid1 | urn:oid:1.2.3.4 | identifier1 | system1 | PI |
| tmpuuid2 | urn:oid:1.2.3.4 | identifier2 | system2 | PI |
| tmpuuid3 | urn:oid:1.2.3.4 | identifier3 | system3 | PI |
| tmpuuid3 | urn:oid:1.2.3.5 | identifier3 | system3 | PI |
| tmpuuid3 | urn:oid:9.8.7.6 | identifier0 | system4 | PI |
And patient is fed with provisional uuid "tmpuuid0"
And patient is fed with provisional uuid "tmpuuid1"
......@@ -32,4 +32,5 @@ Feature: Search Patient information
| tmpuuid | is | tmpuuid0 | 1 |
| tmpuuid | is | tmpuuid1 | 1 |
| uuid | is | uuid123 | 0 |
| identifier.systemIdentifier | is | urn:oid:1.2.3.4 | 3 |
| identifier.value | is | identifier0 | 2 |
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment