Skip to content

Commit

Permalink
[ALS-6344] - Make new query that retuns patient count and concept count
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Jul 1, 2024
1 parent 5f08d17 commit 611a84a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,11 @@ public enum ResultType {
* is suitable to time series analysis and/or loading into another
* instance of HPDS.
*/
DATAFRAME_TIMESERIES
DATAFRAME_TIMESERIES,

/**
* Count number of patients and number of available concept paths. Useful for federated networks
* where not every concept path in a query is guaranteed to be in a specific portal
*/
PATIENT_AND_CONCEPT_COUNT
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,20 @@ public Map<String, Object> runVariantCount(Query query) {
}
return response;
}

public PatientAndConceptCount runPatientAndConceptCount(Query incomingQuery) {
log.info("Starting Patient and Concept Count query {}", incomingQuery.getPicSureId());
log.info("Calculating available concepts");
long concepts = incomingQuery.getFields().stream()
.map(abstractProcessor::nullableGetCube)
.filter(Optional::isPresent)
.count();
log.info("Calculating patient counts");
int patients = runCounts(incomingQuery);
PatientAndConceptCount patientAndConceptCount = new PatientAndConceptCount();
patientAndConceptCount.setConceptCount(concepts);
patientAndConceptCount.setPatientCount(patients);
log.info("Completed Patient and Concept Count query {}", incomingQuery.getPicSureId());
return patientAndConceptCount;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package edu.harvard.hms.dbmi.avillach.hpds.processing;

public class PatientAndConceptCount {
private long patientCount, conceptCount;

public long getPatientCount() {
return patientCount;
}

public void setPatientCount(long patientCount) {
this.patientCount = patientCount;
}

public long getConceptCount() {
return conceptCount;
}

public void setConceptCount(long conceptCount) {
this.conceptCount = conceptCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ private Response submitQueryAndWaitForCompletion(QueryRequest resultRequest) thr
case COUNT:
return queryOkResponse(countProcessor.runCounts(incomingQuery), incomingQuery).build();

case PATIENT_AND_CONCEPT_COUNT:
return queryOkResponse(countProcessor.runPatientAndConceptCount(incomingQuery), incomingQuery).build();

default:
// no valid type
return Response.status(Status.BAD_REQUEST).build();
Expand Down

0 comments on commit 611a84a

Please sign in to comment.