ApiController::actionCreate PHP Method

actionCreate() public method

Create resource.
public actionCreate ( string $resource_type )
$resource_type string
    public function actionCreate($resource_type)
    {
        $service = Yii::app()->service->getFhirService($resource_type, $this->profile_tags);
        if (!$service) {
            throw new services\ProcessingNotSupported("No matching profile found to create resource of type '{$resource_type}'");
        }
        $fhirObject = $this->parseInput();
        if (strtolower($fhirObject->resourceType) != strtolower($resource_type)) {
            throw new services\InvalidValue("Invalid resource type '{$fhirObject->resourceType}', expecting '{$resource_type}'");
        }
        $tx = Yii::app()->db->beginTransaction();
        $ref = $service->fhirCreate($fhirObject);
        $tx->commit();
        $url = Yii::app()->service->referenceToFhirUrl($ref);
        $vid = $ref->getVersionId();
        header('Location: ' . $this->createAbsoluteUrl('api/') . "/{$url}/_history/{$vid}");
        header("ETag: \"{$vid}\"");
        $this->sendInfo("Resource '{$url}' successfully created", 201);
    }