openapi.yaml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. openapi: 3.0.0
  2. info:
  3. title: 医学计算器 API
  4. version: 1.0.0
  5. description: 这个 API 提供了医学计算器的管理和使用功能。
  6. paths:
  7. /api/medical-calculators:
  8. get:
  9. summary: 获取医学计算器列表
  10. tags:
  11. - 医学计算器
  12. responses:
  13. '200':
  14. description: 成功
  15. content:
  16. application/json:
  17. schema:
  18. type: array
  19. items:
  20. $ref: '#/components/schemas/MedicalCalculator'
  21. example:
  22. - id: 1
  23. name: BMI 计算器
  24. disease_name: 肥胖
  25. formula: weight / (height * height)
  26. instructions: 输入体重(kg)和身高(m)来计算 BMI。
  27. - id: 2
  28. name: 心脏病风险评估
  29. disease_name: 心脏病
  30. formula: (age * 0.2) + (bmi * 0.3) + (blood_pressure * 0.5)
  31. instructions: 输入年龄、BMI 和血压来评估心脏病风险。
  32. post:
  33. summary: 创建新的医学计算器
  34. tags:
  35. - 医学计算器
  36. requestBody:
  37. required: true
  38. content:
  39. application/json:
  40. schema:
  41. $ref: '#/components/schemas/MedicalCalculator'
  42. example:
  43. name: 糖尿病风险评估
  44. disease_name: 糖尿病
  45. formula: (age * 0.2) + (bmi * 0.3) + (blood_sugar * 0.5)
  46. instructions: 输入年龄、BMI 和血糖水平来评估糖尿病风险。
  47. responses:
  48. '201':
  49. description: 创建成功
  50. content:
  51. application/json:
  52. schema:
  53. $ref: '#/components/schemas/MedicalCalculator'
  54. /api/medical-calculators/{id}:
  55. get:
  56. summary: 获取特定医学计算器
  57. tags:
  58. - 医学计算器
  59. parameters:
  60. - name: id
  61. in: path
  62. required: true
  63. schema:
  64. type: integer
  65. responses:
  66. '200':
  67. description: 成功
  68. content:
  69. application/json:
  70. schema:
  71. $ref: '#/components/schemas/MedicalCalculator'
  72. example:
  73. id: 1
  74. name: BMI 计算器
  75. disease_name: 肥胖
  76. formula: weight / (height * height)
  77. instructions: 输入体重(kg)和身高(m)来计算 BMI。
  78. put:
  79. summary: 更新医学计算器
  80. tags:
  81. - 医学计算器
  82. parameters:
  83. - name: id
  84. in: path
  85. required: true
  86. schema:
  87. type: integer
  88. requestBody:
  89. required: true
  90. content:
  91. application/json:
  92. schema:
  93. $ref: '#/components/schemas/MedicalCalculator'
  94. example:
  95. name: 更新后的 BMI 计算器
  96. disease_name: 肥胖
  97. formula: weight / (height * height)
  98. instructions: 输入体重(kg)和身高(m)来计算 BMI。结果解释已更新。
  99. responses:
  100. '200':
  101. description: 更新成功
  102. content:
  103. application/json:
  104. schema:
  105. $ref: '#/components/schemas/MedicalCalculator'
  106. delete:
  107. summary: 删除医学计算器
  108. tags:
  109. - 医学计算器
  110. parameters:
  111. - name: id
  112. in: path
  113. required: true
  114. schema:
  115. type: integer
  116. responses:
  117. '204':
  118. description: 删除成功
  119. /api/medical-calculators/{id}/calculate:
  120. post:
  121. summary: 计算医学计算器的结果
  122. description: |
  123. 使用此端点来执行特定医学计算器的计算。
  124. 您需要提供计算器ID和所有必要的输入参数。
  125. tags:
  126. - 医学计算器
  127. parameters:
  128. - name: id
  129. in: path
  130. required: true
  131. schema:
  132. type: integer
  133. description: 医学计算器的ID
  134. example: 1
  135. requestBody:
  136. required: true
  137. content:
  138. application/json:
  139. schema:
  140. type: object
  141. additionalProperties:
  142. type: number
  143. example:
  144. weight: 70
  145. height: 1.75
  146. responses:
  147. '200':
  148. description: 计算结果
  149. content:
  150. application/json:
  151. schema:
  152. type: object
  153. properties:
  154. result:
  155. type: number
  156. example:
  157. result: 22.86
  158. /api/medical-calculators/{id}/questions:
  159. get:
  160. summary: 获取指定计算器的问题及选项
  161. description: |
  162. 使用此端点来获取特定医学计算器的所有问题及其相关选项。
  163. 这可以用于在执行计算之前构建用户界面。
  164. tags:
  165. - 医学计算器
  166. parameters:
  167. - name: id
  168. in: path
  169. required: true
  170. schema:
  171. type: integer
  172. description: 医学计算器的ID
  173. example: 1
  174. responses:
  175. '200':
  176. description: 成功
  177. content:
  178. application/json:
  179. schema:
  180. type: array
  181. items:
  182. $ref: '#/components/schemas/MedicalQuestionWithOptions'
  183. example:
  184. - id: 1
  185. medical_calculator_id: 1
  186. question: 您的体重是多少?
  187. variable_name: weight
  188. type: text
  189. score: null
  190. options: []
  191. - id: 2
  192. medical_calculator_id: 1
  193. question: 您的身高是多少?
  194. variable_name: height
  195. type: text
  196. score: null
  197. options: []
  198. - id: 3
  199. medical_calculator_id: 2
  200. question: 您的年龄范围是?
  201. variable_name: age_range
  202. type: radio
  203. score: null
  204. options:
  205. - id: 1
  206. content: 18-30岁
  207. score: 1
  208. - id: 2
  209. content: 31-50岁
  210. score: 2
  211. - id: 3
  212. content: 51岁以上
  213. score: 3
  214. components:
  215. schemas:
  216. MedicalCalculator:
  217. type: object
  218. properties:
  219. id:
  220. type: integer
  221. name:
  222. type: string
  223. disease_name:
  224. type: string
  225. formula:
  226. type: string
  227. instructions:
  228. type: string
  229. required:
  230. - name
  231. - disease_name
  232. - formula
  233. example:
  234. id: 1
  235. name: BMI计算器
  236. disease_name: 肥胖
  237. formula: weight / (height * height)
  238. instructions: 输入您的体重(公斤)和身高(米)来计算BMI。
  239. MedicalQuestionWithOptions:
  240. type: object
  241. properties:
  242. id:
  243. type: integer
  244. medical_calculator_id:
  245. type: integer
  246. question:
  247. type: string
  248. variable_name:
  249. type: string
  250. type:
  251. type: string
  252. enum: [text, radio, checkbox]
  253. score:
  254. type: string
  255. options:
  256. type: array
  257. items:
  258. $ref: '#/components/schemas/MedicalOption'
  259. required:
  260. - medical_calculator_id
  261. - question
  262. - variable_name
  263. - type
  264. - options
  265. example:
  266. id: 3
  267. medical_calculator_id: 2
  268. question: 您的年龄范围是?
  269. variable_name: age_range
  270. type: radio
  271. score: null
  272. options:
  273. - id: 1
  274. content: 18-30岁
  275. score: 1
  276. - id: 2
  277. content: 31-50岁
  278. score: 2
  279. - id: 3
  280. content: 51岁以上
  281. score: 3
  282. MedicalOption:
  283. type: object
  284. properties:
  285. id:
  286. type: integer
  287. content:
  288. type: string
  289. score:
  290. type: number
  291. required:
  292. - content
  293. - score
  294. example:
  295. id: 1
  296. content: 正常
  297. score: 0