-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,109 additions
and
92 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
api/src/main/java/org/openmrs/module/patientlist/AllCountriesRESTWithCountryCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.openmrs.module.patientlist; | ||
|
||
import org.openmrs.BaseOpenmrsData; | ||
|
||
/** | ||
* @author levine | ||
*/ | ||
public class AllCountriesRESTWithCountryCode extends BaseOpenmrsData { | ||
|
||
String countriesWithCountryCode; // return comma list as: NIGERIA/+234,UGANDA/+235, ... | ||
|
||
public String getCountriesWithCountryCode() { | ||
return countriesWithCountryCode; | ||
} | ||
|
||
public void setCountriesWithCountryCode(String countriesWithCountryCode) { | ||
this.countriesWithCountryCode = countriesWithCountryCode; | ||
} | ||
|
||
@Override | ||
public Integer getId() { | ||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. | ||
} | ||
|
||
@Override | ||
public void setId(Integer intgr) { | ||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
api/src/main/java/org/openmrs/module/patientlist/Country.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.openmrs.module.patientlist; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
import org.openmrs.BaseOpenmrsData; | ||
|
||
/** | ||
* @author levine | ||
*/ | ||
public class Country extends BaseOpenmrsData implements Serializable { | ||
|
||
private int id; | ||
|
||
private String name; | ||
|
||
private String countryCode; | ||
|
||
private Date dateCreated; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getCountryCode() { | ||
return countryCode; | ||
} | ||
|
||
public void setCountryCode(String countryCode) { | ||
this.countryCode = countryCode; | ||
} | ||
|
||
public Date getDateCreated() { | ||
return dateCreated; | ||
} | ||
|
||
public void setDateCreated(Date dateCreated) { | ||
this.dateCreated = dateCreated; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
api/src/main/java/org/openmrs/module/patientlist/CountryConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.openmrs.module.patientlist; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* @author levine | ||
*/ | ||
|
||
@Component("patientlist.CountryConfig") | ||
public class CountryConfig { | ||
|
||
public final static String MODULE_PRIVILEGE = "App: patient list"; | ||
} |
55 changes: 55 additions & 0 deletions
55
api/src/main/java/org/openmrs/module/patientlist/PersonCountry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.openmrs.module.patientlist; | ||
|
||
import java.io.Serializable; | ||
import org.openmrs.BaseOpenmrsData; | ||
|
||
/** | ||
* @author levine | ||
*/ | ||
public class PersonCountry extends BaseOpenmrsData implements Serializable { | ||
|
||
private Integer id; | ||
|
||
private Integer personId; | ||
|
||
private Integer countryId; | ||
|
||
private int isVoid; | ||
|
||
public int getIsVoid() { | ||
return isVoid; | ||
} | ||
|
||
public void setIsVoid(int isVoid) { | ||
this.isVoid = isVoid; | ||
} | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public Integer getPersonId() { | ||
return personId; | ||
} | ||
|
||
public void setPersonId(Integer personId) { | ||
this.personId = personId; | ||
} | ||
|
||
public Integer getCountryId() { | ||
return countryId; | ||
} | ||
|
||
public void setCountryId(Integer countryId) { | ||
this.countryId = countryId; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
api/src/main/java/org/openmrs/module/patientlist/PersonCountryConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.openmrs.module.patientlist; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
@Component("patientlist.PersonCountryConfig") | ||
public class PersonCountryConfig { | ||
|
||
public final static String MODULE_PRIVILEGE = "App: patient list"; | ||
} |
50 changes: 50 additions & 0 deletions
50
api/src/main/java/org/openmrs/module/patientlist/api/CountryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.openmrs.module.patientlist.api; | ||
|
||
import java.util.List; | ||
import org.openmrs.annotation.Authorized; | ||
import org.openmrs.api.APIException; | ||
import org.openmrs.api.OpenmrsService; | ||
import org.openmrs.module.patientlist.Country; | ||
import org.openmrs.module.patientlist.CountryConfig; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
/** | ||
* @author levine | ||
*/ | ||
|
||
@Transactional | ||
public interface CountryService extends OpenmrsService { | ||
|
||
/** | ||
* Saves a patient list item. Sets the owner to superuser, if it is not set. It can be called by | ||
* users with this module's privilege. It is executed in a transaction. | ||
* | ||
* @param item | ||
* @return | ||
* @throws APIException | ||
*/ | ||
@Authorized(CountryConfig.MODULE_PRIVILEGE) | ||
@Transactional | ||
Country saveCountry(Country item) throws APIException; | ||
|
||
/** | ||
* Get a {@link Country} object by primary key id. | ||
* | ||
* @param id the primary key integer id to look up on | ||
* @return the found Country object which matches the row with the given id. If no row with the | ||
* given id exists, null is returned. | ||
*/ | ||
@Authorized() | ||
@Transactional(readOnly = true) | ||
public Country getCountry(Integer id); | ||
|
||
@Authorized() | ||
@Transactional(readOnly = true) | ||
public List<Country> getAllCountry(); | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
api/src/main/java/org/openmrs/module/patientlist/api/PersonCountryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.openmrs.module.patientlist.api; | ||
|
||
import java.util.List; | ||
import org.openmrs.annotation.Authorized; | ||
import org.openmrs.api.APIException; | ||
import org.openmrs.api.OpenmrsService; | ||
import org.openmrs.module.patientlist.PersonCountry; | ||
import org.openmrs.module.patientlist.PersonCountryConfig; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
/** | ||
* @author levine | ||
*/ | ||
@Transactional | ||
public interface PersonCountryService extends OpenmrsService { | ||
|
||
@Authorized(PersonCountryConfig.MODULE_PRIVILEGE) | ||
@Transactional | ||
PersonCountry savePersonCountry(PersonCountry item) throws APIException; | ||
|
||
/** | ||
* Get a {@link PersonCountry} object by primary key id. | ||
* | ||
* @param id the primary key integer id to look up on | ||
* @return the found PersonCountry object which matches the row with the given id. If no row | ||
* with the given id exists, null is returned. | ||
*/ | ||
@Authorized() | ||
@Transactional(readOnly = true) | ||
public PersonCountry getPersonCountry(Integer id); | ||
|
||
@Authorized() | ||
@Transactional(readOnly = true) | ||
public List<PersonCountry> getAllPersonCountryForPerson(Integer personId); | ||
|
||
@Authorized() | ||
@Transactional(readOnly = true) | ||
public List<PersonCountry> getAllPersonCountry(); | ||
} |
22 changes: 22 additions & 0 deletions
22
api/src/main/java/org/openmrs/module/patientlist/api/db/CountryDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.openmrs.module.patientlist.api.db; | ||
|
||
import java.util.List; | ||
import org.openmrs.api.APIException; | ||
import org.openmrs.module.patientlist.Country; | ||
|
||
/** | ||
* @author levine | ||
*/ | ||
public interface CountryDao { | ||
|
||
Country saveCountry(Country item) throws APIException; | ||
|
||
public Country getCountry(Integer id); | ||
|
||
public List<Country> getAllCountry(); | ||
} |
24 changes: 24 additions & 0 deletions
24
api/src/main/java/org/openmrs/module/patientlist/api/db/PersonCountryDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.openmrs.module.patientlist.api.db; | ||
|
||
import java.util.List; | ||
import org.openmrs.api.APIException; | ||
import org.openmrs.module.patientlist.PersonCountry; | ||
|
||
/** | ||
* @author levine | ||
*/ | ||
public interface PersonCountryDao { | ||
|
||
PersonCountry savePersonCountry(PersonCountry item) throws APIException; | ||
|
||
public PersonCountry getPersonCountry(Integer id); | ||
|
||
public List<PersonCountry> getAllPersonCountryForPerson(Integer personId); | ||
|
||
public List<PersonCountry> getAllPersonCountry(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
api/src/main/java/org/openmrs/module/patientlist/api/db/hibernate/HibernateCountryDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.openmrs.module.patientlist.api.db.hibernate; | ||
|
||
import java.util.List; | ||
import org.hibernate.Criteria; | ||
import org.openmrs.api.APIException; | ||
import org.openmrs.api.db.hibernate.DbSessionFactory; | ||
import org.openmrs.module.patientlist.Country; | ||
import org.openmrs.module.patientlist.api.db.CountryDao; | ||
|
||
/** | ||
* @author levine | ||
*/ | ||
public class HibernateCountryDAO implements CountryDao { | ||
|
||
private DbSessionFactory sessionFactory; | ||
|
||
public void setSessionFactory(DbSessionFactory sessionFactory) { | ||
this.sessionFactory = sessionFactory; | ||
} | ||
|
||
@Override | ||
public Country saveCountry(Country item) throws APIException { | ||
sessionFactory.getCurrentSession().saveOrUpdate(item); | ||
return item; | ||
} | ||
|
||
@Override | ||
public Country getCountry(Integer id) { | ||
return (Country) sessionFactory.getCurrentSession().get(Country.class, id); | ||
} | ||
|
||
@Override | ||
public List<Country> getAllCountry() { | ||
Criteria crit = sessionFactory.getCurrentSession().createCriteria(Country.class); | ||
return crit.list(); | ||
} | ||
} |
Oops, something went wrong.