Skip to content

Commit

Permalink
change in UI to support new patient search criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
Reyano132 committed Jul 23, 2019
1 parent 90cc618 commit 0d7145b
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 7 deletions.
21 changes: 21 additions & 0 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
<gem.path>${basedir}/.rubygems</gem.path>
</properties>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>

<!--
Expand Down Expand Up @@ -255,6 +262,20 @@
<scope>provided</scope>
</dependency>

<!-- Patient search criteria module -->
<dependency>
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
<artifactId>patientsearch-api</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
<artifactId>patientsearch-omod</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@

<form method="get" id="patient-search-form" onsubmit="return false">
<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>

<select id="patient-gender-search">
<option value="" selected>${ ui.message("coreapps.gender") }</option>
<option value="M">${ ui.message("coreapps.gender.M") }</option>
<option value="F">${ ui.message("coreapps.gender.F") }</option>
</select>
<input type="checkbox" id="getAgeAndBirthdateFilter" >Search with age or birthdate<br>

<div id="patient-search-age-birthdate" style="display:none">
<input type="radio" name ="patient-age-birthdate" value="patient-age"> Search by range of age
<br>
<input type="radio" name ="patient-age-birthdate" value="patient-birthdate"> Search by birthdate

<p id="patient-age-range-search" style="display:none">
<label>Range of Age</label>
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">
To:<input type="text" id="patient-age-range-to" placeholder="To" maxlength="2"
style="min-width: 5px" onkeypress="return event.charCode >= 48 && event.charCode <= 57">
</p>

<p id="patient-birthdate-search" style="display:none">
Birthdate:<input type="date" id="patient-birthdate" style="min-width: 5px"/>
</p>
</div>
<% if(patientSearchExtensions){
patientSearchExtensions.each {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function PatientSearchWidget(configuration){
var highlightedMouseRowIndex;
var searchDelayTimer;
var requestCount = 0;
var searchUrl = '/' + OPENMRS_CONTEXT_PATH + '/ws/rest/v1/patient';
var searchUrl = '/' + OPENMRS_CONTEXT_PATH + '/ws/rest/v1/patientsearch/patient';
var initialData = [];
var initialPatientData = [];
var initialPatientUuids = [];
Expand Down Expand Up @@ -137,10 +137,16 @@ function PatientSearchWidget(configuration){

query = jq.trim(query);
if (query.indexOf(' ') >= 0) {
searchOnIdentifierAndName(query, currRequestCount);
searchOnIdentifierAndName(query, currRequestCount);
}
else {
searchOnExactIdentifierMatchThenIdentifierAndName(query, currRequestCount, autoSelectIfExactIdentifierMatch);
if(jq('#patient-gender').val()!=''){
var gender_search=jq('#patient-gender').val();
searchOnIdentifierAndNameAndGender(query, gender_search, currRequestCount);
}else{
searchOnExactIdentifierMatchThenIdentifierAndName(query, currRequestCount, autoSelectIfExactIdentifierMatch);
}

}
}

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

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

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

var searchOnIdentifierAndNameAndGender = function(query,gender_search,currRequestCount) {
emr.getJSON(searchUrl, {q: query, gender: gender_search, v: customRep })
.done(function(data) {
//late ajax responses should be ignored not to overwrite the latest
if(data && (!currRequestCount || currRequestCount >= requestCount)){
updateSearchResults(data.results);
}
})
.fail(function (jqXHR) {
failSearch();
});
}


var failSearch = function() {
performingSearch = false;
if (!currRequestCount || currRequestCount >= requestCount) {
Expand Down Expand Up @@ -244,6 +264,41 @@ function PatientSearchWidget(configuration){
}
this.reset = reset;

//Add age range and birthdate search

jq('#getAgeAndBirthdateFilter').click(function (event) {
if(this.checked){
jq('#patient-search-age-birthdate').css('display','block');
}else{
jq('#patient-search-age-birthdate').css('display','none');
jq( '#patient-age' ).prop( 'checked', false );
jq( '#patient-birthdate' ).prop( 'checked', false );
}
})


$("input[name='patient-age-birthdate']").change(function(){
var ageOrBirthdate= $("input[name='patient-age-birthdate']:checked").val()
if(ageOrBirthdate=="patient-age"){
jq('#patient-birthdate-search').css('display','none');
jq('#patient-age-range-search').css('display','block');
jq('input[type=date]').each( function resetDate(){
this.value = this.defaultValue;
} );
}
if(ageOrBirthdate=="patient-birthdate"){
jq('#patient-age-range-search').css('display','none');
jq('#patient-birthdate-search').css('display','block');
jq('#patient-age-range-from').val('');
jq('#patient-age-range-to').val('');
}
});

//for date type support to browsers
if ( jq('[type="date"]').prop('type') != 'date' ) {
jq('[type="date"]').datepicker();
}

var updateSearchResults = function(results){
var dataRows = [];
if(results){
Expand Down
28 changes: 26 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,26 @@
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
<artifactId>patientsearch-api</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
<artifactId>patientsearch-omod</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.5.RELEASE</version>
</dependency>


</dependencies>
</dependencyManagement>
Expand All @@ -290,8 +310,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>1.6</target>
<source>1.6</source>
<target>1.8</target>
<source>1.8</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Expand Down Expand Up @@ -340,6 +360,10 @@
<name>OpenMRS Nexus Repository</name>
<url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<pluginRepositories>
Expand Down

0 comments on commit 0d7145b

Please sign in to comment.