Esempio n. 1
0
  public ElementVerification verifyUsage(
      Profile p, Profile baseP, String id, String type, String eltName, String eltValue) {
    // Type can be SegmentRef, Group, Field, Component, Code
    // EltName is Usage
    String hl7Version = p.getMetaData().getHl7Version();
    Usage referenceUsage = Usage.R;
    Usage currentUsage = Usage.R;

    switch (type) {
      case "segmentRef":
        SegmentRefOrGroup srog = p.getMessages().findOneSegmentRefOrGroup(id);
        currentUsage = srog.getUsage();
        SegmentRefOrGroup basesrog = baseP.getMessages().findOneSegmentRefOrGroup(id);
        referenceUsage = basesrog.getUsage();
        break;
      case "group":
        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);
    ElementVerification ev = new ElementVerification(id, type);
    ElementVerificationResult evRst = new ElementVerificationResult(eltName, eltValue, result);
    ev.addElementVerifications(evRst);

    return ev;
  }
Esempio n. 2
0
  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;
  }