Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement backend for participant Clincial #151

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
147 changes: 147 additions & 0 deletions src/main/java/org/kpmp/participant/ParticipantClinicalDataset.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
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;
@Column(name = "race")
private String race;


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;
}

public void setRace(String race){
this.race = race;
}

public String getRace() {
return race;
}

}

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
17 changes: 17 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,20 @@ 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
race: String
}
12 changes: 12 additions & 0 deletions src/test/java/org/kpmp/QueryControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.kpmp.geneExpressionSummary.GeneExpressionSummaryService;
import org.kpmp.geneExpressionSummary.singleCell.SCRNAGeneExpressionExpressionSummaryValue;
import org.kpmp.geneExpressionSummary.singleNucleus.SNRNAGeneExpressionExpressionSummaryValue;
import org.kpmp.participant.ParticipantClinicalDataset;
import org.kpmp.participant.ParticipantDataTypeSummary;
import org.kpmp.participant.ParticipantRepoDataTypeInformation;
import org.kpmp.participant.ParticipantRepoDataTypeSummary;
Expand Down Expand Up @@ -283,6 +284,16 @@ public void testGetRepoDataTypeInformationByParticipant() throws Exception {

}

@Test
public void testGetParticipantClincialDataset() throws Exception {
ParticipantClinicalDataset expected = new ParticipantClinicalDataset();
when(participantService.getParticipantClinicalDataset("participant_id")).thenReturn(expected);

assertEquals(expected, query.getParticipantClinicalDataset("participant_id"));
verify(participantService).getParticipantClinicalDataset("participant_id");
}

@Test
public void testParticipantSummaryDataset() throws Exception {
ParticipantSummaryDataset expected = new ParticipantSummaryDataset();
when(participantService.getParticipantSummaryDataset("participant_id")).thenReturn(expected);
Expand All @@ -291,6 +302,7 @@ public void testParticipantSummaryDataset() throws Exception {
verify(participantService).getParticipantSummaryDataset("participant_id");
}

@Test
public void getParticipantEnrollmentCategorySummary() throws Exception {
List<ParticipantEnrollmentCategorySummary> expectedResult = new ArrayList<>();

Expand Down
102 changes: 102 additions & 0 deletions src/test/java/org/kpmp/participant/ParticipantClinicalDatasetTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
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());
}

@Test
void testSetRace(){
participantClinicalDataset.setRace("alien from outer space");
assertEquals("alien from outer space", participantClinicalDataset.getRace());
}

}
Loading
Loading