org.openmrs.Obs.getValueAsString()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.openmrs.Obs.getValueAsString()方法的一些代码示例,展示了Obs.getValueAsString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.getValueAsString()方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:getValueAsString

Obs.getValueAsString介绍

[英]Convenience method for obtaining the observation's value as a string If the Obs is complex, returns the title of the complexData denoted by the section of getValueComplex() before the first bar '|' character; or returns the entire getValueComplex() if the bar '|' character is missing.
[中]如果Obs是复杂的,以字符串形式获取观测值的简便方法,返回由第一个栏“|”字符前的getValueComplex()部分表示的complexData的标题;如果缺少条“|”字符,则返回整个getValueComplex()。

代码示例

代码示例来源:origin: openmrs/openmrs-core

@Test
public void getValueAsString_shouldReturnDateInCorrectFormat() throws Exception {
  Obs obs = new Obs();
  obs.setValueDatetime(new Date());
  Concept cn = new Concept();
  ConceptDatatype cdt = new ConceptDatatype();
  cdt.setHl7Abbreviation("DT");
  cn.setDatatype(cdt);
  obs.setConcept(cn);
  
  Date utilDate = new Date();
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  String dateString = dateFormat.format(utilDate);
  Assert.assertEquals(dateString, obs.getValueAsString(Locale.US));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Obs#getValueAsString(Locale)
 */
@Test
public void getValueAsString_shouldNotUseThousandSeparator() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(123456789.0);
  String str = "123456789.0";
  Assert.assertEquals(str, obs.getValueAsString(Locale.ENGLISH));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Obs#getValueAsString(Locale)
 */
@Test
public void getValueAsString_shouldUseCommasOrDecimalPlacesDependingOnLocale() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(123456789.3);
  String str = "123456789,3";
  Assert.assertEquals(str, obs.getValueAsString(Locale.GERMAN));
}

代码示例来源:origin: openmrs/openmrs-core

@Test
public void getValueAsString_shouldNotReturnLongDecimalNumbersAsScientificNotation() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(123456789.0);
  String str = "123456789.0";
  Assert.assertEquals(str, obs.getValueAsString(Locale.US));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Obs#getValueAsString(Locale)
 */
@Test
public void getValueAsString_shouldReturnRegularNumberForSizeOfZeroToOrGreaterThanTenDigits() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(1234567890.0);
  String str = "1234567890.0";
  Assert.assertEquals(str, obs.getValueAsString(Locale.ENGLISH));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Obs#getValueAsString(Locale)
 */
@Test
public void getValueAsString_shouldReturnRegularNumberIfDecimalPlacesAreAsHighAsSix() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(123456789.012345);
  String str = "123456789.012345";
  Assert.assertEquals(str, obs.getValueAsString(Locale.ENGLISH));
}

代码示例来源:origin: openmrs/openmrs-core

sb.append(", ");
sb.append(groupMember.getValueAsString(locale));

代码示例来源:origin: openmrs/openmrs-core

@Test
public void getValueAsString_shouldReturnNonPreciseValuesForNumericConcepts() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(25.125);
  ConceptNumeric cn = new ConceptNumeric();
  ConceptDatatype cdt = new ConceptDatatype();
  cdt.setHl7Abbreviation("NM");
  cn.setDatatype(cdt);
  cn.setAllowDecimal(false);
  obs.setConcept(cn);
  String str = "25";
  Assert.assertEquals(str, obs.getValueAsString(Locale.US));
}

代码示例来源:origin: openmrs/openmrs-core

@Test
public void getValueAsString_shouldReturnLocalizedCodedConcept() throws Exception {
  ConceptDatatype cdt = new ConceptDatatype();
  cdt.setHl7Abbreviation("CWE");
  
  Concept cn = new Concept();
  cn.setDatatype(cdt);
  cn.addName(new ConceptName(VERO, Locale.ITALIAN));
  
  Obs obs = new Obs();
  obs.setValueCoded(cn);
  obs.setConcept(cn);
  obs.setValueCodedName(new ConceptName("True", Locale.US));
  
  Assert.assertEquals(VERO, obs.getValueAsString(Locale.ITALIAN));
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

/**
 * 
 * format the obs value
 * 
 * @param locale
 * @param o
 * @return
 */
public static String getObsValueAsString(Locale locale, Obs o){
  String ret = "";
  if (o.getConcept() != null){
    String abbrev = o.getConcept().getDatatype().getHl7Abbreviation();
    if (abbrev.equals("DT")){
      return (o.getValueDatetime() == null ? "" : Context.getDateFormat().format(o.getValueDatetime()));
    } else if (abbrev.equals("TS") && o.getValueDatetime() != null){
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      return sdf.format(o.getValueDatetime());
    } else {
      ret = o.getValueAsString(locale);
    }    
  }
  return ret;
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

private String printObsHelper(Obs obs) {
  return obs.getConcept().getName(Context.getLocale()) + " = " + obs.getValueAsString(Context.getLocale());
}

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

/**
 * Display string for Obs
 * 
 * @param obs
 * @return String ConceptName = value
 */
@PropertyGetter("display")
public String getDisplayString(Obs obs) {
  if (obs.getConcept() == null)
    return "";
  
  return obs.getConcept().getName() + ": " + obs.getValueAsString(Context.getLocale());
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

String oldString = existingObs.getValueAsString(Context.getLocale());
String newString = newObs.getValueAsString(Context.getLocale());
if (log.isDebugEnabled() && concept != null) {
  log.debug("For concept " + concept.getName(Context.getLocale()) + ": " + oldString + " -> " + newString);

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

/**
 * Removes any Obs that are empty or which have only empty children
 */
public static void removeEmptyObs(Collection<Obs> obsList) {
  if (obsList != null) {
    Set<Obs> obsToRemove = new HashSet<Obs>();
    for (Obs o : obsList) {
      removeEmptyObs(o.getGroupMembers());
      boolean valueEmpty = StringUtils.isEmpty(o.getValueAsString(Context.getLocale()));
      boolean membersEmpty = o.getGroupMembers() == null || o.getGroupMembers().isEmpty();
      if (valueEmpty && membersEmpty) {
        obsToRemove.add(o);
      }
    }
    for (Obs o : obsToRemove) {
      if (o.getObsGroup() != null) {
        o.getObsGroup().removeGroupMember(o);
        o.setObsGroup(null);
      }
      if (o.getEncounter() != null) {
        o.getEncounter().removeObs(o);
        o.setEncounter(null);
      }
      obsList.remove(o);
    }
  }
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

public void printEncounterCreated() {
  if (encounterCreated == null) {
    System.out.println("No encounter created");
  } else {
    System.out.println("=== Encounter created ===");
    System.out.println("Created: " + encounterCreated.getDateCreated() + "  Edited: " + encounterCreated.getDateChanged());
    System.out.println("Date: " + encounterCreated.getEncounterDatetime());
    System.out.println("Location: " + encounterCreated.getLocation().getName());
    System.out.println("Provider: " + getProvider(encounterCreated).getPersonName());
    System.out.println("    (obs)");
    Collection<Obs> obs = encounterCreated.getAllObs(false);
    if (obs == null) {
      System.out.println("None");
    } else {
      for (Obs o : obs) {
        System.out.println(o.getConcept().getName() + " -> " + o.getValueAsString(Context.getLocale()));
      }
    }
  }
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

public boolean matches(Obs obs) {
    
    if (!obs.getConcept().getConceptId().equals(conceptId)) {
      return false;
    }
    String valueAsString = null;
    if(value instanceof Date){
      valueAsString = formatObsValueDate((Date)value);
    }else{
      valueAsString = TestUtil.valueAsStringHelper(value);
    }
    return OpenmrsUtil.nullSafeEquals(valueAsString, obs.getValueAsString(Context.getLocale()));
  }
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

private void assertObsExists(boolean lookForVoided, int conceptId, Object value) {
  // quick checks
  Assert.assertNotNull(encounterCreated);
  Collection<Obs> temp = encounterCreated.getAllObs(lookForVoided);
  Assert.assertNotNull(temp);
  String valueAsString = null;
  if(value instanceof Date){
    valueAsString = formatObsValueDate((Date)value);
  }else{
    valueAsString = TestUtil.valueAsStringHelper(value);
  }
  for (Obs obs : temp) {
    if (lookForVoided && !obs.isVoided())
      continue;
    if (obs.getConcept().getConceptId() == conceptId) {
      if (valueAsString == null)
        return;
      if (valueAsString.equals(obs.getValueAsString(Context.getLocale())))
        return;
    }
  }
  Assert.fail("Could not find obs with conceptId " + conceptId + " and value " + valueAsString);
}

相关文章

微信公众号

最新文章

更多