本文整理汇总了Java中org.openmrs.util.OpenmrsUtil.nullSafeEquals方法的典型用法代码示例。如果您正苦于以下问题:Java OpenmrsUtil.nullSafeEquals方法的具体用法?Java OpenmrsUtil.nullSafeEquals怎么用?Java OpenmrsUtil.nullSafeEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openmrs.util.OpenmrsUtil
的用法示例。
在下文中一共展示了OpenmrsUtil.nullSafeEquals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isConceptFound
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
* Convenient method that determines whether given concept is present in result list or not
*
* @param expected the concept to be checked
* @param result the list of concept lookup result items
* @return true if given concept is present among result items
*/
private boolean isConceptFound(Concept expected, List<Object> result) {
boolean found = Boolean.FALSE;
if (result != null) {
for (Iterator<?> iterator = result.iterator(); iterator.hasNext();) {
Object item = iterator.next();
if (item instanceof ConceptListItem) {
ConceptListItem resultItem = (ConceptListItem) item;
if (resultItem != null && OpenmrsUtil.nullSafeEquals(resultItem.getConceptId(), expected.getConceptId())) {
found = Boolean.TRUE;
break;
}
}
}
}
return found;
}
示例2: hasSameValues
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
* Checks if this reaction has the same values as the given one
*
* @param reaction the reaction whose values to compare with
* @return true if the values match, else false
*/
public boolean hasSameValues(AllergyReaction reaction) {
if (!OpenmrsUtil.nullSafeEquals(getAllergyReactionId(), reaction.getAllergyReactionId())) {
return false;
}
if (!OpenmrsUtil.nullSafeEquals(getReaction(), reaction.getReaction())) {
//if object instances are different but with the same concept id, then not changed
if (getReaction() != null && reaction.getReaction() != null) {
if (!OpenmrsUtil.nullSafeEquals(getReaction().getConceptId(), reaction.getReaction().getConceptId())) {
return false;
}
}
else {
return false;
}
}
if (!OpenmrsUtil.nullSafeEquals(getReactionNonCoded(), reaction.getReactionNonCoded())) {
return false;
}
return true;
}
示例3: equals
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof ConceptReferenceTermListItem) {
ConceptReferenceTermListItem term2 = (ConceptReferenceTermListItem) obj;
OpenmrsUtil.nullSafeEquals(conceptReferenceTermId, term2.getConceptReferenceTermId());
}
return false;
}
示例4: getConceptSet
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
public List<Object> getConceptSet(Integer conceptId) {
Locale locale = Context.getLocale();
ConceptService cs = Context.getConceptService();
FormService fs = Context.getFormService();
Concept concept = cs.getConcept(conceptId);
List<Object> returnList = new ArrayList<Object>();
if (concept.isSet()) {
for (ConceptSet set : concept.getConceptSets()) {
Field field = null;
ConceptName cn = set.getConcept().getName(locale);
ConceptDescription description = set.getConcept().getDescription(locale);
if (description != null) {
for (Field f : fs.getFieldsByConcept(set.getConcept())) {
if (OpenmrsUtil.nullSafeEquals(f.getName(), cn.getName())
&& OpenmrsUtil.nullSafeEquals(f.getDescription(), description.getDescription())
&& f.isSelectMultiple().equals(false)) {
field = f;
}
}
}
if (field == null) {
returnList.add(new ConceptListItem(set.getConcept(), cn, locale));
} else {
returnList.add(new FieldListItem(field, locale));
}
}
}
return returnList;
}
示例5: getAllergyReaction
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
* Gets an allergy reaction with a given id
*
* @param allergyReactionId the allergy reaction id
* @return the allergy reaction with a matching id
*/
public AllergyReaction getAllergyReaction(Integer allergyReactionId) {
for (AllergyReaction reaction : reactions) {
if (OpenmrsUtil.nullSafeEquals(reaction.getAllergyReactionId(), allergyReactionId)) {
return reaction;
}
}
return null;
}
示例6: getAllergy
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
* Gets an allergy with a given id
*
* @param allergyId the allergy id
* @return the allergy with a matching id
*/
public Allergy getAllergy(Integer allergyId) {
for (Allergy allergy : allergies) {
if (OpenmrsUtil.nullSafeEquals(allergy.getAllergyId(), allergyId)) {
return allergy;
}
}
return null;
}
示例7: updatePatientProgram
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
* Updates enrollment date, completion date, and location for a PatientProgram. Compares @param
* enrollmentDateYmd with {@link PatientProgram#getDateEnrolled()} compares @param
* completionDateYmd with {@link PatientProgram#getDateCompleted()}, compares @param locationId
* with {@link PatientProgram#getLocation()}, compares @param outcomeId with
* {@link org.openmrs.PatientProgram#getOutcome()}. At least one of these comparisons must
* indicate a change in order to update the PatientProgram. In other words, if neither the @param
* enrollmentDateYmd, the @param completionDateYmd, or the @param locationId or the @param
* outcomeId match with the persisted object, then the PatientProgram will not be updated.
* <p>
* Also, if the enrollment date comes after the completion date, the PatientProgram will not be
* updated.
* </p>
*
* @param patientProgramId
* @param enrollmentDateYmd
* @param completionDateYmd
* @param locationId
* @param outcomeId
* @throws ParseException
*/
public void updatePatientProgram(Integer patientProgramId, String enrollmentDateYmd, String completionDateYmd,
Integer locationId, Integer outcomeId) throws ParseException {
PatientProgram pp = Context.getProgramWorkflowService().getPatientProgram(patientProgramId);
Location loc = null;
if (locationId != null) {
loc = Context.getLocationService().getLocation(locationId);
}
Concept outcomeConcept = null;
if (outcomeId != null) {
outcomeConcept = Context.getConceptService().getConcept(outcomeId);
}
Date dateEnrolled = null;
Date dateCompleted = null;
Date ppDateEnrolled = null;
Date ppDateCompleted = null;
Location ppLocation = pp.getLocation();
Concept ppOutcome = pp.getOutcome();
// If persisted date enrolled is not null then parse to ymdDf format.
if (null != pp.getDateEnrolled()) {
String enrolled = ymdDf.format(pp.getDateEnrolled());
if (null != enrolled && enrolled.length() > 0) {
ppDateEnrolled = ymdDf.parse(enrolled);
}
}
// If persisted date enrolled is not null then parse to ymdDf format.
if (null != pp.getDateCompleted()) {
String completed = ymdDf.format(pp.getDateCompleted());
if (null != completed && completed.length() > 0) {
ppDateCompleted = ymdDf.parse(completed);
}
}
// Parse parameter dates to ymdDf format.
if (enrollmentDateYmd != null && enrollmentDateYmd.length() > 0) {
dateEnrolled = ymdDf.parse(enrollmentDateYmd);
}
if (completionDateYmd != null && completionDateYmd.length() > 0) {
dateCompleted = ymdDf.parse(completionDateYmd);
}
// If either either parameter and persisted instances
// of enrollment and completion dates are equal, then anyChange is true.
boolean anyChange = OpenmrsUtil.nullSafeEquals(dateEnrolled, ppDateEnrolled);
anyChange |= OpenmrsUtil.nullSafeEquals(dateCompleted, ppDateCompleted);
anyChange |= OpenmrsUtil.nullSafeEquals(loc, ppLocation);
anyChange |= OpenmrsUtil.nullSafeEquals(outcomeConcept, ppOutcome);
// Do not update if the enrollment date is after the completion date.
if (null != dateEnrolled && null != dateCompleted && dateCompleted.before(dateEnrolled)) {
anyChange = false;
}
if (anyChange) {
pp.setDateEnrolled(dateEnrolled);
pp.setDateCompleted(dateCompleted);
pp.setLocation(loc);
pp.setOutcome(outcomeConcept);
Context.getProgramWorkflowService().savePatientProgram(pp);
}
}
示例8: getPatientFromFormData
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
* Convenience method that gets the data from the patientModel
*
* @param patientModel the modelObject holding the form data
* @return the patient object that has been populated with input from the form
*/
private Patient getPatientFromFormData(ShortPatientModel patientModel) {
Patient patient = patientModel.getPatient();
PersonName personName = patientModel.getPersonName();
if (personName != null) {
personName.setPreferred(true);
patient.addName(personName);
}
PersonAddress personAddress = patientModel.getPersonAddress();
if (personAddress != null) {
if (personAddress.isVoided() && StringUtils.isBlank(personAddress.getVoidReason())) {
personAddress.setVoidReason(Context.getMessageSourceService().getMessage("general.default.voidReason"));
}
// don't add an address that is being created and at the
// same time being removed
else if (!(personAddress.isVoided() && personAddress.getPersonAddressId() == null)) {
personAddress.setPreferred(true);
patient.addAddress(personAddress);
}
}
// add all the existing identifiers and any new ones.
if (patientModel.getIdentifiers() != null) {
for (PatientIdentifier id : patientModel.getIdentifiers()) {
// skip past the new ones removed from the user interface(may be
// they were invalid
// and the user changed their mind about adding them and they
// removed them)
if (id.getPatientIdentifierId() == null && id.isVoided()) {
continue;
}
patient.addIdentifier(id);
}
}
// add the person attributes
if (patientModel.getPersonAttributes() != null) {
for (PersonAttribute formAttribute : patientModel.getPersonAttributes()) {
//skip past new attributes with no values, because the user left them blank
if (formAttribute.getPersonAttributeId() == null && StringUtils.isBlank(formAttribute.getValue())) {
continue;
}
//if the value has been changed for an existing attribute, void it and create a new one
if (formAttribute.getPersonAttributeId() != null
&& !OpenmrsUtil.nullSafeEquals(formAttribute.getValue(), patient.getAttribute(
formAttribute.getAttributeType()).getValue())) {
//As per the logic in Person.addAttribute, the old edited attribute will get voided
//as this new one is getting added
formAttribute = new PersonAttribute(formAttribute.getAttributeType(), formAttribute.getValue());
//AOP is failing to set these in unit tests, just set them here for the tests to pass
formAttribute.setDateCreated(new Date());
formAttribute.setCreator(Context.getAuthenticatedUser());
}
patient.addAttribute(formAttribute);
}
}
return patient;
}
示例9: hasSameValues
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
* Checks if this allergy has the same values as a given one.
*
* @param allergy the allergy whose values to compare with
* @return true if the values match, else false
*/
public boolean hasSameValues(Allergy allergy) {
if (!OpenmrsUtil.nullSafeEquals(getAllergyId(), allergy.getAllergyId())) {
return false;
}
if (!OpenmrsUtil.nullSafeEquals(getPatient(), allergy.getPatient())) {
//if object instances are different but with the same patient id, then not changed
if (getPatient() != null && allergy.getPatient() != null) {
if (!OpenmrsUtil.nullSafeEquals(getPatient().getPatientId(), allergy.getPatient().getPatientId())) {
return false;
}
}
else {
return false;
}
}
if (!OpenmrsUtil.nullSafeEquals(getAllergen().getCodedAllergen(), allergy.getAllergen().getCodedAllergen())) {
//if object instances are different but with the same concept id, then not changed
if (getAllergen().getCodedAllergen() != null && allergy.getAllergen().getCodedAllergen() != null) {
if (!OpenmrsUtil.nullSafeEquals(getAllergen().getCodedAllergen().getConceptId(), allergy.getAllergen().getCodedAllergen().getConceptId())) {
return false;
}
}
else {
return false;
}
}
if (!OpenmrsUtil.nullSafeEquals(getAllergen().getNonCodedAllergen(), allergy.getAllergen().getNonCodedAllergen())) {
return false;
}
if (!OpenmrsUtil.nullSafeEquals(getSeverity(), allergy.getSeverity())) {
//if object instances are different but with the same concept id, then not changed
if (getSeverity() != null && allergy.getSeverity() != null) {
if (!OpenmrsUtil.nullSafeEquals(getSeverity().getConceptId(), allergy.getSeverity().getConceptId())) {
return false;
}
}
else {
return false;
}
}
if (!OpenmrsUtil.nullSafeEquals(getComment(), allergy.getComment())) {
return false;
}
if (!hasSameReactions(allergy)) {
return false;
}
return true;
}
示例10: ReadConfigFile
import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
public static Map<String, Object> ReadConfigFile(Map<String,Object> objects, String[] selectedStrategies){
log.info("Starting generate report process sequence");
// open the config.xml file
String configLocation = MatchingConstants.CONFIG_FOLDER_NAME;
File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
File configFile = new File(configFileFolder, MatchingConstants.CONFIG_FILE_NAME);
log.info("Reading matching config file from " + configFile.getAbsolutePath());
RecMatchConfig recMatchConfig = XMLTranslator.createRecMatchConfig(XMLTranslator.getXMLDocFromFile(configFile));
List<PatientMatchingConfiguration> configList = Context.getService(PatientMatchingReportMetadataService.class).getMatchingConfigs();
List<MatchingConfig> matchingConfigLists = new ArrayList<MatchingConfig>();
for (String selectedStrat : selectedStrategies) {
for (PatientMatchingConfiguration config : configList) {
if (OpenmrsUtil.nullSafeEquals(config.getConfigurationName(), selectedStrat)) {
matchingConfigLists.add(ReportMigrationUtils.ptConfigurationToMatchingConfig(config));
}
}
}
DedupMatchResultList handler = new DedupMatchResultList();
Properties c = Context.getRuntimeProperties();
String url = c.getProperty("connection.url");
String user = c.getProperty("connection.username");
String passwd = c.getProperty("connection.password");
String driver = c.getProperty("connection.driver_class");
log.info("URL: " + url);
Connection databaseConnection = null;
try {
Class.forName(driver);
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
url, user, passwd);
databaseConnection = connectionFactory.createConnection();
} catch (Exception e) {
throw new RuntimeException(e);
}
objects.put("databaseConnection", databaseConnection);
objects.put("recMatchConfig", recMatchConfig);
objects.put("driver", driver);
objects.put("url", url);
objects.put("user", user);
objects.put("passwd", passwd);
objects.put("matchingConfigLists", matchingConfigLists);
objects.put("configFileFolder", configFileFolder);
objects.put("handler", handler);
return objects;
}