comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1831:3ae2ff249675

"/instances/.../header" to get the meta information (header) of the DICOM instance
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 26 Nov 2015 18:53:00 +0100
parents ac5b0b4e2434
children 559956d5ceb2
comparison
equal deleted inserted replaced
1830:2921384cc352 1831:3ae2ff249675
1273 ordering.Format(result); 1273 ordering.Format(result);
1274 call.GetOutput().AnswerJson(result); 1274 call.GetOutput().AnswerJson(result);
1275 } 1275 }
1276 1276
1277 1277
1278 static void GetInstanceHeader(RestApiGetCall& call)
1279 {
1280 ServerContext& context = OrthancRestApi::GetContext(call);
1281
1282 std::string publicId = call.GetUriComponent("id", "");
1283 bool simplify = call.HasArgument("simplify");
1284
1285 std::string dicomContent;
1286 context.ReadFile(dicomContent, publicId, FileContentType_Dicom);
1287
1288 ParsedDicomFile dicom(dicomContent);
1289
1290 Json::Value header;
1291 dicom.HeaderToJson(header, DicomToJsonFormat_Full);
1292
1293 if (simplify)
1294 {
1295 Json::Value simplified;
1296 Toolbox::SimplifyTags(simplified, header);
1297 call.GetOutput().AnswerJson(simplified);
1298 }
1299 else
1300 {
1301 call.GetOutput().AnswerJson(header);
1302 }
1303 }
1304
1305
1278 void OrthancRestApi::RegisterResources() 1306 void OrthancRestApi::RegisterResources()
1279 { 1307 {
1280 Register("/instances", ListResources<ResourceType_Instance>); 1308 Register("/instances", ListResources<ResourceType_Instance>);
1281 Register("/patients", ListResources<ResourceType_Patient>); 1309 Register("/patients", ListResources<ResourceType_Patient>);
1282 Register("/series", ListResources<ResourceType_Series>); 1310 Register("/series", ListResources<ResourceType_Series>);
1321 Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>); 1349 Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>);
1322 Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>); 1350 Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>);
1323 Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>); 1351 Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>);
1324 Register("/instances/{id}/image-int16", GetImage<ImageExtractionMode_Int16>); 1352 Register("/instances/{id}/image-int16", GetImage<ImageExtractionMode_Int16>);
1325 Register("/instances/{id}/matlab", GetMatlabImage); 1353 Register("/instances/{id}/matlab", GetMatlabImage);
1354 Register("/instances/{id}/header", GetInstanceHeader);
1326 1355
1327 Register("/patients/{id}/protected", IsProtectedPatient); 1356 Register("/patients/{id}/protected", IsProtectedPatient);
1328 Register("/patients/{id}/protected", SetPatientProtection); 1357 Register("/patients/{id}/protected", SetPatientProtection);
1329 1358
1330 Register("/{resourceType}/{id}/metadata", ListMetadata); 1359 Register("/{resourceType}/{id}/metadata", ListMetadata);