def METHOD_NAME(request, domain, fhir_version_name, resource_type=None):
    fhir_version = _get_fhir_version(fhir_version_name)
    if not fhir_version:
        return JsonResponse(status=400, data={'message': "Unsupported FHIR version"})
    resource_id = request.GET.get('_id', None) or request.GET.get('patient_id')
    if not resource_id:
        return JsonResponse(status=400, data={'message': "Please pass resource ID."})
    try:
        found_case = CommCareCase.objects.get_case(resource_id, domain)
        if found_case.is_deleted:
            return JsonResponse(status=410, data={'message': "Gone"})
    except CaseNotFound:
        return JsonResponse(status=404, data={'message': "Not Found"})
    resource_types = None
    if resource_type:
        resource_types = [resource_type]
    else:
        type_param = request.GET.get('_type')
        resource_types = [resource_type.strip() for resource_type in type_param.split(',')] if type_param else None
    if not resource_types:
        return JsonResponse(status=400,
                            data={'message': "No resource type specified for search."})
    case_types_for_resource_types = list(
        FHIRResourceType.objects.filter(
            domain=domain, name__in=resource_types, fhir_version=fhir_version
        ).values_list('case_type__name', flat=True)
    )
    if not case_types_for_resource_types:
        return JsonResponse(status=400,
                            data={'message':
                                  f"Resource type(s) {', '.join(resource_types)} not available on {domain}"})
    cases = CommCareCase.objects.get_reverse_indexed_cases(
        domain, [resource_id], case_types=case_types_for_resource_types, is_closed=False)
    if found_case.type in case_types_for_resource_types:
        cases.append(found_case)
    response = {
        'resourceType': "Bundle",
        "type": "searchset",
        "entry": []
    }
    for case in cases:
        case_resource_type = FHIRResourceType.objects.get(
            case_type=CaseType.objects.get(domain=domain, name=case.type))
        response["entry"].append({
            "fullUrl": resource_url(domain, fhir_version_name, case_resource_type, case.case_id),
            "search": {
                "mode": "match"
            }
        })
    return JsonResponse(response)