Skip to content

Commit

Permalink
PEPPER-853 added a check for the number of scrolls and uss to not be …
Browse files Browse the repository at this point in the history
…zero
  • Loading branch information
pegahtah committed Jul 28, 2023
1 parent 91ec798 commit af54a7b
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,36 @@
public class MercurySampleDao implements Dao<MercurySampleDto> {
public static String SQL_GET_ELIGIBLE_TISSUES =
"SELECT * FROM ("
+ "SELECT collaborator_sample_id, t.sent_gp, oD.date_px, oD.tissue_received, t.tissue_id "
+ "SELECT collaborator_sample_id, t.sent_gp, oD.date_px, oD.tissue_received, t.tissue_id, "
+ " (SELECT count(*) from sm_id sm "
+ " left join sm_id_type smtype on (sm.sm_id_type_id = smtype.sm_id_type_id) "
+ " where smtype.sm_id_type = \"uss\" and sm.tissue_id = t.tissue_id and NOT sm.deleted <=> 1 "
+ " and sm.received_date is not null) as count_of_uss, "
+ " (SELECT count(*) from sm_id sm "
+ " left join sm_id_type smtype on (sm.sm_id_type_id = smtype.sm_id_type_id) "
+ " where smtype.sm_id_type = \"scrolls\" and sm.tissue_id = t.tissue_id and NOT sm.deleted <=> 1 "
+ " and sm.received_date is not null) as count_of_scrolls "
+ "FROM ddp_participant as p "
+ "LEFT JOIN ddp_instance as ddp on (ddp.ddp_instance_id = p.ddp_instance_id) "
+ "LEFT JOIN ddp_institution inst on (inst.participant_id = p.participant_id) "
+ "LEFT JOIN ddp_medical_record mr on (mr.institution_id = inst.institution_id AND NOT mr.deleted <=> 1) "
+ "LEFT JOIN ddp_onc_history_detail oD on (mr.medical_record_id = oD.medical_record_id AND NOT oD.deleted <=> 1) "
+ "LEFT JOIN ddp_tissue t on (oD.onc_history_detail_id = t.onc_history_detail_id AND NOT t.deleted <=> 1) "
+ "WHERE oD.tissue_received IS NOT NULL AND p.ddp_participant_id = ? AND ddp.instance_name = ? "
+ "AND IFNULL(t.uss_count, 0) = (SELECT count(*) from sm_id sm "
+ "AND IFNULL(t.uss_count, -1) = (SELECT count(*) from sm_id sm "
+ "left join sm_id_type smtype on (sm.sm_id_type_id = smtype.sm_id_type_id) "
+ "where smtype.sm_id_type = \"uss\" and sm.tissue_id = t.tissue_id and NOT sm.deleted <=> 1 "
+ "and sm.received_date is not null) "
+ "AND IFNULL(t.scrolls_count, 0) = (SELECT count(*) from sm_id sm "
+ "AND IFNULL(t.scrolls_count, -1) = (SELECT count(*) from sm_id sm "
+ "left join sm_id_type smtype on (sm.sm_id_type_id = smtype.sm_id_type_id) "
+ "where smtype.sm_id_type = \"scrolls\" and sm.tissue_id = t.tissue_id and NOT sm.deleted <=> 1 "
+ "and sm.received_date is not null) ) as table1 "
+ "left join (select max(mercury_sequencing_id) AS ms_id, tissue_id as seqt "
+ "From ddp_mercury_sequencing where ddp_participant_id = ? group by (tissue_id) ) as table2 "
+ "on table2.seqt = table1.tissue_id "
+ "LEFT JOIN (select order_id, mercury_sequencing_id, order_status, order_date, mercury_pdo_id "
+ "FROM ddp_mercury_sequencing WHERE ddp_participant_id = ?) as table3 ON(table3.mercury_sequencing_id = table2.ms_id)";
+ "FROM ddp_mercury_sequencing WHERE ddp_participant_id = ?) as table3 ON(table3.mercury_sequencing_id = table2.ms_id) "
+ " WHERE (table1.count_of_scrolls != 0 OR table1.count_of_uss != 0) ";


public static String SQL_GET_ELIGIBLE_SAMPLES =
Expand Down

0 comments on commit af54a7b

Please sign in to comment.