Skip to content

Commit

Permalink
change query to add age_binned from participant table
Browse files Browse the repository at this point in the history
  • Loading branch information
Dert1129 committed Oct 29, 2024
1 parent e7a1702 commit 822ae5e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class ParticipantClinicalDataset implements Serializable{
private String onRaasBlockade;
@Column(name = "race")
private String race;
@Column(name = "age_binned")
private String ageBinned;


public int getParticipantClinicalId() {
Expand Down Expand Up @@ -142,6 +144,14 @@ public void setRace(String race){
public String getRace() {
return race;
}

public String getAgeBinned() {
return this.ageBinned;
}

public void setAgeBinned(String ageBinned) {
this.ageBinned = ageBinned;
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@
public interface ParticipantClinicalDatasetRepository extends CrudRepository<ParticipantClinicalDataset, Long> {

@Cacheable("participantById")
@Query(value = "select * from participant_clinical where participant_id= :participantId", nativeQuery = true)
@Query(value = "SELECT " +
"pc.participant_clinical_id, " +
"pc.participant_id, " +
"pc.kdigo_stage," +
"pc.baseline_egfr, " +
"pc.proteinuria," +
"pc.a1c, " +
"pc.albuminuria, " +
"pc.diabetes_history," +
"pc.diabetes_duration, " +
"pc.hypertension_history," +
"pc.hypertension_duration, " +
"pc.on_raas_blockade," +
"pc.race, " +
"p.age_binned " +
"from participant_clinical pc join participant p on pc.participant_id = p.participant_id where pc.participant_id = :participantId ", nativeQuery = true)
ParticipantClinicalDataset findByParticipantId(@Param("participantId") Integer participantId);

}
1 change: 1 addition & 0 deletions src/main/resources/graphql/knowledge_environment.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,5 @@ type ParticipantClinicalDataset {
hypertensionDuration: String
onRaasBlockade: String
race: String
ageBinned: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,11 @@ void testSetRace(){
participantClinicalDataset.setRace("alien from outer space");
assertEquals("alien from outer space", participantClinicalDataset.getRace());
}

@Test
void testSetAgeBinned() {
participantClinicalDataset.setAgeBinned("age-age2");
assertEquals("age-age2", participantClinicalDataset.getAgeBinned());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void testGetParticipantClincialDataset() throws Exception {
expectedResult.setParticipantId(99);
expectedResult.setProteinuria("proteinuria");
expectedResult.setRace("alien from outer space");
expectedResult.setAgeBinned("age");


when(participantSummaryDatasetRepository.findIdByRedcapId(newPart.getRedcapId())).thenReturn(newPart.getParticipantId());
Expand All @@ -92,6 +93,7 @@ public void testGetParticipantClincialDataset() throws Exception {
assertEquals("Yes", result.getOnRaasBlockade());
assertEquals("proteinuria", result.getProteinuria());
assertEquals("alien from outer space", result.getRace());
assertEquals("age", result.getAgeBinned());
}

@Test
Expand Down

0 comments on commit 822ae5e

Please sign in to comment.