Skip to content

Commit

Permalink
implement backend for participant Clincial
Browse files Browse the repository at this point in the history
  • Loading branch information
Dert1129 committed Oct 25, 2024
1 parent 4a712b3 commit 7b36b96
Show file tree
Hide file tree
Showing 8 changed files with 327 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/kpmp/QueryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -191,6 +192,16 @@ public List<RPAccessionGroup> 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);
Expand Down
137 changes: 137 additions & 0 deletions src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java
Original file line number Diff line number Diff line change
@@ -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;
}

}

Original file line number Diff line number Diff line change
@@ -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<ParticipantClinicalDataset, Long> {

@Cacheable("participantById")
@Query(value = "select * from participant_clinical where participant_id= :participantId", nativeQuery = true)
ParticipantClinicalDataset findByParticipantId(@Param("participantId") Integer participantId);
}
9 changes: 8 additions & 1 deletion src/main/java/org/kpmp/participant/ParticipantService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public interface ParticipantSummaryDatasetRepository extends CrudRepository<Part
@Query(value = "select * from participant where redcap_id= :redcapId", nativeQuery = true)
ParticipantSummaryDataset findByRedcapId(@Param("redcapId") String redcapId);

@Query(value = "SELECT participant_id FROM participant WHERE redcap_id= :redcapId", nativeQuery = true)
Integer findIdByRedcapId(@Param("redcapId") String redcapId);

@Cacheable("partipantByEnrollmentCategory")
@Query(value = "select count(*) from participant where enrollment_category= :enrollment_category", nativeQuery = true)
Long getDataSummaryCount(@Param("enrollment_category") String enrollment_category);
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/graphql/knowledge_environment.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Query {
getAtlasSummaryRows: AtlasRepoSummaryResult
getAtlasMessages: [AtlasMessages]
getExperimentalStrategyCountsByParticipant(redcapId: String!): [ParticipantRepoDataTypeInformation]
getParticipantClinicalDataset(redcapId: String!): ParticipantClinicalDataset
}

type AtlasMessages {
Expand Down Expand Up @@ -220,4 +221,19 @@ type ParticipantSummaryDataset {
redcapId: String
enrollmentCategory: String
clinicalData: String
}

type ParticipantClinicalDataset {
participantId: String
participantClinicalId: String
kdigoStage: String
baselineEgfr: String
proteinuria: String
a1c: String
albuminuria: String
diabetesHistory: String
diabetesDuration: String
hypertensionHistory: String
hypertensionDuration: String
onRaasBlockade: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package org.kpmp.participant;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;

@TestInstance(Lifecycle.PER_CLASS)
public class ParticipantClinicalDatasetTest {
ParticipantClinicalDataset participantClinicalDataset;

@BeforeAll
public void setUp() throws Exception {
this.participantClinicalDataset = new ParticipantClinicalDataset();
}

@AfterAll
public void tearDown() throws Exception {
participantClinicalDataset = null;
}

@Test
void testSetParticipantClicalId() {
participantClinicalDataset.setParticipantClinicalId(0);
assertEquals(0, participantClinicalDataset.getParticipantClinicalId());
}

@Test
void testSetParticipantId() {
participantClinicalDataset.setParticipantId(2);
assertEquals(2, participantClinicalDataset.getParticipantId());
}

@Test
void testSetKdigoStage() {
participantClinicalDataset.setKdigoStage("Stage 1");
assertEquals("Stage 1", participantClinicalDataset.getKdigoStage());
}

@Test
void testSetBaselineEgfr() {
participantClinicalDataset.setBaselineEgfr("blah");
assertEquals("blah", participantClinicalDataset.getBaselineEgfr());
}

@Test
void testSetProteinuria() {
participantClinicalDataset.setProteinuria("proteinuria");
assertEquals("proteinuria", participantClinicalDataset.getProteinuria());
}

@Test
void testSetA1c() {
participantClinicalDataset.setA1c("a1c");
assertEquals("a1c", participantClinicalDataset.getA1c());
}

@Test
void testSetAlbuminuria() {
participantClinicalDataset.setAlbuminuria("ouchie");
assertEquals("ouchie", participantClinicalDataset.getAlbuminuria());
}

@Test
void testSetDiabetesHistory() {
participantClinicalDataset.setDiabetesHistory("nope");
assertEquals("nope", participantClinicalDataset.getDiabetesHistory());
}

@Test
void testSetDiabetesDuration () {
participantClinicalDataset.setDiabetesDuration("since the stone age");
assertEquals("since the stone age", participantClinicalDataset.getDiabetesDuration());
}

@Test
void testSetHypertensionHistory() {
participantClinicalDataset.setHypertensionHistory("yes");
assertEquals("yes", participantClinicalDataset.getHypertensionHistory());
}

@Test
void testSetHypertensionDuration() {
participantClinicalDataset.setHypertensionDuration("since the bronze age");
assertEquals("since the bronze age", participantClinicalDataset.getHypertensionDuration());
}

@Test
void testSetOnRaasBlockade() {
participantClinicalDataset.setOnRaasBlockade("yes");
assertEquals("yes", participantClinicalDataset.getOnRaasBlockade());
}

}
Loading

0 comments on commit 7b36b96

Please sign in to comment.