From 6cf6367b30f48aaca129a0b2b47b5259b9426703 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Tue, 1 Sep 2020 17:45:33 -0400 Subject: [PATCH] i am unable to write readable code (#332) --- .../fhir/convertors/misc/VSACImporter.java | 43 +++++++------------ .../cli/model/ValidationOutcome.java | 2 +- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/VSACImporter.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/VSACImporter.java index 42f27af19..2e03d4430 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/VSACImporter.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/VSACImporter.java @@ -1,33 +1,20 @@ package org.hl7.fhir.convertors.misc; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; - import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r5.context.IWorkerContext; -import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; -import org.hl7.fhir.utilities.CSVReader; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; -import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager; -import org.hl7.fhir.utilities.cache.NpmPackage; -import org.hl7.fhir.utilities.cache.ToolsVersion; import org.hl7.fhir.utilities.xml.XMLUtil; import org.w3c.dom.Element; +import java.io.*; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; + public class VSACImporter extends OIDBasedValueSetImporter { public static void main(String[] args) throws FileNotFoundException, FHIRException, IOException, ParseException { @@ -44,19 +31,19 @@ public class VSACImporter extends OIDBasedValueSetImporter { private void process(String source, String dest) { for (File f : new File(source).listFiles()) { try { - System.out.println("Process "+f.getName()); + System.out.println("Process " + f.getName()); List vsl = importValueSet(TextFile.fileToBytes(f)); for (ValueSet vs : vsl) { if (vs.getId() != null) { - new JsonParser().compose(new FileOutputStream(Utilities.path(dest, "ValueSet-"+vs.getId()+".json")), vs); + new JsonParser().compose(new FileOutputStream(Utilities.path(dest, "ValueSet-" + vs.getId() + ".json")), vs); } } } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); } - } + } } - + private List importValueSet(byte[] source) throws Exception { List res = new ArrayList(); Element x = loadXml(new ByteArrayInputStream(source)).getDocumentElement(); @@ -64,8 +51,8 @@ public class VSACImporter extends OIDBasedValueSetImporter { for (Element v : vl) { ValueSet vs = new ValueSet(); vs.setId(v.getAttribute("ID")); - vs.setUrl("http://vsac.nlm.nih.gov/fhir/ValueSet/"+vs.getId()); - vs.getMeta().setSource("https://vsac.nlm.nih.gov/valueset/"+vs.getId()+"/expansion"); + vs.setUrl("http://vsac.nlm.nih.gov/fhir/ValueSet/" + vs.getId()); + vs.getMeta().setSource("https://vsac.nlm.nih.gov/valueset/" + vs.getId() + "/expansion"); vs.setVersion(v.getAttribute("version")); vs.setTitle(v.getAttribute("displayName")); vs.setName(Utilities.titleize(vs.getTitle()).replace(" ", "")); @@ -74,9 +61,9 @@ public class VSACImporter extends OIDBasedValueSetImporter { vs.setDescription(d.getTextContent()); } Element s = XMLUtil.getNamedChild(v, "Status"); - if (s != null && "Active".equals(s.getTextContent())) { + if (s != null && "Active".equals(s.getTextContent())) { vs.setStatus(PublicationStatus.ACTIVE); - } else { + } else { vs.setStatus(PublicationStatus.DRAFT); } Element dt = XMLUtil.getNamedChild(v, "RevisionDate"); @@ -94,7 +81,7 @@ public class VSACImporter extends OIDBasedValueSetImporter { String csver = cc.getAttribute("codeSystemVersion"); String url = context.oid2Uri(csoid); if (url == null) { - url = "urn:oid:"+csoid; + url = "urn:oid:" + csoid; } csver = fixVersionforSystem(url, csver); ConceptSetComponent inc = getInclude(vs, url, csver); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationOutcome.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationOutcome.java index cc9cce989..406b33f2a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationOutcome.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/ValidationOutcome.java @@ -38,7 +38,7 @@ public class ValidationOutcome { } @JsonProperty("issues") - public ValidationOutcome setIssues(List issues) { + public ValidationOutcome setMessages(List issues) { this.messages = issues; return this; }