Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACK-2540] Reports api #77

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions reference/common/models/daterange.v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
title: Date Range
description: >-
start and end datetime
type: object
properties:
startDate:
$ref: './datetime.v1.yaml'
endDate:
$ref: './datetime.v1.yaml'
required:
- startDate
- endDate
2 changes: 0 additions & 2 deletions reference/common/models/error.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ type: object
properties:
code:
type: integer
example: 404
message:
type: string
example: 'Requested resources was not found'
required:
- code
- message
3 changes: 3 additions & 0 deletions reference/common/responses/badrequest.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ content:
'application/json':
schema:
$ref: '../models/error.v1.yaml'
example:
code: 400
message: 'Bad request'
3 changes: 3 additions & 0 deletions reference/common/responses/forbidden.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ content:
'application/json':
schema:
$ref: '../models/error.v1.yaml'
example:
code: 403
message: 'Forbidden'
7 changes: 7 additions & 0 deletions reference/common/responses/nocontent.v1.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
description: 204 No Content
content:
'application/json':
schema:
$ref: '../models/error.v1.yaml'
example:
code: 204
message: 'No Content'
3 changes: 3 additions & 0 deletions reference/common/responses/notfound.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ content:
'application/json':
schema:
$ref: '../models/error.v1.yaml'
example:
code: 404
message: 'Not Found'
3 changes: 3 additions & 0 deletions reference/common/responses/servererror.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ content:
'application/json':
schema:
$ref: '../models/error.v1.yaml'
example:
code: 500
message: 'Server Error'
3 changes: 3 additions & 0 deletions reference/common/responses/unauthorized.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ content:
'application/json':
schema:
$ref: '../models/error.v1.yaml'
example:
code: 401
message: 'Unauthorized'
1 change: 1 addition & 0 deletions reference/data/models/blood/units.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ title: Blood Unit (mg/dL or mmol/L)
oneOf:
- $ref: './unitsmgdl.v1.yaml'
- $ref: './unitsmmol.v1.yaml'
default: mmol/L
x-tags:
- Data
5 changes: 1 addition & 4 deletions reference/data/models/cgmsettings.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ allOf:
enum:
- cgmSettings
units:
type: string
enum:
- mg/dL
- mmol/L
$ref: './blood/units.v1.yaml'
required:
- type
x-tags:
Expand Down
12 changes: 2 additions & 10 deletions reference/data/models/pumpsettings/pumpsettings.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ allOf:
type: object
properties:
units:
type: string
enum:
- mg/dL
- mmol/L
$ref: '../blood/units.v1.yaml'
required:
- units
firmwareVersion:
Expand Down Expand Up @@ -159,12 +156,7 @@ allOf:
type: object
properties:
bg:
type: string
enum:
- mmol/L
- mmol/l
- mg/dL
- mg/dl
$ref: '../blood/units.v1.yaml'
description: A string value encoding the blood glucose units exposed in the user interface on this insulin pump.
carb:
type: string
Expand Down
92 changes: 74 additions & 18 deletions reference/export.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,93 @@ paths:
schema:
$ref: './export/models/excel.v1.yaml'
'400':
$ref: '#/components/responses/BadRequest'
$ref: './common/responses/badrequest.v1.yaml'
'401':
$ref: '#/components/responses/Unauthorized'
$ref: './common/responses/unauthorized.v1.yaml'
'403':
$ref: '#/components/responses/Forbidden'
$ref: './common/responses/forbidden.v1.yaml'
'500':
$ref: '#/components/responses/ServerError'
$ref: './common/responses/servererror.v1.yaml'

security:
- sessionToken: []
- restrictedToken: []
tags:
- Export
- Internal

'/export/report/{userId}':
parameters:
- $ref: './common/parameters/tidepooluserid.yaml'
get:
operationId: WebExportUserReport
summary: Export user report from webapp
description: >-
User report exported in with the requested options.
Either a Tidepool session token, or a restricted token must be supplied.
parameters:
- $ref: './export/parameters/reports.v1.yaml'
- $ref: './export/parameters/birthday.v1.yaml'
- $ref: './export/parameters/fullname.v1.yaml'
- $ref: './export/parameters/timezonename.v1.yaml'
- $ref: './export/parameters/glucoseunits.v1.yaml'
responses:
'200':
description: A PDF report for the given user
content:
application/pdf:
schema:
type: string
format: binary
'400':
$ref: './common/responses/badrequest.v1.yaml'
'401':
$ref: './common/responses/unauthorized.v1.yaml'
'403':
$ref: './common/responses/forbidden.v1.yaml'
'500':
$ref: './common/responses/servererror.v1.yaml'
security:
- sessionToken: []
- restrictedToken: []
tags:
- Export
- Internal
post:
operationId: ExportUserReport
summary: Export user report
description: >-
Export user report called from
requestBody:
content:
application/json:
schema:
$ref: ./export/models/reportrequest.v1.yaml
responses:
'200':
description: A PDF report for the given user
content:
application/pdf:
schema:
type: string
format: binary
'400':
$ref: './common/responses/badrequest.v1.yaml'
'401':
$ref: './common/responses/unauthorized.v1.yaml'
'403':
$ref: './common/responses/forbidden.v1.yaml'
'500':
$ref: './common/responses/servererror.v1.yaml'
security:
- sessionToken: []
- restrictedToken: []
tags:
- Export
- Internal
components:
securitySchemes:
sessionToken:
$ref: './common/security/tidepoolsessiontoken.v1.yaml'

restrictedToken:
$ref: './common/security/tidepoolrestrictedtoken.v1.yaml'

responses:
BadRequest:
description: 'Bad Request'

Unauthorized:
description: 'Unauthorized'

Forbidden:
description: 'Forbidden'

ServerError:
description: 'Server Error'
7 changes: 0 additions & 7 deletions reference/export/models/glucoseunits.v1.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions reference/export/models/reportdetail.v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
title: Report details
description: >-
Report details
type: object
properties:
reports:
$ref: ./reporttype.v1.yaml
default:
- all
tzName:
$ref: ../../data/models/timezonename.v1.yaml
default: UTC
bgUnits:
$ref: ../../data/models/blood/units.v1.yaml
default: mmol/L
startDate:
$ref: ../../common/models/datetime.v1.yaml
endDate:
$ref: ../../common/models/datetime.v1.yaml
example:
reports:
- daily
- basics
- settings
tzName: 'NZ'
bgUnits: mmol/L
startDate: '2022-02-06T02:37:46Z'
endDate: '2022-03-06T02:37:46Z'
10 changes: 10 additions & 0 deletions reference/export/models/reportrequest.v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: New Report
description: >-
User report
type: object
required: [userDetails]
properties:
reportDetails:
$ref: ./reportdetail.v1.yaml
userDetails:
$ref: ./reportuser.v1.yaml
13 changes: 13 additions & 0 deletions reference/export/models/reporttype.v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title: Reports type
type: array
minItems: 1
maxItems: 5
items:
type: string
enum:
- daily
- bgLog
- basics
- agp
- settings
- all
16 changes: 16 additions & 0 deletions reference/export/models/reportuser.v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: Report user
description: >-
Report user
type: object
required: [fullName, mrn, dob]
properties:
fullName:
$ref: ../../metadata/models/fullname.v1.yaml
mrn:
$ref: ../../metadata/models/mrn.v1.yaml
dob:
$ref: ../../common/models/birthday.v1.yaml
example:
fullName: User Name'
mrn: 'mrn123'
dob: '1999-04-01'
6 changes: 6 additions & 0 deletions reference/export/parameters/birthday.v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: >-
Date of birth
name: dob
in: query
schema:
$ref: '../../common/models/birthday.v1.yaml'
6 changes: 6 additions & 0 deletions reference/export/parameters/fullname.v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: >-
Full name
name: fullName
in: query
schema:
$ref: '../../metadata/models/fullname.v1.yaml'
5 changes: 3 additions & 2 deletions reference/export/parameters/glucoseunits.v1.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
description: >-
Glucose units of the exported data
Glucose units
name: bgUnits
in: query
schema:
$ref: '../models/glucoseunits.v1.yaml'
$ref: '../../data/models/blood/units.v1.yaml'
default: mmol/L
11 changes: 11 additions & 0 deletions reference/export/parameters/reports.v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: >-
Report Type. The type of report(s) to produce.
It can be a single value like `/export/report/userid?reports=apg` or a comma separated list like `/export/report/userid?reports=agp,daily,basics`.
name: reports
in: query
required: false
style: form
explode: false
schema:
$ref: '../models/reporttype.v1.yaml'
default: all
8 changes: 8 additions & 0 deletions reference/export/parameters/timezonename.v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
description: >-
Timezone name
name: tzName
in: query
required: false
schema:
$ref: ../../data/models/timezonename.v1.yaml
default: UTC
2 changes: 1 addition & 1 deletion reference/prescription/models/writableattributes.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ properties:
birthday:
$ref: ../../common/models/birthday.v1.yaml
mrn:
type: string
$ref: ../../metadata/models/mrn.v1.yaml
email:
$ref: ../../common/models/emailaddress.v1.yaml
sex:
Expand Down
Loading