Skip to content

Commit

Permalink
Extending Concept Set Items with Annotations (#2403)
Browse files Browse the repository at this point in the history
Co-authored-by: Hernaldo Urbina <[email protected]>
Co-authored-by: hernaldo.urbina <mailto:[email protected]>
Co-authored-by: oleg-odysseus <[email protected]>
  • Loading branch information
4 people authored Dec 17, 2024
1 parent 02a9c9f commit 67f8816
Show file tree
Hide file tree
Showing 19 changed files with 813 additions and 106 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/ohdsi/webapi/conceptset/ConceptSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.OneToOne;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.ohdsi.webapi.model.CommonEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package org.ohdsi.webapi.conceptset.annotation;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.ohdsi.webapi.model.CommonEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

@Entity(name = "ConceptSetAnnotation")
@Table(name = "concept_set_annotation")
public class ConceptSetAnnotation implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;

@Id
@GenericGenerator(
name = "concept_set_annotation_generator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "concept_set_annotation_sequence"),
@Parameter(name = "increment_size", value = "1")
}
)
@GeneratedValue(generator = "concept_set_annotation_generator")
@Column(name = "concept_set_annotation_id")
private Integer id;

@Column(name = "concept_set_id", nullable = false)
private Integer conceptSetId;

@Column(name = "concept_id")
private Integer conceptId;

@Column(name = "annotation_details")
private String annotationDetails;

@Column(name = "vocabulary_version")
private String vocabularyVersion;

@Column(name = "concept_set_version")
private Integer conceptSetVersion;

@Column(name = "copied_from_concept_set_ids")
private String copiedFromConceptSetIds;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Integer getConceptSetId() {
return conceptSetId;
}

public void setConceptSetId(Integer conceptSetId) {
this.conceptSetId = conceptSetId;
}

public Integer getConceptId() {
return conceptId;
}

public void setConceptId(Integer conceptId) {
this.conceptId = conceptId;
}

public String getAnnotationDetails() {
return annotationDetails;
}

public void setAnnotationDetails(String annotationDetails) {
this.annotationDetails = annotationDetails;
}

public String getVocabularyVersion() {
return vocabularyVersion;
}

public void setVocabularyVersion(String vocabularyVersion) {
this.vocabularyVersion = vocabularyVersion;
}

public Integer getConceptSetVersion() {
return conceptSetVersion;
}

public void setConceptSetVersion(Integer conceptSetVersion) {
this.conceptSetVersion = conceptSetVersion;
}

public String getCopiedFromConceptSetIds() {
return copiedFromConceptSetIds;
}

public void setCopiedFromConceptSetIds(String copiedFromConceptSetIds) {
this.copiedFromConceptSetIds = copiedFromConceptSetIds;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.ohdsi.webapi.conceptset.annotation;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface ConceptSetAnnotationRepository extends JpaRepository<ConceptSetAnnotation, Integer> {

@Query("DELETE FROM ConceptSetAnnotation cc WHERE cc.conceptSetId = :conceptSetId and cc.conceptId in :conceptId")
void deleteAnnotationByConceptSetIdAndInConceptId(int conceptSetId, List<Integer> conceptId);

void deleteAnnotationByConceptSetIdAndConceptId(int conceptSetId, int conceptId);

List<ConceptSetAnnotation> findByConceptSetId(int conceptSetId);
ConceptSetAnnotation findById(int id);
void deleteById(int id);
Optional<ConceptSetAnnotation> findConceptSetAnnotationByConceptIdAndConceptId(int conceptSetId, int conceptId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ public class ConceptSetPermissionSchema extends EntityPermissionSchema {
private static Map<String, String> writePermissions = new HashMap<String, String>() {{
put("conceptset:%s:put", "Update Concept Set with ID = %s");
put("conceptset:%s:items:put", "Update Items of Concept Set with ID = %s");
put("conceptset:*:annotation:put", "Create Concept Set Annotation");
put("conceptset:%s:annotation:*:delete", "Delete Annotations of Concept Set with ID = %s");
put("conceptset:*:annotation:*:delete", "Delete Annotations of any Concept Set");
put("conceptset:%s:delete", "Delete Concept Set with ID = %s");
}};

private static Map<String, String> readPermissions = new HashMap<String, String>() {{
put("conceptset:%s:get", "view conceptset definition with id %s");
put("conceptset:%s:expression:get", "Resolve concept set %s expression");
put("conceptset:%s:annotation:get", "Resolve concept set annotations");
put("conceptset:*:annotation:get", "Resolve concept set annotations");
put("conceptset:%s:version:*:expression:get", "Get expression for concept set %s items for default source");
}};

public ConceptSetPermissionSchema() {

super(EntityType.CONCEPT_SET, readPermissions, writePermissions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public enum EntityType {
COHORT_SAMPLE(CohortSample.class),
TAG(Tag.class),
REUSABLE(Reusable.class);

private final Class<? extends CommonEntity> entityClass;

EntityType(Class<? extends CommonEntity> entityClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.ohdsi.webapi.conceptset.ConceptSetComparison;
import org.ohdsi.webapi.conceptset.ConceptSetItemRepository;
import org.ohdsi.webapi.conceptset.ConceptSetRepository;
import org.ohdsi.webapi.conceptset.annotation.ConceptSetAnnotationRepository;
import org.ohdsi.webapi.exception.BadRequestAtlasException;
import org.ohdsi.webapi.ircalc.IncidenceRateAnalysis;
import org.ohdsi.webapi.model.CommonEntity;
Expand Down Expand Up @@ -106,6 +107,9 @@ public abstract class AbstractDaoService extends AbstractAdminService {
@Autowired
private ConceptSetItemRepository conceptSetItemRepository;

@Autowired
private ConceptSetAnnotationRepository conceptSetAnnotationRepository;

@Autowired
protected Security security;

Expand All @@ -120,6 +124,9 @@ public abstract class AbstractDaoService extends AbstractAdminService {
public ConceptSetItemRepository getConceptSetItemRepository() {
return conceptSetItemRepository;
}
public ConceptSetAnnotationRepository getConceptSetAnnotationRepository() {
return conceptSetAnnotationRepository;
}

@Autowired
private ConceptSetRepository conceptSetRepository;
Expand Down
Loading

0 comments on commit 67f8816

Please sign in to comment.