Skip to content

Commit

Permalink
Merge pull request #496 from achabill/RAD-375
Browse files Browse the repository at this point in the history
RAD-375 Order report templates by title
  • Loading branch information
teleivo committed Oct 17, 2016
2 parents 889b5b5 + ca5200c commit bb941ce
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

/**
Expand Down Expand Up @@ -76,6 +77,7 @@ public List<MrrtReportTemplate> getMrrtReportTemplates(MrrtReportTemplateSearchC

final Criteria crit = sessionFactory.getCurrentSession()
.createCriteria(MrrtReportTemplate.class);
crit.addOrder(Order.asc("dcTermsTitle"));

if (searchCriteria.getTitle() != null) {
crit.add(Restrictions.ilike("dcTermsTitle", searchCriteria.getTitle() + "%", MatchMode.ANYWHERE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public interface MrrtReportTemplateService extends OpenmrsService {

/**
* Get all {@code MrrtReportTemplate's} matching a variety of (nullable) criteria.
* Returns results ordered by dcTermsTitle.
*
* @param mrrtReportTemplateSearchCriteria the object containing search parameters
* @return the mrrt report templates matching the given criteria
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class MrrtReportTemplateServiceComponentTest extends BaseModuleContextSen

private static final String NON_EXISTING_UUID = "invalid uuid";

private static final String EXISTING_TEMPLATE_TITLE = "title1";
private static final String EXISTING_TEMPLATE_TITLE = "CT";

private static final String NON_EXISTING_TEMPLATE_TITLE = "invalid";

Expand Down Expand Up @@ -393,7 +393,14 @@ public void getMrrtReportTemplates_shouldReturnAllMrrtReportTemplatesThatMatchGi
.build();
List<MrrtReportTemplate> templates = mrrtReportTemplateService.getMrrtReportTemplates(searchCriteria);
assertNotNull(templates);
assertThat(templates.size(), is(1));
assertThat(templates.size(), is(2));
assertThat(templates.get(0)
.getDcTermsTitle(),
is("CT Cardiac Bypass Graft"));
assertThat(templates.get(1)
.getDcTermsTitle(),
is("CT Chest Pulmonary Embolism"));

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<dataset>
<concept_reference_source concept_source_id="1" name="RADLEX" description="RadLex Playbook is a project of the Radiological Society of North America (RSNA)" creator="1" date_created="2016-08-01 09:00:00" uuid="f689a577-eb63-4e6b-9941-13c7880f5590"/>
<concept_reference_term concept_reference_term_id="1" concept_source_id="1" version="2.1" creator="1" date_created="2016-08-01 09:00:00" uuid="f689a577-eb63-4e6b-9941-13c7880f5590" code="RID10321" name="RADLEX" description="RadLex Playbook is a project of the Radiological Society of North America (RSNA)"/>
<radiology_report_template template_id="1" charset="UTF-8" path="test/test1.html" dcterms_title="title1" dcterms_description="description1" dcterms_language="en" dcterms_identifier="identifier1" dcterms_publisher="IHE CAT Publisher" creator="1" date_created="2015-02-02 12:26:35.0" uuid="aa551445-def0-4f93-9047-95f0a9afbdce"/>
<radiology_report_template template_id="2" charset="UTF-8" path="test/test2.html" dcterms_title="title2" dcterms_description="description2" dcterms_language="en" dcterms_identifier="identifier2" dcterms_publisher="Some cat organization" creator="1" date_created="2015-02-03 13:17:15.0" uuid="59273e52-33b1-4fcb-8c1f-9b670bb11259"/>
<radiology_report_template template_id="1" charset="UTF-8" path="test/test1.html" dcterms_title="CT Chest Pulmonary Embolism" dcterms_description="description1" dcterms_language="en" dcterms_identifier="identifier1" dcterms_publisher="IHE CAT Publisher" creator="1" date_created="2015-02-02 12:26:35.0" uuid="aa551445-def0-4f93-9047-95f0a9afbdce"/>
<radiology_report_template template_id="2" charset="UTF-8" path="test/test2.html" dcterms_title="CT Cardiac Bypass Graft" dcterms_description="description2" dcterms_language="en" dcterms_identifier="identifier2" dcterms_publisher="Some cat organization" creator="1" date_created="2015-02-03 13:17:15.0" uuid="59273e52-33b1-4fcb-8c1f-9b670bb11259"/>
<radiology_report_template_reference_term template_id="1" term_id="1"/>
</dataset>

0 comments on commit bb941ce

Please sign in to comment.