diff --git a/reference/common/models/daterange.v1.yaml b/reference/common/models/daterange.v1.yaml new file mode 100644 index 00000000..ccb0127f --- /dev/null +++ b/reference/common/models/daterange.v1.yaml @@ -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 diff --git a/reference/common/models/error.v1.yaml b/reference/common/models/error.v1.yaml index 65b4b2a4..6a787da2 100644 --- a/reference/common/models/error.v1.yaml +++ b/reference/common/models/error.v1.yaml @@ -3,10 +3,8 @@ type: object properties: code: type: integer - example: 404 message: type: string - example: 'Requested resources was not found' required: - code - message diff --git a/reference/common/responses/badrequest.v1.yaml b/reference/common/responses/badrequest.v1.yaml index 7247324a..79cb6bed 100644 --- a/reference/common/responses/badrequest.v1.yaml +++ b/reference/common/responses/badrequest.v1.yaml @@ -3,3 +3,6 @@ content: 'application/json': schema: $ref: '../models/error.v1.yaml' + example: + code: 400 + message: 'Bad request' diff --git a/reference/common/responses/forbidden.v1.yaml b/reference/common/responses/forbidden.v1.yaml index c14ae541..47e625d3 100644 --- a/reference/common/responses/forbidden.v1.yaml +++ b/reference/common/responses/forbidden.v1.yaml @@ -3,3 +3,6 @@ content: 'application/json': schema: $ref: '../models/error.v1.yaml' + example: + code: 403 + message: 'Forbidden' diff --git a/reference/common/responses/nocontent.v1.yaml b/reference/common/responses/nocontent.v1.yaml index ece5811d..776adb03 100644 --- a/reference/common/responses/nocontent.v1.yaml +++ b/reference/common/responses/nocontent.v1.yaml @@ -1 +1,8 @@ description: 204 No Content +content: + 'application/json': + schema: + $ref: '../models/error.v1.yaml' + example: + code: 204 + message: 'No Content' diff --git a/reference/common/responses/notfound.v1.yaml b/reference/common/responses/notfound.v1.yaml index fa58f0a9..5902492e 100644 --- a/reference/common/responses/notfound.v1.yaml +++ b/reference/common/responses/notfound.v1.yaml @@ -3,3 +3,6 @@ content: 'application/json': schema: $ref: '../models/error.v1.yaml' + example: + code: 404 + message: 'Not Found' diff --git a/reference/common/responses/servererror.v1.yaml b/reference/common/responses/servererror.v1.yaml index 88dfae11..643aafb9 100644 --- a/reference/common/responses/servererror.v1.yaml +++ b/reference/common/responses/servererror.v1.yaml @@ -3,3 +3,6 @@ content: 'application/json': schema: $ref: '../models/error.v1.yaml' + example: + code: 500 + message: 'Server Error' diff --git a/reference/common/responses/unauthorized.v1.yaml b/reference/common/responses/unauthorized.v1.yaml index 737a092f..9aaae884 100644 --- a/reference/common/responses/unauthorized.v1.yaml +++ b/reference/common/responses/unauthorized.v1.yaml @@ -3,3 +3,6 @@ content: 'application/json': schema: $ref: '../models/error.v1.yaml' + example: + code: 401 + message: 'Unauthorized' diff --git a/reference/data/models/blood/units.v1.yaml b/reference/data/models/blood/units.v1.yaml index 95123045..c099a1ec 100644 --- a/reference/data/models/blood/units.v1.yaml +++ b/reference/data/models/blood/units.v1.yaml @@ -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 diff --git a/reference/data/models/cgmsettings.v1.yaml b/reference/data/models/cgmsettings.v1.yaml index fa8040f3..9a2f2ea3 100644 --- a/reference/data/models/cgmsettings.v1.yaml +++ b/reference/data/models/cgmsettings.v1.yaml @@ -142,10 +142,7 @@ allOf: enum: - cgmSettings units: - type: string - enum: - - mg/dL - - mmol/L + $ref: './blood/units.v1.yaml' required: - type x-tags: diff --git a/reference/data/models/pumpsettings/pumpsettings.v1.yaml b/reference/data/models/pumpsettings/pumpsettings.v1.yaml index 09a8b8f2..c3dff951 100644 --- a/reference/data/models/pumpsettings/pumpsettings.v1.yaml +++ b/reference/data/models/pumpsettings/pumpsettings.v1.yaml @@ -103,10 +103,7 @@ allOf: type: object properties: units: - type: string - enum: - - mg/dL - - mmol/L + $ref: '../blood/units.v1.yaml' required: - units firmwareVersion: @@ -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 diff --git a/reference/export.v1.yaml b/reference/export.v1.yaml index 09c65df3..72e3da1a 100644 --- a/reference/export.v1.yaml +++ b/reference/export.v1.yaml @@ -66,20 +66,89 @@ 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: @@ -87,16 +156,3 @@ components: restrictedToken: $ref: './common/security/tidepoolrestrictedtoken.v1.yaml' - - responses: - BadRequest: - description: 'Bad Request' - - Unauthorized: - description: 'Unauthorized' - - Forbidden: - description: 'Forbidden' - - ServerError: - description: 'Server Error' diff --git a/reference/export/models/glucoseunits.v1.yaml b/reference/export/models/glucoseunits.v1.yaml deleted file mode 100644 index f52d2521..00000000 --- a/reference/export/models/glucoseunits.v1.yaml +++ /dev/null @@ -1,7 +0,0 @@ -title: Export Glucose Units -type: string -enum: - - mmol/L - - mg/dL -default: mmol/L -example: mmol/L diff --git a/reference/export/models/reportdetail.v1.yaml b/reference/export/models/reportdetail.v1.yaml new file mode 100644 index 00000000..7de957bf --- /dev/null +++ b/reference/export/models/reportdetail.v1.yaml @@ -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' diff --git a/reference/export/models/reportrequest.v1.yaml b/reference/export/models/reportrequest.v1.yaml new file mode 100644 index 00000000..9bd566aa --- /dev/null +++ b/reference/export/models/reportrequest.v1.yaml @@ -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 diff --git a/reference/export/models/reporttype.v1.yaml b/reference/export/models/reporttype.v1.yaml new file mode 100644 index 00000000..a4fa2866 --- /dev/null +++ b/reference/export/models/reporttype.v1.yaml @@ -0,0 +1,13 @@ +title: Reports type +type: array +minItems: 1 +maxItems: 5 +items: + type: string + enum: + - daily + - bgLog + - basics + - agp + - settings + - all diff --git a/reference/export/models/reportuser.v1.yaml b/reference/export/models/reportuser.v1.yaml new file mode 100644 index 00000000..e6e9a41d --- /dev/null +++ b/reference/export/models/reportuser.v1.yaml @@ -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' diff --git a/reference/export/parameters/birthday.v1.yaml b/reference/export/parameters/birthday.v1.yaml new file mode 100644 index 00000000..4983cb29 --- /dev/null +++ b/reference/export/parameters/birthday.v1.yaml @@ -0,0 +1,6 @@ +description: >- + Date of birth +name: dob +in: query +schema: + $ref: '../../common/models/birthday.v1.yaml' diff --git a/reference/export/parameters/fullname.v1.yaml b/reference/export/parameters/fullname.v1.yaml new file mode 100644 index 00000000..76a1e496 --- /dev/null +++ b/reference/export/parameters/fullname.v1.yaml @@ -0,0 +1,6 @@ +description: >- + Full name +name: fullName +in: query +schema: + $ref: '../../metadata/models/fullname.v1.yaml' diff --git a/reference/export/parameters/glucoseunits.v1.yaml b/reference/export/parameters/glucoseunits.v1.yaml index 31441f0e..89eaffad 100644 --- a/reference/export/parameters/glucoseunits.v1.yaml +++ b/reference/export/parameters/glucoseunits.v1.yaml @@ -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 diff --git a/reference/export/parameters/reports.v1.yaml b/reference/export/parameters/reports.v1.yaml new file mode 100644 index 00000000..c0a5e0ff --- /dev/null +++ b/reference/export/parameters/reports.v1.yaml @@ -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 diff --git a/reference/export/parameters/timezonename.v1.yaml b/reference/export/parameters/timezonename.v1.yaml new file mode 100644 index 00000000..efbec787 --- /dev/null +++ b/reference/export/parameters/timezonename.v1.yaml @@ -0,0 +1,8 @@ +description: >- + Timezone name +name: tzName +in: query +required: false +schema: + $ref: ../../data/models/timezonename.v1.yaml + default: UTC diff --git a/reference/prescription/models/writableattributes.v1.yaml b/reference/prescription/models/writableattributes.v1.yaml index 7a07b283..48ff042d 100644 --- a/reference/prescription/models/writableattributes.v1.yaml +++ b/reference/prescription/models/writableattributes.v1.yaml @@ -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: