Commit 18e477f4 authored by Franck Desaize's avatar Franck Desaize
Browse files

Merge branch...

Merge branch 'feature/PATREG-139-implement-service-on-xref-query-with-identifier' into feature/PATREG-122

# Conflicts:
#	patient-registry-model-api/src/main/java/net/ihe/gazelle/app/patientregistryapi/application/PatientCrossReferenceSearch.java
#	patient-registry-model-api/src/main/java/net/ihe/gazelle/app/patientregistryapi/application/SearchCrossReferenceException.java
parents 51e2b00f eafab500
Pipeline #262936 failed with stages
in 7 minutes and 14 seconds
......@@ -2,6 +2,7 @@ package net.ihe.gazelle.app.patientregistryapi.application;
import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier;
import net.ihe.gazelle.app.patientregistryapi.business.PatientAliases;
import net.ihe.gazelle.lib.searchmodelapi.business.exception.SearchException;
/**
......
......@@ -21,9 +21,9 @@ public class PatientAliases {
/**
* Constructor for the class
*
* @param uuid the identifier of the patient aliases
* @param lastModifier the name of the last modifier
* @param lastModifierDateTime the date time of the last update
* @param uuid the identifier of the patient aliases
* @param lastModifier the name of the last modifier
* @param lastModifierDateTime the date time of the last update
*/
public PatientAliases(String uuid, String lastModifier, Date lastModifierDateTime) {
this.uuid = uuid;
......@@ -43,7 +43,7 @@ public class PatientAliases {
/**
* set patientAliases gazelle identifier
*
* @param uuid the value to set to the uuid property
* @param uuid the value to set to the uuid property
*/
public void setUuid(String uuid) {
this.uuid = uuid;
......@@ -61,7 +61,7 @@ public class PatientAliases {
/**
* set the last modifier of the PatientAliases
*
* @param lastModifier the name of the last modifier
* @param lastModifier the name of the last modifier
*/
public void setLastModifier(String lastModifier) {
this.lastModifier = lastModifier;
......@@ -78,7 +78,6 @@ public class PatientAliases {
/**
* set the Date Time of the last modifier
*
*/
public void setLastModifierDateTime() {
this.lastModifierDateTime = new Timestamp(new Date().getTime());
......@@ -93,10 +92,34 @@ public class PatientAliases {
return members;
}
/**
* Add a list of patient to the current list of patient if it is not already in the list
*
* @param patients
*/
public void addMembers(List<Patient> patients) {
if (patients != null) {
for (Patient patient : patients) {
setLastModifierDateTime();
if (!this.members.contains(patient)) {
this.members.add(patient);
}
}
}
}
public void setMembers(List<Patient> patients) {
if (patients != null) {
setLastModifierDateTime();
this.members = patients;
}
}
/**
* add a patient to a members
*
* @param member the patient to add
* @param member the patient to add
*/
public void addMember(Patient member) {
setLastModifierDateTime();
......@@ -106,8 +129,8 @@ public class PatientAliases {
/**
* add a patient to a members
*
* @param member the patient to add
* @param index the index to insert the patient
* @param member the patient to add
* @param index the index to insert the patient
*/
public void addMember(Patient member, int index) {
setLastModifierDateTime();
......@@ -117,7 +140,7 @@ public class PatientAliases {
/**
* remove a member to a list of members
*
* @param member the patient to remove
* @param member the patient to remove
*/
public void removeMember(Patient member) {
setLastModifierDateTime();
......
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fae1b83732b, pid=188769, tid=188787
#
# JRE version: OpenJDK Runtime Environment (11.0.11+9) (build 11.0.11+9-Ubuntu-0ubuntu2.20.10)
# Java VM: OpenJDK 64-Bit Server VM (11.0.11+9-Ubuntu-0ubuntu2.20.10, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C [libjimage.so+0x332b]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P %E" (or dumping to /home/mbr@kereval.com/Documents/Gazelle/patient-registry/patient-registry-service/core.188769)
#
# If you would like to submit a bug report, please visit:
# https://bugs.launchpad.net/ubuntu/+source/openjdk-lts
#
--------------- S U M M A R Y ------------
Command Line: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:46797 -ea -javaagent:/home/mbr@kereval.com/.eclipse/360744286_linux_gtk_x86_64/configuration/org.eclipse.osgi/222/0/.cp/lib/javaagent-shaded.jar -Dfile.encoding=UTF-8 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 46111 -testLoaderClass org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader -loaderpluginname org.eclipse.jdt.junit5.runtime -classNames net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.patient.PatientCrossReferenceDAOImplTest
Host:
\ No newline at end of file
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f486804532b, pid=189587, tid=189603
#
# JRE version: OpenJDK Runtime Environment (11.0.11+9) (build 11.0.11+9-Ubuntu-0ubuntu2.20.10)
# Java VM: OpenJDK 64-Bit Server VM (11.0.11+9-Ubuntu-0ubuntu2.20.10, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C [libjimage.so+0x332b]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P %E" (or dumping to /home/mbr@kereval.com/Documents/Gazelle/patient-registry/patient-registry-service/core.189587)
#
# If you would like to submit a bug report, please visit:
# https://bugs.launchpad.net/ubuntu/+source/openjdk-lts
#
--------------- S U M M A R Y ------------
Command Line: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:33683 -ea -javaagent:/home/mbr@kereval.com/.eclipse/360744286_linux_gtk_x86_64/configuration/org.eclipse.osgi/222/0/.cp/lib/javaagent-shaded.jar -Dfile.encoding=UTF-8 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 33139 -testLoaderClass org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader -loaderpluginname org.eclipse.jdt.junit5.runtime -classNames net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.patient.PatientCrossReferenceDAOImplTest
Host:
\ No newline at end of file
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f924eb9832b, pid=199710, tid=199727
#
# JRE version: OpenJDK Runtime Environment (11.0.11+9) (build 11.0.11+9-Ubuntu-0ubuntu2.20.10)
# Java VM: OpenJDK 64-Bit Server VM (11.0.11+9-Ubuntu-0ubuntu2.20.10, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C [libjimage.so+0x332b]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P %E" (or dumping to /home/mbr@kereval.com/Documents/Gazelle/patient-registry/patient-registry-service/core.199710)
#
# If you would like to submit a bug report, please visit:
# https://bugs.launchpad.net/ubuntu/+source/openjdk-lts
#
--------------- S U M M A R Y ------------
Command Line: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:35843 -ea -javaagent:/home/mbr@kereval.com/.eclipse/360744286_linux_gtk_x86_64/configuration/org.eclipse.osgi/222/0/.cp/lib/javaagent-shaded.jar -Dfile.encoding=UTF-8 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 42603 -testLoaderClass org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader -loaderpluginname org.eclipse.jdt.junit5.runtime -classNames net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.patient.PatientCrossReferenceDAOImplTest
Host:
\ No newline at end of file
......@@ -157,6 +157,24 @@
<version>3.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.7.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
......
package net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.converter;
import net.ihe.gazelle.app.patientregistryapi.business.*;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.GenderCodeDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.PatientDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.references.CrossReferenceDB;
import java.util.ArrayList;
import java.util.List;
/**
* Converter for Names from business model to Database model and back.
*/
public class PatientAliasesConverter {
/**
* Private constructor to hide implicit one.
*/
private PatientAliasesConverter() {
}
/**
* @param patientaliases
* @return
*/
public static CrossReferenceDB toCrossReferenceDB(PatientAliases patientaliases) {
CrossReferenceDB crossReferenceDB = new CrossReferenceDB();
List<PatientDB> patientDB = new ArrayList<>();
for (Patient patient : patientaliases.getMembers()) {
patientDB.add(PatientConverter.toPatientDB(patient));
}
crossReferenceDB.setPatients(patientDB);
crossReferenceDB.setLastModifier(patientaliases.getLastModifier());
crossReferenceDB.setLastChanged(patientaliases.getLastModifierDateTime());
return crossReferenceDB;
}
/**
* @param crossReferenceDB
* @return
*/
public static PatientAliases toPatientAliases(CrossReferenceDB crossReferenceDB) {
PatientAliases patientaliases = new PatientAliases();
List<Patient> patients = new ArrayList<>();
for (PatientDB patientDB : crossReferenceDB.getPatients()) {
patients.add(PatientConverter.toPatient(patientDB));
}
patientaliases.setMembers(patients);
patientaliases.setLastModifier(crossReferenceDB.getLastModifier());
patientaliases.setLastModifierDateTime();
return patientaliases;
}
public static List<PatientAliases> toListOfPatientAliases(List<CrossReferenceDB> crossReferenceDBS){
List<PatientAliases> patientAliases = new ArrayList<>();
crossReferenceDBS.forEach(crossReference -> {
PatientAliases patientAlias = toPatientAliases(crossReference);
patientAliases.add(patientAlias);
});
return patientAliases;
}
}
......@@ -17,6 +17,7 @@ import java.util.List;
@NamedQuery(name = "PatientDB.findByUuid", query = "SELECT p FROM PatientDB p WHERE p.uuid = :uuid")
@NamedQuery(name = "PatientDB.findForSimulatedActor", query = "SELECT p FROM PatientDB p WHERE p.simulatedActor = :actorKeyword")
@NamedQuery(name = "PatientDB.findUUID", query = "SELECT p.uuid FROM PatientDB p WHERE p.uuid = :uuid")
@NamedQuery(name = "PatientDB.findByPatientIdentifier", query = "SELECT p.patientIdentifiers FROM PatientDB p WHERE p.patientIdentifiers = :patientIdentifier")
@Table(name = "pat_patient", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = "id"))
@SequenceGenerator(name = "pat_patient_sequence", sequenceName = "pat_patient_id_seq", allocationSize = 1)
public class PatientDB extends AbstractPatientDB {
......
......@@ -14,6 +14,7 @@ import java.util.List;
@Table(name = "pam_patient_identifier", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = {
"full_patient_id", "identifier_type_code" }))
@SequenceGenerator(name = "pam_patient_identifier_sequence", sequenceName = "pam_patient_identifier_id_seq", allocationSize = 1)
@NamedQuery(name = "PatientIdentifierDB.findByHierarchicDomainAndId", query = "SELECT pi FROM PatientIdentifierDB pi WHERE pi.domain = :domain_id and pi.identifier = :id_number" )
public class PatientIdentifierDB {
@Id
......
......@@ -8,100 +8,104 @@ import java.util.Date;
import java.util.List;
@Entity
//@NamedQuery(name = "CrossReferenceDB.findUUID", query = "SELECT c.patients FROM CrossReferenceDB c WHERE c.patients = :")
@Table(name = "pix_cross_reference", schema = "public")
@SequenceGenerator(name = "pix_cross_reference_sequence", sequenceName = "pix_cross_reference_id_seq", allocationSize = 1)
@NamedQuery(name = "CrossReferenceDB.findByPatient", query = "SELECT cr FROM CrossReferenceDB cr WHERE :patient in (cr.patients)")
@NamedQuery(name = "CrossReferenceDB.findByCrossRefId", query = "SELECT cr FROM CrossReferenceDB cr WHERE :pixReference = id")
@NamedQuery(name = "CrossReferenceDB.countPatient", query = "SELECT COUNT (cr) FROM CrossReferenceDB cr WHERE :patient in (cr.patients)")
public class CrossReferenceDB {
@Id
@GeneratedValue(generator = "pix_cross_reference_sequence", strategy = GenerationType.SEQUENCE)
@Column(name = "id")
private Integer id;
@OneToMany(mappedBy = "pixReference", fetch = FetchType.LAZY)
private List<PatientDB> patients;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_changed")
private Date lastChanged;
@Column(name = "last_modifier")
private String lastModifier;
public CrossReferenceDB(String username) {
this.lastChanged = new Date();
this.lastModifier = username;
}
public CrossReferenceDB() {
this.lastChanged = new Date();
}
public List<PatientDB> getPatients() {
return patients;
}
public void setPatients(List<PatientDB> patients) {
this.patients = patients;
}
public Date getLastChanged() {
if (lastChanged != null){
return (Date) lastChanged.clone();
}
return null;
}
public void setLastChanged(Date lastChanged) {
if (lastChanged != null) {
this.lastChanged = (Date) lastChanged.clone();
} else {
this.lastChanged = null;
}
}
public String getLastModifier() {
return lastModifier;
}
public void setLastModifier(String lastModifier) {
this.lastModifier = lastModifier;
}
public Integer getId() {
return id;
}
public CrossReferenceDB updateReference(EntityManager entityManager, String user) {
this.lastChanged = new Date();
this.lastModifier = user;
return entityManager.merge(this);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CrossReferenceDB)) {
return false;
}
CrossReferenceDB that = (CrossReferenceDB) o;
if (patients != null ? !patients.equals(that.patients) : that.patients != null) {
return false;
}
if (lastChanged != null ? !lastChanged.equals(that.lastChanged) : that.lastChanged != null) {
return false;
}
return lastModifier != null ? lastModifier.equals(that.lastModifier) : that.lastModifier == null;
}
@Override
public int hashCode() {
int result = patients != null ? patients.hashCode() : 0;
result = 31 * result + (lastChanged != null ? lastChanged.hashCode() : 0);
result = 31 * result + (lastModifier != null ? lastModifier.hashCode() : 0);
return result;
}
@Id
@GeneratedValue(generator = "pix_cross_reference_sequence", strategy = GenerationType.SEQUENCE)
@Column(name = "id")
private Integer id;
@OneToMany(mappedBy = "pixReference", fetch = FetchType.LAZY)
private List<PatientDB> patients;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_changed")
private Date lastChanged;
@Column(name = "last_modifier")
private String lastModifier;
public CrossReferenceDB(String username) {
this.lastChanged = new Date();
this.lastModifier = username;
}
public CrossReferenceDB() {
this.lastChanged = new Date();
}
public List<PatientDB> getPatients() {
return patients;
}
public void setPatients(List<PatientDB> patients) {
this.patients = patients;
}
public Date getLastChanged() {
if (lastChanged != null) {
return (Date) lastChanged.clone();
}
return null;
}
public void setLastChanged(Date lastChanged) {
if (lastChanged != null) {
this.lastChanged = (Date) lastChanged.clone();
} else {
this.lastChanged = null;
}
}
public String getLastModifier() {
return lastModifier;
}
public void setLastModifier(String lastModifier) {
this.lastModifier = lastModifier;
}
public Integer getId() {
return id;
}
public CrossReferenceDB updateReference(EntityManager entityManager, String user) {
this.lastChanged = new Date();
this.lastModifier = user;
return entityManager.merge(this);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CrossReferenceDB)) {
return false;
}
CrossReferenceDB that = (CrossReferenceDB) o;
if (patients != null ? !patients.equals(that.patients) : that.patients != null) {
return false;
}
if (lastChanged != null ? !lastChanged.equals(that.lastChanged) : that.lastChanged != null) {
return false;
}
return lastModifier != null ? lastModifier.equals(that.lastModifier) : that.lastModifier == null;
}
@Override
public int hashCode() {
int result = patients != null ? patients.hashCode() : 0;
result = 31 * result + (lastChanged != null ? lastChanged.hashCode() : 0);
result = 31 * result + (lastModifier != null ? lastModifier.hashCode() : 0);
return result;
}
}
......@@ -62,6 +62,7 @@ public class DomainDAOImpl implements DomainDAO, DomainService {
* @param domainIdentifier identifier of the Domain to retrieve.
* @return retrieved Domain if exists, or null.
*/
//TODO refactor pour virer le null | a recopier dans PCRDAOImpl ?
public HierarchicDesignatorDB retrieve(String domainIdentifier) {
TypedQuery<HierarchicDesignatorDB> query = entityManager.createNamedQuery("HierarchicDesignatorDB.findByUniversalID",
HierarchicDesignatorDB.class);
......
package net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service;
import net.ihe.gazelle.app.patientregistryapi.application.SearchCrossReferenceException;
import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.PatientDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.references.CrossReferenceDB;
import java.util.List;
public interface PatientCrossReferenceDAO {
PatientDB searchForPatientDBWithSourceIdentifier(EntityIdentifier sourceIdentifier) throws SearchCrossReferenceException;
List<CrossReferenceDB> searchForPatientAliasesWithPatientDB(PatientDB patient) throws SearchCrossReferenceException;
}
package net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service;
import net.ihe.gazelle.app.patientregistryapi.application.SearchCrossReferenceException;
import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier;
import net.ihe.gazelle.app.patientregistryapi.business.PatientAliases;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.EntityManagerProducer;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.converter.PatientAliasesConverter;
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.app.patientregistryservice.adapter.dao.pamsimulator.model.references.CrossReferenceDB;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.NonUniqueResultException;
import javax.persistence.TypedQuery;
import java.util.ArrayList;
import java.util.List;
@Named("PatientCrossReferenceDAO")
public class PatientCrossReferenceDAOImpl implements PatientCrossReferenceDAO {
private EntityManager entityManager;
//private Constructor
private PatientCrossReferenceDAOImpl() {
}