# Path: dhis2_core/src/dhis2/facility_list/models/mcsd.py
# class OrgUnit(BaseEntity):
#     geometry: Optional[OrgUnitGeometry]
#     parent: Optional[BaseEntity]


import logging
from base64 import b64encode
from typing import List
from fhir.resources.attachment import Attachment
from fhir.resources.bundle import Bundle, BundleEntry, BundleEntryRequest
from fhir.resources.codeableconcept import CodeableConcept
from fhir.resources.coding import Coding
from fhir.resources.extension import Extension
from fhir.resources.fhirreference import FHIRReference
from fhir.resources.identifier import Identifier
from fhir.resources.location import Location, LocationPosition
from fhir.resources.meta import Meta
from fhir.resources.organization import Organization
from .models.mcsd import OrgUnit

        resource.type.append(c2)

    return resource


def build_location_bundle_entry(org_unit: OrgUnit, base_url: str) -> BundleEntry:
    entry = BundleEntry()

    entry.request = BundleEntryRequest()
    entry.request.method = "PUT"
    entry.request.url = f"Location?identifier={org_unit.id}"

    entry.resource = build_mcsd_location(org_unit, base_url)

    return entry


def build_organization_bundle_entry(org_unit: OrgUnit, base_url: str) -> BundleEntry:
    entry = BundleEntry()

    entry.request = BundleEntryRequest()
    entry.request.method = "PUT"
    entry.request.url = f"Organization?identifier={org_unit.id}"

    entry.resource = build_mcsd_organization(org_unit, base_url)

    return entry



# Path: dhis2_core/src/dhis2/facility_list/models/mcsd.py
# class OrgUnit(BaseEntity):
#     geometry: Optional[OrgUnitGeometry]
#     parent: Optional[BaseEntity]


# Path: dhis2_core/src/dhis2/facility_list/mcsd_resources.py
import logging
from base64 import b64encode
from typing import List
from fhir.resources.attachment import Attachment
from fhir.resources.bundle import Bundle, BundleEntry, BundleEntryRequest
from fhir.resources.codeableconcept import CodeableConcept
from fhir.resources.coding import Coding
from fhir.resources.extension import Extension
from fhir.resources.fhirreference import FHIRReference
from fhir.resources.identifier import Identifier
from fhir.resources.location import Location, LocationPosition
from fhir.resources.meta import Meta
from fhir.resources.organization import Organization
from .models.mcsd import OrgUnit


        resource.type.append(c2)

    return resource


def build_location_bundle_entry(org_unit: OrgUnit, base_url: str) -> BundleEntry:
    entry = BundleEntry()

    entry.request = BundleEntryRequest()
    entry.request.method = "PUT"
    entry.request.url = f"Location?identifier={org_unit.id}"

    entry.resource = build_mcsd_location(org_unit, base_url)

    return entry


def build_organization_bundle_entry(org_unit: OrgUnit, base_url: str) -> BundleEntry:
    entry = BundleEntry()

    entry.request = BundleEntryRequest()
    entry.request.method = "PUT"
    entry.request.url = f"Organization?identifier={org_unit.id}"

    entry.resource = build_mcsd_organization(org_unit, base_url)

    return entry



def build_bundle(org_units: List[OrgUnit], base_url: str) -> Bundle: