(
    importer: FHIRImportConfig,
    child_cases: List[ParentInfo],
)
Creates parent-child relationships on imported cases.

    If ``ResourceTypeRelationship.related_resource_is_parent`` is
    ``True`` then this function will add an ``index`` on the child case
    to its parent case.
Creates parent-child relationships on imported cases.
Creates parent - child relationships on imported cases .
def create_parent_indices(
    importer: FHIRImportConfig,
    child_cases: List[ParentInfo],
):
    """
    Creates parent-child relationships on imported cases.

    If ``ResourceTypeRelationship.related_resource_is_parent`` is
    ``True`` then this function will add an ``index`` on the child case
    to its parent case.
    """
    if not child_cases:
        return

    case_blocks = []
    for child_case_id, parent_ref, parent_resource_type in child_cases:
        resource_type_name, external_id = parent_ref.split('/')
        parent_case = get_case_by_external_id(
            parent_resource_type.domain,
            external_id,
            parent_resource_type.case_type.name,
        )
        if not parent_case:
            raise ConfigurationError(
                f'Case not found with external_id {external_id!r}')

        case_blocks.append(CaseBlock(
            child_case_id,
            index={'parent': (parent_case.type, parent_case.case_id)},
        ))
    submit_case_blocks(
        [cb.as_text() for cb in case_blocks],
        importer.domain,
        xmlns=XMLNS_FHIR,
        device_id=f'FHIRImportConfig-{importer.pk}',
    )
def create_parent_indices ( importer : FHIRImportConfig , child_cases : List [ ParentInfo ] , ) : if not child_cases : return case_blocks = [ ] for child_case_id , parent_ref , parent_resource_type in child_cases : resource_type_name , external_id = parent_ref . split ( '/' ) parent_case = get_case_by_external_id ( parent_resource_type . domain , external_id , parent_resource_type . case_type . name , ) if not parent_case : raise ConfigurationError ( f'Case not found with external_id {external_id!r}' ) case_blocks . append ( CaseBlock ( child_case_id , index = { 'parent' : ( parent_case . type , parent_case . case_id ) } , ) ) submit_case_blocks ( [ cb . as_text ( ) for cb in case_blocks ] , importer . domain , xmlns = XMLNS_FHIR , device_id = f'FHIRImportConfig-{importer.pk}' , )