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