Skip to content

Commit

Permalink
PN-239: Allow filtering matches separately by phenotipic and genotipi…
Browse files Browse the repository at this point in the history
…c score

Removed score parameter from find all matches
  • Loading branch information
veronikaslc committed Jan 16, 2018
1 parent 8502f6f commit 9e543ca
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 50 deletions.
Expand Up @@ -18,7 +18,6 @@
package org.phenotips.matchingnotification;

import org.phenotips.data.similarity.PatientSimilarityView;
import org.phenotips.matchingnotification.match.PatientMatch;
import org.phenotips.matchingnotification.notification.PatientMatchNotificationResponse;

import org.xwiki.component.annotation.Role;
Expand All @@ -34,11 +33,8 @@ public interface MatchingNotificationManager
{
/**
* Find and save matches to all local patients.
*
* @param score save matches with score higher or equals to this value
* @return true if successful
*/
List<PatientMatch> findAndSaveMatches(double score);
void findAndSaveMatches();

/**
* Sends notification to the owner of every match with id in {@code matchesId}, then marks match as notified.
Expand Down
Expand Up @@ -89,29 +89,14 @@ public class DefaultMatchingNotificationManager implements MatchingNotificationM
private MatchStorageManager matchStorageManager;

@Override
public List<PatientMatch> findAndSaveMatches(double score)
public void findAndSaveMatches()
{
List<PatientMatch> addedMatches = new LinkedList<>();

List<Patient> patients = this.getPatientsList();
for (Patient patient : patients) {

this.logger.debug("Finding matches for patient {}.", patient.getId());

List<PatientMatch> matchesForPatient = this.matchFinderManager.findMatches(patient);
if (matchesForPatient.isEmpty()) {
continue;
}

this.filterMatchesByScore(matchesForPatient, score);
if (matchesForPatient.isEmpty()) {
continue;
}

addedMatches.addAll(matchesForPatient);
this.matchFinderManager.findMatches(patient);
}

return addedMatches;
}

/*
Expand Down Expand Up @@ -193,20 +178,6 @@ private List<PatientMatch> getSuccessfulNotifications(List<PatientMatchNotificat
return successfulMatches;
}

/*
* Removes all matches from list with score lower than score.
*/
private void filterMatchesByScore(List<PatientMatch> matches, double score)
{
List<PatientMatch> toRemove = new LinkedList<>();
for (PatientMatch match : matches) {
if (match.getScore() < score) {
toRemove.add(match);
}
}
matches.removeAll(toRemove);
}

@Override
public boolean saveLocalMatchesViews(List<PatientSimilarityView> similarityViews, String patientId)
{
Expand Down
Expand Up @@ -90,19 +90,11 @@ public class MatchingNotificationScriptService implements ScriptService
private Logger logger = LoggerFactory.getLogger(MatchingNotificationScriptService.class);

/**
* Find patient matches and saves only those with score higher or equals to {@code score}.
*
* @param score only matches with score higher or equal to this value are saved
* @return JSON with the saved matches (after filtering)
* Find and save matches to all local patients.
*/
public String findAndSaveMatches(double score)
public void findAndSaveMatches()
{
List<PatientMatch> matches = this.matchingNotificationManager.findAndSaveMatches(score);
if (!isAdmin()) {
filterNonUsersMatches(matches);
}
JSONObject json = this.patientMatchExport.toJSON(matches);
return json.toString();
this.matchingNotificationManager.findAndSaveMatches();
}

/**
Expand Down
Expand Up @@ -40,8 +40,7 @@
<content>{{velocity}}
#set ($discard = $response.setContentType('application/json'))
#if ($request.action == 'find-matches')
#set ($score = $request.score)
$services.matchingNotification.findAndSaveMatches($score)
$services.matchingNotification.findAndSaveMatches()
#elseif ($request.action == 'show-matches')
#set ($score = $request.score)
#set ($phenScore = $request.phenScore)
Expand Down
Expand Up @@ -46,7 +46,6 @@ $xwiki.jsfx.use('uicomponents/matchingNotification/unnotifiedMatchesTable.js', t
{{html}}
&lt;div&gt;
&lt;label&gt;$escapetool.xml($services.localization.render('phenotips.matchingNotifications.table.findMatches.label')) &lt;/label&gt;
&lt;input id="find-matches-score" type="text" style="width: 5em;"/&gt;
&lt;button id="find-matches-button" type="button"&gt;$escapetool.xml($services.localization.render('phenotips.matchingNotifications.table.go.label'))&lt;/button&gt;
&lt;div id="find-matches-messages"/&gt;
&lt;/div&gt;
Expand Down
32 changes: 32 additions & 0 deletions pom.xml
Expand Up @@ -448,6 +448,38 @@
<method>java.util.List loadMatches(double, boolean)</method>
<justification>Added phenotypical and genotypical score parameters.</justification>
</difference>
<difference>
<className>org/phenotips/matchingnotification/MatchingNotificationManager</className>
<differenceType>7004</differenceType>
<method>java.util.List findAndSaveMatches(double)</method>
<justification>Removed score parameter.</justification>
</difference>
<difference>
<className>org/phenotips/matchingnotification/script/MatchingNotificationScriptService</className>
<differenceType>7004</differenceType>
<method>java.lang.String findAndSaveMatches(double)</method>
<justification>Removed score parameter.</justification>
</difference>
<difference>
<className>org/phenotips/matchingnotification/script/MatchingNotificationScriptService</className>
<differenceType>7004</differenceType>
<method>java.lang.String getMatches(double, boolean)</method>
<justification>Added phenotypical and genotypical score parameters.</justification>
</difference>
<difference>
<className>org/phenotips/matchingnotification/MatchingNotificationManager</className>
<differenceType>7006</differenceType>
<method>java.util.List findAndSaveMatches(double)</method>
<to>void</to>
<justification>Removed unused return.</justification>
</difference>
<difference>
<className>org/phenotips/matchingnotification/script/MatchingNotificationScriptService</className>
<differenceType>7006</differenceType>
<method>java.lang.String findAndSaveMatches(double)</method>
<to>void</to>
<justification>Removed unused return.</justification>
</difference>
</ignored>
<excludes>
<exclude>**/internal/**</exclude>
Expand Down

0 comments on commit 9e543ca

Please sign in to comment.