001package org.hl7.fhir.r5.terminologies;
002
003import java.util.ArrayList;
004import java.util.HashMap;
005import java.util.List;
006import java.util.Map;
007
008import org.hl7.fhir.r5.model.Enumerations.FHIRVersion;
009import org.hl7.fhir.utilities.MarkedToMoveToAdjunctPackage;
010
011@MarkedToMoveToAdjunctPackage
012public class TerminologyServerDetails {
013  public enum ServerAuthorizationMethod {
014    OPEN,
015    TOKEN, 
016    SMART_ON_FHIR
017  }
018  private String name;
019  private ServerAuthorizationMethod auth;
020  private Map<FHIRVersion, String> endpoints = new HashMap<>();
021  private List<String> codeSystems = new ArrayList<>();
022  
023  public boolean handlesSystem(String uri, String version) {
024    for (String s : codeSystems) {
025      if (s.contains("|")) {
026        String u = s.substring(0, s.lastIndexOf("|"));
027        String v = s.substring(s.lastIndexOf("|")+1);
028        if (v.equals(version) && (s.equals(uri) || uri.matches(s))) {
029          return true;
030        }
031      } else {
032        if (s.equals(uri) || uri.matches(s)) {
033          return true;
034        }
035      }
036    }
037    return false;
038  }
039
040  public String getName() {
041    return name;
042  }
043
044  public ServerAuthorizationMethod getAuth() {
045    return auth;
046  }
047
048  public Map<FHIRVersion, String> getEndpoints() {
049    return endpoints;
050  }
051
052  public List<String> getCodeSystems() {
053    return codeSystems;
054  }
055  
056  
057}