diff OrthancFramework/Sources/Enumerations.cpp @ 4399:80fd140b12ba

New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Dec 2020 12:21:03 +0100
parents b002f9abe802
children d9473bd5ed43
line wrap: on
line diff
--- a/OrthancFramework/Sources/Enumerations.cpp	Tue Dec 22 09:39:06 2020 +0100
+++ b/OrthancFramework/Sources/Enumerations.cpp	Wed Dec 23 12:21:03 2020 +0100
@@ -2282,6 +2282,97 @@
 
     LOG(INFO) << "Default encoding for DICOM was changed to: " << name;
   }
+
+
+  const char* GetResourceTypeText(ResourceType type,
+                                  bool isPlural,
+                                  bool isUpperCase)
+  {
+    if (isPlural && !isUpperCase)
+    {
+      switch (type)
+      {
+        case ResourceType_Patient:
+          return "patients";
+
+        case ResourceType_Study:
+          return "studies";
+
+        case ResourceType_Series:
+          return "series";
+
+        case ResourceType_Instance:
+          return "instances";
+      
+        default:
+          throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
+    else if (isPlural && isUpperCase)
+    {
+      switch (type)
+      {
+        case ResourceType_Patient:
+          return "Patients";
+
+        case ResourceType_Study:
+          return "Studies";
+
+        case ResourceType_Series:
+          return "Series";
+
+        case ResourceType_Instance:
+          return "Instances";
+      
+        default:
+          throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
+    else if (!isPlural && !isUpperCase)
+    {
+      switch (type)
+      {
+        case ResourceType_Patient:
+          return "patient";
+
+        case ResourceType_Study:
+          return "study";
+
+        case ResourceType_Series:
+          return "series";
+
+        case ResourceType_Instance:
+          return "instance";
+      
+        default:
+          throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
+    else if (!isPlural && isUpperCase)
+    {
+      switch (type)
+      {
+        case ResourceType_Patient:
+          return "Patient";
+
+        case ResourceType_Study:
+          return "Study";
+
+        case ResourceType_Series:
+          return "Series";
+
+        case ResourceType_Instance:
+          return "Instance";
+      
+        default:
+          throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
+    else
+    {
+      throw OrthancException(ErrorCode_InternalError);
+    }
+  }
 }