private function getSearchService($resource_type, array &$params)
{
$profiles = isset($params['_profile']) ? array($params['_profile']) : array();
$service = Yii::app()->service->getFhirService($resource_type, $profiles);
if (!$service) {
return;
}
// If a profile was supplied it must match
if (isset($params['_profile'])) {
$resource_class = $service->getResourceClass();
if ($resource_class::getOeFhirProfile() != $params['_profile']) {
return;
}
}
// Special case for when there's a resource ID as part of the search (which doesn't seem very useful...)
if (isset($params['_id'])) {
if (!($ref = Yii::app()->service->fhirIdToReference($resource_type, $params['_id']))) {
// Not an error: we support the resource type, you just asked for an ID that doesn't exist
return;
}
$params['id'] = $ref->getId();
if ($ref->getServiceName() != $service::getServiceName()) {
// service mismatch
return;
}
}
return $service;
}