diff --git a/omod/pom.xml b/omod/pom.xml index 313237685..715bb1e76 100644 --- a/omod/pom.xml +++ b/omod/pom.xml @@ -18,6 +18,13 @@ ${basedir}/.rubygems + + + jitpack.io + https://jitpack.io + + + + + com.github.Reyano132.openmrs-module-patientsearchcriteria + patientsearch-api + 1.0.2 + provided + + + com.github.Reyano132.openmrs-module-patientsearchcriteria + patientsearch-omod + 1.0.2 + provided + + diff --git a/omod/src/main/webapp/fragments/patientsearch/patientSearchWidget.gsp b/omod/src/main/webapp/fragments/patientsearch/patientSearchWidget.gsp index 7af3ebed9..3821a9a38 100644 --- a/omod/src/main/webapp/fragments/patientsearch/patientSearchWidget.gsp +++ b/omod/src/main/webapp/fragments/patientsearch/patientSearchWidget.gsp @@ -93,6 +93,30 @@
value="${doInitialSearch}"<% } %>/> + + + Search with age or birthdate
+ + <% if(patientSearchExtensions){ patientSearchExtensions.each { diff --git a/omod/src/main/webapp/resources/scripts/patientsearch/patientSearchWidget.js b/omod/src/main/webapp/resources/scripts/patientsearch/patientSearchWidget.js index f5460a1a2..ec634da02 100644 --- a/omod/src/main/webapp/resources/scripts/patientsearch/patientSearchWidget.js +++ b/omod/src/main/webapp/resources/scripts/patientsearch/patientSearchWidget.js @@ -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 = []; @@ -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); + } + } } @@ -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); @@ -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)) { @@ -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) { @@ -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){ diff --git a/pom.xml b/pom.xml index 1773229c0..f0d61c35a 100644 --- a/pom.xml +++ b/pom.xml @@ -279,6 +279,26 @@ test tests + + com.github.Reyano132.openmrs-module-patientsearchcriteria + patientsearch-api + 1.0.2 + provided + + + com.github.Reyano132.openmrs-module-patientsearchcriteria + patientsearch-omod + 1.0.2 + provided + + + + + org.springframework + spring-core + 4.0.5.RELEASE + + @@ -290,8 +310,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.6 - 1.6 + 1.8 + 1.8 UTF-8 @@ -340,6 +360,10 @@ OpenMRS Nexus Repository http://mavenrepo.openmrs.org/nexus/content/repositories/public + + jitpack.io + https://jitpack.io +