/*
 * Copyright 2018 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.fhir.core.codesystems;

import java.util.List;
import java.util.stream.Collectors;

import com.b2international.commons.StringUtils;
import com.b2international.snowowl.fhir.core.ResourceNarrative;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.google.common.collect.Lists;

/**
 * FHIR Code system content mode
 * 
 * @since 6.4
 */
@ResourceNarrative("How much of the content of the code system - the concepts and codes it defines - are represented in a code system resource.")
public enum CodeSystemContentMode implements FhirCodeSystem {
	
	//None of the concepts defined by the code system are included in the code system resource.
	NOT_PRESENT,
	
	//A few representative concepts are included in the code system resource
	EXAMPLE,
	
	//A subset of the code system concepts are included in the code system resource
	FRAGMENT,
	
	//All the concepts defined by the code system are included in the code system resource
	COMPLETE;
	
	public static final String CODE_SYSTEM_URI = "http://hl7.org/fhir/codesystem-content-mode";

	@Override
	public String getCodeValue() {
		return name().toLowerCase().replaceAll("_", "-");
	}
	
	@Override
	public String getDisplayName() {
		
		String name = name().toLowerCase();
		if (StringUtils.isSingleWord(name)) {
			return StringUtils.capitalizeFirstLetter(name);
		} else {
			Iterable<String> words = StringUtils.getWords(name());
			List<String> wordList = Lists.newArrayList(words);
			return wordList.stream().map(StringUtils::capitalizeFirstLetter).collect(Collectors.joining());
		}
	}
	
	@JsonCreator
	public static CodeSystemContentMode getByCodeValue(String codeValue) {
		for (CodeSystemContentMode code : values()) {
			if (code.getCodeValue().equals(codeValue)) {
				return code;
			}
		}
		throw new IllegalArgumentException("Unknown content mode. '" + codeValue + "'.");
	}
	
	@Override
	public String getCodeSystemUri() {
		return CODE_SYSTEM_URI;
	}

}

@@ -13,16 +13,21 @@
 ght 2018
+-2022
  B2i Hea
@@ -1219,16 +1219,17 @@
  %7B%0A%09%0A%09//
+ 
 None of 
@@ -1329,16 +1329,17 @@
 T,%0A%09%0A%09//
+ 
 A few re
@@ -1416,16 +1416,17 @@
 E,%0A%09%0A%09//
+ 
 A subset
@@ -1511,16 +1511,17 @@
 T,%0A%09%0A%09//
+ 
 All the 
@@ -1606,16 +1606,161 @@
 COMPLETE
+,%0A%09%0A%09// The resource doesn't define any new concepts; it just provides additional designations and properties to another code system.%0A%09SUPPLEMENT
 ;%0A%09%0A%09pub

Add "SUPPLEMENT" as an allowed CodeSystemContentMode value