Skip to content

Commit

Permalink
Merge pull request #2474 from opencb/TASK-5964
Browse files Browse the repository at this point in the history
TASK-5964 - Clinical Improvements
  • Loading branch information
pfurio authored Aug 28, 2024
2 parents 35074a6 + 40651f8 commit d624826
Show file tree
Hide file tree
Showing 49 changed files with 1,663 additions and 656 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ private RestResponse<ClinicalAnalysis> create() throws Exception {
putNestedIfNotEmpty(beanParams, "disorder.id", commandOptions.disorderId, true);
putNestedIfNotEmpty(beanParams, "proband.id", commandOptions.probandId, true);
putNestedIfNotEmpty(beanParams, "family.id", commandOptions.familyId, true);
putNestedIfNotNull(beanParams, "panelLock", commandOptions.panelLock, true);
putNestedIfNotNull(beanParams, "panelLocked", commandOptions.panelLocked, true);
putNestedIfNotEmpty(beanParams, "analyst.id", commandOptions.analystId, true);
putNestedIfNotEmpty(beanParams, "report.title", commandOptions.reportTitle, true);
putNestedIfNotEmpty(beanParams, "report.overview", commandOptions.reportOverview, true);
Expand All @@ -367,6 +367,7 @@ private RestResponse<ClinicalAnalysis> create() throws Exception {
putNestedIfNotEmpty(beanParams, "responsible.address", commandOptions.responsibleAddress, true);
putNestedIfNotEmpty(beanParams, "responsible.city", commandOptions.responsibleCity, true);
putNestedIfNotEmpty(beanParams, "responsible.postcode", commandOptions.responsiblePostcode, true);
putNestedIfNotEmpty(beanParams, "interpretation.name", commandOptions.interpretationName, true);
putNestedIfNotEmpty(beanParams, "interpretation.description", commandOptions.interpretationDescription, true);
putNestedIfNotEmpty(beanParams, "interpretation.clinicalAnalysisId", commandOptions.interpretationClinicalAnalysisId, true);
putNestedIfNotEmpty(beanParams, "interpretation.creationDate", commandOptions.interpretationCreationDate, true);
Expand Down Expand Up @@ -419,6 +420,7 @@ private RestResponse<ObjectMap> distinct() throws Exception {
queryParams.putIfNotEmpty("dueDate", commandOptions.dueDate);
queryParams.putIfNotEmpty("qualityControlSummary", commandOptions.qualityControlSummary);
queryParams.putIfNotEmpty("release", commandOptions.release);
queryParams.putIfNotNull("snapshot", commandOptions.snapshot);
queryParams.putIfNotEmpty("status", commandOptions.status);
queryParams.putIfNotEmpty("internalStatus", commandOptions.internalStatus);
queryParams.putIfNotEmpty("annotation", commandOptions.annotation);
Expand All @@ -439,6 +441,7 @@ private RestResponse<ObjectMap> distinctInterpretation() throws Exception {
queryParams.putIfNotEmpty("study", commandOptions.study);
queryParams.putIfNotEmpty("id", commandOptions.id);
queryParams.putIfNotEmpty("uuid", commandOptions.uuid);
queryParams.putIfNotEmpty("name", commandOptions.name);
queryParams.putIfNotEmpty("clinicalAnalysisId", commandOptions.clinicalAnalysisId);
queryParams.putIfNotEmpty("analystId", commandOptions.analystId);
queryParams.putIfNotEmpty("methodName", commandOptions.methodName);
Expand Down Expand Up @@ -471,6 +474,7 @@ private RestResponse<Interpretation> searchInterpretation() throws Exception {
queryParams.putIfNotEmpty("study", commandOptions.study);
queryParams.putIfNotEmpty("id", commandOptions.id);
queryParams.putIfNotEmpty("uuid", commandOptions.uuid);
queryParams.putIfNotEmpty("name", commandOptions.name);
queryParams.putIfNotEmpty("clinicalAnalysisId", commandOptions.clinicalAnalysisId);
queryParams.putIfNotEmpty("analystId", commandOptions.analystId);
queryParams.putIfNotEmpty("methodName", commandOptions.methodName);
Expand Down Expand Up @@ -1145,6 +1149,7 @@ private RestResponse<ClinicalAnalysis> search() throws Exception {
queryParams.putIfNotEmpty("dueDate", commandOptions.dueDate);
queryParams.putIfNotEmpty("qualityControlSummary", commandOptions.qualityControlSummary);
queryParams.putIfNotEmpty("release", commandOptions.release);
queryParams.putIfNotNull("snapshot", commandOptions.snapshot);
queryParams.putIfNotEmpty("status", commandOptions.status);
queryParams.putIfNotEmpty("internalStatus", commandOptions.internalStatus);
queryParams.putIfNotEmpty("annotation", commandOptions.annotation);
Expand Down Expand Up @@ -1293,7 +1298,7 @@ private RestResponse<ClinicalAnalysis> update() throws Exception {
putNestedIfNotEmpty(beanParams, "description", commandOptions.description, true);
putNestedIfNotNull(beanParams, "type", commandOptions.type, true);
putNestedIfNotEmpty(beanParams, "disorder.id", commandOptions.disorderId, true);
putNestedIfNotNull(beanParams, "panelLock", commandOptions.panelLock, true);
putNestedIfNotNull(beanParams, "panelLocked", commandOptions.panelLocked, true);
putNestedIfNotEmpty(beanParams, "proband.id", commandOptions.probandId, true);
putNestedIfNotEmpty(beanParams, "family.id", commandOptions.familyId, true);
putNestedIfNotNull(beanParams, "locked", commandOptions.locked, true);
Expand Down Expand Up @@ -1325,6 +1330,7 @@ private RestResponse<ClinicalAnalysis> update() throws Exception {
putNestedIfNotEmpty(beanParams, "priority.id", commandOptions.priorityId, true);
putNestedMapIfNotEmpty(beanParams, "attributes", commandOptions.attributes, true);
putNestedIfNotEmpty(beanParams, "status.id", commandOptions.statusId, true);
putNestedIfNotNull(beanParams, "panelLock", commandOptions.panelLock, true);

clinicalAnalysisUpdateParams = JacksonUtils.getDefaultObjectMapper().copy()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
Expand Down Expand Up @@ -1369,6 +1375,7 @@ private RestResponse<ClinicalAnalysis> info() throws Exception {
queryParams.putIfNotEmpty("exclude", commandOptions.exclude);
queryParams.putIfNotNull("flattenAnnotations", commandOptions.flattenAnnotations);
queryParams.putIfNotEmpty("study", commandOptions.study);
queryParams.putIfNotEmpty("version", commandOptions.version);
queryParams.putIfNotNull("deleted", commandOptions.deleted);
if (queryParams.get("study") == null && OpencgaMain.isShellMode()) {
queryParams.putIfNotEmpty("study", sessionManager.getSession().getCurrentStudy());
Expand Down Expand Up @@ -1404,6 +1411,7 @@ private RestResponse<Interpretation> createInterpretation() throws Exception {
.readValue(new java.io.File(commandOptions.jsonFile), InterpretationCreateParams.class);
} else {
ObjectMap beanParams = new ObjectMap();
putNestedIfNotEmpty(beanParams, "name", commandOptions.name, true);
putNestedIfNotEmpty(beanParams, "description", commandOptions.description, true);
putNestedIfNotEmpty(beanParams, "clinicalAnalysisId", commandOptions.clinicalAnalysisId, true);
putNestedIfNotEmpty(beanParams, "creationDate", commandOptions.creationDate, true);
Expand Down Expand Up @@ -1493,6 +1501,7 @@ private RestResponse<Interpretation> updateInterpretation() throws Exception {
.readValue(new java.io.File(commandOptions.jsonFile), InterpretationUpdateParams.class);
} else {
ObjectMap beanParams = new ObjectMap();
putNestedIfNotEmpty(beanParams, "name", commandOptions.name, true);
putNestedIfNotEmpty(beanParams, "description", commandOptions.description, true);
putNestedIfNotEmpty(beanParams, "analyst.id", commandOptions.analystId, true);
putNestedIfNotEmpty(beanParams, "method.name", commandOptions.methodName, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ public class CreateCommandOptions {
@Parameter(names = {"--family-id"}, description = "The body web service id parameter", required = false, arity = 1)
public String familyId;

@Parameter(names = {"--panel-lock"}, description = "The body web service panelLock parameter", required = false, arity = 1)
public Boolean panelLock;
@Parameter(names = {"--panel-locked"}, description = "The body web service panelLocked parameter", required = false, arity = 1)
public Boolean panelLocked;

@Parameter(names = {"--analyst-id"}, description = "The body web service id parameter", required = false, arity = 1)
public String analystId;
Expand Down Expand Up @@ -301,6 +301,9 @@ public class CreateCommandOptions {
@Parameter(names = {"--responsible-postcode"}, description = "The body web service postcode parameter", required = false, arity = 1)
public String responsiblePostcode;

@Parameter(names = {"--interpretation-name"}, description = "The body web service name parameter", required = false, arity = 1)
public String interpretationName;

@Parameter(names = {"--interpretation-description"}, description = "The body web service description parameter", required = false, arity = 1)
public String interpretationDescription;

Expand Down Expand Up @@ -423,6 +426,9 @@ public class DistinctCommandOptions {
@Parameter(names = {"--release"}, description = "Release when it was created", required = false, arity = 1)
public String release;

@Parameter(names = {"--snapshot"}, description = "Snapshot value (Latest version of the entry in the specified release)", required = false, arity = 1)
public Integer snapshot;

@Parameter(names = {"--status"}, description = "Filter by status", required = false, arity = 1)
public String status;

Expand Down Expand Up @@ -455,6 +461,9 @@ public class DistinctInterpretationCommandOptions {
@Parameter(names = {"--uuid"}, description = "Comma separated list of Interpretation UUIDs up to a maximum of 100", required = false, arity = 1)
public String uuid;

@Parameter(names = {"--name", "-n"}, description = "Comma separated list of Interpretation names up to a maximum of 100", required = false, arity = 1)
public String name;

@Parameter(names = {"--clinical-analysis-id"}, description = "Clinical Analysis id", required = false, arity = 1)
public String clinicalAnalysisId;

Expand Down Expand Up @@ -523,6 +532,9 @@ public class SearchInterpretationCommandOptions {
@Parameter(names = {"--uuid"}, description = "Comma separated list of Interpretation UUIDs up to a maximum of 100", required = false, arity = 1)
public String uuid;

@Parameter(names = {"--name", "-n"}, description = "Comma separated list of Interpretation names up to a maximum of 100", required = false, arity = 1)
public String name;

@Parameter(names = {"--clinical-analysis-id"}, description = "Clinical Analysis id", required = false, arity = 1)
public String clinicalAnalysisId;

Expand Down Expand Up @@ -1740,6 +1752,9 @@ public class SearchCommandOptions {
@Parameter(names = {"--release"}, description = "Release when it was created", required = false, arity = 1)
public String release;

@Parameter(names = {"--snapshot"}, description = "Snapshot value (Latest version of the entry in the specified release)", required = false, arity = 1)
public Integer snapshot;

@Parameter(names = {"--status"}, description = "Filter by status", required = false, arity = 1)
public String status;

Expand Down Expand Up @@ -2027,8 +2042,8 @@ public class UpdateCommandOptions {
@Parameter(names = {"--disorder-id"}, description = "The body web service id parameter", required = false, arity = 1)
public String disorderId;

@Parameter(names = {"--panel-lock"}, description = "The body web service panelLock parameter", required = false, arity = 1)
public Boolean panelLock;
@Parameter(names = {"--panel-locked"}, description = "The body web service panelLocked parameter", required = false, arity = 1)
public Boolean panelLocked;

@Parameter(names = {"--proband-id"}, description = "The body web service id parameter", required = false, arity = 1)
public String probandId;
Expand Down Expand Up @@ -2123,6 +2138,9 @@ public class UpdateCommandOptions {
@Parameter(names = {"--status-id"}, description = "The body web service id parameter", required = false, arity = 1)
public String statusId;

@Parameter(names = {"--panel-lock"}, description = "The body web service panelLock parameter", required = false, arity = 1)
public Boolean panelLock;

}

@Parameters(commandNames = {"annotation-sets-annotations-update"}, commandDescription ="Update annotations from an annotationSet")
Expand Down Expand Up @@ -2172,6 +2190,9 @@ public class InfoCommandOptions {
@Parameter(names = {"--study", "-s"}, description = "Study [[organization@]project:]study where study and project can be either the ID or UUID", required = false, arity = 1)
public String study;

@Parameter(names = {"--version"}, description = "Comma separated list of clinical versions. 'all' to get all the clinical versions. Not supported if multiple clinical ids are provided", required = false, arity = 1)
public String version;

@Parameter(names = {"--deleted"}, description = "Boolean to retrieve deleted entries", required = false, help = true, arity = 0)
public boolean deleted = false;

Expand Down Expand Up @@ -2207,6 +2228,9 @@ public class CreateInterpretationCommandOptions {
@Parameter(names = {"--include-result"}, description = "Flag indicating to include the created or updated document result in the response", required = false, help = true, arity = 0)
public boolean includeResult = false;

@Parameter(names = {"--name", "-n"}, description = "The body web service name parameter", required = false, arity = 1)
public String name;

@Parameter(names = {"--description"}, description = "The body web service description parameter", required = false, arity = 1)
public String description;

Expand Down Expand Up @@ -2344,6 +2368,9 @@ public class UpdateInterpretationCommandOptions {
@Parameter(names = {"--include-result"}, description = "Flag indicating to include the created or updated document result in the response", required = false, help = true, arity = 0)
public boolean includeResult = false;

@Parameter(names = {"--name", "-n"}, description = "The body web service name parameter", required = false, arity = 1)
public String name;

@Parameter(names = {"--description"}, description = "The body web service description parameter", required = false, arity = 1)
public String description;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.opencb.opencga.app.migrations.v3.v3_2_0.TASK_5964;

import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Projections;
import com.mongodb.client.model.UpdateOneModel;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.opencb.opencga.catalog.db.mongodb.OrganizationMongoDBAdaptorFactory;
import org.opencb.opencga.catalog.migration.Migration;
import org.opencb.opencga.catalog.migration.MigrationTool;

import java.util.Arrays;

@Migration(id = "add_interpretation_name", description = "Add Interpretation name #TASK-5964", version = "3.2.0",
language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20240610)
public class AddInterpretationName extends MigrationTool {

@Override
protected void run() throws Exception {
// Add new Interpretation name field
Bson nameDoesNotExistQuery = Filters.exists("name", false);
Bson projection = Projections.include("id");
for (String collection : Arrays.asList(OrganizationMongoDBAdaptorFactory.INTERPRETATION_COLLECTION,
OrganizationMongoDBAdaptorFactory.INTERPRETATION_ARCHIVE_COLLECTION,
OrganizationMongoDBAdaptorFactory.DELETED_INTERPRETATION_COLLECTION)) {
migrateCollection(collection, nameDoesNotExistQuery, projection,
(document, bulk) -> {
Document updateDocument = new Document()
.append("name", document.get("id"));
bulk.add(new UpdateOneModel<>(Filters.eq("_id", document.get("_id")), new Document("$set", updateDocument)));
});
}
}

}
Loading

0 comments on commit d624826

Please sign in to comment.