-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ALS-8098] Produce a list of all patients involved in query
- Add new expected result type PATIENTS - Add new PatientProcessor to produce result - Add to FileSharingService to enable uploader integration
- Loading branch information
Luke Sikina
committed
Dec 23, 2024
1 parent
0d35b8c
commit 5d83730
Showing
8 changed files
with
176 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/patient/PatientProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.patient; | ||
|
||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.AbstractProcessor; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.AsyncResult; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.HpdsProcessor; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class PatientProcessor implements HpdsProcessor { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(PatientProcessor.class); | ||
private final AbstractProcessor abstractProcessor; | ||
|
||
@Autowired | ||
public PatientProcessor(AbstractProcessor abstractProcessor) { | ||
this.abstractProcessor = abstractProcessor; | ||
} | ||
|
||
@Override | ||
public String[] getHeaderRow(Query query) { | ||
return new String[]{"PATIENT_NUM"}; | ||
} | ||
|
||
@Override | ||
public void runQuery(Query query, AsyncResult asyncResult) { | ||
LOG.info("Pulling results for query {}", query.getId()); | ||
// floating all this in memory is a bit gross, but the whole list of | ||
// patient IDs was already there, so I don't feel too bad | ||
List<String[]> allPatients = abstractProcessor.getPatientSubsetForQuery(query).stream() | ||
.map(patient -> new String[]{patient.toString()}) | ||
.toList(); | ||
LOG.info("Writing results for query {}", query.getId()); | ||
asyncResult.appendResults(allPatients); | ||
LOG.info("Completed query {}", query.getId()); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/patient/PatientProcessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.patient; | ||
|
||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; | ||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.ResultType; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.AbstractProcessor; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.AsyncResult; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
|
||
import java.util.List; | ||
import java.util.TreeSet; | ||
|
||
@EnableAutoConfiguration | ||
@SpringBootTest(classes = PatientProcessor.class) | ||
class PatientProcessorTest { | ||
|
||
@MockBean | ||
AbstractProcessor abstractProcessor; | ||
|
||
@Autowired | ||
PatientProcessor subject; | ||
|
||
@Test | ||
void shouldProcessPatientQuery() { | ||
Query q = new Query(); | ||
q.setId("frank"); | ||
q.setPicSureId("frank"); | ||
q.setExpectedResultType(ResultType.PATIENTS); | ||
AsyncResult writeToThis = Mockito.mock(AsyncResult.class); | ||
Mockito.when(abstractProcessor.getPatientSubsetForQuery(q)) | ||
.thenReturn(new TreeSet<>(List.of(1, 2, 42))); | ||
|
||
subject.runQuery(q, writeToThis); | ||
|
||
Mockito.verify(writeToThis, Mockito.times(1)) | ||
.appendResults(Mockito.argThat(strings -> | ||
strings.size() == 3 && | ||
strings.get(0)[0].equals("1") && | ||
strings.get(1)[0].equals("2") && | ||
strings.get(2)[0].equals("42")) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters