Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC 2019: Patient search criteria module #219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
<gem.path>${basedir}/.rubygems</gem.path>
</properties>

<!-- Repository for patient search criteria -->
<repositories>
<repository>
<id>jitpack.io</id>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any idea why u wanna publish these on jitpack?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaweesi sir, I added this repository in PR so you can use the patient search criteria module(which is not merge yet). Once you merge patient search criteria module PR(openmrs/openmrs-module-patientsearchcriteria#1) and create its remote repository, I will replace this jitpack with that repository. Another thing is that the PR of patient search criteria also consists of a jitpack repository of openmrs-core(openmrs/openmrs-core#2980).

Overall, there are dependencies between the PRs as I explained in the talk.
please 1st merge openmrs core PR(openmrs/openmrs-core#2980).
Then merge patient search criteria module PR(openmrs/openmrs-module-patientsearchcriteria#1) and create a remote repository of that module and at last, after creating a repository of patient search criteria module I just need to replace jitpack repository with patient search criteria repository

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


<dependencies>

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

<!-- Patient search criteria module -->
<dependency>
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revise this groupid to match our conventions https://wiki.openmrs.org/display/docs/Module+Conventions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaweesi sir, here I used jitpack to host my remote repository. Jitpack added "com.github.Reyano132" prefix to the group ID. Once we officially host the patient search criteria module (https://github.com/openmrs/openmrs-module-patientsearchcriteria), I'll change the groupId value here.

<artifactId>patientsearch-api</artifactId>
<version>v1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Reyano132.openmrs-module-patientsearchcriteria</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

<artifactId>patientsearch-omod</artifactId>
<version>v1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.5.RELEASE</version>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,32 @@
<div class="col-md-12 col-sm-12 col-xs-12">
<form method="get" id="patient-search-form" onsubmit="return false">
<input class="form-control input-sm input-lg" 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>
<% if(patientSearchExtensions){
<select id="patient-gender-search">
Reyano132 marked this conversation as resolved.
Show resolved Hide resolved
<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 {
// create a base map from the fragmentConfig if it exists, otherwise just create an empty map
def configs = [:];
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 @@ -140,7 +140,52 @@ function PatientSearchWidget(configuration){
searchOnIdentifierAndName(query, currRequestCount);
}
else {
searchOnExactIdentifierMatchThenIdentifierAndName(query, currRequestCount, autoSelectIfExactIdentifierMatch);
var gender_search=jq('#patient-gender-search').val();
var from_search=jq('#patient-age-range-from').val();
var to_search=jq('#patient-age-range-to').val();
var date_search;
if(jq('#patient-birthdate').val()!=''){
console.log('birth '+jq('#patient-birthdate').val());
date_search =new Date(jq('#patient-birthdate').val());
date_search.setHours(0);
date_search.setMinutes(0);
}


if(query==''){
if(gender_search!='' && from_search=='' && to_search=='' && jq('#patient-birthdate').val()==''){
searchOnGender(gender_search,currRequestCount);
} else if(gender_search=='' && from_search!='' && to_search !='' && jq('#patient-birthdate').val()==''){
searchOnRangeOfAge(from_search,to_search,currRequestCount);
}else if(gender_search=='' && jq('#patient-birthdate').val()!=''){
searchOnBirthdate(date_search.getTime(),currRequestCount);
}else if(gender_search!='' && from_search!='' && to_search!=''){
searchOnGenderAndRangeOfAge(gender_search,from_search,to_search,currRequestCount);
}else if(gender_search!='' && jq('#patient-birthdate').val()!=''){
searchOnGenderAndBirthdate(gender_search,date_search.getTime(),currRequestCount);
}else{
updateSearchResults();
}

}
else{
if(gender_search!=''){
if( from_search=='' && to_search=='' && jq('#patient-birthdate').val()==''){
searchOnIdentifierAndNameAndGender(query,gender_search,currRequestCount);
}else if(from_search!='' && to_search !=''){
searchOnIdentifierAndNameAndGenderAndRangeOfAge(query,gender_search,from_search,to_search,currRequestCount);
}else{
searchOnIdentifierAndNameAndGenderAndBirthdate(query,gender_search,date_search.getTime(),currRequestCount);
}
}else if(from_search!='' && to_search !=''){
searchOnIdentifierAndNameAndRangeOfAge(query,from_search,to_search,currRequestCount);
}else if(jq('#patient-birthdate').val()!=''){
searchOnIdentifierAndNameAndBirthdate(query,date_search.getTime(),currRequestCount);
}else{
searchOnExactIdentifierMatchThenIdentifierAndName(query, currRequestCount, autoSelectIfExactIdentifierMatch);
}
}

}
}

Expand Down Expand Up @@ -210,6 +255,136 @@ 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 searchOnIdentifierAndNameAndRangeOfAge = function(query,from_search,to_search,currRequestCount) {
emr.getJSON(searchUrl, {q: query, from: from_search, to: to_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 searchOnIdentifierAndNameAndBirthdate = function(query,birthdate_search,currRequestCount) {
emr.getJSON(searchUrl, {q: query, birthdate: birthdate_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 searchOnIdentifierAndNameAndGenderAndRangeOfAge = function(query,gender_search,from_search,to_search,currRequestCount) {
emr.getJSON(searchUrl, {q: query, gender: gender_search, from: from_search, to: to_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 searchOnIdentifierAndNameAndGenderAndBirthdate = function(query,gender_search,birthdate_search,currRequestCount) {
emr.getJSON(searchUrl, {q: query, gender: gender_search, birthdate: birthdate_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 searchOnGenderAndRangeOfAge = function(gender_search,from_search,to_search,currRequestCount) {
emr.getJSON(searchUrl, {gender: gender_search, from: from_search, to: to_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 searchOnGenderAndBirthdate = function(gender_search,birthdate_search,currRequestCount) {
emr.getJSON(searchUrl, {gender: gender_search,birthdate: birthdate_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 searchOnGender = function(gender_search,currRequestCount) {
emr.getJSON(searchUrl, {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 searchOnRangeOfAge = function(from_search,to_search,currRequestCount) {
emr.getJSON(searchUrl, {from: from_search, to: to_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 searchOnBirthdate = function(birthdate_search,currRequestCount) {
emr.getJSON(searchUrl, {birthdate: birthdate_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 +419,47 @@ 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 );
jq('#patient-age-range-from').val('');
jq('#patient-age-range-to').val('');
jq('input[type=date]').each( function resetDate(){
this.value = this.defaultValue;
} );
}
})


$("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 Expand Up @@ -295,6 +511,7 @@ function PatientSearchWidget(configuration){
});
}else if(config.initialPatients){
//show the recently viewed
reset();
searchResultsData = initialPatientData;
dataRows = initialData;
}
Expand Down Expand Up @@ -595,6 +812,39 @@ function PatientSearchWidget(configuration){
clearSearch();
});

var searchByPatientSearchCriteria = function(){
cancelAnyExistingSearch();
var text=jq.trim(input.val());
var currentCount = ++requestCount;
var effectiveSearchDelay = config.searchDelayShort;
window.setTimeout(function(){
if(text=='' || text.length <= config.minSearchCharacters){
doSearch('', currentCount);
}else{
doSearch(text, currentCount);
}
}, effectiveSearchDelay);

}

jq('select').change( function(){
searchByPatientSearchCriteria();
});

jq('input[type="date"]').change(function(){
searchByPatientSearchCriteria();
});


jq('#patient-age-range-from').keyup(function(){
searchByPatientSearchCriteria();
});

jq('#patient-age-range-to').keyup(function(){
searchByPatientSearchCriteria();
});


input.keyup(function(event) {
var kc = event.keyCode;
//ignore enter(because it was handled already onkeydown), keyboard navigation and control keys
Expand Down
Loading