Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Patient Registry
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gazelle
A
Applications
T
Test execution
Simulator
Patient Registry
Commits
87f7e9d3
Commit
87f7e9d3
authored
Apr 21, 2020
by
luc chatty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PATREG-33 | code review
parent
582b5ee3
Pipeline
#138647
passed with stages
in 7 minutes and 47 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
141 deletions
+99
-141
patient-registry-service/src/main/java/net/ihe/gazelle/app/patientregistryservice/adapter/dao/pamsimulator/service/IdentifierDAOImpl.java
...e/adapter/dao/pamsimulator/service/IdentifierDAOImpl.java
+3
-0
patient-registry-service/src/test/java/net/ihe/gazelle/app/patientregistryservice/feature/search/it/SearchExecutionStepDefinition.java
...vice/feature/search/it/SearchExecutionStepDefinition.java
+49
-71
patient-registry-service/src/test/java/net/ihe/gazelle/app/patientregistryservice/feature/search/ut/SearchExecutionStepDefinition.java
...vice/feature/search/ut/SearchExecutionStepDefinition.java
+47
-70
No files found.
patient-registry-service/src/main/java/net/ihe/gazelle/app/patientregistryservice/adapter/dao/pamsimulator/service/IdentifierDAOImpl.java
View file @
87f7e9d3
...
...
@@ -11,6 +11,9 @@ import javax.persistence.criteria.*;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* DAO for Identifier Objects.
*/
public
class
IdentifierDAOImpl
implements
IdentifierDAO
{
private
EntityManager
entityManager
;
...
...
patient-registry-service/src/test/java/net/ihe/gazelle/app/patientregistryservice/feature/search/it/SearchExecutionStepDefinition.java
View file @
87f7e9d3
...
...
@@ -350,115 +350,93 @@ public class SearchExecutionStepDefinition {
*/
@Then
(
"all received patients verify one"
)
public
void
allReceiverPatientsVerifyOne
(
List
<
Map
<
String
,
String
>>
patientDataList
)
{
List
<
Patient
>
checkedPatients
=
new
ArrayList
<>();
if
(
patientDataList
!=
null
)
{
for
(
Map
<
String
,
String
>
criterionMap
:
patientDataList
)
{
String
parameter
=
criterionMap
.
get
(
"parameter"
);
String
verb
=
criterionMap
.
get
(
"verb"
);
String
value
=
criterionMap
.
get
(
"value"
);
if
(
parameter
==
null
||
verb
==
null
||
value
==
null
)
{
fail
(
String
.
format
(
"Criterion shall always have a parameter, verb and value : %s, %s, %s"
,
parameter
,
verb
,
value
));
}
getPatientsWhoVerify
(
parameter
,
verb
,
value
).
forEach
(
patient
->
{
if
(!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
boolean
allReceiverPatientsVerifyOne
=
true
;
for
(
Patient
patient
:
searchedPatients
)
{
boolean
patientVerifyAtLeastOne
=
false
;
for
(
Map
<
String
,
String
>
criterionMap
:
patientDataList
)
{
String
parameter
=
criterionMap
.
get
(
"parameter"
);
String
verb
=
criterionMap
.
get
(
"verb"
);
String
value
=
criterionMap
.
get
(
"value"
);
if
(
parameter
==
null
||
verb
==
null
||
value
==
null
)
{
fail
(
String
.
format
(
"Criterion shall always have a parameter, verb and value : %s, %s, %s"
,
parameter
,
verb
,
value
));
}
});
patientVerifyAtLeastOne
=
patientVerifyAtLeastOne
||
patientVerify
(
patient
,
parameter
,
verb
,
value
);
}
allReceiverPatientsVerifyOne
=
allReceiverPatientsVerifyOne
&&
patientVerifyAtLeastOne
;
}
assertTrue
(
allReceiverPatientsVerifyOne
,
"All patients should match at least one criterion"
);
}
assertEquals
(
searchedPatients
.
size
(),
checkedPatients
.
size
(),
"All patients should match at least one criterion"
);
}
/**
* Checks that some patient verify all Criterion in a list and store them in the checkerdPatients property.
*
* @param patientDataList
* @param patientDataList
List of criterion that received patients may verify
*/
@Then
(
"some patient verifies all"
)
public
void
somePatientsVerifyAll
(
List
<
Map
<
String
,
String
>>
patientDataList
)
{
if
(
patientDataList
!=
null
)
{
List
<
Patient
>
somePatients
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
criterionMap
:
patientDataList
)
{
String
parameter
=
criterionMap
.
get
(
"parameter"
);
String
verb
=
criterionMap
.
get
(
"verb"
);
String
value
=
criterionMap
.
get
(
"value"
);
if
(
parameter
==
null
||
verb
==
null
||
value
==
null
)
{
fail
(
String
.
format
(
"Criterion shall always have a parameter, verb and value : %s, %s, %s"
,
parameter
,
verb
,
value
));
}
List
<
Patient
>
verifyPatients
=
getPatientsWhoVerify
(
parameter
,
verb
,
value
);
verifyPatients
.
forEach
(
patient
->
{
if
(!
somePatients
.
contains
(
patient
))
{
somePatients
.
add
(
patient
);
boolean
somePatientsVerifyAll
=
false
;
for
(
Patient
patient
:
searchedPatients
)
{
for
(
Map
<
String
,
String
>
criterionMap
:
patientDataList
)
{
String
parameter
=
criterionMap
.
get
(
"parameter"
);
String
verb
=
criterionMap
.
get
(
"verb"
);
String
value
=
criterionMap
.
get
(
"value"
);
if
(
parameter
==
null
||
verb
==
null
||
value
==
null
)
{
fail
(
String
.
format
(
"Criterion shall always have a parameter, verb and value : %s, %s, %s"
,
parameter
,
verb
,
value
));
}
});
somePatients
.
forEach
(
patient
->
{
if
(!
verifyPatients
.
contains
(
patient
))
{
verifyPatients
.
remove
(
patient
);
}
});
}
somePatients
.
forEach
(
patient
->
{
if
(!
this
.
checkedPatients
.
contains
(
patient
))
{
this
.
checkedPatients
.
add
(
patient
);
somePatientsVerifyAll
=
somePatientsVerifyAll
||
patientVerify
(
patient
,
parameter
,
verb
,
value
);
}
});
}
assertTrue
(
somePatientsVerifyAll
,
"Some patients shall verify all criteria"
);
}
}
/**
* Checks that all returned patients have been checked correct.
* Checks that all retu
always have a parameter, verb and value : always have a parameter, verb and value :
rned patients have been checked correct.
*/
@Then
(
"all return patients match criteria"
)
public
void
allReturnedPatientsMatchCriteria
()
{
assertEquals
(
searchedPatients
.
size
(),
checkedPatients
.
size
(),
"All patients should verify criteria."
);
}
/**
* Checks some of the received patients verify asked criterion
*
* @param parameter name of the criterion
* * @param value value to search
* * @param verb operator to use
* assert that a patient verify a criterion
* @param patient the patient to check
* @param parameter the parameter if the criterion
* @param verb the verb of the criterion
* @param value the value of the criterion
* @return true is the patient verify the criterion
*/
private
List
<
Patient
>
getPatientsWhoVerify
(
String
parameter
,
String
verb
,
String
value
)
{
private
boolean
patientVerify
(
Patient
patient
,
String
parameter
,
String
verb
,
String
value
)
{
if
(
parameter
!=
null
)
{
List
<
Patient
>
checkedPatients
=
new
ArrayList
<>();
if
(
parameter
.
equals
(
"tmpuuid"
))
{
for
(
Patient
patient
:
searchedPatients
)
{
if
(
checkStringValueWithOperator
(
verb
,
uuidOfFedPatients
.
get
(
value
),
patient
.
getUuid
())
&&
!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
}
}
}
else
if
(
parameter
.
equals
(
"uuid"
))
{
for
(
Patient
patient
:
searchedPatients
)
{
if
(
checkStringValueWithOperator
(
verb
,
value
,
patient
.
getUuid
())
&&
!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
}
}
}
else
if
(
parameter
.
equals
(
"identifier.value"
))
{
for
(
Patient
patient
:
searchedPatients
)
{
switch
(
parameter
)
{
case
"tmpuuid"
:
return
checkStringValueWithOperator
(
verb
,
uuidOfFedPatients
.
get
(
value
),
patient
.
getUuid
())
&&
!
checkedPatients
.
contains
(
patient
);
case
"uuid"
:
return
checkStringValueWithOperator
(
verb
,
value
,
patient
.
getUuid
())
&&
!
checkedPatients
.
contains
(
patient
);
case
"identifier.value"
:
{
List
<
String
>
identifierList
=
new
ArrayList
<>();
patient
.
getIdentifiers
().
forEach
(
identifier
->
identifierList
.
add
(
identifier
.
getValue
()));
if
(
checkStringListWithOperator
(
verb
,
value
,
identifierList
)
&&
!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
}
return
checkStringListWithOperator
(
verb
,
value
,
identifierList
);
}
}
else
if
(
parameter
.
equals
(
"identifier.systemIdentifier"
))
{
for
(
Patient
patient
:
searchedPatients
)
{
case
"identifier.systemIdentifier"
:
{
List
<
String
>
identifierList
=
new
ArrayList
<>();
patient
.
getIdentifiers
().
forEach
(
identifier
->
identifierList
.
add
(
identifier
.
getSystemIdentifier
()));
if
(
checkStringListWithOperator
(
verb
,
value
,
identifierList
)
&&
!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
}
return
checkStringListWithOperator
(
verb
,
value
,
identifierList
)
&&
!
checkedPatients
.
contains
(
patient
);
}
}
else
{
fail
(
String
.
format
(
"Unsupported criteria %s"
,
parameter
));
default
:
fail
(
String
.
format
(
"Unsupported criteria %s"
,
parameter
));
break
;
}
return
checkedPatients
;
return
false
;
}
else
{
fail
(
"Criterion name shall not be null !"
);
}
return
null
;
return
false
;
}
...
...
patient-registry-service/src/test/java/net/ihe/gazelle/app/patientregistryservice/feature/search/ut/SearchExecutionStepDefinition.java
View file @
87f7e9d3
...
...
@@ -412,58 +412,46 @@ public class SearchExecutionStepDefinition {
*/
@Then
(
"all received patients verify one"
)
public
void
allReceiverPatientsVerifyOne
(
List
<
Map
<
String
,
String
>>
patientDataList
)
{
List
<
Patient
>
checkedPatients
=
new
ArrayList
<>();
if
(
patientDataList
!=
null
)
{
for
(
Map
<
String
,
String
>
criterionMap
:
patientDataList
)
{
String
parameter
=
criterionMap
.
get
(
"parameter"
);
String
verb
=
criterionMap
.
get
(
"verb"
);
String
value
=
criterionMap
.
get
(
"value"
);
if
(
parameter
==
null
||
verb
==
null
||
value
==
null
)
{
fail
(
String
.
format
(
"Criterion shall always have a parameter, verb and value : %s, %s, %s"
,
parameter
,
verb
,
value
));
}
getPatientsWhoVerify
(
parameter
,
verb
,
value
).
forEach
(
patient
->
{
if
(!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
boolean
allReceiverPatientsVerifyOne
=
true
;
for
(
Patient
patient
:
searchedPatients
)
{
boolean
patientVerifyAtLeastOne
=
false
;
for
(
Map
<
String
,
String
>
criterionMap
:
patientDataList
)
{
String
parameter
=
criterionMap
.
get
(
"parameter"
);
String
verb
=
criterionMap
.
get
(
"verb"
);
String
value
=
criterionMap
.
get
(
"value"
);
if
(
parameter
==
null
||
verb
==
null
||
value
==
null
)
{
fail
(
String
.
format
(
"Criterion shall always have a parameter, verb and value : %s, %s, %s"
,
parameter
,
verb
,
value
));
}
});
patientVerifyAtLeastOne
=
patientVerifyAtLeastOne
||
patientVerify
(
patient
,
parameter
,
verb
,
value
);
}
allReceiverPatientsVerifyOne
=
allReceiverPatientsVerifyOne
&&
patientVerifyAtLeastOne
;
}
assertTrue
(
allReceiverPatientsVerifyOne
,
"All patients should match at least one criterion"
);
}
assertEquals
(
searchedPatients
.
size
(),
checkedPatients
.
size
(),
"All patients should match at least one criterion"
);
}
/**
* Checks that some patient verify all Criterion in a list and store them in the checkerdPatients property.
*
* @param patientDataList
* @param patientDataList
List of criterion that received patients may verify
*/
@Then
(
"some patient verifies all"
)
public
void
somePatientsVerifyAll
(
List
<
Map
<
String
,
String
>>
patientDataList
)
{
if
(
patientDataList
!=
null
)
{
List
<
Patient
>
somePatients
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
criterionMap
:
patientDataList
)
{
String
parameter
=
criterionMap
.
get
(
"parameter"
);
String
verb
=
criterionMap
.
get
(
"verb"
);
String
value
=
criterionMap
.
get
(
"value"
);
if
(
parameter
==
null
||
verb
==
null
||
value
==
null
)
{
fail
(
String
.
format
(
"Criterion shall always have a parameter, verb and value : %s, %s, %s"
,
parameter
,
verb
,
value
));
}
List
<
Patient
>
verifyPatients
=
getPatientsWhoVerify
(
parameter
,
verb
,
value
);
verifyPatients
.
forEach
(
patient
->
{
if
(!
somePatients
.
contains
(
patient
))
{
somePatients
.
add
(
patient
);
boolean
somePatientsVerifyAll
=
false
;
for
(
Patient
patient
:
searchedPatients
)
{
for
(
Map
<
String
,
String
>
criterionMap
:
patientDataList
)
{
String
parameter
=
criterionMap
.
get
(
"parameter"
);
String
verb
=
criterionMap
.
get
(
"verb"
);
String
value
=
criterionMap
.
get
(
"value"
);
if
(
parameter
==
null
||
verb
==
null
||
value
==
null
)
{
fail
(
String
.
format
(
"Criterion shall always have a parameter, verb and value : %s, %s, %s"
,
parameter
,
verb
,
value
));
}
});
somePatients
.
forEach
(
patient
->
{
if
(!
verifyPatients
.
contains
(
patient
))
{
verifyPatients
.
remove
(
patient
);
}
});
}
somePatients
.
forEach
(
patient
->
{
if
(!
this
.
checkedPatients
.
contains
(
patient
))
{
this
.
checkedPatients
.
add
(
patient
);
somePatientsVerifyAll
=
somePatientsVerifyAll
||
patientVerify
(
patient
,
parameter
,
verb
,
value
);
}
});
}
assertTrue
(
somePatientsVerifyAll
,
"Some patients shall verify all criteria"
);
}
}
...
...
@@ -476,51 +464,40 @@ public class SearchExecutionStepDefinition {
}
/**
* Checks some of the received patients verify asked criterion
*
* @param parameter name of the criterion
* * @param value value to search
* * @param verb operator to use
* assert that a patient verify a criterion
* @param patient the patient to check
* @param parameter the parameter if the criterion
* @param verb the verb of the criterion
* @param value the value of the criterion
* @return true is the patient verify the criterion
*/
private
List
<
Patient
>
getPatientsWhoVerify
(
String
parameter
,
String
verb
,
String
value
)
{
private
boolean
patientVerify
(
Patient
patient
,
String
parameter
,
String
verb
,
String
value
)
{
if
(
parameter
!=
null
)
{
List
<
Patient
>
checkedPatients
=
new
ArrayList
<>();
if
(
parameter
.
equals
(
"tmpuuid"
))
{
for
(
Patient
patient
:
searchedPatients
)
{
if
(
checkStringValueWithOperator
(
verb
,
uuidOfFedPatients
.
get
(
value
),
patient
.
getUuid
())
&&
!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
}
}
}
else
if
(
parameter
.
equals
(
"uuid"
))
{
for
(
Patient
patient
:
searchedPatients
)
{
if
(
checkStringValueWithOperator
(
verb
,
value
,
patient
.
getUuid
())
&&
!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
}
}
}
else
if
(
parameter
.
equals
(
"identifier.value"
))
{
for
(
Patient
patient
:
searchedPatients
)
{
switch
(
parameter
)
{
case
"tmpuuid"
:
return
checkStringValueWithOperator
(
verb
,
uuidOfFedPatients
.
get
(
value
),
patient
.
getUuid
())
&&
!
checkedPatients
.
contains
(
patient
);
case
"uuid"
:
return
checkStringValueWithOperator
(
verb
,
value
,
patient
.
getUuid
())
&&
!
checkedPatients
.
contains
(
patient
);
case
"identifier.value"
:
{
List
<
String
>
identifierList
=
new
ArrayList
<>();
patient
.
getIdentifiers
().
forEach
(
identifier
->
identifierList
.
add
(
identifier
.
getValue
()));
if
(
checkStringListWithOperator
(
verb
,
value
,
identifierList
)
&&
!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
}
return
checkStringListWithOperator
(
verb
,
value
,
identifierList
);
}
}
else
if
(
parameter
.
equals
(
"identifier.systemIdentifier"
))
{
for
(
Patient
patient
:
searchedPatients
)
{
case
"identifier.systemIdentifier"
:
{
List
<
String
>
identifierList
=
new
ArrayList
<>();
patient
.
getIdentifiers
().
forEach
(
identifier
->
identifierList
.
add
(
identifier
.
getSystemIdentifier
()));
if
(
checkStringListWithOperator
(
verb
,
value
,
identifierList
)
&&
!
checkedPatients
.
contains
(
patient
))
{
checkedPatients
.
add
(
patient
);
}
return
checkStringListWithOperator
(
verb
,
value
,
identifierList
)
&&
!
checkedPatients
.
contains
(
patient
);
}
}
else
{
fail
(
String
.
format
(
"Unsupported criteria %s"
,
parameter
));
default
:
fail
(
String
.
format
(
"Unsupported criteria %s"
,
parameter
));
break
;
}
return
checkedPatients
;
return
false
;
}
else
{
fail
(
"Criterion name shall not be null !"
);
}
return
null
;
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment