-
Notifications
You must be signed in to change notification settings - Fork 2
Client and Server communication
Thomas Storli edited this page May 4, 2021
·
12 revisions
This is how a successful response is formatted
{
"success": true,
"payload": {
//Payload based on request
}
}
This is how an unsuccessful response is formatted
{
"success": false,
"error": {
"Name": str,
"Message": str,
"Code": int
}
}
- Request type: POST
- Endpoint: /calculate/
Request data:
{
"age": int,
"parity": int,
"gdm": bool,
"congenital": bool,
"stillbirth": bool,
"miscarriage": bool,
"preterm": bool,
"macrosomia": bool,
"height": int,
"weight": int,
"white": bool,
"family_diabetes": bool,
"polycystic": bool,
"blood_pressure_family": bool,
"blood_pressure_not_family": bool,
"diet_not_varied": bool,
"diet_sugar": bool,
"diet_sweets": bool,
"diet_processed_meat": bool,
"diet_whole_grain": bool,
"diet_diary": bool,
"diet_vitamin_d": bool,
"activity_walking_minute": bool,
"activity_vigorous": bool,
"activity_stairs": bool
}
The response from server is based on the criteria found in on risk calculation page.
- "severity" is an integer between 0 - 4
- 0 Low, 1 Increased, 2 Moderate, 3 High, 4 Very High
- "risk_score" is an integer representing the total amount of points added together (no known max) Communication to the server is done by sending requests to various endpoints.
-
/calculate/<lang_code>
- Methods: POST
- Response body:
{
"success": true,
"payload": [
{
"complication": "Gestational Diabetes Mellitus",
"severity": 4,
"severity_str": "High",
"risk_str": ">50 % of pregancies",
"risk_score": 53
},
{
"complication": "Gestational Diabetes Mellitus",
"severity": 4,
"severity_str": "High",
"risk_str": ">50 % of pregancies",
"risk_score": 53
}
]
}
This is how a successful response is formatted. (? means optional)
{
"factors": [
{
"factor": string,
"question": string,
"answertype": string,
"skippable": boolean,
"maxdigits"?: int,
"requirement"?: string,
"subfactors"?: [
{},
{},
{},
]
}
]
}
Requirements should have a syntax like: comparator;value
such as >;0
, =;T
, <=;5
, etc.
Comparator | Value |
---|---|
= |
int or T/F
|
>, <, >=, <= | int |