001package org.hl7.fhir.utilities; 002 003import java.util.ArrayList; 004import java.util.Collection; 005import java.util.List; 006import java.util.Map; 007 008public class SIDUtilities { 009 010 public static List<String> codeSystemList() { 011 List<String> codeSystems = new ArrayList<>(); 012 codeSystems.add("http://hl7.org/fhir/sid/ndc"); 013 codeSystems.add("http://hl7.org/fhir/sid/icpc2"); 014 codeSystems.add("http://hl7.org/fhir/sid/icd-9"); 015 codeSystems.add("http://hl7.org/fhir/sid/icd-10"); 016 codeSystems.add("http://hl7.org/fhir/sid/cvx"); 017 codeSystems.add("http://hl7.org/fhir/sid/srt"); 018 codeSystems.add("http://hl7.org/fhir/sid/icd-10-vn"); 019 codeSystems.add("http://hl7.org/fhir/sid/icd-10-cm"); 020 codeSystems.add("http://hl7.org/fhir/sid/icd-9-cm"); 021 return codeSystems; 022 } 023 024 public static List<String> idSystemList() { 025 List<String> idSystems = new ArrayList<>(); 026 idSystems.add("http://hl7.org/fhir/sid/us-ssn"); 027 idSystems.add("http://hl7.org/fhir/sid/us-npi"); 028 idSystems.add("http://hl7.org/fhir/sid/eui-48/bluetooth"); 029 idSystems.add("http://hl7.org/fhir/sid/eui-48/ethernet"); 030 return idSystems; 031 } 032 033 private static boolean isPassPortSID(String url) { 034 // TODO: verify ISO countrycode part vs country code list 035 return url.matches("^http:\\/\\/hl7.org\\/fhir\\/sid\\/passport-[a-zA-Z]{3}$"); 036 } 037 038 public static boolean isknownCodeSystem(String system) { 039 return codeSystemList().contains(system); 040 } 041 042 public static boolean isKnownSID(String url) { 043 return isknownCodeSystem(url) || isknownIDSystem(url); 044 } 045 046 private static boolean isknownIDSystem(String url) { 047 return idSystemList().contains(url) || isPassPortSID(url); 048 } 049 050 public static List<String> allSystemsList() { 051 List<String> allSystems = new ArrayList<>(); 052 allSystems.addAll(codeSystemList()); 053 allSystems.addAll(idSystemList()); 054 return allSystems; 055 } 056 057 public static boolean isInvalidVersion(String u, String v) { 058 if (v == null) { 059 return false; 060 } else { 061 if (idSystemList().contains(u)) { 062 return true; 063 } else { 064 switch (u) { 065 case "http://hl7.org/fhir/sid/ndc": 066 return v.matches("[\\d]{8}"); 067 case "http://hl7.org/fhir/sid/icpc2": 068 return false; 069 case "http://hl7.org/fhir/sid/icd-10": 070 return false; 071 case "http://hl7.org/fhir/sid/icd-9": 072 return false; 073 case "http://hl7.org/fhir/sid/cvx": 074 return v.matches("[\\d]{8}"); 075 case "http://hl7.org/fhir/sid/srt": 076 return false; 077 case "http://hl7.org/fhir/sid/icd-10-vn": 078 return false; 079 case "http://hl7.org/fhir/sid/icd-10-cm": 080 return false; 081 case "http://hl7.org/fhir/sid/icd-9-cm": 082 return false; 083 default: 084 return true; 085 } 086 } 087 } 088 } 089 090}