Пример #1
0
function listMarkupJson($matches)
{
    $annotationFiles = array('annotationFiles' => array());
    header("Content-Type: application/json");
    $viewingSessionId = $_GET['DocumentID'];
    // Call PCCIS
    $url = PccConfig::getImagingService() . "/ViewingSession/" . urlencode($viewingSessionId);
    $acsApiKey = PccConfig::getApiKey();
    $options = array('http' => array('method' => 'GET', 'header' => "Accept: application/json\r\n" . "Acs-Api-Key: {$acsApiKey}\r\n"));
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    $response = json_decode($result);
    if ($result === 0 || !$response->externalId || !strlen($response->externalId)) {
        header("HTTP/1.1 500 Internal Server Error");
    } else {
        $path2Save = PccConfig::getMarkupsPath();
        $i = 1;
        $fileList = glob($path2Save . '*.xml');
        foreach ($fileList as $file) {
            if (stristr($file, $response->externalId . '_' . $response->attachmentIndex) == TRUE) {
                $nameParts = explode('.', array_pop(explode('_', basename($file))));
                $name = substr($nameParts[0], 1);
                $annotationFiles['annotationFiles'][] = array('annotationLabel' => $name, 'annotationName' => basename($file), 'ID' => (string) $i++);
            }
        }
    }
    echo json_encode($annotationFiles);
    flush();
}