Mercurial > hg > orthanc
comparison Plugins/OrthancCPlugin/OrthancCPlugin.h @ 1068:f54a9c6fea5d
documentation of plugin sdk
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 28 Jul 2014 11:34:01 +0200 |
parents | ace99e272203 |
children | a91b4900f06a |
comparison
equal
deleted
inserted
replaced
1067:ace99e272203 | 1068:f54a9c6fea5d |
---|---|
12 * - Check its compatibility with the Orthanc version using | 12 * - Check its compatibility with the Orthanc version using |
13 * ::OrthancPluginCheckVersion(). | 13 * ::OrthancPluginCheckVersion(). |
14 * - Store the context pointer so that it can use the plugin | 14 * - Store the context pointer so that it can use the plugin |
15 * services of Orthanc. | 15 * services of Orthanc. |
16 * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback(). | 16 * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback(). |
17 * - Register all its callbacks for received instances using ::OrthancPluginRegisterOnStoredInstanceCallback(). | |
17 * -# <tt>void OrthancPluginFinalize()</tt>: | 18 * -# <tt>void OrthancPluginFinalize()</tt>: |
18 * This function is invoked by Orthanc during its shutdown. The plugin | 19 * This function is invoked by Orthanc during its shutdown. The plugin |
19 * must free all its memory. | 20 * must free all its memory. |
20 * -# <tt>const char* OrthancPluginGetName()</tt>: | 21 * -# <tt>const char* OrthancPluginGetName()</tt>: |
21 * The plugin must return a short string to identify itself. | 22 * The plugin must return a short string to identify itself. |
872 * | 873 * |
873 * Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). | 874 * Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). |
874 * | 875 * |
875 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 876 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
876 * @param patientID The Patient ID of interest. | 877 * @param patientID The Patient ID of interest. |
877 * @return The NULL string if the patient is non-existent, or a string containing the | 878 * @return The NULL value if the patient is non-existent, or a string containing the |
878 * Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString(). | 879 * Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString(). |
879 **/ | 880 **/ |
880 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupPatient( | 881 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupPatient( |
881 OrthancPluginContext* context, | 882 OrthancPluginContext* context, |
882 const char* patientID) | 883 const char* patientID) |
904 * | 905 * |
905 * Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). | 906 * Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). |
906 * | 907 * |
907 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 908 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
908 * @param studyUID The Study Instance UID of interest. | 909 * @param studyUID The Study Instance UID of interest. |
909 * @return The NULL string if the study is non-existent, or a string containing the | 910 * @return The NULL value if the study is non-existent, or a string containing the |
910 * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). | 911 * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). |
911 **/ | 912 **/ |
912 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudy( | 913 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudy( |
913 OrthancPluginContext* context, | 914 OrthancPluginContext* context, |
914 const char* studyUID) | 915 const char* studyUID) |
936 * | 937 * |
937 * Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). | 938 * Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). |
938 * | 939 * |
939 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 940 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
940 * @param seriesUID The Series Instance UID of interest. | 941 * @param seriesUID The Series Instance UID of interest. |
941 * @return The NULL string if the series is non-existent, or a string containing the | 942 * @return The NULL value if the series is non-existent, or a string containing the |
942 * Orthanc ID of the series. This string must be freed by OrthancPluginFreeString(). | 943 * Orthanc ID of the series. This string must be freed by OrthancPluginFreeString(). |
943 **/ | 944 **/ |
944 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupSeries( | 945 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupSeries( |
945 OrthancPluginContext* context, | 946 OrthancPluginContext* context, |
946 const char* seriesUID) | 947 const char* seriesUID) |
968 * | 969 * |
969 * Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). | 970 * Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). |
970 * | 971 * |
971 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 972 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
972 * @param sopInstanceUID The SOP Instance UID of interest. | 973 * @param sopInstanceUID The SOP Instance UID of interest. |
973 * @return The NULL string if the instance is non-existent, or a string containing the | 974 * @return The NULL value if the instance is non-existent, or a string containing the |
974 * Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString(). | 975 * Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString(). |
975 **/ | 976 **/ |
976 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupInstance( | 977 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupInstance( |
977 OrthancPluginContext* context, | 978 OrthancPluginContext* context, |
978 const char* sopInstanceUID) | 979 const char* sopInstanceUID) |
1111 const char* key; | 1112 const char* key; |
1112 OrthancPluginDicomInstance* instance; | 1113 OrthancPluginDicomInstance* instance; |
1113 } _OrthancPluginAccessDicomInstance; | 1114 } _OrthancPluginAccessDicomInstance; |
1114 | 1115 |
1115 | 1116 |
1117 /** | |
1118 * @brief Get the AET of a DICOM instance. | |
1119 * | |
1120 * This function returns the Application Entity Title (AET) of the | |
1121 * DICOM modality from which a DICOM instance originates. | |
1122 * | |
1123 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1124 * @param instance The instance of interest. | |
1125 * @return The AET if success, NULL if error. | |
1126 **/ | |
1116 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteAet( | 1127 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteAet( |
1117 OrthancPluginContext* context, | 1128 OrthancPluginContext* context, |
1118 OrthancPluginDicomInstance* instance) | 1129 OrthancPluginDicomInstance* instance) |
1119 { | 1130 { |
1120 const char* result; | 1131 const char* result; |
1134 return result; | 1145 return result; |
1135 } | 1146 } |
1136 } | 1147 } |
1137 | 1148 |
1138 | 1149 |
1150 /** | |
1151 * @brief Get the size of a DICOM file. | |
1152 * | |
1153 * This function returns the number of bytes of the given DICOM instance. | |
1154 * | |
1155 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1156 * @param instance The instance of interest. | |
1157 * @return The size of the file, -1 in case of error. | |
1158 **/ | |
1139 ORTHANC_PLUGIN_INLINE int64_t OrthancPluginGetInstanceSize( | 1159 ORTHANC_PLUGIN_INLINE int64_t OrthancPluginGetInstanceSize( |
1140 OrthancPluginContext* context, | 1160 OrthancPluginContext* context, |
1141 OrthancPluginDicomInstance* instance) | 1161 OrthancPluginDicomInstance* instance) |
1142 { | 1162 { |
1143 int64_t size; | 1163 int64_t size; |
1157 return size; | 1177 return size; |
1158 } | 1178 } |
1159 } | 1179 } |
1160 | 1180 |
1161 | 1181 |
1182 /** | |
1183 * @brief Get the data of a DICOM file. | |
1184 * | |
1185 * This function returns a pointer to the content of the given DICOM instance. | |
1186 * | |
1187 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1188 * @param instance The instance of interest. | |
1189 * @return The pointer to the DICOM data, NULL in case of error. | |
1190 **/ | |
1162 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceData( | 1191 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceData( |
1163 OrthancPluginContext* context, | 1192 OrthancPluginContext* context, |
1164 OrthancPluginDicomInstance* instance) | 1193 OrthancPluginDicomInstance* instance) |
1165 { | 1194 { |
1166 const char* result; | 1195 const char* result; |
1180 return result; | 1209 return result; |
1181 } | 1210 } |
1182 } | 1211 } |
1183 | 1212 |
1184 | 1213 |
1214 /** | |
1215 * @brief Get the DICOM tag hierarchy as a JSON file. | |
1216 * | |
1217 * This function returns a pointer to a newly created string | |
1218 * containing a JSON file. This JSON file encodes the tag hierarchy | |
1219 * of the given DICOM instance. | |
1220 * | |
1221 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1222 * @param instance The instance of interest. | |
1223 * @return The NULL value in case of error, or a string containing the JSON file. | |
1224 * This string must be freed by OrthancPluginFreeString(). | |
1225 **/ | |
1185 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceJson( | 1226 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceJson( |
1186 OrthancPluginContext* context, | 1227 OrthancPluginContext* context, |
1187 OrthancPluginDicomInstance* instance) | 1228 OrthancPluginDicomInstance* instance) |
1188 { | 1229 { |
1189 char* result; | 1230 char* result; |
1203 return result; | 1244 return result; |
1204 } | 1245 } |
1205 } | 1246 } |
1206 | 1247 |
1207 | 1248 |
1249 /** | |
1250 * @brief Get the DICOM tag hierarchy as a JSON file (with simplification). | |
1251 * | |
1252 * This function returns a pointer to a newly created string | |
1253 * containing a JSON file. This JSON file encodes the tag hierarchy | |
1254 * of the given DICOM instance. In contrast with | |
1255 * ::OrthancPluginGetInstanceJson(), the returned JSON file is in | |
1256 * its simplified version. | |
1257 * | |
1258 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1259 * @param instance The instance of interest. | |
1260 * @return The NULL value in case of error, or a string containing the JSON file. | |
1261 * This string must be freed by OrthancPluginFreeString(). | |
1262 **/ | |
1208 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceSimplifiedJson( | 1263 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceSimplifiedJson( |
1209 OrthancPluginContext* context, | 1264 OrthancPluginContext* context, |
1210 OrthancPluginDicomInstance* instance) | 1265 OrthancPluginDicomInstance* instance) |
1211 { | 1266 { |
1212 char* result; | 1267 char* result; |
1226 return result; | 1281 return result; |
1227 } | 1282 } |
1228 } | 1283 } |
1229 | 1284 |
1230 | 1285 |
1286 /** | |
1287 * @brief Check whether a DICOM instance is associated with some metadata. | |
1288 * | |
1289 * This function checks whether the DICOM instance of interest is | |
1290 * associated with some metadata. As of Orthanc 0.8.1, in the | |
1291 * callbacks registered by | |
1292 * ::OrthancPluginRegisterOnStoredInstanceCallback(), the only | |
1293 * possibly available metadata are "ReceptionDate", "RemoteAET" and | |
1294 * "IndexInSeries". | |
1295 * | |
1296 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1297 * @param instance The instance of interest. | |
1298 * @param metadata The metadata of interest. | |
1299 * @return 1 if the metadata is present, 0 if it is absent, -1 in case of error. | |
1300 **/ | |
1231 ORTHANC_PLUGIN_INLINE int OrthancPluginHasInstanceMetadata( | 1301 ORTHANC_PLUGIN_INLINE int OrthancPluginHasInstanceMetadata( |
1232 OrthancPluginContext* context, | 1302 OrthancPluginContext* context, |
1233 OrthancPluginDicomInstance* instance, | 1303 OrthancPluginDicomInstance* instance, |
1234 const char* key) | 1304 const char* metadata) |
1235 { | 1305 { |
1236 int64_t result; | 1306 int64_t result; |
1237 | 1307 |
1238 _OrthancPluginAccessDicomInstance params; | 1308 _OrthancPluginAccessDicomInstance params; |
1239 memset(¶ms, 0, sizeof(params)); | 1309 memset(¶ms, 0, sizeof(params)); |
1240 params.resultInt64 = &result; | 1310 params.resultInt64 = &result; |
1241 params.instance = instance; | 1311 params.instance = instance; |
1242 params.key = key; | 1312 params.key = metadata; |
1243 | 1313 |
1244 if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, ¶ms)) | 1314 if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, ¶ms)) |
1245 { | 1315 { |
1246 /* Error */ | 1316 /* Error */ |
1247 return -1; | 1317 return -1; |
1251 return (result != 0); | 1321 return (result != 0); |
1252 } | 1322 } |
1253 } | 1323 } |
1254 | 1324 |
1255 | 1325 |
1326 /** | |
1327 * @brief Get the value of some metadata associated with a given DICOM instance. | |
1328 * | |
1329 * This functions returns the value of some metadata that is associated with the DICOM instance of interest. | |
1330 * Before calling this function, the existence of the metadata must have been checked with | |
1331 * ::OrthancPluginHasInstanceMetadata(). | |
1332 * | |
1333 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1334 * @param instance The instance of interest. | |
1335 * @param metadata The metadata of interest. | |
1336 * @return The metadata value if success, NULL if error. | |
1337 **/ | |
1256 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceMetadata( | 1338 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceMetadata( |
1257 OrthancPluginContext* context, | 1339 OrthancPluginContext* context, |
1258 OrthancPluginDicomInstance* instance, | 1340 OrthancPluginDicomInstance* instance, |
1259 const char* key) | 1341 const char* metadata) |
1260 { | 1342 { |
1261 const char* result; | 1343 const char* result; |
1262 | 1344 |
1263 _OrthancPluginAccessDicomInstance params; | 1345 _OrthancPluginAccessDicomInstance params; |
1264 memset(¶ms, 0, sizeof(params)); | 1346 memset(¶ms, 0, sizeof(params)); |
1265 params.resultString = &result; | 1347 params.resultString = &result; |
1266 params.instance = instance; | 1348 params.instance = instance; |
1267 params.key = key; | 1349 params.key = metadata; |
1268 | 1350 |
1269 if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, ¶ms)) | 1351 if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, ¶ms)) |
1270 { | 1352 { |
1271 /* Error */ | 1353 /* Error */ |
1272 return NULL; | 1354 return NULL; |