From 822ae5e78c9f429b7328808d62934f8a0a319e64 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Tue, 29 Oct 2024 11:02:03 -0400 Subject: [PATCH] change query to add age_binned from participant table --- .../ParticipantClinicalDataset.java | 10 ++++++++++ .../ParticipantClinicalDatasetRepository.java | 18 +++++++++++++++++- .../graphql/knowledge_environment.graphqls | 1 + .../ParticipantClinicalDatasetTest.java | 6 ++++++ .../participant/ParticipantServiceTest.java | 2 ++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java b/src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java index cb5e3d4..5d97a51 100644 --- a/src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java +++ b/src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java @@ -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() { @@ -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; + } } diff --git a/src/main/java/org/kpmp/participant/ParticipantClinicalDatasetRepository.java b/src/main/java/org/kpmp/participant/ParticipantClinicalDatasetRepository.java index b46c99e..8033ff2 100644 --- a/src/main/java/org/kpmp/participant/ParticipantClinicalDatasetRepository.java +++ b/src/main/java/org/kpmp/participant/ParticipantClinicalDatasetRepository.java @@ -10,6 +10,22 @@ public interface ParticipantClinicalDatasetRepository extends CrudRepository { @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); + } diff --git a/src/main/resources/graphql/knowledge_environment.graphqls b/src/main/resources/graphql/knowledge_environment.graphqls index b06b56b..0b65d89 100755 --- a/src/main/resources/graphql/knowledge_environment.graphqls +++ b/src/main/resources/graphql/knowledge_environment.graphqls @@ -237,4 +237,5 @@ type ParticipantClinicalDataset { hypertensionDuration: String onRaasBlockade: String race: String + ageBinned: String } \ No newline at end of file diff --git a/src/test/java/org/kpmp/participant/ParticipantClinicalDatasetTest.java b/src/test/java/org/kpmp/participant/ParticipantClinicalDatasetTest.java index 252053b..960659d 100644 --- a/src/test/java/org/kpmp/participant/ParticipantClinicalDatasetTest.java +++ b/src/test/java/org/kpmp/participant/ParticipantClinicalDatasetTest.java @@ -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()); + } } diff --git a/src/test/java/org/kpmp/participant/ParticipantServiceTest.java b/src/test/java/org/kpmp/participant/ParticipantServiceTest.java index 49965bd..dc79dd4 100755 --- a/src/test/java/org/kpmp/participant/ParticipantServiceTest.java +++ b/src/test/java/org/kpmp/participant/ParticipantServiceTest.java @@ -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()); @@ -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