コード例 #1
0
ファイル: JsonLDParser.java プロジェクト: hl7-fhir/fhir-svn
 private void primitiveValue(Element item) throws IOException {
   String type = item.getType();
   if (Utilities.existsInList(type, "date", "dateTime", "instant")) {
     String v = item.getValue();
     if (v.length() > 10) {
       int i = v.substring(10).indexOf("-");
       if (i == -1) i = v.substring(10).indexOf("+");
       v = i == -1 ? v : v.substring(0, 10 + i);
     }
     if (v.length() > 10) json.name("dateTime");
     else if (v.length() == 10) json.name("date");
     else if (v.length() == 7) json.name("gYearMonth");
     else if (v.length() == 4) json.name("gYear");
     json.value(item.getValue());
   } else if (Utilities.existsInList(type, "boolean")) {
     json.name("boolean");
     json.value(item.getValue().equals("true") ? new Boolean(true) : new Boolean(false));
   } else if (Utilities.existsInList(type, "integer", "unsignedInt", "positiveInt")) {
     json.name("integer");
     json.value(new Integer(item.getValue()));
   } else if (Utilities.existsInList(type, "decimal")) {
     json.name("decimal");
     json.value(item.getValue());
   } else if (Utilities.existsInList(type, "base64Binary")) {
     json.name("binary");
     json.value(item.getValue());
   } else {
     json.name("value");
     json.value(item.getValue());
   }
 }
コード例 #2
0
 public String getEnhancedDefinition() {
   if (isModifier() && getMustSupport())
     return Utilities.removePeriod(getDefinition())
         + " (this element modifies the meaning of other elements, and must be supported)";
   else if (isModifier())
     return Utilities.removePeriod(getDefinition())
         + " (this element modifies the meaning of other elements)";
   else if (getMustSupport())
     return Utilities.removePeriod(getDefinition()) + " (this element must be supported)";
   else return Utilities.removePeriod(getDefinition());
 }
コード例 #3
0
  public String summary(FetchedResource r, boolean xml, boolean json, boolean ttl)
      throws Exception {
    //    return "[--Summary goes here--]";
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"grid\">\r\n");
    b.append(
        " <tbody><tr><td>Defining URL:</td><td>"
            + Utilities.escapeXml(map.getUrl())
            + "</td></tr>\r\n");
    b.append(" <tr><td>Name:</td><td>" + Utilities.escapeXml(map.getName()) + "</td></tr>\r\n");
    if (map.hasDescription())
      b.append(
          " <tr><td>Definition:</td><td>"
              + processMarkdown("description", map.getDescription())
              + "</td></tr>\r\n");
    if (map.hasPublisher())
      b.append(
          " <tr><td>Publisher:</td><td>"
              + Utilities.escapeXml(map.getPublisher())
              + "</td></tr>\r\n");
    if (map.hasCopyright())
      b.append(
          " <tr><td>Copyright:</td><td>"
              + Utilities.escapeXml(map.getCopyright())
              + "</td></tr>\r\n");
    if (xml || json || ttl) {
      b.append(" <tr><td>Source Resource</td><td>");
      boolean first = true;
      String filename = igp.getProperty(r, "format");
      if (filename == null) filename = "ValueSet-" + r.getId() + ".{{[fmt]}}.html";
      if (xml) {
        first = false;
        b.append("<a href=\"" + igp.doReplacements(filename, r, null, "xml") + "\">XML</a>");
      }
      if (json) {
        if (first) first = false;
        else b.append(" / ");
        b.append("<a href=\"" + igp.doReplacements(filename, r, null, "json") + "\">JSON</a>");
      }
      if (ttl) {
        if (first) first = false;
        else b.append(" / ");
        b.append("<a href=\"" + igp.doReplacements(filename, r, null, "ttl") + "\">Turtle</a>");
      }
      b.append("</td></tr>\r\n");
    }
    b.append("</tbody></table>\r\n");

    return b.toString();
  }
 private String ref(BindingSpecification cd) {
   if (!cd.hasReference()) return Utilities.escapeXml(cd.getDescription());
   else if (cd.getValueSet() != null)
     return "<a href=\""
         + cd.getReference()
         + ".html\">"
         + Utilities.escapeXml(cd.getValueSet().getName())
         + "</a>";
   else
     return "<a href=\""
         + cd.getReference()
         + "\">"
         + Utilities.escapeXml(cd.getDescription())
         + "</a>";
 }
コード例 #5
0
  public void checkConditions(List<String> errors, Map<String, Long> dates) throws Exception {
    Utilities.checkFolder(srcDir, errors);
    Utilities.checkFolder(termDir, errors);
    Utilities.checkFolder(imgDir, errors);
    this.dates = dates;
    checkFile("required", termDir, "bindings.xml", errors, "all");
    checkFile("required", dtDir, "primitives.xml", errors, "all");

    for (String n : ini.getPropertyNames("types"))
      if (ini.getStringProperty("types", n).equals("")) {
        TypeRef t = new TypeParser().parse(n).get(0);
        checkFile("type definition", dtDir, t.getName().toLowerCase() + ".xml", errors, "all");
      }
    for (String n : ini.getPropertyNames("structures"))
      checkFile("structure definition", dtDir, n.toLowerCase() + ".xml", errors, "all");

    String[] shared = ini.getPropertyNames("shared");

    if (shared != null)
      for (String n : shared)
        checkFile("shared structure definition", dtDir, n.toLowerCase() + ".xml", errors, "all");

    for (String n : ini.getPropertyNames("infrastructure"))
      checkFile("infrastructure definition", dtDir, n.toLowerCase() + ".xml", errors, "all");

    for (String n : ini.getPropertyNames("resources")) {
      if (!new File(srcDir + n).exists()) errors.add("unable to find folder for resource " + n);
      else {
        if (new CSFile(srcDir + n + File.separatorChar + n + "-spreadsheet.xml").exists()) {
          checkFile(
              "definition", srcDir + n + File.separatorChar, n + "-spreadsheet.xml", errors, n);
        } else checkFile("definition", srcDir + n + File.separatorChar, n + "-def.xml", errors, n);
        checkFile("example xml", srcDir + n + File.separatorChar, n + "-example.xml", errors, n);
        // now iterate all the files in the directory checking data

        for (String fn : new File(srcDir + n + File.separatorChar).list())
          checkFile("source", srcDir + n + File.separatorChar, fn, errors, n);
      }
    }
    for (String n : ini.getPropertyNames("special-resources")) {
      if (new CSFile(srcDir + n + File.separatorChar + n + "-spreadsheet.xml").exists())
        checkFile("definition", srcDir + n + File.separatorChar, n + "-spreadsheet.xml", errors, n);
      else checkFile("definition", srcDir + n + File.separatorChar, n + "-def.xml", errors, n);
      // now iterate all the files in the directory checking data
      for (String fn : new File(srcDir + n + File.separatorChar).list())
        checkFile("source", srcDir + n + File.separatorChar, fn, errors, n);
    }
  }
コード例 #6
0
  private static String compareElements(String path, Element e1, Element e2) {
    if (!e1.getNamespaceURI().equals(e2.getNamespaceURI()))
      return "Namespaces differ at "
          + path
          + ": "
          + e1.getNamespaceURI()
          + "/"
          + e2.getNamespaceURI();
    if (!e1.getLocalName().equals(e2.getLocalName()))
      return "Names differ at " + path + ": " + e1.getLocalName() + "/" + e2.getLocalName();
    path = path + "/" + e1.getLocalName();
    String s = compareAttributes(path, e1.getAttributes(), e2.getAttributes());
    if (!Utilities.noString(s)) return s;
    s = compareAttributes(path, e2.getAttributes(), e1.getAttributes());
    if (!Utilities.noString(s)) return s;

    Node c1 = e1.getFirstChild();
    Node c2 = e2.getFirstChild();
    c1 = skipBlankText(c1);
    c2 = skipBlankText(c2);
    while (c1 != null && c2 != null) {
      if (c1.getNodeType() != c2.getNodeType())
        return "node type mismatch in children of "
            + path
            + ": "
            + Integer.toString(e1.getNodeType())
            + "/"
            + Integer.toString(e2.getNodeType());
      if (c1.getNodeType() == Node.TEXT_NODE) {
        if (!normalise(c1.getTextContent()).equals(normalise(c2.getTextContent())))
          return "Text differs at "
              + path
              + ": "
              + normalise(c1.getTextContent())
              + "/"
              + normalise(c2.getTextContent());
      } else if (c1.getNodeType() == Node.ELEMENT_NODE) {
        s = compareElements(path, (Element) c1, (Element) c2);
        if (!Utilities.noString(s)) return s;
      }

      c1 = skipBlankText(c1.getNextSibling());
      c2 = skipBlankText(c2.getNextSibling());
    }
    if (c1 != null) return "node mismatch - more nodes in source in children of " + path;
    if (c2 != null) return "node mismatch - more nodes in target in children of " + path;
    return null;
  }
コード例 #7
0
ファイル: ExpressionNode.java プロジェクト: joelsch/hapi-fhir
 public static Operation fromCode(String name) {
   if (Utilities.noString(name)) return null;
   if (name.equals("=")) return Operation.Equals;
   if (name.equals("~")) return Operation.Equivalent;
   if (name.equals("!=")) return Operation.NotEquals;
   if (name.equals("!~")) return Operation.NotEquivalent;
   if (name.equals(">")) return Operation.Greater;
   if (name.equals("<")) return Operation.LessThen;
   if (name.equals(">=")) return Operation.GreaterOrEqual;
   if (name.equals("<=")) return Operation.LessOrEqual;
   if (name.equals("|")) return Operation.Union;
   if (name.equals("or")) return Operation.Or;
   if (name.equals("and")) return Operation.And;
   if (name.equals("xor")) return Operation.Xor;
   if (name.equals("is")) return Operation.Is;
   if (name.equals("as")) return Operation.As;
   if (name.equals("*")) return Operation.Times;
   if (name.equals("/")) return Operation.DivideBy;
   if (name.equals("+")) return Operation.Plus;
   if (name.equals("-")) return Operation.Minus;
   if (name.equals("&")) return Operation.Concatenate;
   if (name.equals("implies")) return Operation.Implies;
   if (name.equals("div")) return Operation.Div;
   if (name.equals("mod")) return Operation.Mod;
   if (name.equals("in")) return Operation.In;
   if (name.equals("contains")) return Operation.Contains;
   return null;
 }
コード例 #8
0
ファイル: JsonLDParser.java プロジェクト: hl7-fhir/fhir-svn
 @Override
 public void compose(Element e, OutputStream stream, OutputStyle style, String base)
     throws Exception {
   this.base = base;
   OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
   if (style == OutputStyle.CANONICAL) json = new JsonCreatorCanonical(osw);
   else json = new JsonCreatorGson(osw);
   json.setIndent(style == OutputStyle.PRETTY ? "  " : "");
   json.beginObject();
   prop("@type", "fhir:" + e.getType());
   prop("@context", jsonLDBase + "fhir.jsonld");
   prop("role", "fhir:treeRoot");
   String id = e.getChildValue("id");
   if (base != null && id != null) {
     if (base.endsWith("#")) prop("@id", base + e.getType() + "-" + id + ">");
     else prop("@id", Utilities.pathReverse(base, e.getType(), id));
   }
   Set<String> done = new HashSet<String>();
   for (Element child : e.getChildren()) {
     compose(e.getName(), e, done, child);
   }
   json.endObject();
   json.finish();
   osw.flush();
 }
コード例 #9
0
  public void compose(IXMLWriter writer, AtomFeed feed, boolean htmlPretty) throws Exception {
    this.htmlPretty = htmlPretty;
    xml = writer;
    xml.setDefaultNamespace(ATOM_NS);

    xml.open(ATOM_NS, "feed");
    if (feed.getTitle() != null) xml.element(ATOM_NS, "title", feed.getTitle());
    if (feed.getId() != null) xml.element(ATOM_NS, "id", feed.getId());
    for (String n : feed.getLinks().keySet()) {
      xml.attribute("href", feed.getLinks().get(n));
      xml.attribute("rel", n);
      xml.element(ATOM_NS, "link", null);
    }
    if (feed.getTotalResults() != null) {
      xml.setDefaultNamespace("http://purl.org/atompub/tombstones/1.0");
      xml.element("totalResults", feed.getTotalResults().toString());
      xml.setDefaultNamespace(ATOM_NS);
    }
    if (feed.getUpdated() != null) xml.element(ATOM_NS, "updated", feed.getUpdated().toString());
    if (feed.getAuthorName() != null || feed.getAuthorUri() != null) {
      xml.open(ATOM_NS, "author");
      if (feed.getAuthorName() != null) xml.element(ATOM_NS, "name", feed.getAuthorName());
      if (feed.getAuthorUri() != null) xml.element(ATOM_NS, "uri", feed.getAuthorUri());
      xml.close(ATOM_NS, "author");
    }
    for (AtomCategory cat : feed.getTags()) {
      xml.attribute("scheme", cat.getScheme());
      xml.attribute("term", cat.getTerm());
      if (!Utilities.noString(cat.getLabel())) xml.attribute("label", cat.getLabel());
      xml.element("category", null);
    }

    for (AtomEntry<? extends Resource> e : feed.getEntryList()) composeEntry(e);
    xml.close(ATOM_NS, "feed");
  }
コード例 #10
0
  private String checkExists(List<Boolean> indents, boolean hasChildren) throws IOException {
    String filename = makeName(indents);

    StringBuilder b = new StringBuilder();
    if (inLineGraphics) {
      if (files.containsKey(filename)) return files.get(filename);
      ByteArrayOutputStream bytes = new ByteArrayOutputStream();
      genImage(indents, hasChildren, bytes);
      b.append("data: image/png;base64,");
      byte[] encodeBase64 = Base64.encodeBase64(bytes.toByteArray());
      b.append(new String(encodeBase64));
      files.put(filename, b.toString());
      return b.toString();
    } else {
      b.append("tbl_bck");
      for (Boolean i : indents) b.append(i ? "0" : "1");
      if (hasChildren) b.append("1");
      else b.append("0");
      b.append(".png");
      String file = Utilities.path(dest, b.toString());
      if (!new File(file).exists()) {
        FileOutputStream stream = new FileOutputStream(file);
        genImage(indents, hasChildren, stream);
      }
      return b.toString();
    }
  }
コード例 #11
0
ファイル: JsonLDParser.java プロジェクト: hl7-fhir/fhir-svn
  private String getFormalName(Element element) {
    String en = null;
    if (element.getSpecial() == null) {
      if (element.getProperty().getDefinition().hasBase())
        en = element.getProperty().getDefinition().getBase().getPath();
    } else if (element.getSpecial() == SpecialElement.BUNDLE_ENTRY) en = "Bundle.entry.resource";
    else if (element.getSpecial() == SpecialElement.BUNDLE_OUTCOME)
      en = "Bundle.entry.response.outcome";
    else if (element.getSpecial() == SpecialElement.PARAMETER)
      en = element.getElementProperty().getDefinition().getPath();
    else // CONTAINED
    en = "DomainResource.contained";

    if (en == null) en = element.getProperty().getDefinition().getPath();
    boolean doType = false;
    if (en.endsWith("[x]")) {
      en = en.substring(0, en.length() - 3);
      doType = true;
    }
    if (doType
        || (element.getProperty().getDefinition().getType().size() > 1
            && !allReference(element.getProperty().getDefinition().getType())))
      en = en + Utilities.capitalize(element.getType());
    return en;
  }
コード例 #12
0
 private static Node skipBlankText(Node node) {
   while (node != null
       && (((node.getNodeType() == Node.TEXT_NODE)
               && Utilities.isWhitespace(node.getTextContent()))
           || (node.getNodeType() == Node.COMMENT_NODE))) node = node.getNextSibling();
   return node;
 }
コード例 #13
0
ファイル: Attachment.java プロジェクト: HHSIDEAlab/hapi-fhir
 /**
  * @param value The human language of the content. The value can be any valid value according to
  *     BCP 47.
  */
 public Attachment setLanguage(String value) {
   if (Utilities.noString(value)) this.language = null;
   else {
     if (this.language == null) this.language = new CodeType();
     this.language.setValue(value);
   }
   return this;
 }
コード例 #14
0
ファイル: Substance.java プロジェクト: HHSIDEAlab/hapi-fhir
 /**
  * @param value A description of the substance - its appearance, handling requirements, and other
  *     usage notes.
  */
 public Substance setDescription(String value) {
   if (Utilities.noString(value)) this.description = null;
   else {
     if (this.description == null) this.description = new StringType();
     this.description.setValue(value);
   }
   return this;
 }
コード例 #15
0
ファイル: Goal.java プロジェクト: molsches/FHIR-Server
 /** @param value Any comments related to the goal. */
 public Goal setNotes(String value) {
   if (Utilities.noString(value)) this.notes = null;
   else {
     if (this.notes == null) this.notes = new StringType();
     this.notes.setValue(value);
   }
   return this;
 }
コード例 #16
0
 /** @param value The note text. */
 public ProcessResponseNotesComponent setText(String value) {
   if (Utilities.noString(value)) this.text = null;
   else {
     if (this.text == null) this.text = new StringType();
     this.text.setValue(value);
   }
   return this;
 }
コード例 #17
0
ファイル: Quantity.java プロジェクト: aemay2/hapi-fhir
 /** @param value The identification of the system that provides the coded form of the unit. */
 public Quantity setSystem(String value) {
   if (Utilities.noString(value)) this.system = null;
   else {
     if (this.system == null) this.system = new UriType();
     this.system.setValue(value);
   }
   return this;
 }
コード例 #18
0
 /**
  * @param value This will either be a name or a description. E.g. "Aunt Susan", "my cousin with
  *     the red hair".
  */
 public FamilyMemberHistory setName(String value) {
   if (Utilities.noString(value)) this.name = null;
   else {
     if (this.name == null) this.name = new StringType();
     this.name.setValue(value);
   }
   return this;
 }
コード例 #19
0
ファイル: Attachment.java プロジェクト: HHSIDEAlab/hapi-fhir
 /** @param value An alternative location where the data can be accessed. */
 public Attachment setUrl(String value) {
   if (Utilities.noString(value)) this.url = null;
   else {
     if (this.url == null) this.url = new UriType();
     this.url.setValue(value);
   }
   return this;
 }
コード例 #20
0
 /** @param value A description of the status of the adjudication. */
 public EnrollmentResponse setDisposition(String value) {
   if (Utilities.noString(value)) this.disposition = null;
   else {
     if (this.disposition == null) this.disposition = new StringType();
     this.disposition.setValue(value);
   }
   return this;
 }
コード例 #21
0
ファイル: Attachment.java プロジェクト: HHSIDEAlab/hapi-fhir
 /** @param value A label or set of text to display in place of the data. */
 public Attachment setTitle(String value) {
   if (Utilities.noString(value)) this.title = null;
   else {
     if (this.title == null) this.title = new StringType();
     this.title.setValue(value);
   }
   return this;
 }
コード例 #22
0
 /** @param value A reference to supply which authenticates the process. */
 public ProcessRequest setReference(String value) {
   if (Utilities.noString(value)) this.reference = null;
   else {
     if (this.reference == null) this.reference = new StringType();
     this.reference.setValue(value);
   }
   return this;
 }
コード例 #23
0
ファイル: Quantity.java プロジェクト: aemay2/hapi-fhir
 /** @param value A human-readable form of the unit. */
 public Quantity setUnit(String value) {
   if (Utilities.noString(value)) this.unit = null;
   else {
     if (this.unit == null) this.unit = new StringType();
     this.unit.setValue(value);
   }
   return this;
 }
コード例 #24
0
 /**
  * @param value Additional diagnostic information about the issue. Typically, this may be a
  *     description of how a value is erroneous, or a stck dump to help trace the issue.
  */
 public OperationOutcomeIssueComponent setDetails(String value) {
   if (Utilities.noString(value)) this.details = null;
   else {
     if (this.details == null) this.details = new StringType();
     this.details.setValue(value);
   }
   return this;
 }
コード例 #25
0
ファイル: Quantity.java プロジェクト: aemay2/hapi-fhir
 /** @param value A computer processable form of the unit in some unit representation system. */
 public Quantity setCode(String value) {
   if (Utilities.noString(value)) this.code = null;
   else {
     if (this.code == null) this.code = new CodeType();
     this.code.setValue(value);
   }
   return this;
 }
コード例 #26
0
ファイル: CareTeam.java プロジェクト: aemay2/hapi-fhir
 /** @param value Name of the care team. */
 public CareTeam setName(String value) {
   if (Utilities.noString(value)) this.name = null;
   else {
     if (this.name == null) this.name = new StringType();
     this.name.setValue(value);
   }
   return this;
 }
コード例 #27
0
 /** @param value An area where general notes can be placed about this specific condition. */
 public FamilyMemberHistoryConditionComponent setNote(String value) {
   if (Utilities.noString(value)) this.note = null;
   else {
     if (this.note == null) this.note = new StringType();
     this.note.setValue(value);
   }
   return this;
 }
コード例 #28
0
ファイル: Coverage.java プロジェクト: cotsog/fhir-svn
 /**
  * @param value Identifies a style or collective of coverage issues by the underwriter, for
  *     example may be used to identify a class of coverage or employer group. May also be referred
  *     to as a Policy or Group ID.
  */
 public Coverage setGroup(String value) {
   if (Utilities.noString(value)) this.group = null;
   else {
     if (this.group == null) this.group = new StringType();
     this.group.setValue(value);
   }
   return this;
 }
コード例 #29
0
 /** @param value unique id for the element within a resource (for internal references). */
 public Element setId(String value) {
   if (Utilities.noString(value)) this.id = null;
   else {
     if (this.id == null) this.id = new IdType();
     this.id.setValue(value);
   }
   return this;
 }
コード例 #30
0
ファイル: Coverage.java プロジェクト: cotsog/fhir-svn
 /**
  * @param value Identifies a sub-style or sub-collective of coverage issues by the underwriter,
  *     for example may be used to identify a specific employer group within a class of employers.
  *     May be referred to as a Section or Division ID.
  */
 public Coverage setSubPlan(String value) {
   if (Utilities.noString(value)) this.subPlan = null;
   else {
     if (this.subPlan == null) this.subPlan = new StringType();
     this.subPlan.setValue(value);
   }
   return this;
 }