searchNonCoded(UiSessionContext context,
@RequestParam(value = "start", defaultValue = "0") Integer start,
@RequestParam(value = "size", defaultValue = "50") Integer size) throws Exception {
- return search(context, ui, emrApiProperties, emrConceptService, conceptService, query, null, null, start, size);
+ return search(context, ui, emrApiProperties, emrConceptService, conceptService, query, null, null, null, start, size);
}
public FragmentActionResult codeDiagnosis(UiUtils ui,
diff --git a/omod/src/main/webapp/fragments/diagnosis/encounterDiagnoses.gsp b/omod/src/main/webapp/fragments/diagnosis/encounterDiagnoses.gsp
index f92e7cd3b..90d9acdaa 100644
--- a/omod/src/main/webapp/fragments/diagnosis/encounterDiagnoses.gsp
+++ b/omod/src/main/webapp/fragments/diagnosis/encounterDiagnoses.gsp
@@ -66,7 +66,7 @@
-
+
<% if(jsForPrior.size > 0) { %>
diff --git a/omod/src/main/webapp/resources/scripts/diagnoses/diagnoses-angular.js b/omod/src/main/webapp/resources/scripts/diagnoses/diagnoses-angular.js
index 86af21284..9afcb3e27 100644
--- a/omod/src/main/webapp/resources/scripts/diagnoses/diagnoses-angular.js
+++ b/omod/src/main/webapp/resources/scripts/diagnoses/diagnoses-angular.js
@@ -4,7 +4,7 @@ var app = angular.module('diagnoses', [])
// I don't know how to use an angular template programmatically, so use an underscore template instead. :-(
var itemFormatter = _.template($('#' + attrs.itemformatter).html());
element.autocomplete({
- source: emr.fragmentActionLink("coreapps", "diagnoses", "search", {diagnosisSets: attrs.diagnosissets, diagnosisConceptSources: attrs.diagnosisconceptsources}),
+ source: emr.fragmentActionLink("coreapps", "diagnoses", "search", {diagnosisSets: attrs.diagnosissets, diagnosisConceptSources: attrs.diagnosisconceptsources, diagnosisConceptClasses: attrs.diagnosisconceptclasses}),
response: function(event, ui) {
var query = event.target.value.toLowerCase();
var items = ui.content;
diff --git a/omod/src/test/java/org/openmrs/module/coreapps/fragment/controller/DiagnosesFragmentControllerTest.java b/omod/src/test/java/org/openmrs/module/coreapps/fragment/controller/DiagnosesFragmentControllerTest.java
index ad54a499e..5c0673f93 100644
--- a/omod/src/test/java/org/openmrs/module/coreapps/fragment/controller/DiagnosesFragmentControllerTest.java
+++ b/omod/src/test/java/org/openmrs/module/coreapps/fragment/controller/DiagnosesFragmentControllerTest.java
@@ -14,20 +14,28 @@
package org.openmrs.module.coreapps.fragment.controller;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.openmrs.api.ConceptService;
+import org.openmrs.Concept;
+import org.openmrs.ConceptClass;
+import org.openmrs.ConceptSource;
import org.openmrs.module.appui.UiSessionContext;
import org.openmrs.module.emrapi.EmrApiProperties;
import org.openmrs.module.emrapi.concept.EmrConceptService;
import org.openmrs.ui.framework.UiUtils;
+import java.util.List;
+import java.util.ArrayList;
+
@RunWith(MockitoJUnitRunner.class)
public class DiagnosesFragmentControllerTest {
@@ -53,7 +61,7 @@ public class DiagnosesFragmentControllerTest {
@Test
public void search_shouldSearchForDiagnosisConceptsFromSpecifiedSets() throws Exception {
// replay
- controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, "1st_diagnosis_set_uuid,2nd_diagnosis_set_uuid", null, null, null);
+ controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, "1st_diagnosis_set_uuid,2nd_diagnosis_set_uuid", null, null, null, null);
// verify
verify(emrApiProperties, never()).getDiagnosisSets();
@@ -62,7 +70,7 @@ public void search_shouldSearchForDiagnosisConceptsFromSpecifiedSets() throws Ex
@Test
public void search_shouldSearchForDiagnosisConceptsUsingGloballyDefinedSuperSetGivenEmptyDiagnosisSets() throws Exception {
// replay
- controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, "", null, null, null);
+ controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, "", null, null, null, null);
// verify
verify(emrApiProperties, times(1)).getDiagnosisSets();
@@ -71,7 +79,7 @@ public void search_shouldSearchForDiagnosisConceptsUsingGloballyDefinedSuperSetG
@Test
public void search_shouldSearchForDiagnosisConceptsUsingGloballyDefinedSuperSetGivenNullDiagnosisSets() throws Exception {
// replay
- controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, null, null, null, null);
+ controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, null, null, null, null, null);
// verify
verify(emrApiProperties, times(1)).getDiagnosisSets();
@@ -81,7 +89,7 @@ public void search_shouldSearchForDiagnosisConceptsUsingGloballyDefinedSuperSetG
@Test
public void search_shouldSearchForDiagnosesFromSpecifiedDiagnosisConceptSources() throws Exception {
// replay
- controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, null, "CIEL,ICD-10-WHO", null, null);
+ controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, null, "CIEL,ICD-10-WHO", null, null, null);
// verify
verify(emrApiProperties, never()).getConceptSourcesForDiagnosisSearch();
@@ -90,7 +98,7 @@ public void search_shouldSearchForDiagnosesFromSpecifiedDiagnosisConceptSources(
@Test
public void search_shouldSearchForDiagnosesUsingGloballyDefinedConceptSourcesGivenEmptyDiagnosisConceptSourcesAttr() throws Exception {
// replay
- controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, null, "", null, null);
+ controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, null, "", null, null, null);
// verify
verify(emrApiProperties, times(1)).getConceptSourcesForDiagnosisSearch();
@@ -99,9 +107,30 @@ public void search_shouldSearchForDiagnosesUsingGloballyDefinedConceptSourcesGiv
@Test
public void search_shouldSearchForDiagnosesUsingGloballyDefinedConceptSourcesGivenNullDiagnosisConceptSourcesAttr() throws Exception {
// replay
- controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, null, null, null, null);
+ controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, null, null, null, null, null);
// verify
verify(emrApiProperties, times(1)).getConceptSourcesForDiagnosisSearch();
}
+
+ @Test
+ public void search_shouldSearchForDiagnosesUsingSpecifiedDiagnosisConceptClasses() throws Exception {
+ // setup
+ ConceptClass conceptClass = new ConceptClass();
+ List classList = new ArrayList ();
+ classList.add(conceptClass);
+
+ ConceptSource source = new ConceptSource();
+ List sourceList = new ArrayList ();
+ sourceList.add(source);
+ when(conceptService.getConceptClassByName(eq("Diagnosis"))).thenReturn(conceptClass);
+ when(conceptService.getConceptSourceByName(eq("ICD-10-WHO"))).thenReturn(source);
+ when(emrApiProperties.getDiagnosisSets()).thenReturn(null);
+
+ // replay
+ controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, null, "ICD-10-WHO", "Diagnosis", null, null);
+
+ // verify
+ verify(emrConceptService, times(1)).conceptSearch(queryString, null, classList, null, sourceList, null);
+ }
}
\ No newline at end of file
diff --git a/omod/src/test/java/org/openmrs/module/coreapps/htmlformentry/EncounterDiagnosesTagHandlerComponentTest.java b/omod/src/test/java/org/openmrs/module/coreapps/htmlformentry/EncounterDiagnosesTagHandlerComponentTest.java
index ddc8636d1..f25aa79d9 100644
--- a/omod/src/test/java/org/openmrs/module/coreapps/htmlformentry/EncounterDiagnosesTagHandlerComponentTest.java
+++ b/omod/src/test/java/org/openmrs/module/coreapps/htmlformentry/EncounterDiagnosesTagHandlerComponentTest.java
@@ -506,6 +506,42 @@ public void getSubstitution_shouldAddEmptyStringToDiagnosisConceptSourcesAttribu
// verify
assertTrue(StringUtils.contains(generatedHtml, "diagnosisConceptSources=\"" + diagnosisConceptSources + "\""));
}
+
+ @Test
+ public void getSubstitution_shouldAddDiagnosisConceptClassesAttributeOnDiagnosisSearchField() throws Exception {
+ // setup
+ String diagnosisConceptClasses = "Diagnosis,Findig";
+
+ Map attributes = new HashMap();
+ attributes.put("required", "true");
+ attributes.put(CoreAppsConstants.HTMLFORMENTRY_ENCOUNTER_DIAGNOSES_TAG_INCLUDE_PRIOR_DIAGNOSES_ATTRIBUTE_NAME, "admit");
+ attributes.put("selectedDiagnosesTarget", "example-target");
+
+ // replay
+ attributes.put("diagnosisConceptClasses", "Diagnosis,Findig");
+ String generatedHtml = encounterDiagnosesTagHandler.getSubstitution(formEntrySession, formSubmissionController, attributes);
+
+ // verify
+ assertTrue(StringUtils.contains(generatedHtml, "diagnosisConceptClasses=\"" + diagnosisConceptClasses + "\""));
+ }
+
+ @Test
+ public void getSubstitution_shouldAddEmptyStringToDiagnosisConceptClassesAttributeOnDiagnosisSearchFieldGivenNullAttribute() throws Exception {
+ // setup
+ String diagnosisConceptClasses = "";
+
+ Map attributes = new HashMap();
+ attributes.put("required", "true");
+ attributes.put(CoreAppsConstants.HTMLFORMENTRY_ENCOUNTER_DIAGNOSES_TAG_INCLUDE_PRIOR_DIAGNOSES_ATTRIBUTE_NAME, "admit");
+ attributes.put("selectedDiagnosesTarget", "example-target");
+
+ // replay
+ attributes.put("diagnosisConceptClasses", null);
+ String generatedHtml = encounterDiagnosesTagHandler.getSubstitution(formEntrySession, formSubmissionController, attributes);
+
+ // verify
+ assertTrue(StringUtils.contains(generatedHtml, "diagnosisConceptClasses=\"" + diagnosisConceptClasses + "\""));
+ }
private String renderFragmentHtml(Map fragmentConfig) throws Exception {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("web/module/fragments/diagnosis/encounterDiagnoses.gsp");