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 added in openmrs core #1

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
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.classpath
.project
.settings/*
target/*
api/.classpath
api/.project
api/.settings/*
api/target/*
omod/.classpath
omod/.project
omod/.settings/*
omod/target/*
/.settings


10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# openmrs-module-patientsearchcriteria
![alt text](https://camo.githubusercontent.com/93680c923c12178e9fa6b523b1bbb644d32f4039/68747470733a2f2f74616c6b2e6f70656e6d72732e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f32582f662f663165633537396230333938636230346338306135346335366461323139623234343066653234392e6a7067)

Patient Search Criteria Module
==========================

Description
-----------
This module provides the different patient search criteria which are used in core apps module

1 change: 1 addition & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
37 changes: 37 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>patientsearch</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>patientsearch-api</artifactId>
<packaging>jar</packaging>
<name>PatientSearchCriteria API</name>
<description>API project for PatientSearchCriteria</description>

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

<dependencies>
<dependency>
<groupId>com.github.Reyano132.openmrs-core</groupId>
<artifactId>openmrs-api</artifactId>
<version>0112f622</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Reyano132.openmrs-core</groupId>
<artifactId>openmrs-api</artifactId>
<version>0112f622</version>
<type>test-jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.patientsearch;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.module.BaseModuleActivator;

/**
* This class contains the logic that is run every time this module is either started or shutdown
*/
public class PatientSearchCriteriaActivator extends BaseModuleActivator {

private Log log = LogFactory.getLog(this.getClass());

/**
* @see #started()
*/
public void started() {
log.info("Started PatientSearchCriteria");
}

/**
* @see #shutdown()
*/
public void shutdown() {
log.info("Shutdown PatientSearchCriteria");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.patientsearch;

import org.springframework.stereotype.Component;

/**
* Contains module's config.
*/
@Component("patientsearch.PatientSearchCriteriaConfig")
public class PatientSearchCriteriaConfig {

public final static String MODULE_PRIVILEGE = "PatientSearchCriteria Privilege";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.patientsearch.api;

import java.util.Date;
import java.util.List;

import org.openmrs.Patient;
import org.openmrs.PatientIdentifierType;
import org.openmrs.annotation.Authorized;
import org.openmrs.api.APIException;
import org.openmrs.api.PatientService;
import org.openmrs.util.PrivilegeConstants;

/**
* This provide patient search criteria service. It helps to retrieve patient with different fields
* such as gender, birthdate, age.
*/
public interface PatientSearchCriteriaService extends PatientService {

/**
* Return the list of patient which has required name or identifier or gender or birthdate or
* age.
*
* @param name (optional) this is a slight break from the norm, patients with a partial match on
* this name will be returned
* @param identifier (optional) only patients with a matching identifier are returned. This
* however applies only if <code>name</code> argument is null. Otherwise, its
* ignored.
* @param identifierTypes (optional) the PatientIdentifierTypes to restrict to
* @param matchIdentifierExactly (required) if true, then the given <code>identifier</code> must
* equal the id in the database. if false, then the identifier is 'searched' for by
* using a regular expression
* @param gender(optional) : if user want to search patient by gender or filter the search
* result by gender. value of gender parameter is either "M" or "F".
* @param to(optional) : user wants to search patients having age between some range, at that
* time this paramater represent the upper boundary of range.
* @param from(optional):user wants to search patients having age between some range, at that
* time this paramater represent the lower boundary of range.
* @param birthdate(optional) : User can search patient by birthdate.
* @return patients that matched the given criteria (and are not voided)
* @throws APIException
* @should fetch all patients that partially match given name
* @should fetch all patients that partially match given identifier if <code>name</code>
* argument is null
* @should fetch all patients that partially match given identifier when match identifier
* exactly equals false and if <code>name</code> argument is null
* @should fetch all patients that exactly match given identifier when match identifier exactly
* equals true and if <code>name</code> argument is null
* @should fetch all patients that match given identifier types
* @should not return duplicates
* @should not return voided patients
* @should return empty list when no match is found
* @should search familyName2 with name
* @should support simple regex
* @should support pattern using last digit as check digit
* @should return empty list if name and identifier is empty
* @should support all the search criteria
*/
@Authorized({ PrivilegeConstants.GET_PATIENTS })
public List<Patient> getPatients(String name, String identifier, List<PatientIdentifierType> identifierTypes,
boolean matchIdentifierExactly, String gender, Integer from, Integer to, Date birthdate) throws APIException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.patientsearch.api.dao;

import java.util.Date;
import java.util.List;

import org.openmrs.Patient;
import org.openmrs.api.db.DAOException;
import org.openmrs.api.db.PatientDAO;

/**
* methods to search patients with different fields
*/
public interface PatientSearchCriteriaDAO extends PatientDAO {

/**
* @param query : name or identifier of patients
* @param gender : gender of patients
* @param length : maximum number of patients should return
* @return : list of patients who follow the query regex and having required gender
* @throws DAOException
*/
public List<Patient> getPatientsByNameOrIdAndGender(String query, String gender, Integer start, Integer length,
Boolean includeVoided) throws DAOException;

/**
* @return : list of patient having required gender
* @throws DAOException
*/
public List<Patient> getPatientsByGender(String gender, Integer start, Integer length, Boolean includeVoided)
throws DAOException;

/**
* @param from: lower boundary of range of age
* @param to : upper boundary of range of age
* @return list of patients, who's age is in between the required range
* @throws DAOException
*/
public List<Patient> getPatientsByRangeOfAge(Date from, Date to, Integer start, Integer length, Boolean includeVoided)
throws DAOException;

/**
* @param birthdate : birthdate of patient
* @return list of patient/s , who's birthdate is similar to required birthdate
* @throws DAOException
*/
public List<Patient> getPatientsByBirthdate(Date birthdate, Integer start, Integer length, Boolean includeVoided)
throws DAOException;

/**
* @param query : name or identifier of patient/s.
* @param gender : gender of patient
* @param from : lower boundary of range of age
* @param to : upper boundary of range of age
* @return list of patients who follow the query regex and having required gender and having age
* in required range
* @throws DAOException
*/
public List<Patient> getPatientsByNameOrIdAndGenderAndRangeOfAge(String query, String gender, Date from, Date to,
Integer start, Integer length, Boolean includeVoided) throws DAOException;

/**
* @param query : name or identifier of patient/s
* @param gender : gender of patient
* @param birthdate : birthdate of patient
* @return list of patients who follow the query regex and having required gender and having
* required birthdate
* @throws DAOException
*/
public List<Patient> getPatientsByNameOrIdAndGenderAndBirthdate(String query, String gender, Date birthdate,
Integer start, Integer length, Boolean includeVoided) throws DAOException;

/**
* @param from: lower boundary of range of age
* @param to : upper boundary of range of age
* @return list of patients who follow the query regex and having age in required range
* @throws DAOException
*/
public List<Patient> getPatientsByNameOrIdAndRangeOfAge(String query, Date from, Date to, Integer start, Integer length,
Boolean includeVoided) throws DAOException;

/**
* @param birthdate: birthdate of patient
* @return list of patients who follow the query regex and having birthdate as required.
* @throws DAOException
*/
public List<Patient> getPatientsByNameOrIdAndBirthdate(String query, Date birthdate, Integer start, Integer length,
Boolean includeVoided) throws DAOException;

/**
* @param gender : gender of patients
* @param birthdate: birthdate of patient
* @return list of patients which have required birthdate and gender
* @throws DAOException
*/
public List<Patient> getPatientsByGenderAndBirthdate(String gender, Date birthdate, Integer start, Integer length,
Boolean includeVoided) throws DAOException;

/**
* @param gender : gender of patients
* @param from: lower boundary of range of age
* @param to : upper boundary of range of age
* @return list of patients which have required gender and age in required range.
* @throws DAOException
*/
public List<Patient> getPatientsByGenderAndAge(String gender, Date from, Date to, Integer start, Integer length,
Boolean includeVoided) throws DAOException;

}
Loading