本文整理汇总了Java中org.openmrs.api.PatientService类的典型用法代码示例。如果您正苦于以下问题:Java PatientService类的具体用法?Java PatientService怎么用?Java PatientService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PatientService类属于org.openmrs.api包,在下文中一共展示了PatientService类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPatient
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* Get {@code Patient} by ID or UUID string.
*
* @param patientId the id or uuid of wanted patient
* @return patient matching given patient id
* @should return patient if given patient id is an existing id
* @should return patient if given patient id is an existing uuid
* @should return null if given null or whitespaces only
* @should return null if given patient id is not an existing id
* @should return null if given patient id is not an existing uuid
*/
private Patient getPatient(String patientId) {
if (StringUtils.isBlank(patientId)) {
return null;
}
PatientService ps = Context.getPatientService();
Patient patient = null;
try {
patient = ps.getPatient(Integer.valueOf(patientId));
}
catch (Exception ex) {
patient = ps.getPatientByUuid(patientId);
}
return patient;
}
示例2: onSubmit
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* The onSubmit function receives the form/command object that was modified by the input form
* and saves it to the db
*
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
HttpSession httpSession = request.getSession();
String view = getFormView();
if (Context.isAuthenticated()) {
String[] patientList = request.getParameterValues("patientId");
PatientService ps = Context.getPatientService();
for (String o : patientList) {
//TODO convenience method deletePatient(Integer, String) ??
ps.voidPatient(ps.getPatient(Integer.valueOf(o)), "");
}
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Patient.voided");
view = getSuccessView();
}
return new ModelAndView(new RedirectView(view));
}
示例3: findCountAndPatients_shouldMatchPatientWithIdentifiersThatContainNoDigit
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* @see DWRPatientService#findCountAndPatients(String,Integer,Integer,null)
*/
@Test
@Verifies(value = "should match patient with identifiers that contain no digit", method = "findCountAndPatients(String,Integer,Integer,null)")
public void findCountAndPatients_shouldMatchPatientWithIdentifiersThatContainNoDigit() throws Exception {
PatientService ps = Context.getPatientService();
final String identifier = "XYZ";
//should have no patient with this identifiers
Assert.assertEquals(0, ps.getCountOfPatients(identifier).intValue());
Patient patient = ps.getPatient(2);
PatientIdentifier pId = new PatientIdentifier(identifier, ps.getPatientIdentifierType(5), Context
.getLocationService().getLocation(1));
patient.addIdentifier(pId);
ps.savePatient(patient);
//Let's do this in a case insensitive way
Map<String, Object> resultObjects = new DWRPatientService().findCountAndPatients(identifier.toLowerCase(), 0, null,
true);
Assert.assertEquals(1, resultObjects.get("count"));
Assert.assertEquals(1, ((List<?>) resultObjects.get("objectList")).size());
}
示例4: syncRecordDemographics
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* This method must be called before any call to LinkDBConnection's patientToRecord method.
*/
public void syncRecordDemographics() {
PatientService patientService = Context.getPatientService();
PersonService personService = Context.getPersonService();
patientIdentifierTypes = patientService.getAllPatientIdentifierTypes();
personAttributeTypes = personService.getAllPersonAttributeTypes();
// nothing is excluded
AdministrationService adminService = Context.getAdministrationService();
String excluded = adminService.getGlobalProperty("patientmatching.excludedProperties", "");
String[] excludedArray = excluded.split(",");
List<String> listExcludedProperties = Arrays.asList(excludedArray);
patientPropertyList = MatchingUtils.introspectBean(listExcludedProperties, Patient.class);
namePropertyList = MatchingUtils.introspectBean(listExcludedProperties, PersonName.class);
addressPropertyList = MatchingUtils.introspectBean(listExcludedProperties, PersonAddress.class);
matching_attr_type = personService.getPersonAttributeTypeByName(PatientMatchingActivator.MATCHING_ATTRIBUTE);
}
示例5: getPatient
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* Convenience method for dwr/javascript to convert a patient id into a Patient object (or at
* least into data about the patient)
*
* @param patientId the {@link Patient#getPatientId()} to match on
* @return a truncated Patient object in the form of a PatientListItem
*/
public PatientListItem getPatient(Integer patientId) {
PatientService ps = Context.getPatientService();
Patient p = ps.getPatient(patientId);
PatientListItem pli = new PatientListItem(p);
if (p != null && p.getAddresses() != null && p.getAddresses().size() > 0) {
PersonAddress pa = (PersonAddress) p.getAddresses().toArray()[0];
pli.setAddress1(pa.getAddress1());
pli.setAddress2(pa.getAddress2());
}
return pli;
}
示例6: formBackingObject
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
//default empty Object
List<PatientIdentifierType> identifierTypeList = new Vector<PatientIdentifierType>();
//only fill the Object is the user has authenticated properly
if (Context.isAuthenticated()) {
PatientService ps = Context.getPatientService();
identifierTypeList = ps.getAllPatientIdentifierTypes(true);
}
return identifierTypeList;
}
示例7: formBackingObject
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
//only fill the Object is the user has authenticated properly
if (Context.isAuthenticated()) {
PatientService ps = Context.getPatientService();
return ps.getPatients("", null, null, false);
}
//default empty Object
return new HashSet<Patient>();
}
示例8: populateMatchingTable
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* Method iterates through existing Patient objects and adds them to the linkage
* database for use when matching. Method also creates the table, if needed,
* with the correct column taken from the LinkDataSource object.
*
*/
private void populateMatchingTable(){
// get the list of patient objects
//link_db.createTable();
LinkDBConnections ldb_con = LinkDBConnections.getInstance();
RecordDBManager link_db = ldb_con.getRecDBManager();
if(!link_db.connect()){
log.warn("Error connecting to link db when populating database");
return;
}
// iterate through them, and if linkage tables does not contain
// a record with openmrs_id equal to patient.getID, then add
PatientMatchingReportMetadataService pms = Context.getService(PatientMatchingReportMetadataService.class);
PatientService patientService = Context.getPatientService();
Set<Integer> patient_list = pms.getAllPatients().getMemberIds();
Iterator<Integer> it = patient_list.iterator();
while(it.hasNext()){
Patient p = patientService.getPatient(it.next());
Integer id = p.getPatientId();
int existing_patients = link_db.getRecordCountFromDB(LINK_TABLE_KEY_DEMOGRAPHIC, id.toString());
if(existing_patients == 0){
if(link_db.addRecordToDB(LinkDBConnections.getInstance().patientToRecord(p))){
if(log.isDebugEnabled()){
log.debug("Adding patient " + p.getPatientId() + " to link DB succeeded");
}
} else {
log.warn("Adding patient " + p.getPatientId() + " to link DB failed");
}
}
}
}
示例9: addIdentifier
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* @param patientId
* @param identifierType
* @param identifier
* @param identifierLocationId
* @return empty string or, in case of an error, a message key for the error description
*/
public String addIdentifier(Integer patientId, String identifierType, String identifier, Integer identifierLocationId) {
String ret = "";
if (identifier == null || identifier.length() == 0) {
return "PatientIdentifier.error.general";
}
PatientService ps = Context.getPatientService();
LocationService ls = Context.getLocationService();
Patient p = ps.getPatient(patientId);
PatientIdentifierType idType = ps.getPatientIdentifierTypeByName(identifierType);
//ps.updatePatientIdentifier(pi);
Location location = ls.getLocation(identifierLocationId);
log.debug("idType=" + identifierType + "->" + idType + " , location=" + identifierLocationId + "->" + location
+ " identifier=" + identifier);
PatientIdentifier id = new PatientIdentifier();
id.setIdentifierType(idType);
id.setIdentifier(identifier);
id.setLocation(location);
// in case we are editing, check to see if there is already an ID of this type and location
for (PatientIdentifier previousId : p.getActiveIdentifiers()) {
if (previousId.getIdentifierType().equals(idType) && previousId.getLocation().equals(location)) {
log.debug("Found equivalent ID: [" + idType + "][" + location + "][" + previousId.getIdentifier()
+ "], about to remove");
p.removeIdentifier(previousId);
} else {
if (!previousId.getIdentifierType().equals(idType)) {
log.debug("Previous ID id type does not match: [" + previousId.getIdentifierType().getName() + "]["
+ previousId.getIdentifier() + "]");
}
if (!previousId.getLocation().equals(location)) {
log.debug("Previous ID location is: " + previousId.getLocation());
log.debug("New location is: " + location);
}
}
}
p.addIdentifier(id);
try {
ps.savePatient(p);
}
catch (InvalidIdentifierFormatException iife) {
log.error(iife);
ret = "PatientIdentifier.error.formatInvalid";
}
catch (InvalidCheckDigitException icde) {
log.error(icde);
ret = "PatientIdentifier.error.checkDigit";
}
catch (IdentifierNotUniqueException inue) {
log.error(inue);
ret = "PatientIdentifier.error.notUnique";
}
catch (DuplicateIdentifierException die) {
log.error(die);
ret = "PatientIdentifier.error.duplicate";
}
catch (InsufficientIdentifiersException iie) {
log.error(iie);
ret = "PatientIdentifier.error.insufficientIdentifiers";
}
catch (PatientIdentifierException pie) {
log.error(pie);
ret = "PatientIdentifier.error.general";
}
return ret;
}
示例10: onSubmit
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* The onSubmit function receives the form/command object that was modified by the input form
* and saves it to the db
*
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
HttpSession httpSession = request.getSession();
if (Context.isAuthenticated()) {
StringBuilder view = new StringBuilder(getSuccessView());
PatientService ps = Context.getPatientService();
String pref = request.getParameter("preferred");
String[] nonPreferred = request.getParameter("nonPreferred").split(",");
String redirectURL = request.getParameter("redirectURL");
String modalMode = request.getParameter("modalMode");
Patient preferred = ps.getPatient(Integer.valueOf(pref));
List<Patient> notPreferred = new ArrayList<Patient>();
view.append("?patientId=").append(preferred.getPatientId());
for (int i = 0; i < nonPreferred.length; i++) {
notPreferred.add(ps.getPatient(Integer.valueOf(nonPreferred[i])));
view.append("&patientId=").append(nonPreferred[i]);
}
try {
ps.mergePatients(preferred, notPreferred);
}
catch (APIException e) {
log.error("Unable to merge patients", e);
String message = e.getMessage();
if(message == null || "".equals(message)){
message = "Patient.merge.fail";
}
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, message);
return showForm(request, response, errors);
}
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Patient.merged");
if ("true".equals(modalMode)) {
return showForm(request, response, errors);
}
int index = redirectURL.indexOf(request.getContextPath(), 2);
if (index != -1) {
redirectURL = redirectURL.substring(index);
if (redirectURL.contains(getSuccessView())) {
redirectURL = "findDuplicatePatients.htm";
}
} else {
redirectURL = view.toString();
}
return new ModelAndView(new RedirectView(redirectURL));
}
return new ModelAndView(new RedirectView(getFormView()));
}
示例11: persistReportToDB
import org.openmrs.api.PatientService; //导入依赖的package包/类
/**
* Method to persist the report to the database
* @param rptName The report name of the new report
* @param matchingPairs A list of the matching pair sets
*/
public static void persistReportToDB(String rptName, List<Set<Long>> matchingPairs, Set<String> includeColumns) throws FileNotFoundException {
Report report = new Report();
report.setCreatedBy(Context.getAuthenticatedUser());
report.setReportName(rptName);
report.setCreatedOn(new Date());
String selectedStrategies = MatchingRunData.getInstance().getFileStrat();
String[] selectedStrategyNamesArray = selectedStrategies.split(",");
Set<PatientMatchingConfiguration> usedConfigurations = new TreeSet<PatientMatchingConfiguration>();
PatientMatchingReportMetadataService reportMetadataService = Context.getService(PatientMatchingReportMetadataService.class);
for(String strategyName : selectedStrategyNamesArray){
PatientMatchingConfiguration configuration = reportMetadataService.findPatientMatchingConfigurationByName(strategyName);
usedConfigurations.add(configuration);
}
report.setUsedConfigurationList(usedConfigurations);
PatientService patientService = Context.getPatientService();
Set<MatchingRecord> matchingRecordSet = new TreeSet<MatchingRecord>();
for (int j = 0; j < matchingPairs.size(); j++) {
Set<Long> matchSet = matchingPairs.get(j);
for(Long patientId: matchSet){
MatchingRecord matchingRecord = new MatchingRecord();
matchingRecord.setGroupId(j);
matchingRecord.setState("PENDING"); //TODO move to a constant
matchingRecord.setPatient(patientService.getPatient(patientId.intValue()));
matchingRecord.setReport(report);
Set<MatchingRecordAttribute> matchingRecordAttributeSet = new TreeSet<MatchingRecordAttribute>();
Record record = RecordSerializer.deserialize(String.valueOf(patientId));
for(String includedColumn:includeColumns){
MatchingRecordAttribute matchingRecordAttribute = new MatchingRecordAttribute();
matchingRecordAttribute.setFieldName(includedColumn);
matchingRecordAttribute.setFieldValue(record.getDemographic(includedColumn));
matchingRecordAttribute.setMatchingRecord(matchingRecord);
matchingRecordAttributeSet.add(matchingRecordAttribute);
}
matchingRecord.setMatchingRecordAttributeSet(matchingRecordAttributeSet);
matchingRecordSet.add(matchingRecord);
}
}
report.setMatchingRecordSet(matchingRecordSet);
Set<ReportGenerationStep> reportGenerationSteps = new TreeSet<ReportGenerationStep>();
List<Long> proTimeList = MatchingRunData.getInstance().getProTimeList();
int noOfSteps = Math.min(proTimeList.size(),REPORT_GEN_STAGES.length);
for (int j = 0; j < noOfSteps; j++) {
ReportGenerationStep step = new ReportGenerationStep();
step.setProcessName(REPORT_GEN_STAGES[j]);
step.setTimeTaken(proTimeList.get(j).intValue());
step.setReport(report);
step.setSequenceNo(j);
reportGenerationSteps.add(step);
}
report.setReportGenerationSteps(reportGenerationSteps);
reportMetadataService.savePatientMatchingReport(report);
}