public ElementVerification verifyMessage(Profile p, Profile baseP, String id, String type) {
    ElementVerification evm = new ElementVerification(id, type);
    Message m = p.getMessages().findOne(id);

    for (SegmentRefOrGroup srog : m.getChildren()) {
      evm.addChildrenVerification(verifySegmentOrGroup(p, baseP, srog.getId(), srog.getType()));
    }
    return evm;
  }
  public InputStream verifyUsage2(
      Profile p, Profile baseP, String id, String type, String eltName, String eltValue) {
    // Type can be Field, Component, Code
    // EltName is Usage
    String hl7Version = p.getMetaData().getHl7Version();
    Usage referenceUsage = Usage.R;
    Usage currentUsage = Usage.R;

    switch (type) {
      case "segmentreforgroup":
        SegmentRefOrGroup srog = p.getMessages().findOneSegmentRefOrGroup(id);
        currentUsage = srog.getUsage();
        SegmentRefOrGroup basesrog = baseP.getMessages().findOneSegmentRefOrGroup(id);
        referenceUsage = basesrog.getUsage();
        break;
      case "field":
        // Field f = p.getSegmentLibrary().findOneField(id);
        // currentUsage = f.getUsage();
        // Field basef = baseP.getSegmentLibrary().findOneField(id);
        // referenceUsage = basef.getUsage();
        break;
      case "component":
        // Component c = p.getDatatypeLibrary().findOneComponent(id);
        // currentUsage = c.getUsage();
        // Component basec = baseP.getDatatypeLibrary().findOneComponent(id);
        // referenceUsage = basec.getUsage();
        break;
      case "code":
        // Code cd = p.getTableLibrary().findOneCodeById(id);
        // currentUsage = Usage.fromValue(cd.getCodeUsage());
        // Code basecd = baseP.getTableLibrary().findOneCodeById(id);
        // referenceUsage = Usage.fromValue(basecd.getCodeUsage());
        break;
    }

    String result = this.validateChangeUsage(hl7Version, referenceUsage, currentUsage);
    return this.generateOneJsonResult(id, type, eltName, eltValue, result);
  }
  private ElementVerification verifySegmentRef(SegmentRefOrGroup srog) {
    String result = "";
    ElementVerification evsrog = new ElementVerification(srog.getId(), srog.getType());
    ElementVerificationResult evsrogRst =
        new ElementVerificationResult("usage", srog.getUsage().value(), result);
    evsrog.addElementVerifications(evsrogRst);

    result =
        this.validateChangeCardinality(
            String.valueOf(srog.getMin()), srog.getMax(), srog.getUsage());
    evsrogRst = new ElementVerificationResult("min", String.valueOf(srog.getMin()), result);
    evsrog.addElementVerifications(evsrogRst);

    result =
        this.validateChangeCardinality(
            String.valueOf(srog.getMin()), srog.getMax(), srog.getUsage());
    evsrogRst = new ElementVerificationResult("max", String.valueOf(srog.getMax()), result);
    evsrog.addElementVerifications(evsrogRst);

    return evsrog;
  }