Skip to content

Commit cd88214

Browse files
committed
change in UI to support new patient search criteria
1 parent 90cc618 commit cd88214

File tree

5 files changed

+137
-9
lines changed

5 files changed

+137
-9
lines changed

Diff for: .travis.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
language: java
22
jdk:
3-
- oraclejdk8
3+
- openjdk8
44
addons:
55
firefox: "43.0"
6+
cache:
7+
directories:
8+
- .autoconf
9+
- $HOME/.m2
610
install:
711
- export DISPLAY=:99.0
812
- sh -e /etc/init.d/xvfb start
913
- tar -xjf /tmp/firefox-43.0.tar.bz2 --directory /tmp
1014
- export PATH="/tmp/firefox:$PATH"
11-
script: mvn clean install
15+
script: mvn clean install -q

Diff for: omod/pom.xml

+21
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
<gem.path>${basedir}/.rubygems</gem.path>
1919
</properties>
2020

21+
<repositories>
22+
<repository>
23+
<id>jitpack.io</id>
24+
<url>https://jitpack.io</url>
25+
</repository>
26+
</repositories>
27+
2128
<dependencies>
2229

2330
<!--
@@ -255,6 +262,20 @@
255262
<scope>provided</scope>
256263
</dependency>
257264

265+
<!-- Patient search criteria module -->
266+
<dependency>
267+
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
268+
<artifactId>patientsearch-api</artifactId>
269+
<version>1.0.2</version>
270+
<scope>provided</scope>
271+
</dependency>
272+
<dependency>
273+
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
274+
<artifactId>patientsearch-omod</artifactId>
275+
<version>1.0.2</version>
276+
<scope>provided</scope>
277+
</dependency>
278+
258279
</dependencies>
259280

260281
<build>

Diff for: omod/src/main/webapp/fragments/patientsearch/patientSearchWidget.gsp

+24
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,30 @@
9393

9494
<form method="get" id="patient-search-form" onsubmit="return false">
9595
<input type="text" id="patient-search" placeholder="${ ui.message("coreapps.findPatient.search.placeholder") }" autocomplete="off" <% if (doInitialSearch) { %>value="${doInitialSearch}"<% } %>/><i id="patient-search-clear-button" class="small icon-remove-sign"></i>
96+
97+
<select id="patient-gender-search">
98+
<option value="" selected>${ ui.message("coreapps.gender") }</option>
99+
<option value="M">${ ui.message("coreapps.gender.M") }</option>
100+
<option value="F">${ ui.message("coreapps.gender.F") }</option>
101+
</select>
102+
<input type="checkbox" id="getAgeAndBirthdateFilter" >Search with age or birthdate<br>
103+
104+
<div id="patient-search-age-birthdate" style="display:none">
105+
<input type="radio" name ="patient-age-birthdate" value="patient-age"> Search by range of age
106+
<br>
107+
<input type="radio" name ="patient-age-birthdate" value="patient-birthdate"> Search by birthdate
108+
109+
<p id="patient-age-range-search" style="display:none">
110+
<label>Range of Age</label>
111+
From:<input type="text" id="patient-age-range-from" placeholder="From" maxlength="2" style="min-width: 5px" onkeypress="return event.charCode >= 48 && event.charCode <= 57">
112+
To:<input type="text" id="patient-age-range-to" placeholder="To" maxlength="2"
113+
style="min-width: 5px" onkeypress="return event.charCode >= 48 && event.charCode <= 57">
114+
</p>
115+
116+
<p id="patient-birthdate-search" style="display:none">
117+
Birthdate:<input type="date" id="patient-birthdate" style="min-width: 5px"/>
118+
</p>
119+
</div>
96120
<% if(patientSearchExtensions){
97121
98122
patientSearchExtensions.each {

Diff for: omod/src/main/webapp/resources/scripts/patientsearch/patientSearchWidget.js

+60-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function PatientSearchWidget(configuration){
4343
var highlightedMouseRowIndex;
4444
var searchDelayTimer;
4545
var requestCount = 0;
46-
var searchUrl = '/' + OPENMRS_CONTEXT_PATH + '/ws/rest/v1/patient';
46+
var searchUrl = '/' + OPENMRS_CONTEXT_PATH + '/ws/rest/v1/patientsearch/patient';
4747
var initialData = [];
4848
var initialPatientData = [];
4949
var initialPatientUuids = [];
@@ -137,10 +137,16 @@ function PatientSearchWidget(configuration){
137137

138138
query = jq.trim(query);
139139
if (query.indexOf(' ') >= 0) {
140-
searchOnIdentifierAndName(query, currRequestCount);
140+
searchOnIdentifierAndName(query, currRequestCount);
141141
}
142142
else {
143-
searchOnExactIdentifierMatchThenIdentifierAndName(query, currRequestCount, autoSelectIfExactIdentifierMatch);
143+
if(jq('#patient-gender').val()!=''){
144+
var gender_search=jq('#patient-gender').val();
145+
searchOnIdentifierAndNameAndGender(query, gender_search, currRequestCount);
146+
}else{
147+
searchOnExactIdentifierMatchThenIdentifierAndName(query, currRequestCount, autoSelectIfExactIdentifierMatch);
148+
}
149+
144150
}
145151
}
146152

@@ -154,7 +160,7 @@ function PatientSearchWidget(configuration){
154160
var deferredList = [];
155161

156162
jq.each(identifiers, function (idx, identifier) {
157-
var deferred = emr.getJSON(searchUrl, {identifier: identifier, v: customRep})
163+
var deferred = emr.getJSON(searchUrl, {q: identifier, v: customRep})
158164
.then(function (data) {
159165
if (data && data.results && data.results.length > 0) {
160166
updateSearchResults(data.results);
@@ -180,7 +186,7 @@ function PatientSearchWidget(configuration){
180186
}
181187

182188
var searchOnExactIdentifierMatchThenIdentifierAndName = function(query, currRequestCount, autoSelectIfExactIdentifierMatch) {
183-
emr.getJSON(searchUrl, {identifier: query, v: customRep })
189+
emr.getJSON(searchUrl, {q: query, v: customRep })
184190
.done(function (data) {
185191
// update only if we've got results, and not late (late ajax responses should be ignored not to overwrite the latest)
186192
if (data && data.results && data.results.length > 0 && (!currRequestCount || currRequestCount >= requestCount)) {
@@ -210,6 +216,20 @@ function PatientSearchWidget(configuration){
210216
});
211217
}
212218

219+
var searchOnIdentifierAndNameAndGender = function(query,gender_search,currRequestCount) {
220+
emr.getJSON(searchUrl, {q: query, gender: gender_search, v: customRep })
221+
.done(function(data) {
222+
//late ajax responses should be ignored not to overwrite the latest
223+
if(data && (!currRequestCount || currRequestCount >= requestCount)){
224+
updateSearchResults(data.results);
225+
}
226+
})
227+
.fail(function (jqXHR) {
228+
failSearch();
229+
});
230+
}
231+
232+
213233
var failSearch = function() {
214234
performingSearch = false;
215235
if (!currRequestCount || currRequestCount >= requestCount) {
@@ -244,6 +264,41 @@ function PatientSearchWidget(configuration){
244264
}
245265
this.reset = reset;
246266

267+
//Add age range and birthdate search
268+
269+
jq('#getAgeAndBirthdateFilter').click(function (event) {
270+
if(this.checked){
271+
jq('#patient-search-age-birthdate').css('display','block');
272+
}else{
273+
jq('#patient-search-age-birthdate').css('display','none');
274+
jq( '#patient-age' ).prop( 'checked', false );
275+
jq( '#patient-birthdate' ).prop( 'checked', false );
276+
}
277+
})
278+
279+
280+
$("input[name='patient-age-birthdate']").change(function(){
281+
var ageOrBirthdate= $("input[name='patient-age-birthdate']:checked").val()
282+
if(ageOrBirthdate=="patient-age"){
283+
jq('#patient-birthdate-search').css('display','none');
284+
jq('#patient-age-range-search').css('display','block');
285+
jq('input[type=date]').each( function resetDate(){
286+
this.value = this.defaultValue;
287+
} );
288+
}
289+
if(ageOrBirthdate=="patient-birthdate"){
290+
jq('#patient-age-range-search').css('display','none');
291+
jq('#patient-birthdate-search').css('display','block');
292+
jq('#patient-age-range-from').val('');
293+
jq('#patient-age-range-to').val('');
294+
}
295+
});
296+
297+
//for date type support to browsers
298+
if ( jq('[type="date"]').prop('type') != 'date' ) {
299+
jq('[type="date"]').datepicker();
300+
}
301+
247302
var updateSearchResults = function(results){
248303
var dataRows = [];
249304
if(results){

Diff for: pom.xml

+26-2
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,26 @@
279279
<scope>test</scope>
280280
<classifier>tests</classifier>
281281
</dependency>
282+
<dependency>
283+
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
284+
<artifactId>patientsearch-api</artifactId>
285+
<version>1.0.2</version>
286+
<scope>provided</scope>
287+
</dependency>
288+
<dependency>
289+
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
290+
<artifactId>patientsearch-omod</artifactId>
291+
<version>1.0.2</version>
292+
<scope>provided</scope>
293+
</dependency>
294+
295+
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
296+
<dependency>
297+
<groupId>org.springframework</groupId>
298+
<artifactId>spring-core</artifactId>
299+
<version>4.0.5.RELEASE</version>
300+
</dependency>
301+
282302

283303
</dependencies>
284304
</dependencyManagement>
@@ -290,8 +310,8 @@
290310
<groupId>org.apache.maven.plugins</groupId>
291311
<artifactId>maven-compiler-plugin</artifactId>
292312
<configuration>
293-
<target>1.6</target>
294-
<source>1.6</source>
313+
<target>1.8</target>
314+
<source>1.8</source>
295315
<encoding>UTF-8</encoding>
296316
</configuration>
297317
</plugin>
@@ -340,6 +360,10 @@
340360
<name>OpenMRS Nexus Repository</name>
341361
<url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url>
342362
</repository>
363+
<repository>
364+
<id>jitpack.io</id>
365+
<url>https://jitpack.io</url>
366+
</repository>
343367
</repositories>
344368

345369
<pluginRepositories>

0 commit comments

Comments
 (0)