R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

# The User opens the application thus triggering each API: Quality of Life by Waltham Institute and Periodontal Disease by Pedigree. The application requests all available surveys from each API.
# Each API returns the list of surveys.
# The User selects a survey from the response [2], which triggers a request to the source API to get survey questions.
# The API returns a list of pages and questions associated with the survey and a list of styling settings for the related application and platform.
# The Survey SDK applies the settings to the survey.
# The User enters the values and saves the survey, which saves results and executes a request to the API

library(plantuml)
## The package is by default using the online plantuml server
## at http://www.plantuml.com/plantuml/
## If you want to use a different server or the local plantuml server,
## please set the addresss and the port by e.g.
## 
##    plantumlOptions(server_url = 'http://localhost/')
##    plantumlOptions(server_port = '8080')
## 
## If you are using the local plantuml server, you have to start it by
## 
##    server_set("local")
##    server_start()
## 
## and stop it t the end using
## 
##    stop_server()   server_set("local")
uu <- '
caption : Use Case 1: Owner completes a survey
actor "User 1" as owner #9769b8
actor "User 2" as owner #9769b8
participant "Survey SDK" as sdk #fff
participant "Application" as app #fff
skinparam maxMessageSize 350
owner -> app : opens the application
owner <-- sdk : return surveys : e.g QoL and Periodontal Disease
owner -> app : select survey (in user_draft status)
activate sdk
app -> sdk : request pages and questions from the sdk configuration for the selected survey
app <-- sdk : return pages questions as defined in the survey
deactivate sdk
app -> app : display the first page as defined in the survey
owner -> app : click Next to proceed the next page

loop until the last page
owner -> app: enter the values 
owner -> app : click Next to proceed the next page
end
owner -> app : click Submit
app -> sdk : request the score
activate API #red
activate sdk #red
sdk -> API : request the score
API -> API : calculate the score based on the submitted survey values
API -> app : display the score
app -> sdk : return the score
sdk -> sdk : save last score
deactivate API #red
deactivate sdk #red
'

uu <- plantuml(
  uu
)

plot(
  x = uu
)

## [1] "/var/folders/b6/3b4sxsy165v998fnc8tzv3kr0000gn/T//RtmpO25kTP/plantuml.13f70514f27fb.svg"
library(plantuml)
z <- '
caption Use Case 2: Administrator adds rules and publishes the survey
actor "Administrator" as admin #9769b8
participant "Survey SDK" as sdk #fff
participant "Business Logic layer (server-side)" as bll
admin->sdk: authentication request
activate sdk
sdk <- sdk: validate admin`s credentials
admin <-- sdk: authentication response
deactivate sdk
admin -> sdk : get available surveys (in created and creator_draft statuses) and rules
sdk --> admin : return survey id, survey status, rule settings
sdk -> bll : get rules
bll --> sdk : return rule ids and attributes
admin -> sdk : post survey id, rule attribute values, survey status

'
z <- plantuml(
  z
)

plot(
  x = z
)

## [1] "/var/folders/b6/3b4sxsy165v998fnc8tzv3kr0000gn/T//RtmpO25kTP/plantuml.13f7023c9f971.svg"
library(plantuml)
q <- '
caption Use Case 4: User views survey results
footer: here it is assumed that a User may use Survey SDK or any other tools to access survey data at his discretion, for the current MVP implementation of this UC is outside of the scope
actor User as da #ff5f1f
participant "Survey DB" as db #fff
  da -> Application : get survey results by owner id and/or survey id and/or time range
  activate sdk
  Application --> da : return survey data as requested or an HTTP status code
'
q <- plantuml(
  q
)

plot(
  x = q
)

## [1] "/var/folders/b6/3b4sxsy165v998fnc8tzv3kr0000gn/T//RtmpO25kTP/plantuml.13f7021177c12.svg"
library(plantuml)
u <- '
skinparam maxMessageSize 350
caption Use Cases by Roles
footer: here it is assumed that Creator has unlimited provileges and may act as Analyst or Owner (if any pets and surveys are associated with him)
actor Owner as owner
  package "Mars Petcare" {
    actor "Administrator" as admin
    actor "Analyst" as da
  }
  package "Mars Petcare Partners" {
    actor "Researcher" as researcher
  }
  package Survey {
    usecase "Complete" as UC1
    usecase "Create" as UC2
    usecase "Remove" as UC3
    usecase "Edit" as UC4
    usecase "Assigns the survey to applications" as UC5
    usecase "Apply rules to surveys" as UC6
    usecase "Publish" as UC9
    usecase "Unpublish" as UC10
    usecase "Get Survey Data" as UC5
    usecase "View results" as UC7
  }
  owner --> UC1
  researcher --> UC2
  researcher --> UC3
  researcher --> UC4
  researcher --> UC5
  researcher --> UC5
  admin --> UC6
  admin --> UC9
  admin --> UC10
'
u <- plantuml(
  u
)

plot(
  x = u
  )

## [1] "/var/folders/b6/3b4sxsy165v998fnc8tzv3kr0000gn/T//RtmpO25kTP/plantuml.13f70cd292b7.svg"
library(plantuml)
s <- '
state "new" as n
state draft
state complete
state e <<end>>

 
[*] --> n
n --> draft : User has selected a survey in the application
draft --> complete : [all questions answered]
complete -> e

state draft {
  state "unanswered" as ua
  state answered
  ua : User opened the page with a question, but did not input any value and didn`t click Next
  [*] --> ua
  ua --> answered : value input and the User clicked Next
}
draft --> draft : [not all questions answered, user selected the next page]
'


s <- plantuml(
  s
)

plot(
  x = s
)

## [1] "/var/folders/b6/3b4sxsy165v998fnc8tzv3kr0000gn/T//RtmpO25kTP/plantuml.13f70549e32f4.svg"
library(plantuml)
u1 <- '
skinparam maxMessageSize 350
caption Use Cases by Roles
actor User 
  package Survey {
    usecase "Complete" as UC1
    usecase "Create" as UC2
    usecase "Remove" as UC3
    usecase "Edit" as UC4
    usecase "Apply rules to surveys" as UC6
    usecase "Publish" as UC9
    usecase "Unpublish" as UC10
    usecase "Get Survey Data" as UC7
  }
  User --> UC1
  User --> UC2
  User --> UC3
  User --> UC4
  User --> UC6
  User --> UC7
  User --> UC9
  User --> UC10
'
u1 <- plantuml(
  u1
)

plot(
  x = u1
)

## [1] "/var/folders/b6/3b4sxsy165v998fnc8tzv3kr0000gn/T//RtmpO25kTP/plantuml.13f705e235c92.svg"
library(plantuml)
a <- '
start 
: SDK creates a blank copy of the survey 
(at 00:00 GMT, t - times the survey has been completed (t) = 0);
: User opens the Application;
if (t = 1) is (no) then
while (all questions are answered) is (no)
: Application displays the page with the first unanswered question in the Survey;
: User responds to the question;
: Application stores intermittent results locally;
backward : t = t + 1;
endwhile (yes)
: Application submits results to the API (Researcher);
else (yes)
endif
: Application displays the scrore to User;
stop
'
a <- plantuml(
  a
)

plot(
  x = a
)

## [1] "/var/folders/b6/3b4sxsy165v998fnc8tzv3kr0000gn/T//RtmpO25kTP/plantuml.13f706392a586.svg"