Esempio n. 1
0
 // duh! what a cheap way to make a set, but really we don't expect there to be too many more than
 // 2 parents!
 private ActMood(
     ActMood parent,
     ActMood parent2,
     ActMood parent3,
     String domainName,
     String code,
     String displayName) {
   _parent = parent;
   _parent2 = parent2;
   _parent3 = parent3;
   _domainName = domainName;
   _code = ValueFactory.getInstance().STvalueOfLiteral(code);
   _displayName = ValueFactory.getInstance().STvalueOfLiteral(displayName);
 }
Esempio n. 2
0
 protected PQR valueOf(TreeContentHandler.Element element) throws SAXException {
   String nullFlavorString = element.getAttributeValue(ATTR_NULL_FLAVOR);
   if (nullFlavorString != null) {
     throw new UnsupportedOperationException("Can't have a null PQR in PQRPresenter!");
     // return CVnull.valueOf(nullFlavorString);
   }
   // Handle other attributes.
   ST code = ValueFactory.getInstance().STvalueOfLiteral(element.getAttributeValue(ATTR_CODE));
   UID codeSystem =
       ValueFactory.getInstance().UIDvalueOfLiteral(element.getAttributeValue(ATTR_CODE_SYSTEM));
   ST codeSystemName =
       ValueFactory.getInstance()
           .STvalueOfLiteral(element.getAttributeValue(ATTR_CODE_SYSTEM_NAME));
   ST codeSystemVersion =
       ValueFactory.getInstance()
           .STvalueOfLiteral(element.getAttributeValue(ATTR_CODE_SYSTEM_VERSION));
   ST displayName =
       ValueFactory.getInstance().STvalueOfLiteral(element.getAttributeValue(ATTR_DISPLAY_NAME));
   String strValue = element.getAttributeValue(ATTR_VALUE);
   REAL value;
   if (strValue != null) value = ValueFactory.getInstance().REALvalueOfLiteral(strValue);
   else value = REALnull.NI;
   // Handle nested elements...
   Iterator<Element> it = element.findChildren(ATTR_ORIGINAL_TEXT);
   ST originalTextString =
       ValueFactory.getInstance().STvalueOfLiteral(it.hasNext() ? it.next().getText() : null);
   return PQRimpl.valueOf(
       value,
       code,
       codeSystem,
       originalTextString,
       displayName,
       codeSystemName,
       codeSystemVersion);
 }
Esempio n. 3
0
 protected void notifyActivation(Attributes atts) {
   String nullFlavorString = atts.getValue(ATTR_NULL_FLAVOR);
   if (nullFlavorString != null) {
     _result = REALnull.valueOf(nullFlavorString);
   } else {
     String valueString = atts.getValue(ATTR_VALUE);
     if (valueString != null) {
       _result = ValueFactory.getInstance().REALvalueOfLiteral(valueString);
     }
   }
 }
Esempio n. 4
0
/**
 * A code distinguishing whether an Act is conceived of as a factual statement or in some other
 * manner as a command, possibility, goal, etc.
 *
 * <p><emph>Constraints:</emph> An Act-instance must have one and only one moodCode value.
 *
 * <p>The moodCode of a single Act-instance never changes. Mood is not state.
 *
 * <p>To describe the progression of a business activity from defined to planned to executed, etc.
 * one must instantiate different Act-instances in the different moods and link them using
 * ActRelationship of general type "sequel". (See ActRelationship.type.)
 *
 * <p>This table controls values for structural elements of the HL7 Reference Information Model.
 * Therefore, it is part of the Normative Ballot for the RIM.
 */
public enum ActMood implements CS {

  // ACTUAL DATA

  root(null, "ActMood", null, null),
  /**
   * These are moods describing activities as they progress in the business cycle, from defined,
   * through planned and ordered to completed.
   */
  CompletionTrack(null, "ActMoodCompletionTrack", null, null),
  /**
   * An intention or plan to perform a service. Historical note: in previous RIM versions, the
   * intent mood was captured as a separate class hierarchy, called Service_intent_or_order.
   */
  Intent(CompletionTrack, "ActMoodIntent", "INT", "intent"),
  /**
   * A non-mandated intent to perform an act. Used to record intents that are explicitly not Orders.
   * Professional responsibility for the 'proposal' may or may not be present.
   */
  Proposal(Intent, "ActMoodProposal", "PRP", "proposal"),
  /**
   * A non-mandated intent to perform an act where a level of professional responsibility is being
   * accepted by making the proposal.
   */
  Recommendation(Proposal, "Recommendation", "RMD", "recommendation"),
  /** A planned Act for a specific time and place. */
  Appointment(Intent, "Appointment", "APT", "appointment"),
  /** A request for the booking of an appointment. */
  AppointmentRequest(Intent, "Appointment request", "ARQ", "appointment request"),
  /**
   * An intent to perform a service that has the strength of a commitment, i.e., other parties may
   * rely on the originator of such promise that said originator will see to it that the promised
   * act will be fulfilled. A promise can be either solicited or unsolicited.
   */
  Promise(Intent, "Promise", "PRMS", "promise"),
  /**
   * A request or order for a service is an intent directed from a placer (request author) to a
   * fulfiller (service performer).
   *
   * <p><emph>Rationale:</emph> The concepts of a "request" and an "order" are viewed as different,
   * because there is an implication of a mandate associated with order. In practice, however, this
   * distinction has no general functional value in the inter-operation of health care computing.
   * "Orders" are commonly refused for a variety of clinical and business reasons, and the notion of
   * a "request" obligates the recipient (the fulfiller) to respond to the sender (the author).
   * Indeed, in many regions, including Australia and Europe, the common term used is "request."
   *
   * <p>Thus, the concept embodies both notions, as there is no useful distinction to be made. If a
   * mandate is to be associated with a request, this will be embodied in the "local" business rules
   * applied to the transactions. Should HL7 desire to provide a distinction between these in the
   * future, the individual concepts could be added as specializations of this concept.
   *
   * <p>The critical distinction here, is the difference between this concept and an "intent", of
   * which it is a specialization. An intent involves decisions by a single party, the author. A
   * request, however, involves decisions by two parties, the author and the fulfiller, with an
   * obligation on the part of the fulfiller to respond to the request indicating that the fulfiller
   * will indeed fulfill the request.
   */
  Request(Intent, "Request", "RQO", "request"),
  /**
   * A definition of a service (master).
   *
   * <p>Historical note: in previous RIM versions, the definition mood was captured as a separate
   * class hierarchy, called Master_service.
   */
  Definition(CompletionTrack, "Definition", "DEF", "definition"),
  /**
   * A service that actually happens, may be an ongoing service or a documentation of a past
   * service.
   *
   * <p>Historical note: in previous RIM versions, the event mood was captured as a separate class
   * hierarchy, called Patient_service_event, and later Service_event.
   */
  Event(CompletionTrack, "Event (occurrence)", "EVN", "event (occurrence)"),
  /**
   * Any of the above service moods (e.g., event, intent, or goal) can be turned into a predicate
   * used as a criterion to express conditionals (or queries.) However, currently we allow only
   * criteria on service events.
   */
  Predicate(null, "ActMoodPredicate", null, null),
  /**
   * <emph role="strong">Definition:</emph>An observation that is considered to be desirable to
   * occur in the future. The essential feature of a goal is that if it occurs it would be
   * considered as a marker of a positive outcome or of progress towards a positive outcome.
   *
   * <p><emph role="strong">Examples:</emph>Target weight below 80Kg, Stop smoking, Regain ability
   * to walk, goal is to administer thrombolytics to candidate patients presenting with acute
   * myocardial infarction.
   *
   * <p><emph role="strong">Discussion:</emph> INT (intent) reflects a plan for the future, which is
   * a declaration to do something. This contrasts with goal which doesn't represent an intention to
   * act, merely a hope for an eventual result. A goal is distinct from the intended actions to
   * reach that goal. "I will reduce the dose of drug x to 20mg" is an intent. "I hope to be able to
   * get the patient to the point where I can reduce the dose of drug x to 20mg" is a goal. EXPEC
   * (expectation) reflects a prediction rather than a hope. RSK (risk) reflects a potential
   * negative event rather than a hope.
   */
  Goal(Predicate, "Goal", "GOL", "Goal"),
  /**
   * A criterion or condition over service events that must apply for an associated service to be
   * considered.
   */
  EventCriterion(Predicate, "Event criterion", "EVN.CRT", "event criterion"),
  /**
   * <emph role="strong">Definition:</emph>An act that is considered likely to occur in the future.
   * The essential feature of an act expressed in expectation mood is that it is likely to occur. An
   * expectation may be desirable, undesirable or neutral in effect.
   *
   * <p><emph role="strong">Examples:</emph>Prognosis of a condition, Expected date of discharge
   * from hospital, patient will likely need an emergency decompression of the intracranial pressure
   * by morning.
   *
   * <p><emph role="strong">Discussion:</emph>INT (intent) reflects a plan for the future, which is
   * a declaration to do something. This contrasts with expectation, which is a prediction that
   * something will happen in the future. GOL (goal) reflects a hope rather than a prediction. RSK
   * (risk) reflects a potential negative event that may or may not be expected to happen.
   */
  Expectation(Predicate, "Expectation", "EXPEC", "expectation"),
  /**
   * An option is an alternative set of property-value bindings. Options specify alternative sets of
   * values, typically used in definitions or orders to describe alternatives. An option can only be
   * used as a group, that is, all assigned values must be used together.
   *
   * <p>Historical note: in HL7 v2.x option existed in the special case for alternative medication
   * routes (RXR segment).
   */
  Option(Predicate, "Option", "OPT", "option"),
  /** A kind of service which is authorized to be performed. */
  Permission(Predicate, "Permission", "PERM", "permission"),
  /**
   * A request for authorization to perform a kind of service.
   *
   * <p>This is distinct from RQO which is a request for an actual act. PERMRQ is merely a request
   * for permission to perform an act. <emph>Discussion:</emph>
   */
  PermissionRequest(Predicate, "Permission request", "PERMRQ", "permission request"),
  /**
   * <emph role="strong">Definition:</emph>An act that may occur in the future and which is regarded
   * as undesirable. The essential feature of a risk is that if it occurs this would be regarded as
   * a marker of a negative outcome or of deterioration towards a negative outcome. Recording a risk
   * indicates that it is seen as more likely to occur in the subject than in a general member of
   * the population but does not mean it is expected to occur.
   *
   * <p><emph role="strong">Examples:</emph>Increased risk of DVT, at risk for sub-acute bacterial
   * endocarditis.
   *
   * <p><emph role="strong">Discussion:</emph>Note: An observation in RSK mood expresses the
   * undesirable act, and not the underlying risk factor. A risk factor that is present (e.g.
   * obesity, smoking, etc) should be expressed in event mood. INT (intent) reflects a plan for the
   * future, which is a declaration to do something. This contrasts with RSK (risk), which is the
   * potential that something negative will occur that may or may not ever happen. GOL (goal)
   * reflects a hope to achieve something. EXPEC (expectation) is the prediction of a positive or
   * negative event. This contrasts with RSK (risk), which is the potential that something negative
   * will occur that may or may not ever happen, and may not be expected to happen.
   */
  Risk(Predicate, "Risk", "RSK", "risk");

  // BOILER PLATE CODE IN WHICH ONLY THE ENUM NAME MUST BE INSERTED

  public static final UID CODE_SYSTEM =
      ValueFactory.getInstance().UIDvalueOfLiteral("2.16.840.1.113883.5.1001");
  public static final ST CODE_SYSTEM_NAME = ValueFactory.getInstance().STvalueOfLiteral("ActMood");

  private final ActMood _parent;
  // duh! what a cheap way to make a set, but really we don't expect there to be too many more than
  // 2 parents!
  private final ActMood _parent2;
  private final ActMood _parent3; // well, found a 3rd :(
  private EnumSet<ActMood> _impliedConcepts = null;

  private ActMood(ActMood parent, String domainName, String code, String displayName) {
    this(parent, null, domainName, code, displayName);
  }

  private ActMood(
      ActMood parent, ActMood parent2, String domainName, String code, String displayName) {
    this(parent, null, null, domainName, code, displayName);
  }

  // duh! what a cheap way to make a set, but really we don't expect there to be too many more than
  // 2 parents!
  private ActMood(
      ActMood parent,
      ActMood parent2,
      ActMood parent3,
      String domainName,
      String code,
      String displayName) {
    _parent = parent;
    _parent2 = parent2;
    _parent3 = parent3;
    _domainName = domainName;
    _code = ValueFactory.getInstance().STvalueOfLiteral(code);
    _displayName = ValueFactory.getInstance().STvalueOfLiteral(displayName);
  }

  private EnumSet<ActMood> getImpliedConcepts() {
    if (_impliedConcepts == null) {
      if (_parent == null) { // then _parent2, 3 is also null
        _impliedConcepts = EnumSet.of(root);
        _impliedConcepts.add(this);
      } else {
        _impliedConcepts = EnumSet.copyOf(_parent.getImpliedConcepts());
        _impliedConcepts.add(this);
        if (_parent2 != null) _impliedConcepts.addAll(_parent2.getImpliedConcepts());
        if (_parent3 != null) _impliedConcepts.addAll(_parent3.getImpliedConcepts());
      }
    }
    return _impliedConcepts;
  }

  public final BL equal(ANY that) {
    if (this == that) return BLimpl.TRUE;
    if (!(that instanceof CD)) return BLimpl.FALSE;
    else if (that instanceof ActMood) return BLimpl.FALSE;
    else
      throw new UnsupportedOperationException("cannot handle argument of class " + that.getClass());
  }

  public BL implies(CD that) {
    if (this == that || this.equals(that)) return BLimpl.TRUE;
    if (!(that instanceof ActMood))
      throw new UnsupportedOperationException("cannot handle argument of class " + that.getClass());
    final ActMood thatActMood = (ActMood) that;
    return BLimpl.valueOf(getImpliedConcepts().contains(thatActMood));
  }

  public ActMood mostSpecificGeneralization(CD that) {
    if (this == that || this.equals(that)) return this;
    if (!(that instanceof ActMood))
      throw new UnsupportedOperationException("cannot handle argument of class " + that.getClass());
    final ActMood thatActMood = (ActMood) that;

    // First build the intersection of the implied concepts
    // the remainder is a single path of which we have to
    // find the most specific concept, i.e., the one who
    // has all others as parents, i.e., the one with the
    // largest set of implied concepts.
    EnumSet<ActMood> intersection = EnumSet.copyOf(getImpliedConcepts());
    intersection.removeAll(EnumSet.complementOf(thatActMood.getImpliedConcepts()));
    intersection.remove(root);

    // XXX: this iterative search is likely to be least optimal because
    // we probably have to search the path from the root here.
    // I don't know of any better way to do it right now though.

    ActMood mostSpecificKnownGeneralization = root;
    int maxKnownSpecificity = 1;

    for (ActMood candidate : intersection) {
      int specificity = candidate.getImpliedConcepts().size();
      if (specificity > maxKnownSpecificity) {
        maxKnownSpecificity = specificity;
        mostSpecificKnownGeneralization = candidate;
      }
    }

    return mostSpecificKnownGeneralization;
  }

  private static Map<ST, ActMood> _codeMap = null;

  public static ActMood valueOf(ST code) {
    // set up the _codeMap if needed for the first time
    if (_codeMap == null) {
      synchronized (ActMood.class) { // that one time might just as well keep it thread-safe
        if (_codeMap == null) {
          _codeMap = new HashMap();
          for (ActMood concept : EnumSet.allOf(ActMood.class)) {
            ST conceptCode = concept.code();
            if (conceptCode != null && conceptCode.nonNull().isTrue()) {
              _codeMap.put(conceptCode, concept);
            }
          }
        }
      }
    }

    if (code.nonNull().isTrue()) {
      ActMood concept = _codeMap.get(code);
      if (concept == null)
        throw new IllegalArgumentException(
            ("unknown code "
                + code
                + " at codeSystem = "
                + "2.16.840.1.113883.5.1001"
                + ", domain = "
                + "ActMood"));
      else return concept;
    } else return null;
  }

  // INVARIANT BOILER PLATE CODE

  public String toString() {
    return code().toString();
  }

  private final String _domainName;
  private final ST _code;
  private final ST _displayName;

  public String domainName() {
    return _domainName;
  }

  public ST code() {
    return _code;
  }

  public ST displayName() {
    return _displayName;
  }

  public UID codeSystem() {
    return CODE_SYSTEM;
  }

  public ST codeSystemName() {
    return CODE_SYSTEM_NAME;
  }

  public ST codeSystemVersion() {
    return STnull.NI;
  }

  public ST originalText() {
    return STnull.NI;
  }

  public SET<CD> translation() {
    return SETnull.NA;
  }

  public LIST<CR> qualifier() {
    return LISTnull.NA;
  }

  public NullFlavor nullFlavor() {
    return NullFlavorImpl.NOT_A_NULL_FLAVOR;
  }

  public boolean isNullJ() {
    return false;
  }

  public boolean nonNullJ() {
    return true;
  }

  public boolean notApplicableJ() {
    return false;
  }

  public boolean unknownJ() {
    return false;
  }

  public boolean otherJ() {
    return false;
  }

  public BL isNull() {
    return BLimpl.FALSE;
  }

  public BL nonNull() {
    return BLimpl.TRUE;
  }

  public BL notApplicable() {
    return BLimpl.FALSE;
  }

  public BL unknown() {
    return BLimpl.FALSE;
  }

  public BL other() {
    return BLimpl.FALSE;
  }
}
 public void test_LiteralsR8() {
   assertEquals("0.0001235", ValueFactory.getInstance().REALvalueOf(1.2345e-4, 4).toString());
 }
 public void test_LiteralsR7() {
   assertEquals("0.00012345", ValueFactory.getInstance().REALvalueOf(12345.e-8, 5).toString());
 }
 public void test_LiteralsR5() {
   assertEquals("123.", ValueFactory.getInstance().REALvalueOf(12345.e-2, 3).toString());
 }
 public void test_LiteralsR4() {
   String s = "123.45000";
   assertEquals(s, ValueFactory.getInstance().REALvalueOfLiteral(s).toString());
 }
 static REAL R(String s) {
   return VF.REALvalueOfLiteral(s);
 }
public class REALdoubleAdapterTest extends TestCase {

  private static final ValueFactory VF = ValueFactory.getInstance();

  static REAL R(String s) {
    return VF.REALvalueOfLiteral(s);
  }

  final REAL real0_1 = ValueFactory.getInstance().REALvalueOfLiteral("0");
  final REAL real0_11 = ValueFactory.getInstance().REALvalueOfLiteral("0.");
  final REAL real0_2 = ValueFactory.getInstance().REALvalueOfLiteral("0.0");
  final REAL real0_3 = ValueFactory.getInstance().REALvalueOfLiteral("0.00");
  final REAL real0_4 = ValueFactory.getInstance().REALvalueOfLiteral("00.00");

  final REAL real0_5 = ValueFactory.getInstance().REALvalueOf(0);

  final REAL real250_1 = ValueFactory.getInstance().REALvalueOfLiteral("250");
  final REAL real250_2 = ValueFactory.getInstance().REALvalueOfLiteral("250.0");
  final REAL real250_3 = ValueFactory.getInstance().REALvalueOfLiteral("0250.0");
  final REAL real250_4 = ValueFactory.getInstance().REALvalueOfLiteral("0250.00");
  final REAL real250_9 = ValueFactory.getInstance().REALvalueOfLiteral("250.");

  final REAL real1_1 = ValueFactory.getInstance().REALvalueOfLiteral("1");
  final REAL real1_2 = ValueFactory.getInstance().REALvalueOfLiteral("1.0");
  final REAL real1_3 = ValueFactory.getInstance().REALvalueOfLiteral("1.00");

  final REAL real250_5 = ValueFactory.getInstance().REALvalueOf(250);
  final REAL real250_6 = ValueFactory.getInstance().REALvalueOf(250.0);
  final REAL real250_7 = ValueFactory.getInstance().REALvalueOf(0250.0);
  final REAL real250_8 = ValueFactory.getInstance().REALvalueOf(0250.00);

  final REAL real03_1 = ValueFactory.getInstance().REALvalueOfLiteral("0.3");
  final REAL real03_2 = ValueFactory.getInstance().REALvalueOfLiteral(".3");
  final REAL real03_3 = ValueFactory.getInstance().REALvalueOfLiteral(".30");
  final REAL real03_4 = ValueFactory.getInstance().REALvalueOfLiteral("0.33");
  final REAL real03_5 = ValueFactory.getInstance().REALvalueOfLiteral("0.303");

  final REAL real03_6 = ValueFactory.getInstance().REALvalueOf(0.3);
  final REAL real03_7 = ValueFactory.getInstance().REALvalueOf(.3);
  final REAL real03_8 = ValueFactory.getInstance().REALvalueOf(.30);
  final REAL real03_9 = ValueFactory.getInstance().REALvalueOf(0.33);
  final REAL real03_10 = ValueFactory.getInstance().REALvalueOf(0.303);

  final REAL real0254_1 = ValueFactory.getInstance().REALvalueOf(0.254);
  final REAL real0254_2 = ValueFactory.getInstance().REALvalueOf(.254);
  final REAL real0254_3 = ValueFactory.getInstance().REALvalueOf(00.254);
  final REAL real0254_4 = ValueFactory.getInstance().REALvalueOf(254e-3);
  final REAL real0254_5 = ValueFactory.getInstance().REALvalueOf(2540e-4);

  final REAL real0254_6 = ValueFactory.getInstance().REALvalueOfLiteral("0.254");
  final REAL real0254_7 = ValueFactory.getInstance().REALvalueOfLiteral(".254");
  final REAL real0254_8 = ValueFactory.getInstance().REALvalueOfLiteral("00.254");
  final REAL real0254_9 = ValueFactory.getInstance().REALvalueOfLiteral("254e-3");
  final REAL real0254_10 = ValueFactory.getInstance().REALvalueOfLiteral("2540e-4");

  final REAL real00254_e = ValueFactory.getInstance().REALvalueOfLiteral("254e-4");
  final REAL real00254_1 = ValueFactory.getInstance().REALvalueOfLiteral("254.e-4");
  final REAL real00254_2 = ValueFactory.getInstance().REALvalueOfLiteral("2.54e-2");

  final REAL realAvog = ValueFactory.getInstance().REALvalueOfLiteral("6.1234e24");

  final PQ umol_L_6 = ValueFactory.getInstance().PQvalueOf("2", "umol/L");
  final PQ umol_L_0_0 = ValueFactory.getInstance().PQvalueOf("1", "umol/L");
  final IVL<PQ> umol_L_0_0_6 =
      ValueFactory.getInstance().IVLvalueOf(umol_L_0_0, umol_L_6, BLimpl.TRUE, BLimpl.TRUE);
  final REAL umol_L_0_0_6_low_value = umol_L_0_0_6.low().value();

  final REAL r_umol_L = ValueFactory.getInstance().PQvalueOf("1", "mmol/L").canonical().value();
  final REAL r_umol_L_6 = ValueFactory.getInstance().REALvalueOfLiteral("2").times(r_umol_L);
  final REAL r_umol_L_0_0 = ValueFactory.getInstance().REALvalueOfLiteral("1").times(r_umol_L);
  final IVL<REAL> r_umol_L_0_0_6 =
      IVLimpl.valueOf(r_umol_L_0_0, r_umol_L_6, BLimpl.TRUE, BLimpl.TRUE);
  final REAL r_umol_L_0_0_6_low_value = r_umol_L_0_0_6.low();
  final REAL r_umol_b =
      ValueFactory.getInstance().REALvalueOfLiteral("602213670.e15"); // ("1.20442734E24");
  final REAL r_umol_a =
      ValueFactory.getInstance().REALvalueOfLiteral("60221367.E16"); // ("6.0221367E23");

  public void test_prec_minus() {
    assertEquals(2, real1_2.minus(real1_3).precision().intValue());
  }

  public void test_prec_minus2() {
    assertEquals(2, real1_3.minus(real1_2).precision().intValue());
  }

  public void test_prec_plus() {
    assertEquals(2, real1_2.plus(real1_3).precision().intValue());
  }

  public void test_prec_plus2() {
    assertEquals(2, real1_3.plus(real1_2).precision().intValue());
  }

  public void test_prec_plus3() {
    assertEquals(3, real0_3.plus(real0_2).precision().intValue());
  }

  public void test_prec_times() {
    assertEquals(2, real1_2.times(real1_3).precision().intValue());
  }

  public void test_prec_times2() {
    assertEquals(2, real1_3.times(real1_2).precision().intValue());
  }

  public void test_prec_times3() {
    assertEquals(2, real1_2.times(real1_1).precision().intValue());
  }

  public void test_prec_times4() {
    assertEquals(2, real1_2.times(REALdoubleAdapter.HALF).precision().intValue());
  }

  public void test_prec1() {
    // System.err.println("0.04 " + REALdoubleAdapter.valueOf(0.04,INTlongAdapter.TWO) + " " +
    // REALdoubleAdapter.valueOf("0.04").precision());
    // System.err.println(REALdoubleAdapter.formatDouble(1.04, INTlongAdapter.valueOf(3)));
    // System.err.println(REALdoubleAdapter.formatDouble(0.04, INTlongAdapter.valueOf(1)));
    // System.err.println(REALdoubleAdapter.formatDouble(0.04, INTlongAdapter.valueOf(3)));
    // System.err.println(REALdoubleAdapter.formatDouble(0.04, INTlongAdapter.valueOf(2)));
    // System.err.println(REALdoubleAdapter.formatDouble(0.04,
    // REALdoubleAdapter.INFINITE_PRECISION));
    // System.err.println(REALdoubleAdapter.formatDouble(0.04, REALdoubleAdapter.DOUBLE_PRECISION));
    assertEquals("0.04", REALdoubleAdapter.valueOf(0.04, INTlongAdapter.ONE).toString());
  }

  public void test_Avog1() {
    // System.err.println("XXXXXX: " +  umol_L_0_0_6);
    // System.err.println("XXXXXW: " +  umol_L_0_0_6.width());
    // System.err.println("XXXXXLVD: " +  umol_L_0_0_6_low_value.doubleValue());
    // System.err.println("XXXXXH: " +  umol_L_0_0_6.high());
    // System.err.println("XXXXXLVP: " +  umol_L_0_0_6_low_value.precision());
    assertEquals("61234.e20", realAvog.toString());
  }

  public void test_Avog2() {
    // System.err.println("RXXXXX: " +  umol_L_0_0_6);
    // System.err.println("NNNNNNNP: " +
    // r_umol_a.minus(r_umol_b.times(REALdoubleAdapter.HALF)).precision());
    // System.err.println("RXXXXLVD: " +  r_umol_L_0_0_6_low_value.doubleValue());
    // System.err.println("RXXXXLVP: " +  r_umol_L_0_0_6_low_value.precision());
    // System.err.println("R2XXXLVP: " +  r_umol_L.precision());
    // System.err.println("R3XXXLVP: " +  r_umol_L_6.precision());
    // System.err.println("R4XXXLVP: " +  r_umol_L_0_0.precision());
    // System.err.println("R5XXXLVP: " +  r_umol_L_0_0.minus(r_umol_L_6).precision());
    // System.err.println("R51XXLVP: " +
    // r_umol_L_0_0.minus(r_umol_L_6).times(REALdoubleAdapter.HALF).precision());
    // System.err.println("R6XXXLVP: " +  r_umol_L_0_0.plus(r_umol_L_6).precision());
    assertEquals("61234.e20", realAvog.toString());
  }

  public void test_Literals1() {
    assertEquals("0", real0_1.toString());
  }

  public void test_Literals2() {
    assertEquals("0.", real0_11.toString());
  }

  public void test_Literals3() {
    assertEquals("0.0", real0_2.toString());
  }

  public void test_Literals4() {
    assertEquals("0.00", real0_3.toString());
  }

  public void test_Literals5() {
    assertEquals("0.00", real0_4.toString());
  }

  public void test_Literals6() {
    assertEquals("250", real250_1.toString());
  }

  public void test_Literals7() {
    assertEquals("250.0", real250_2.toString());
  }

  public void test_Literals8() {
    assertEquals("250.0", real250_3.toString());
  }

  public void test_Literals9() {
    assertEquals("250.00", real250_4.toString());
  }

  public void test_LiteralsA() {
    assertEquals("250.", real250_9.toString());
  }

  public void test_LiteralsB() {
    assertEquals("1", real1_1.toString());
  }

  public void test_LiteralsC() {
    assertEquals("1.0", real1_2.toString());
  }

  public void test_LiteralsD() {
    assertEquals("1.00", real1_3.toString());
  }

  public void test_LiteralsE() {
    assertEquals("0.3", real03_1.toString());
  }

  public void test_LiteralsF() {
    assertEquals("0.3", real03_2.toString());
  }

  public void test_LiteralsG() {
    assertEquals("0.30", real03_3.toString());
  }

  public void test_LiteralsH() {
    assertEquals("0.33", real03_4.toString());
  }

  public void test_LiteralsI() {
    assertEquals("0.303", real03_5.toString());
  }

  public void test_LiteralsJ() {
    assertEquals("0.254", real0254_6.toString());
  }

  public void test_LiteralsK() {
    assertEquals("0.254", real0254_7.toString());
  }

  public void test_LiteralsL() {
    assertEquals("0.254", real0254_8.toString());
  }

  public void test_LiteralsM() {
    assertEquals("254e-3", real0254_9.toString());
  }

  public void test_LiteralsN() {
    assertEquals("254e-3", real0254_10.toString());
  }

  public void test_LiteralsO() {
    assertEquals("254e-4", real00254_e.toString());
  }

  public void test_LiteralsP() {
    assertEquals(real00254_1.doubleValue(), 0.0254);
  }

  public void test_LiteralsQ() {
    assertEqual(real00254_2, real00254_1);
  }

  public void test_LiteralsR() {
    assertEqual(real00254_1, real00254_2);
  }

  public void test_LiteralsS() {
    assertEquals("0.0254", real00254_1.toString());
  }

  public void test_LiteralsR1() {
    String s = "12345.000";
    assertEquals(s, ValueFactory.getInstance().REALvalueOfLiteral(s).toString());
  }

  public void test_LiteralsR2() {
    String s = "12345000.e1";
    assertEquals(s, ValueFactory.getInstance().REALvalueOfLiteral(s).toString());
  }

  public void test_LiteralsR3() {
    assertEquals("123.e4", ValueFactory.getInstance().REALvalueOf(12345.e2, 3).toString());
  }

  public void test_LiteralsR4() {
    String s = "123.45000";
    assertEquals(s, ValueFactory.getInstance().REALvalueOfLiteral(s).toString());
  }

  public void test_LiteralsR5() {
    assertEquals("123.", ValueFactory.getInstance().REALvalueOf(12345.e-2, 3).toString());
  }

  public void test_LiteralsR6() {
    assertEquals("0.00012345000", ValueFactory.getInstance().REALvalueOf(12345.e-8, 8).toString());
  }

  public void test_LiteralsR7() {
    assertEquals("0.00012345", ValueFactory.getInstance().REALvalueOf(12345.e-8, 5).toString());
  }

  public void test_LiteralsR8() {
    assertEquals("0.0001235", ValueFactory.getInstance().REALvalueOf(1.2345e-4, 4).toString());
  }

  private void assertEqual(ANY a, ANY b) {
    assertTrue("" + a + ".equal(" + b + ")", a.equal(b).isTrue());
  }

  public void test_doubles() {
    assertEquals("0", real0_5.toString());

    assertEquals("250", real250_5.toString());
    assertEquals("250.000000000000", real250_6.toString());
    assertEquals("250.000000000000", real250_7.toString());
    assertEquals("250.000000000000", real250_8.toString());
    assertEquals("250", real250_5.toString());

    assertEquals("0.300000000000000", real03_6.toString());
    assertEquals("0.300000000000000", real03_7.toString());
    assertEquals("0.300000000000000", real03_8.toString());
    assertEquals("0.330000000000000", real03_9.toString());
    assertEquals("0.303000000000000", real03_10.toString());

    assertEquals("0.254000000000000", real0254_1.toString());
    assertEquals("0.254000000000000", real0254_2.toString());
    assertEquals("0.254000000000000", real0254_3.toString());
    assertEquals("0.254000000000000", real0254_4.toString());
    assertEquals("0.254000000000000", real0254_5.toString());
  }

  public void test_p1() {
    assertEquals(4, REALdoubleAdapter.valueOf("2000.").precision().intValue());
  }

  public void test_p2() {
    assertEquals(1, REALdoubleAdapter.valueOf("2.e3").precision().intValue());
  }

  public void test_p3() {
    assertEquals(1, REALdoubleAdapter.valueOf("0.001").precision().intValue());
  }

  public void test_p4() {
    assertEquals(1, REALdoubleAdapter.valueOf("1.e-3").precision().intValue());
  }

  public void test_p5() {
    assertEquals(1, REALdoubleAdapter.valueOf("0.").precision().intValue());
  }

  public void test_p6() {
    assertEquals(2, REALdoubleAdapter.valueOf("0.0").precision().intValue());
  }

  public void test_p7() {
    assertEquals(2, REALdoubleAdapter.valueOf("000.0").precision().intValue());
  }

  public void test_p8() {
    assertEquals(3, REALdoubleAdapter.valueOf("0.00").precision().intValue());
  }

  public void test_p9() {
    assertEquals(3, REALdoubleAdapter.valueOf("4.10").precision().intValue());
  }

  public void test_p10() {
    assertEquals(3, REALdoubleAdapter.valueOf("4.09").precision().intValue());
  }

  public void test_p11() {
    assertEquals(2, REALdoubleAdapter.valueOf("4.1").precision().intValue());
  }

  public void test_p12() {
    assertEquals(1, REALdoubleAdapter.valueOf("0.04").precision().intValue());
  }

  //	public void test_precprop1() { assertEquals(R("25.e2"), R("1234").times(R("2.0"))); }
  public void test_precprop1s() {
    assertEquals(R("25.e2").toString(), R("1234").times(R("2.0")).toString());
  }
  // public void test_precprop1_1() { assertEquals(R("24.e2"), R("1222").times(R("2.0"))); }
  public void test_precprop1_1s() {
    assertEquals(R("24.e2").toString(), R("1222").times(R("2.0")).toString());
  }

  public void test_precprop2() {
    assertEquals(R("1500."), R("2000.").minus(R("500.")));
  }

  public void test_precprop2s() {
    assertEquals(R("1500.").toString(), R("2000.").minus(R("500.")).toString());
  }

  public void test_precprop3() {
    assertEquals(R("1500."), R("2000.000").minus(R("500.")));
  }

  public void test_precprop3s() {
    assertEquals(R("1500.").toString(), R("2000.000").minus(R("500.")).toString());
  }

  public void test_precprop4() {
    assertEquals(R("1500."), R("2000.").minus(R("500.000")));
  }

  public void test_precprop4s() {
    assertEquals(R("1500.").toString(), R("2000.").minus(R("500.000")).toString());
  }

  public void test_precprop5() {
    assertEquals(R("1500.00").toString(), R("2000.00").minus(R("500.000")).toString());
  }

  public void test_precprop5s() {
    assertEquals(R("1500.00"), R("2000.00").minus(R("500.000")));
  }

  public void test_precprop6() {
    assertEquals(R("0.04"), R("1000.39").minus(R("1000.35")));
  }

  public void test_precprop6s() {
    assertEquals(R("0.04").toString(), R("1000.39").minus(R("1000.35")).toString());
  }
}