use of org.pmiops.workbench.model.SearchParameter in project workbench by all-of-us.
the class DemoQueryBuilderTest method buildQueryJobConfig.
@Test
public void buildQueryJobConfig() throws Exception {
String genderNamedParameter = "";
String ageNamedParameter = "";
String raceNamedParameter = "";
List<SearchParameter> params = new ArrayList<>();
params.add(new SearchParameter().type("DEMO").subtype("GEN").conceptId(8507L));
params.add(new SearchParameter().type("DEMO").subtype("AGE").attribute(new Attribute().operator("=").operands(Arrays.asList("18"))));
params.add(new SearchParameter().type("DEM0").subtype("RACE").conceptId(1234L));
params.add(new SearchParameter().type("DEM0").subtype("RACE").conceptId(1235L));
QueryJobConfiguration queryJobConfiguration = queryBuilder.buildQueryJobConfig(new QueryParameters().type("DEMO").parameters(params));
for (String key : queryJobConfiguration.getNamedParameters().keySet()) {
if (key.startsWith("gen")) {
genderNamedParameter = key;
} else if (key.startsWith("race")) {
raceNamedParameter = key;
} else {
ageNamedParameter = key;
}
}
String expected = "select person_id\n" + "from `${projectId}.${dataSetId}.person` p\n" + "where\n" + "p.gender_concept_id in unnest(@" + genderNamedParameter + ")\n" + "and\n" + "p.race_concept_id in unnest(@" + raceNamedParameter + ")\n" + "and\n" + "CAST(FLOOR(DATE_DIFF(CURRENT_DATE, DATE(p.year_of_birth, p.month_of_birth, p.day_of_birth), MONTH)/12) as INT64) =\n" + "@" + ageNamedParameter + "\n";
assertEquals(expected, queryJobConfiguration.getQuery());
assertEquals("8507", queryJobConfiguration.getNamedParameters().get(genderNamedParameter).getArrayValues().get(0).getValue());
assertEquals("18", queryJobConfiguration.getNamedParameters().get(ageNamedParameter).getValue());
assertEquals("1234", queryJobConfiguration.getNamedParameters().get(raceNamedParameter).getArrayValues().get(0).getValue());
assertEquals("1235", queryJobConfiguration.getNamedParameters().get(raceNamedParameter).getArrayValues().get(1).getValue());
}
use of org.pmiops.workbench.model.SearchParameter in project workbench by all-of-us.
the class SearchRequests method codesRequest.
public static SearchRequest codesRequest(String type, String... codes) {
SearchGroupItem searchGroupItem = new SearchGroupItem().id("id1").type(type);
for (String code : codes) {
SearchParameter parameter = new SearchParameter().type(type).group(true).value(code);
searchGroupItem.addSearchParametersItem(parameter);
}
return searchRequest(searchGroupItem);
}
use of org.pmiops.workbench.model.SearchParameter in project workbench by all-of-us.
the class DomainLookupService method findCodesForEmptyDomains.
/**
* Find all domain ids for {@link SearchGroup}s in the following groups:
* ICD9, ICD10 and CPT.
*
* @param searchGroups
*/
public void findCodesForEmptyDomains(List<SearchGroup> searchGroups) {
searchGroups.stream().flatMap(searchGroup -> searchGroup.getItems().stream()).filter(item -> item.getType().matches("ICD9|ICD10")).forEach(item -> {
List<SearchParameter> paramsWithDomains = new ArrayList<>();
for (SearchParameter parameter : item.getSearchParameters()) {
if (parameter.getDomain() == null || parameter.getDomain().isEmpty()) {
List<String> domainLookups = (parameter.getSubtype() == null) ? criteriaDao.findCriteriaByTypeAndCode(parameter.getType(), parameter.getValue()) : criteriaDao.findCriteriaByTypeAndSubtypeAndCode(parameter.getType(), parameter.getSubtype(), parameter.getValue());
for (String row : domainLookups) {
paramsWithDomains.add(new SearchParameter().domain(row).value(parameter.getValue()).type(parameter.getType()).subtype(parameter.getSubtype()).group(parameter.getGroup()));
}
} else {
paramsWithDomains.add(parameter);
}
}
item.setSearchParameters(paramsWithDomains);
});
}
use of org.pmiops.workbench.model.SearchParameter in project workbench by all-of-us.
the class CohortBuilderControllerTest method countSubjectsDemoDec.
@Test
public void countSubjectsDemoDec() throws Exception {
Criteria demoGender = createDemoCriteria("DEMO", "DEC", null);
SearchParameter demo = createSearchParameter(demoGender, "Deceased");
SearchRequest searchRequest = createSearchRequests(demoGender.getType(), Arrays.asList(demo));
assertParticipants(controller.countParticipants(cdrVersion.getCdrVersionId(), searchRequest), 1);
}
use of org.pmiops.workbench.model.SearchParameter in project workbench by all-of-us.
the class CohortBuilderControllerTest method countSubjectsICD10ProcedureOccurrenceParent.
@Test
public void countSubjectsICD10ProcedureOccurrenceParent() throws Exception {
SearchParameter icd10 = createSearchParameter(icd10ProcedureParent, "16");
SearchRequest searchRequest = createSearchRequests(icd10ProcedureParent.getType(), Arrays.asList(icd10));
assertParticipants(controller.countParticipants(cdrVersion.getCdrVersionId(), searchRequest), 1);
}
Aggregations