org.hl7.fhir.dstu3.model.ConceptMap Java Examples
The following examples show how to use
org.hl7.fhir.dstu3.model.ConceptMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConceptMapsTest.java From bunsen with Apache License 2.0 | 6 votes |
@Test public void testExpandMappings() { ConceptMap conceptMap = ConceptMaps.getEmpty(spark) .withConceptMaps(conceptMap("urn:cerner:conceptmap:map", "1")) .getConceptMap("urn:cerner:conceptmap:map", "1"); List<Mapping> mappings = ConceptMaps.expandMappings(conceptMap); Mapping expectedValue = new Mapping("urn:cerner:conceptmap:map", "1", "urn:source:valueset", "urn:target:valueset", "urn:source:system", "urn:source:code:a", "urn:target:system", "urn:target:code:1", Mapping.EQUIVALENT); Assert.assertEquals(1, mappings.size()); Assert.assertEquals(expectedValue, mappings.get(0)); }
Example #2
Source File: ConceptMapsTest.java From bunsen with Apache License 2.0 | 6 votes |
@Test public void testWithDisjointMapsFromDirectory() { String database = "test_conceptmaps_disjoint"; spark.sql("CREATE DATABASE " + database); ConceptMaps.getEmpty(spark) .withMapsFromDirectory("src/test/resources/xml/conceptmaps") .writeToDatabase(database); ConceptMaps maps = ConceptMaps.getFromDatabase(spark, database) .withDisjointMapsFromDirectory("src/test/resources/xml/conceptmaps", database); ConceptMap genderMap = maps.getConceptMap( "urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1"); Assert.assertEquals(1, maps.getMaps().count()); Assert.assertNotNull(genderMap); Assert.assertEquals("urn:cerner:poprec:fhir:conceptmap:demographics:gender", genderMap.getUrl()); Assert.assertEquals("0.0.1", genderMap.getVersion()); }
Example #3
Source File: ConceptMapsTest.java From bunsen with Apache License 2.0 | 6 votes |
@Test public void testWithMapsFromDirectoryJson() { ConceptMaps maps = ConceptMaps.getEmpty(spark) .withMapsFromDirectory("src/test/resources/json/conceptmaps"); ConceptMap genderMap = maps.getConceptMap( "urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1"); Assert.assertNotNull(genderMap); Assert.assertEquals("urn:cerner:poprec:fhir:conceptmap:demographics:gender", genderMap.getUrl()); Assert.assertEquals("0.0.1", genderMap.getVersion()); }
Example #4
Source File: ConceptMapsTest.java From bunsen with Apache License 2.0 | 6 votes |
@Test public void testWithMapsFromDirectoryXml() { ConceptMaps maps = ConceptMaps.getEmpty(spark) .withMapsFromDirectory("src/test/resources/xml/conceptmaps"); ConceptMap genderMap = maps.getConceptMap( "urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1"); Assert.assertNotNull(genderMap); Assert.assertEquals("urn:cerner:poprec:fhir:conceptmap:demographics:gender", genderMap.getUrl()); Assert.assertEquals("0.0.1", genderMap.getVersion()); }
Example #5
Source File: ConceptMapsTest.java From bunsen with Apache License 2.0 | 6 votes |
@Test public void testAppendMappings() throws FHIRException { ConceptMaps original = ConceptMaps.getEmpty(spark) .withConceptMaps(conceptMap("urn:cerner:map:testmap", "1"), conceptMap("urn:cerner:map:othermap", "1")); ConceptMaps maps = original.withConceptMaps( conceptMap("urn:cerner:map:newmap", "1")); // The original should be unchanged. Assert.assertEquals(2, original.getMappings().count()); Assert.assertEquals(3, maps.getMappings().count()); ConceptMap firstMap = maps.getConceptMap("urn:cerner:map:testmap", "1"); checkMap(firstMap, "urn:cerner:map:testmap", "1"); ConceptMap secondMap = maps.getConceptMap("urn:cerner:map:othermap", "1"); checkMap(secondMap, "urn:cerner:map:othermap", "1"); ConceptMap newMap = maps.getConceptMap("urn:cerner:map:newmap", "1"); checkMap(newMap, "urn:cerner:map:newmap", "1"); }
Example #6
Source File: ConceptMapsTest.java From bunsen with Apache License 2.0 | 6 votes |
@Test public void testCreateSimpleMappings() throws FHIRException { ConceptMaps maps = ConceptMaps.getEmpty(spark) .withConceptMaps(conceptMap("urn:cerner:map:testmap", "1"), conceptMap("urn:cerner:map:othermap", "1")); Dataset<Mapping> mappings = maps.getMappings(); Assert.assertEquals(2, mappings.count()); ConceptMap firstMap = maps.getConceptMap("urn:cerner:map:testmap", "1"); checkMap(firstMap, "urn:cerner:map:testmap", "1"); ConceptMap secondMap = maps.getConceptMap("urn:cerner:map:othermap", "1"); checkMap(secondMap, "urn:cerner:map:othermap", "1"); }
Example #7
Source File: SimpleWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public void seeResource(String url, Resource r) throws FHIRException { if (r instanceof StructureDefinition) seeProfile(url, (StructureDefinition) r); else if (r instanceof ValueSet) seeValueSet(url, (ValueSet) r); else if (r instanceof CodeSystem) seeCodeSystem(url, (CodeSystem) r); else if (r instanceof OperationDefinition) seeOperationDefinition(url, (OperationDefinition) r); else if (r instanceof ConceptMap) maps.put(((ConceptMap) r).getUrl(), (ConceptMap) r); else if (r instanceof StructureMap) transforms.put(((StructureMap) r).getUrl(), (StructureMap) r); else if (r instanceof NamingSystem) systems.add((NamingSystem) r); }
Example #8
Source File: FHIRToolingClient.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public ConceptMap updateClosure(String name, Coding coding) { Parameters params = new Parameters(); params.addParameter().setName("name").setValue(new StringType(name)); params.addParameter().setName("concept").setValue(coding); List<Header> headers = null; ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()), utils.getResourceAsByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers); result.addErrorStatus(410);//gone result.addErrorStatus(404);//unknown result.addErrorStatus(405); result.addErrorStatus(422);//Unprocessable Entity result.addSuccessStatus(200); result.addSuccessStatus(201); if(result.isUnsuccessfulRequest()) { throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); } return (ConceptMap) result.getPayload(); }
Example #9
Source File: FHIRToolingClient.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public ConceptMap initializeClosure(String name) { Parameters params = new Parameters(); params.addParameter().setName("name").setValue(new StringType(name)); List<Header> headers = null; ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()), utils.getResourceAsByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers); result.addErrorStatus(410);//gone result.addErrorStatus(404);//unknown result.addErrorStatus(405); result.addErrorStatus(422);//Unprocessable Entity result.addSuccessStatus(200); result.addSuccessStatus(201); if(result.isUnsuccessfulRequest()) { throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); } return (ConceptMap) result.getPayload(); }
Example #10
Source File: IEEE11073Convertor.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private static ConceptMap generateLoincMdcMap(CodeSystem mdc, String dst, String src) throws IOException, FHIRException { ConceptMap cm = new ConceptMap(); cm.setId("loinc-mdc"); cm.setUrl("http:/???/fhir/ConceptMap/loinc-mdc"); cm.setVersion("[todo]"); cm.setName("LoincMdcCrossMap"); cm.setTitle("Cross Map between LOINC and MDC"); cm.setStatus(PublicationStatus.DRAFT); cm.setExperimental(true); cm.setDateElement(new DateTimeType()); cm.setPublisher("HL7, Inc"); ContactDetail cd = cm.addContact(); cd.setName("LOINC + IEEE"); ContactPoint cp = cd.addTelecom(); cp.setSystem(ContactPointSystem.URL); cp.setValue("http://loinc.org"); cm.setDescription("A Cross Map between the LOINC and MDC Code systems"); cm.setPurpose("To implementers map between medical device codes and LOINC codes"); cm.setCopyright("This content LOINC \u00ae is copyright \u00a9 1995 Regenstrief Institute, Inc. and the LOINC Committee, and available at no cost under the license at http://loinc.org/terms-of-use"); cm.setSource(new UriType("http://loinc.org/vs")); cm.setTarget(new UriType(MDC_ALL_VALUES)); ConceptMapGroupComponent g = cm.addGroup(); g.setSource("urn:iso:std:iso:11073:10101"); g.setTarget("http://loinc.org"); CSVReader csv = new CSVReader(new FileInputStream(src)); csv.readHeaders(); while (csv.line()) { SourceElementComponent e = g.addElement(); e.setCode(csv.cell("IEEE_CF_CODE10")); e.setDisplay(csv.cell("IEEE_DESCRIPTION")); TargetElementComponent t = e.addTarget(); t.setEquivalence(ConceptMapEquivalence.EQUIVALENT); t.setCode(csv.cell("LOINC_NUM")); t.setDisplay(csv.cell("LOINC_LONG_COMMON_NAME")); } new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "conceptmap-"+cm.getId()+".xml")), cm); System.out.println("Done"); return cm; }
Example #11
Source File: ConceptMapsTest.java From bunsen with Apache License 2.0 | 5 votes |
@Test public void testLoadExpandedMappings() throws FHIRException { ConceptMap map = conceptMap("urn:cerner:map:testmap", "1"); // Explicitly create a mapping dataset to simulate an ETL load from an external source. Mapping mapping = new Mapping(); mapping.setConceptMapUri(map.getUrl()); mapping.setConceptMapVersion(map.getVersion()); mapping.setSourceValueSet("urn:source:valueset"); mapping.setTargetValue("urn:target:valueset"); mapping.setSourceSystem("urn:source:system"); mapping.setSourceValue("urn:source:code:a"); mapping.setTargetSystem("urn:target:system"); mapping.setTargetValue("urn:target:code:1"); Dataset<Mapping> mappings = spark.createDataset(Arrays.asList(mapping), ConceptMaps.getMappingEncoder()); ConceptMaps maps = ConceptMaps.getEmpty(spark) .withExpandedMap(map, mappings); Dataset<Mapping> loadedMappings = maps.getMappings(); Assert.assertEquals(1, loadedMappings.count()); Mapping loadedMapping = loadedMappings.head(); Assert.assertEquals(mapping, loadedMapping); }
Example #12
Source File: ConceptMaps.java From bunsen with Apache License 2.0 | 5 votes |
/** * Returns the children of a given concept map to which the parent * may delegate mapped items. */ private static Set<String> getMapChildren(ConceptMap map) { return map.getGroup() .stream() .filter(group -> group.getUnmapped() != null && group.getUnmapped().getMode() == ConceptMapGroupUnmappedMode.OTHERMAP) .map(group -> group.getUnmapped().getUrl()) .collect(Collectors.toSet()); }
Example #13
Source File: BaseWorkerContext.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
@Override public List<ConceptMap> findMapsForSource(String url) { List<ConceptMap> res = new ArrayList<ConceptMap>(); for (ConceptMap map : maps.values()) { if (((Reference) map.getSource()).getReference().equals(url)) { res.add(map); } } return res; }
Example #14
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private List<TargetElementComponentWrapper> findMappingsForCode(String code, ConceptMap map) { List<TargetElementComponentWrapper> mappings = new ArrayList<TargetElementComponentWrapper>(); for (ConceptMapGroupComponent g : map.getGroup()) { for (SourceElementComponent c : g.getElement()) { if (c.getCode().equals(code)) for (TargetElementComponent cc : c.getTarget()) mappings.add(new TargetElementComponentWrapper(g, cc)); } } return mappings; }
Example #15
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void addMapHeaders(XhtmlNode tr, Map<ConceptMap, String> mymaps) throws FHIRFormatError, DefinitionException, IOException { for (ConceptMap m : mymaps.keySet()) { XhtmlNode td = tr.td(); XhtmlNode b = td.b(); XhtmlNode a = b.ah(prefix+mymaps.get(m)); a.addText(m.getName()); if (m.hasDescription()) addMarkdown(td, m.getDescription()); } }
Example #16
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private boolean generateDefinition(XhtmlNode x, CodeSystem cs, boolean header) throws FHIRFormatError, DefinitionException, IOException { boolean hasExtensions = false; Map<ConceptMap, String> mymaps = new HashMap<ConceptMap, String>(); // for (ConceptMap a : context.findMapsForSource(cs.getValueSet())) { // String url = ""; // ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) a.getTarget()).getReference()); // if (vsr != null) // url = (String) vsr.getUserData("filename"); // mymaps.put(a, url); // } // also, look in the contained resources for a concept map for (Resource r : cs.getContained()) { if (r instanceof ConceptMap) { ConceptMap cm = (ConceptMap) r; if (((Reference) cm.getSource()).getReference().equals(cs.getValueSet())) { String url = ""; ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) cm.getTarget()).getReference()); if (vsr != null) url = (String) vsr.getUserData("filename"); mymaps.put(cm, url); } } } List<String> langs = new ArrayList<String>(); if (header) { XhtmlNode h = x.h2(); h.addText(cs.hasTitle() ? cs.getTitle() : cs.getName()); addMarkdown(x, cs.getDescription()); if (cs.hasCopyright()) generateCopyright(x, cs); } generateProperties(x, cs); generateFilters(x, cs); hasExtensions = generateCodeSystemContent(x, cs, hasExtensions, mymaps, langs); return hasExtensions; }
Example #17
Source File: ConceptMap14_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu3.model.ContactDetail convertConceptMapContactComponent(org.hl7.fhir.dstu2016may.model.ConceptMap.ConceptMapContactComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail(); VersionConvertor_14_30.copyElement(src, tgt); if (src.hasName()) tgt.setNameElement(VersionConvertor_14_30.convertString(src.getNameElement())); for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(VersionConvertor_14_30.convertContactPoint(t)); return tgt; }
Example #18
Source File: ConceptMap10_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu3.model.ContactDetail convertConceptMapContactComponent(org.hl7.fhir.dstu2.model.ConceptMap.ConceptMapContactComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail(); VersionConvertor_10_30.copyElement(src, tgt); if (src.hasNameElement()) tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement())); for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(VersionConvertor_10_30.convertContactPoint(t)); return tgt; }
Example #19
Source File: StructureMapUtilities.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private static void renderConceptMaps(StringBuilder b, StructureMap map) { for (Resource r : map.getContained()) { if (r instanceof ConceptMap) { produceConceptMap(b, (ConceptMap) r); } } }
Example #20
Source File: ConceptMap14_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static List<VersionConvertor_14_30.SourceElementComponentWrapper> convertSourceElementComponent(org.hl7.fhir.dstu2016may.model.ConceptMap.SourceElementComponent src) throws FHIRException { List<VersionConvertor_14_30.SourceElementComponentWrapper> res = new ArrayList<VersionConvertor_14_30.SourceElementComponentWrapper>(); if (src == null || src.isEmpty()) return res; for (org.hl7.fhir.dstu2016may.model.ConceptMap.TargetElementComponent t : src.getTarget()) { org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent(); VersionConvertor_14_30.copyElement(src, tgt); if (src.hasCode()) tgt.setCode(src.getCode()); tgt.addTarget(convertTargetElementComponent(t)); res.add(new VersionConvertor_14_30.SourceElementComponentWrapper(tgt, src.getSystem(), t.getSystem())); } return res; }
Example #21
Source File: ConceptMap14_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu2016may.model.ConceptMap.SourceElementComponent convertSourceElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent src, org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent g) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.dstu2016may.model.ConceptMap.SourceElementComponent(); VersionConvertor_14_30.copyElement(src, tgt); if (g.hasSource()) tgt.setSystem(g.getSource()); if (src.hasCode()) tgt.setCodeElement(VersionConvertor_14_30.convertCode(src.getCodeElement())); for (org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent t : src.getTarget()) tgt.addTarget(convertTargetElementComponent(t, g)); return tgt; }
Example #22
Source File: ConceptMap14_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.dstu2016may.model.ConceptMap.OtherElementComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent(); VersionConvertor_14_30.copyElement(src, tgt); if (src.hasElementElement()) tgt.setPropertyElement(VersionConvertor_14_30.convertUri(src.getElementElement())); if (src.hasSystemElement()) tgt.setSystemElement(VersionConvertor_14_30.convertUri(src.getSystemElement())); if (src.hasCodeElement()) tgt.setCodeElement(VersionConvertor_14_30.convertString(src.getCodeElement())); return tgt; }
Example #23
Source File: ConceptMap14_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu2016may.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.dstu2016may.model.ConceptMap.OtherElementComponent(); VersionConvertor_14_30.copyElement(src, tgt); if (src.hasPropertyElement()) tgt.setElementElement(VersionConvertor_14_30.convertUri(src.getPropertyElement())); if (src.hasSystemElement()) tgt.setSystemElement(VersionConvertor_14_30.convertUri(src.getSystemElement())); if (src.hasCodeElement()) tgt.setCodeElement(VersionConvertor_14_30.convertString(src.getCodeElement())); return tgt; }
Example #24
Source File: ConceptMap10_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu2.model.ConceptMap.ConceptMapContactComponent convertConceptMapContactComponent(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ConceptMap.ConceptMapContactComponent tgt = new org.hl7.fhir.dstu2.model.ConceptMap.ConceptMapContactComponent(); VersionConvertor_10_30.copyElement(src, tgt); if (src.hasNameElement()) tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement())); for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(VersionConvertor_10_30.convertContactPoint(t)); return tgt; }
Example #25
Source File: ConceptMap10_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.dstu2.model.ConceptMap.OtherElementComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent(); VersionConvertor_10_30.copyElement(src, tgt); if (src.hasElementElement()) tgt.setPropertyElement(VersionConvertor_10_30.convertUri(src.getElementElement())); if (src.hasCodeSystemElement()) tgt.setSystemElement(VersionConvertor_10_30.convertUri(src.getCodeSystemElement())); if (src.hasCodeElement()) tgt.setCodeElement(VersionConvertor_10_30.convertString(src.getCodeElement())); return tgt; }
Example #26
Source File: ConceptMap14_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu2016may.model.ConceptMap.ConceptMapContactComponent convertConceptMapContactComponent(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.ConceptMap.ConceptMapContactComponent tgt = new org.hl7.fhir.dstu2016may.model.ConceptMap.ConceptMapContactComponent(); VersionConvertor_14_30.copyElement(src, tgt); if (src.hasName()) tgt.setNameElement(VersionConvertor_14_30.convertString(src.getNameElement())); for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(VersionConvertor_14_30.convertContactPoint(t)); return tgt; }
Example #27
Source File: ConceptMap10_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu2.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.dstu2.model.ConceptMap.OtherElementComponent(); VersionConvertor_10_30.copyElement(src, tgt); if (src.hasPropertyElement()) tgt.setElementElement(VersionConvertor_10_30.convertUri(src.getPropertyElement())); if (src.hasSystemElement()) tgt.setCodeSystemElement(VersionConvertor_10_30.convertUri(src.getSystemElement())); if (src.hasCodeElement()) tgt.setCodeElement(VersionConvertor_10_30.convertString(src.getCodeElement())); return tgt; }
Example #28
Source File: ConceptMap10_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static List<VersionConvertor_10_30.SourceElementComponentWrapper> convertSourceElementComponent(org.hl7.fhir.dstu2.model.ConceptMap.SourceElementComponent src) throws FHIRException { List<VersionConvertor_10_30.SourceElementComponentWrapper> res = new ArrayList<VersionConvertor_10_30.SourceElementComponentWrapper>(); if (src == null || src.isEmpty()) return res; for (org.hl7.fhir.dstu2.model.ConceptMap.TargetElementComponent t : src.getTarget()) { org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent(); VersionConvertor_10_30.copyElement(src, tgt); tgt.setCode(src.getCode()); tgt.addTarget(convertTargetElementComponent(t)); res.add(new VersionConvertor_10_30.SourceElementComponentWrapper(tgt, src.getCodeSystem(), t.getCodeSystem())); } return res; }
Example #29
Source File: ConceptMap10_30.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public static org.hl7.fhir.dstu2.model.ConceptMap.SourceElementComponent convertSourceElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent src, org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent g) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.dstu2.model.ConceptMap.SourceElementComponent(); VersionConvertor_10_30.copyElement(src, tgt); tgt.setCodeSystem(g.getSource()); if (src.hasCodeElement()) tgt.setCodeElement(VersionConvertor_10_30.convertCode(src.getCodeElement())); for (org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent t : src.getTarget()) tgt.addTarget(convertTargetElementComponent(t, g)); return tgt; }
Example #30
Source File: ConceptMaps.java From bunsen with Apache License 2.0 | 4 votes |
/** * Returns a list of concept maps in the order they need to be loaded. */ private static List<String> sortMapsToLoad(Set<String> mapsToLoad, Map<String,ConceptMap> allMaps) { Deque<String> pendingMaps = new ArrayDeque<>(mapsToLoad); List<String> loadOrder = new ArrayList<>(); Set<String> loadedMaps = new HashSet<>(); while (!pendingMaps.isEmpty()) { String nextMap = pendingMaps.peek(); // If the map has already been loaded, // remove it and continue. if (loadedMaps.contains(nextMap)) { pendingMaps.pop(); continue; } ConceptMap mapToLoad = allMaps.get(nextMap); if (mapToLoad == null) { throw new IllegalStateException("Concept map " + nextMap + " " + " is referenced but not in the collection of concept maps."); } // Get the set of children we need to load before the pending map. Set<String> childrenToLoad = getMapChildren(mapToLoad); childrenToLoad.removeAll(loadedMaps); // If the pending map has no children to load, we can // add it to our load order. if (childrenToLoad.isEmpty()) { loadedMaps.add(nextMap); loadOrder.add(nextMap); pendingMaps.pop(); } else { // The pending map has children, so we need to load them first. for (String child: childrenToLoad) { pendingMaps.push(child); } } } return loadOrder; }