protected function sendResource(services\Resource $resource, $status = 200)
{
header("Category: {$resource->getOeFhirProfile()}; scheme=http://hl7.org/fhir/tag/profile");
if ($last_modified = $resource->getLastModified()) {
header('Last-modified: ' . date(DATE_RFC1123, $last_modified));
}
$data = $resource->toFhir();
if ($this->output_format == 'xml') {
header('Content-type: ' . self::XML_MIMETYPE);
$this->sendResponse($status, Yii::app()->fhirMarshal->renderXml($data));
} else {
header('Content-type: ' . self::JSON_MIMETYPE);
$this->sendResponse($status, Yii::app()->fhirMarshal->renderJson($data), self::JSON_MIMETYPE);
}
}