001package org.hl7.fhir.r4.terminologies; 002 003/*- 004 * #%L 005 * org.hl7.fhir.r4 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023 024import org.hl7.fhir.r4.model.Enumerations.PublicationStatus; 025import org.hl7.fhir.r4.model.ValueSet; 026import org.hl7.fhir.utilities.Utilities; 027 028public class ImplicitValueSets { 029 030 public static ValueSet build(String url) { 031 if (Utilities.noString(url)) 032 return null; 033 034 if (url.startsWith("http://snomed.info/sct")) 035 return buildSnomedValueSet(url); 036 if (url.startsWith("http://loinc.org/vs")) 037 return buildLoincValueSet(url); 038 if (url.equals("http://unitsofmeasure.org/vs")) 039 return allUcumValueSet(); 040 return null; 041 } 042 043 private static ValueSet buildSnomedValueSet(String url) { 044 return null; 045 } 046 047 private static ValueSet buildLoincValueSet(String url) { 048 if (url.startsWith("http://loinc.org/vs/LL")) { 049 ValueSet vs = new ValueSet(); 050 vs.setUrl(url); 051 vs.setStatus(PublicationStatus.ACTIVE); 052 vs.setName("LoincVS"+url.substring(21).replace("-", "")); 053 vs.setTitle("Loinc Implicit ValueSet for "+url.substring(21)); 054 // todo: populate the compose fro the terminology server 055 return vs; 056 } else if (url.equals("http://loinc.org/vs")) { 057 ValueSet vs = new ValueSet(); 058 vs.setUrl(url); 059 vs.setStatus(PublicationStatus.ACTIVE); 060 vs.setName("LoincVSAll"); 061 vs.setTitle("Loinc Implicit ValueSet : all codes"); 062 // todo: populate the compose for the terminology server 063 return vs; 064 } else { 065 return null; 066 } 067 } 068 069 private static ValueSet allUcumValueSet() { 070 ValueSet vs = new ValueSet(); 071 vs.setUrl("http://unitsofmeasure.org/vs"); 072 vs.setStatus(PublicationStatus.ACTIVE); 073 vs.setName("AllUcumCodes"); 074 vs.setTitle("All Ucum Codes"); 075 vs.getCompose().addInclude().setSystem("http://unitsofmeasure.org"); 076 return vs; 077 } 078 079}