SafePlaces Discreet <=> Duration Translation Service
Overview
The SafePaths mobile application collects points data in discreet format (one point every five minutes) while the SafePlaces contact tracing tool displays the same points data in duration format (see below). We need a centralized location to handle translation between the two formats .
Discreet Format
[
{
"id": 21,
"longitude": 14.91328448,
"latitude": 41.24060321,
"time": "2020-05-30T18:25:00.511Z"
},
{
"id": 22,
"longitude": 14.91328448,
"latitude": 41.24060321,
"time": "2020-05-30T18:30:00.511Z"
},
{
"id": 23,
"longitude": 14.91328448,
"latitude": 41.24060321,
"time": "2020-05-30T18:35:00.511Z"
}
]
Duration Format
{
"discreetPointIDs": [21, 22, 23],
"longitude": 14.91328448,
"latitude": 41.24060321,
"time": "2020-05-30T18:25:00.511Z",
"duration": 15
}
Database Implications
All points data will be stored in the points
table in discreet format.
Service Endpoints
POST /case/points
The SafePlaces web client will utilize this endpoint to retrieve all points associated with a case. The points data associated with the case will be read from the existing private database, translated in memory to duration format, and returned to the web client.
Sample Request Payload
{
"caseId": 1
}
Sample Response Payload
POST /cases/points
The SafePlaces web client will utilize this endpoint to retrieve all points associated with the cases provided. The points data associated with the cases will be read from the existing private database, translated in memory to duration format, and returned to the web client.
Sample Request Payload
Sample Response Payload
POST /case/points/ingest
The SafePlaces web application will utilize this endpoint to retrieve points uploaded by a user from the SafePaths mobile app within the context of an ongoing contact tracing interview. The SafePlaces web application will provide the API with an access code and case ID. The API will query the public ingest database for points of concern (in discreet format) that are associated with the access code. The points of concern will then be associated with the case having an ID that matches the caseID
request param and persisted (in discreet format) in the private database. The points will be translated to duration format in memory and returned to the SafePlaces web application in the response payload.
Sample Request Payload
Sample Response Payload
POST /case/point
The SafePlaces web client will call this endpoint when attempting to create a new point of concern. The points data in the request payload will be translated from duration format to discreet format before being persisted in the database. The new point of concern will be returned to the client in duration format.
Sample Request Payload
Sample Response Payload
PATCH /case/point
The SafePlaces web client will call this endpoint when attempting to update an existing concern point. Concern points with ids matching the discreetPointIds
in the request payload will be deleted from the private database. The rest of the data in the payload will be translated from duration format to discreet format and saved to the private database. The newly created points data will be represented in duration format in the response payload.
Sample Request Payload
Sample Response Payload
POST /case/point/delete
This SafePlaces web client will call this endpoint when attempting to remove a concern point from the case. The API will locate the points of concern corresponding with the discreetPointIds
in the request payload in the database and delete them.
Sample Request Payload
Sample Response