From 7b36b968f6c595da65143cb614ca2e1964e150c5 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Fri, 25 Oct 2024 14:09:07 -0400 Subject: [PATCH] implement backend for participant Clincial --- src/main/java/org/kpmp/QueryController.java | 11 ++ .../ParticipantClinicalDataset.java | 137 ++++++++++++++++++ .../ParticipantClinicalDatasetRepository.java | 15 ++ .../kpmp/participant/ParticipantService.java | 9 +- .../ParticipantSummaryDatasetRepository.java | 3 + .../graphql/knowledge_environment.graphqls | 16 ++ .../ParticipantClinicalDatasetTest.java | 96 ++++++++++++ .../participant/ParticipantServiceTest.java | 42 +++++- 8 files changed, 327 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java create mode 100644 src/main/java/org/kpmp/participant/ParticipantClinicalDatasetRepository.java create mode 100644 src/test/java/org/kpmp/participant/ParticipantClinicalDatasetTest.java diff --git a/src/main/java/org/kpmp/QueryController.java b/src/main/java/org/kpmp/QueryController.java index ce2d1e9..1e31bdf 100755 --- a/src/main/java/org/kpmp/QueryController.java +++ b/src/main/java/org/kpmp/QueryController.java @@ -18,6 +18,7 @@ import org.kpmp.geneExpression.*; import org.kpmp.geneExpressionSummary.GeneExpressionSummary; import org.kpmp.geneExpressionSummary.GeneExpressionSummaryService; +import org.kpmp.participant.ParticipantClinicalDataset; import org.kpmp.participant.ParticipantDataTypeSummary; import org.kpmp.participant.ParticipantRepoDataTypeInformation; import org.kpmp.participant.ParticipantRepoDataTypeSummary; @@ -191,6 +192,16 @@ public List getRPGeneExpressionByTissue(@Argument String geneS } } + @QueryMapping + public ParticipantClinicalDataset getParticipantClinicalDataset(@Argument String redcapId) { + try{ + return participantService.getParticipantClinicalDataset(redcapId); + }catch (Exception e) { + logger.error(e.getMessage()); + throw e; + } + } + @QueryMapping public ParticipantDataTypeSummary getDataTypeInformationByParticipant(@Argument String redcapId) { return participantService.getExperimentCounts(redcapId); diff --git a/src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java b/src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java new file mode 100644 index 0000000..daa762c --- /dev/null +++ b/src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java @@ -0,0 +1,137 @@ +package org.kpmp.participant; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "participant_clinical") +public class ParticipantClinicalDataset implements Serializable{ + @Id + @Column(name="participant_clinical_id") + private int participantClinicalId; + @Column(unique = true, name = "participant_id") + private int participantId; + @Column(name = "kdigo_stage") + private String kdigoStage; + @Column(name = "baseline_egfr") + private String baselineEgfr; + @Column(name = "proteinuria") + private String proteinuria; + @Column(name = "a1c") + private String a1c; + @Column(name = "albuminuria") + private String albuminuria; + @Column(name = "diabetes_history") + private String diabetesHistory; + @Column(name = "diabetes_duration") + private String diabetesDuration; + @Column(name = "hypertension_history") + private String hypertensionHistory; + @Column(name = "hypertension_duration") + private String hypertensionDuration; + @Column(name = "on_raas_blockade") + private String onRaasBlockade; + + + public int getParticipantClinicalId() { + return this.participantClinicalId; + } + + public void setParticipantClinicalId(int participantClinicalId) { + this.participantClinicalId = participantClinicalId; + } + + public int getParticipantId() { + return this.participantId; + } + + public void setParticipantId(int participantId) { + this.participantId = participantId; + } + + public String getKdigoStage() { + return this.kdigoStage; + } + + public void setKdigoStage(String kdigoStage) { + this.kdigoStage = kdigoStage; + } + + public String getBaselineEgfr() { + return this.baselineEgfr; + } + + public void setBaselineEgfr(String baselineEgfr) { + this.baselineEgfr = baselineEgfr; + } + + public String getProteinuria() { + return this.proteinuria; + } + + public void setProteinuria(String proteinuria) { + this.proteinuria = proteinuria; + } + + public String getA1c() { + return this.a1c; + } + + public void setA1c(String a1c) { + this.a1c = a1c; + } + + public String getAlbuminuria() { + return this.albuminuria; + } + + public void setAlbuminuria(String albuminuria) { + this.albuminuria = albuminuria; + } + + public String getDiabetesHistory() { + return this.diabetesHistory; + } + + public void setDiabetesHistory(String diabetesHistory) { + this.diabetesHistory = diabetesHistory; + } + + public String getDiabetesDuration() { + return this.diabetesDuration; + } + + public void setDiabetesDuration(String diabetesDuration) { + this.diabetesDuration = diabetesDuration; + } + + public String getHypertensionHistory() { + return this.hypertensionHistory; + } + + public void setHypertensionHistory(String hypertensionHistory) { + this.hypertensionHistory = hypertensionHistory; + } + + public String getHypertensionDuration() { + return this.hypertensionDuration; + } + + public void setHypertensionDuration(String hypertensionDuration) { + this.hypertensionDuration = hypertensionDuration; + } + + public String getOnRaasBlockade() { + return this.onRaasBlockade; + } + + public void setOnRaasBlockade(String onRaasBlockade) { + this.onRaasBlockade = onRaasBlockade; + } + +} + diff --git a/src/main/java/org/kpmp/participant/ParticipantClinicalDatasetRepository.java b/src/main/java/org/kpmp/participant/ParticipantClinicalDatasetRepository.java new file mode 100644 index 0000000..b46c99e --- /dev/null +++ b/src/main/java/org/kpmp/participant/ParticipantClinicalDatasetRepository.java @@ -0,0 +1,15 @@ +package org.kpmp.participant; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +@Repository +public interface ParticipantClinicalDatasetRepository extends CrudRepository { + + @Cacheable("participantById") + @Query(value = "select * from participant_clinical where participant_id= :participantId", nativeQuery = true) + ParticipantClinicalDataset findByParticipantId(@Param("participantId") Integer participantId); +} diff --git a/src/main/java/org/kpmp/participant/ParticipantService.java b/src/main/java/org/kpmp/participant/ParticipantService.java index da2f4ac..c3d794c 100755 --- a/src/main/java/org/kpmp/participant/ParticipantService.java +++ b/src/main/java/org/kpmp/participant/ParticipantService.java @@ -41,13 +41,14 @@ public class ParticipantService { private RTParticipantRepository rtParticipantRepo; private ParticipantRepoDataRepository fileByParticipantRepo; private RPParticipantRepository rpParticipantRepository; + private ParticipantClinicalDatasetRepository participantClinicalDatasetRepo; @Autowired public ParticipantService(DataSummaryRepository dataSummaryRepo, SpatialViewerTypeRepository svTypeRepo, SingleCellMetadataRepository scMetadataRepo, SingleNucleusMetadataRepository snMetadataRepo, RTParticipantRepository rtParticipantRepo, ParticipantSummaryDatasetRepository participantSummaryDatasetRepository, RPParticipantRepository rpParticipantRepository, - ParticipantRepoDataRepository fileByParticipantRepo) { + ParticipantRepoDataRepository fileByParticipantRepo, ParticipantClinicalDatasetRepository participantClinicalDatasetRepo) { this.dataSummaryRepo = dataSummaryRepo; this.svTypeRepo = svTypeRepo; this.scMetadataRepo = scMetadataRepo; @@ -56,8 +57,14 @@ public ParticipantService(DataSummaryRepository dataSummaryRepo, SpatialViewerTy this.participantSummaryDatasetRepository = participantSummaryDatasetRepository; this.rpParticipantRepository = rpParticipantRepository; this.fileByParticipantRepo = fileByParticipantRepo; + this.participantClinicalDatasetRepo = participantClinicalDatasetRepo; } + public ParticipantClinicalDataset getParticipantClinicalDataset(String redcapId){ + Integer participantId = participantSummaryDatasetRepository.findIdByRedcapId(redcapId); + return participantClinicalDatasetRepo.findByParticipantId(participantId); + } + public ParticipantSummaryDataset getParticipantSummaryDataset(String redcapId) { return participantSummaryDatasetRepository.findByRedcapId(redcapId); } diff --git a/src/main/java/org/kpmp/participant/ParticipantSummaryDatasetRepository.java b/src/main/java/org/kpmp/participant/ParticipantSummaryDatasetRepository.java index c262d60..e3e817a 100755 --- a/src/main/java/org/kpmp/participant/ParticipantSummaryDatasetRepository.java +++ b/src/main/java/org/kpmp/participant/ParticipantSummaryDatasetRepository.java @@ -13,6 +13,9 @@ public interface ParticipantSummaryDatasetRepository extends CrudRepository=1000 mg/g cr"); + + + when(participantSummaryDatasetRepository.findIdByRedcapId(newPart.getRedcapId())).thenReturn(newPart.getParticipantId()); + + when(participantService.getParticipantClinicalDataset(newPart.getRedcapId())).thenReturn(expectedResult); + + ParticipantClinicalDataset result = participantService.getParticipantClinicalDataset("1234"); + + assertEquals(0, result.getParticipantClinicalId()); + assertEquals(99, result.getParticipantId()); + assertEquals("40%", result.getA1c()); + assertEquals("30 to <300 mg/g cr", result.getAlbuminuria()); + assertEquals("50-59 ml/min/1.73m2", result.getBaselineEgfr()); + assertEquals("40-49 Years", result.getDiabetesDuration()); + assertEquals("Yes", result.getDiabetesHistory()); + assertEquals("Stage 4", result.getKdigoStage()); + assertEquals("Yes", result.getOnRaasBlockade()); + assertEquals(">=1000 mg/g cr", result.getProteinuria()); + } + @Test public void testGetParticipantSummaryDataset() throws Exception {