# Path: dhis2_core/src/dhis2/code_list/models/svcm.py
# class CodeList(BaseEntity):
#     type: Literal["optionSets", "categories"] = "optionSets"
#     version: Union[str, int] = "1"
#     codes: List[Code] = []


import logging
from typing import List
from fhir.resources.bundle import Bundle, BundleEntry, BundleEntryRequest
from fhir.resources.codesystem import CodeSystem, CodeSystemConcept
from fhir.resources.identifier import Identifier
from fhir.resources.valueset import ValueSet, ValueSetCompose, ValueSetComposeInclude
from .models.svcm import CodeList

    if code_list.code:
        identifier = Identifier()
        identifier.system = f"{base_url}/api/{code_list.type}"
        identifier.value = code_list.code

        resource.identifier.append(identifier)

    resource.publisher = base_url
    resource.status = "active"
    resource.content = "complete"
    resource.version = str(code_list.version)
    resource.name = code_list.name
    resource.title = code_list.name
    resource.description = code_list.name
    resource.experimental = False
    resource.caseSensitive = True
    resource.concept = []

    for code in code_list.codes:
        concept = CodeSystemConcept()
        resource.concept.append(concept)

        concept.code = code.get("code")
        concept.display = code.get("name")
        concept.definition = code.get("name")

    return resource



# Path: dhis2_core/src/dhis2/code_list/models/svcm.py
# class CodeList(BaseEntity):
#     type: Literal["optionSets", "categories"] = "optionSets"
#     version: Union[str, int] = "1"
#     codes: List[Code] = []


# Path: dhis2_core/src/dhis2/code_list/svcm_resources.py
import logging
from typing import List
from fhir.resources.bundle import Bundle, BundleEntry, BundleEntryRequest
from fhir.resources.codesystem import CodeSystem, CodeSystemConcept
from fhir.resources.identifier import Identifier
from fhir.resources.valueset import ValueSet, ValueSetCompose, ValueSetComposeInclude
from .models.svcm import CodeList


    if code_list.code:
        identifier = Identifier()
        identifier.system = f"{base_url}/api/{code_list.type}"
        identifier.value = code_list.code

        resource.identifier.append(identifier)

    resource.publisher = base_url
    resource.status = "active"
    resource.content = "complete"
    resource.version = str(code_list.version)
    resource.name = code_list.name
    resource.title = code_list.name
    resource.description = code_list.name
    resource.experimental = False
    resource.caseSensitive = True
    resource.concept = []

    for code in code_list.codes:
        concept = CodeSystemConcept()
        resource.concept.append(concept)

        concept.code = code.get("code")
        concept.display = code.get("name")
        concept.definition = code.get("name")

    return resource



def build_svcm_valueset(code_list: CodeList, base_url: str) -> ValueSet: