123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- openapi: 3.0.0
- info:
- title: 医学计算器 API
- version: 1.0.0
- description: 这个 API 提供了医学计算器的管理和使用功能。
- paths:
- /api/medical-calculators:
- get:
- summary: 获取医学计算器列表
- tags:
- - 医学计算器
- responses:
- '200':
- description: 成功
- content:
- application/json:
- schema:
- type: array
- items:
- $ref: '#/components/schemas/MedicalCalculator'
- example:
- - id: 1
- name: BMI 计算器
- disease_name: 肥胖
- formula: weight / (height * height)
- instructions: 输入体重(kg)和身高(m)来计算 BMI。
- - id: 2
- name: 心脏病风险评估
- disease_name: 心脏病
- formula: (age * 0.2) + (bmi * 0.3) + (blood_pressure * 0.5)
- instructions: 输入年龄、BMI 和血压来评估心脏病风险。
- post:
- summary: 创建新的医学计算器
- tags:
- - 医学计算器
- requestBody:
- required: true
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/MedicalCalculator'
- example:
- name: 糖尿病风险评估
- disease_name: 糖尿病
- formula: (age * 0.2) + (bmi * 0.3) + (blood_sugar * 0.5)
- instructions: 输入年龄、BMI 和血糖水平来评估糖尿病风险。
- responses:
- '201':
- description: 创建成功
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/MedicalCalculator'
- /api/medical-calculators/{id}:
- get:
- summary: 获取特定医学计算器
- tags:
- - 医学计算器
- parameters:
- - name: id
- in: path
- required: true
- schema:
- type: integer
- responses:
- '200':
- description: 成功
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/MedicalCalculator'
- example:
- id: 1
- name: BMI 计算器
- disease_name: 肥胖
- formula: weight / (height * height)
- instructions: 输入体重(kg)和身高(m)来计算 BMI。
- put:
- summary: 更新医学计算器
- tags:
- - 医学计算器
- parameters:
- - name: id
- in: path
- required: true
- schema:
- type: integer
- requestBody:
- required: true
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/MedicalCalculator'
- example:
- name: 更新后的 BMI 计算器
- disease_name: 肥胖
- formula: weight / (height * height)
- instructions: 输入体重(kg)和身高(m)来计算 BMI。结果解释已更新。
- responses:
- '200':
- description: 更新成功
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/MedicalCalculator'
- delete:
- summary: 删除医学计算器
- tags:
- - 医学计算器
- parameters:
- - name: id
- in: path
- required: true
- schema:
- type: integer
- responses:
- '204':
- description: 删除成功
- /api/medical-calculators/{id}/calculate:
- post:
- summary: 计算医学计算器的结果
- description: |
- 使用此端点来执行特定医学计算器的计算。
- 您需要提供计算器ID和所有必要的输入参数。
- tags:
- - 医学计算器
- parameters:
- - name: id
- in: path
- required: true
- schema:
- type: integer
- description: 医学计算器的ID
- example: 1
- requestBody:
- required: true
- content:
- application/json:
- schema:
- type: object
- additionalProperties:
- type: number
- example:
- weight: 70
- height: 1.75
- responses:
- '200':
- description: 计算结果
- content:
- application/json:
- schema:
- type: object
- properties:
- result:
- type: number
- example:
- result: 22.86
- /api/medical-calculators/{id}/questions:
- get:
- summary: 获取指定计算器的问题及选项
- description: |
- 使用此端点来获取特定医学计算器的所有问题及其相关选项。
- 这可以用于在执行计算之前构建用户界面。
- tags:
- - 医学计算器
- parameters:
- - name: id
- in: path
- required: true
- schema:
- type: integer
- description: 医学计算器的ID
- example: 1
- responses:
- '200':
- description: 成功
- content:
- application/json:
- schema:
- type: array
- items:
- $ref: '#/components/schemas/MedicalQuestionWithOptions'
- example:
- - id: 1
- medical_calculator_id: 1
- question: 您的体重是多少?
- variable_name: weight
- type: text
- score: null
- options: []
- - id: 2
- medical_calculator_id: 1
- question: 您的身高是多少?
- variable_name: height
- type: text
- score: null
- options: []
- - id: 3
- medical_calculator_id: 2
- question: 您的年龄范围是?
- variable_name: age_range
- type: radio
- score: null
- options:
- - id: 1
- content: 18-30岁
- score: 1
- - id: 2
- content: 31-50岁
- score: 2
- - id: 3
- content: 51岁以上
- score: 3
- components:
- schemas:
- MedicalCalculator:
- type: object
- properties:
- id:
- type: integer
- name:
- type: string
- disease_name:
- type: string
- formula:
- type: string
- instructions:
- type: string
- required:
- - name
- - disease_name
- - formula
- example:
- id: 1
- name: BMI计算器
- disease_name: 肥胖
- formula: weight / (height * height)
- instructions: 输入您的体重(公斤)和身高(米)来计算BMI。
- MedicalQuestionWithOptions:
- type: object
- properties:
- id:
- type: integer
- medical_calculator_id:
- type: integer
- question:
- type: string
- variable_name:
- type: string
- type:
- type: string
- enum: [text, radio, checkbox]
- score:
- type: string
- options:
- type: array
- items:
- $ref: '#/components/schemas/MedicalOption'
- required:
- - medical_calculator_id
- - question
- - variable_name
- - type
- - options
- example:
- id: 3
- medical_calculator_id: 2
- question: 您的年龄范围是?
- variable_name: age_range
- type: radio
- score: null
- options:
- - id: 1
- content: 18-30岁
- score: 1
- - id: 2
- content: 31-50岁
- score: 2
- - id: 3
- content: 51岁以上
- score: 3
- MedicalOption:
- type: object
- properties:
- id:
- type: integer
- content:
- type: string
- score:
- type: number
- required:
- - content
- - score
- example:
- id: 1
- content: 正常
- score: 0
|