From 86b9db4aec22b5b1a85511b93672abf92b9d60b1 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 24 Aug 2020 17:13:56 +1000 Subject: [PATCH] update PHINVads importer for URL and version issues --- .../convertors/misc/PhinVadsImporter.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/PhinVadsImporter.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/PhinVadsImporter.java index 03b63fb99..016332dcd 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/PhinVadsImporter.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/PhinVadsImporter.java @@ -52,7 +52,9 @@ public class PhinVadsImporter { try { System.out.println("Process "+f.getName()); ValueSet vs = importValueSet(TextFile.fileToBytes(f)); - new JsonParser().compose(new FileOutputStream(Utilities.path(dest, "ValueSet-"+vs.getId()+".json")), vs); + if (vs.getId() != null) { + new JsonParser().compose(new FileOutputStream(Utilities.path(dest, "ValueSet-"+vs.getId()+".json")), vs); + } } catch (Exception e) { e.printStackTrace(); } @@ -74,7 +76,7 @@ public class PhinVadsImporter { ValueSet vs = new ValueSet(); vs.setId(rdr.cell("Value Set OID")); - vs.setUrl("https://phinvads.cdc.gov/fhir/ValueSet/"+vs.getId()); + vs.setUrl("http://phinvads.cdc.gov/fhir/ValueSet/"+vs.getId()); vs.getMeta().setSource("https://phinvads.cdc.gov/vads/ViewValueSet.action?oid="+vs.getId()); vs.setVersion(rdr.cell("Value Set Version")); vs.setTitle(rdr.cell("Value Set Name")); @@ -100,12 +102,31 @@ public class PhinVadsImporter { if (url == null) { url = "urn:oid:"+csoid; } + csver = fixVersionforSystem(url, csver); ConceptSetComponent inc = getInclude(vs, url, csver); inc.addConcept().setCode(code).setDisplay(display); } return vs; } + private String fixVersionforSystem(String url, String csver) { + if ("http://snomed.info/sct".equals(url)) { + return "http://snomed.info/sct|http://snomed.info/sct/731000124108/"+csver; + } + if ("http://loinc.org".equals(url)) { + return csver; + } + if ("http://www.nlm.nih.gov/research/umls/rxnorm".equals(url)) { + if (csver.length() == 8) { + return csver.substring(4,6)+csver.substring(6,8)+csver.substring(0,4); + } else { + return csver; + } + + } + return csver; + } + private ConceptSetComponent getInclude(ValueSet vs, String url, String csver) { for (ConceptSetComponent t : vs.getCompose().getInclude()) { if (csver == null) {