diff --git a/.github/codeql/codeql-analysis.yml b/.github/codeql/codeql-analysis.yml new file mode 100644 index 0000000..b04a1dc --- /dev/null +++ b/.github/codeql/codeql-analysis.yml @@ -0,0 +1,46 @@ + + +name: "CodeQL" + +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + # workflow_dispatch: + +jobs: + analyze-codeql: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ["typescript"] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + config-file: ./.github/codeql/codeql-config.yml + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..78cb6a8 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,51 @@ +change-template: "* $TITLE (#$NUMBER) by @$AUTHOR" +name-template: '$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: '⚑ Breaking Changes' + labels: + - 'breaking-change' + - title: '🌟New features and non-breaking changes' + labels: + - 'major' + - 'feature' + - title: '🌟 Minor Changes' + labels: + - 'enhancement' + - title: 'πŸ“œ Documentation updates' + labels: + - 'documentation' + - title: 'πŸ› Bug and hot fixes' + labels: + - 'bug' + - 'fix' + - title: 'πŸš’ Deprecations' + labels: + - 'deprecated' + - title: 'πŸ”§ Maintenance' + labels: + - 'internal' + - 'dependencies' +exclude-labels: + - 'skip-changelog' +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: major +template: | + ## Summary + + ## Changes + + $CHANGES + + ## This release was made possible by the following contributors: + + $CONTRIBUTORS diff --git a/.github/workflows/aha-prod-ci-cd.yml b/.github/workflows/aha-prod-ci-cd.yml new file mode 100644 index 0000000..90c7455 --- /dev/null +++ b/.github/workflows/aha-prod-ci-cd.yml @@ -0,0 +1,136 @@ +name: AHA-PROD-CI-CD + +# Controls when the workflow will run +on: + # Triggers the workflow on push events but only for the develop branch + workflow_dispatch: + inputs: + Tag_name: + description: Tag name of your release(please include "v" if needed) + required: true + +jobs: + + + Github-ECR-Tag-Check: + runs-on: ubuntu-latest + + steps: + - name: check tag + uses: mukunku/tag-exists-action@v1.2.0 + id: checkTag + with: + tag: ${{ github.event.inputs.Tag_name }} + + - name: Get release + if: ${{ steps.checkTag.outputs.exists == 'true' }} + id: result_release + uses: cardinalby/git-get-release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }} + with: + tag: ${{ github.event.inputs.Tag_name }} + repo: REAN-Foundation/awards-service + + - name: Configure AWS credentials + if: ${{ steps.checkTag.outputs.exists == 'true' }} + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Get ECR Image Tag + if: ${{ steps.checkTag.outputs.exists == 'true' }} + id: imageidvar + run: | + image_tag+=${{ steps.result_release.outputs.tag_name }} && image_tag+=_ && image_tag+=${{ steps.result_release.outputs.id }} + echo "imagetag_value=$(aws ecr-public describe-image-tags --repository-name awards-service --region us-east-1 --query "imageTagDetails[?imageTag=='$image_tag'].imageTag" --output text)" >> $GITHUB_OUTPUT + + - name: ECR Image and Github Tag Check + run: | + if [[ ${{ steps.checkTag.outputs.exists }} == 'false' ]]; then exit 1; fi + if [[ -z "${{ steps.imageidvar.outputs.imagetag_value }}" ]]; then exit 1; fi + + outputs: + release_name: ${{ steps.result_release.outputs.tag_name }} + release_id: ${{ steps.result_release.outputs.id }} + + + + Deploy-ECS: + needs: Github-ECR-Tag-Check + environment: aha-prod + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Get release + id: result_release + uses: cardinalby/git-get-release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }} + with: + tag: ${{ github.event.inputs.Tag_name }} + repo: REAN-Foundation/awards-service + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Amazon ECR + run: | + aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} \ + --query taskDefinition > task-definition.json + + - name: New image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: default + image: public.ecr.aws/i9y2d4u3/awards-service:${{ needs.Github-ECR-Tag-Check.outputs.release_name }}_${{ needs.Github-ECR-Tag-Check.outputs.release_id }} + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + wait-for-service-stability: true + + - name: Task Definition Variable + id: taskdefintionvar + shell: bash + run: | + echo "task_definition_arn=$(aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} | jq '.[] | .taskDefinitionArn')" >> $GITHUB_OUTPUT + + - name: Task Defintion ARN + run: | + echo "Task Defintion: ${{ steps.taskdefintionvar.outputs.task_definition_arn }}" + + - name: Deploy Amazon ECS task definition using Duplo API + uses: fjogeleit/http-request-action@master + with: + url: 'https://reanfoundation.duplocloud.net/subscriptions/${{ secrets.DUPLO_ID }}/UpdateEcsService' + method: 'POST' + data: '{"TaskDefinition":${{ steps.taskdefintionvar.outputs.task_definition_arn }},"Name": "${{ secrets.SERVICE_NAME }}","Replicas":1, "HealthCheckGracePeriodSeconds": 1200, "DnsPrfx": ""}' + bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }} diff --git a/.github/workflows/aha-uat-ci-cd.yml b/.github/workflows/aha-uat-ci-cd.yml new file mode 100644 index 0000000..bd8f32b --- /dev/null +++ b/.github/workflows/aha-uat-ci-cd.yml @@ -0,0 +1,141 @@ +name: AHA-UAT-CI-CD + +# Controls when the workflow will run +on: + # Triggers the workflow on push events but only for the develop branch + workflow_dispatch: + inputs: + Tag_name: + description: Tag name of your release(please include "v") + required: true + +jobs: + + CodeScan-ESLint: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Lint Code Base + uses: github/super-linter@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LINTER_RULES_PATH: / + TYPESCRIPT_ES_CONFIG_FILE: .eslintrc.json + VALIDATE_TYPESCRIPT_ES: true + + + Github-ECR-Tag-Check: + runs-on: ubuntu-latest + steps: + - name: check tag + uses: mukunku/tag-exists-action@v1.2.0 + id: checkTag + with: + tag: ${{ github.event.inputs.Tag_name }} + + - name: Get release + if: ${{ steps.checkTag.outputs.exists == 'true' }} + id: result_release + uses: cardinalby/git-get-release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }} + with: + tag: ${{ github.event.inputs.Tag_name }} + repo: REAN-Foundation/awards-service + + - name: Configure AWS credentials + if: ${{ steps.checkTag.outputs.exists == 'true' }} + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Get ECR Image Tag + if: ${{ steps.checkTag.outputs.exists == 'true' }} + id: imageidvar + run: | + image_tag+=${{ steps.result_release.outputs.tag_name }} && image_tag+=_ && image_tag+=${{ steps.result_release.outputs.id }} + echo "imagetag_value=$(aws ecr-public describe-image-tags --repository-name awards-service --region us-east-1 --query "imageTagDetails[?imageTag=='$image_tag'].imageTag" --output text)" >> $GITHUB_OUTPUT + + - name: ECR Image and Github Tag Check + run: | + if [[ ${{ steps.checkTag.outputs.exists }} == 'false' ]]; then exit 1; fi + if [[ -z "${{ steps.imageidvar.outputs.imagetag_value }}" ]]; then exit 1; fi + + outputs: + release_name: ${{ steps.result_release.outputs.tag_name }} + release_id: ${{ steps.result_release.outputs.id }} + + Deploy-ECS: + needs: Github-ECR-Tag-Check + environment: aha-uat + runs-on: ubuntu-latest + + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Amazon ECR + run: | + aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} \ + --query taskDefinition > task-definition.json + + - name: New image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: default + image: public.ecr.aws/i9y2d4u3/awards-service:${{ needs.Github-ECR-Tag-Check.outputs.release_name }}_${{ needs.Github-ECR-Tag-Check.outputs.release_id }} + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + wait-for-service-stability: true + + - name: Task Definition Variable + id: taskdefintionvar + shell: bash + run: | + echo "task_definition_arn=$(aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} | jq '.[] | .taskDefinitionArn')" >> $GITHUB_OUTPUT + + - name: Task Defintion ARN + run: | + echo "Task Defintion: ${{ steps.taskdefintionvar.outputs.task_definition_arn }}" + + - name: Deploy Amazon ECS task definition using Duplo API + uses: fjogeleit/http-request-action@master + with: + url: 'https://reanfoundation.duplocloud.net/subscriptions/${{ secrets.DUPLO_ID }}/UpdateEcsService' + method: 'POST' + data: '{"TaskDefinition":${{ steps.taskdefintionvar.outputs.task_definition_arn }},"Name": "${{ secrets.SERVICE_NAME }}","Replicas":1, "HealthCheckGracePeriodSeconds": 1200, "DnsPrfx": ""}' + bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }} diff --git a/.github/workflows/dev-ci-cd.yml b/.github/workflows/dev-ci-cd.yml new file mode 100644 index 0000000..191fa97 --- /dev/null +++ b/.github/workflows/dev-ci-cd.yml @@ -0,0 +1,120 @@ +# This workflow will trigger pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see : +# https://github.com/actions/labeler + + +name: Dev-CI-CD + +## Controls when the workflow will run +on: + # Triggers the workflow on push events but only for the develop branch + push: + branches: [develop] + +jobs: + Deploy-ECS: + environment: dev + runs-on: ubuntu-latest +# group: Default Larger Runners +# labels: ubuntu-latest-4-cores + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Declare some variables + id: vars + shell: bash + run: | + echo "branch=$(echo ${GITHUB_REF#refs/heads/} | sed "s/\\//-/g")" >> $GITHUB_OUTPUT + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "repo_name=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}')" >> $GITHUB_OUTPUT + + - name: Another step + run: | + echo "Branch: ${{ steps.vars.outputs.branch }}" + echo "Sha: ${{ steps.vars.outputs.sha_short }}" + echo "Repo: ${{ steps.vars.outputs.repo_name }}" + + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v3 + with: + context: ./ + file: ./Dockerfile + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: ${{ steps.login-ecr.outputs.registry }}/awards-service:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + env: + # 7 GiB by default on GitHub, setting this to 16 GiB + NODE_OPTIONS: "--max_old_space_size=8192" + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} \ + --query taskDefinition > task-definition.json + + - name: New image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: default + image: ${{ steps.login-ecr.outputs.registry }}/awards-service:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }} + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + wait-for-service-stability: true + + - name: Task Definition Variable + id: taskdefintionvar + shell: bash + run: | + echo "task_definition_arn=$(aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} | jq '.[] | .taskDefinitionArn')" >> $GITHUB_OUTPUT + + - name: Task Defintion ARN + run: | + echo "Task Defintion: ${{ steps.taskdefintionvar.outputs.task_definition_arn }}" + + + - name: Deploy Amazon ECS task definition using Duplo API + uses: fjogeleit/http-request-action@master + with: + url: 'https://reanfoundation.duplocloud.net/subscriptions/${{ secrets.DUPLO_ID }}/UpdateEcsService' + method: 'POST' + data: '{"TaskDefinition":${{ steps.taskdefintionvar.outputs.task_definition_arn }},"Name": "${{ secrets.SERVICE_NAME }}","Replicas":1, "HealthCheckGracePeriodSeconds": 1200, "DnsPrfx": ""}' + bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }} + diff --git a/.github/workflows/pr-ci-cd.yml b/.github/workflows/pr-ci-cd.yml new file mode 100644 index 0000000..0982f8d --- /dev/null +++ b/.github/workflows/pr-ci-cd.yml @@ -0,0 +1,76 @@ +# This workflow will trigger pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see: +# https://github.com/actions/labeler + +name: PR-CI-CD + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the develop branch + pull_request: + branches: [develop] + +jobs: + CodeScan-ESLint: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + + - name: Lint Code Base + uses: docker://ghcr.io/github/super-linter:latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LINTER_RULES_PATH: / + TYPESCRIPT_ES_CONFIG_FILE: .eslintrc.json + VALIDATE_TYPESCRIPT_ES: true + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: develop + + Build-Docker-Image: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Declare some variables + id: vars + shell: bash + run: | + echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/} | sed "s/\\//-/g")" + echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "::set-output name=repo_name::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}')" + + - name: Another step + run: | + echo "Branch: ${{ steps.vars.outputs.branch }}" + echo "Sha: ${{ steps.vars.outputs.sha_short }}" + echo "Repo: ${{ steps.vars.outputs.repo_name }}" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + builder: ${{ steps.buildx.outputs.name }} + push: false + tags: reancare/services:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml new file mode 100644 index 0000000..e0e31db --- /dev/null +++ b/.github/workflows/prod.yml @@ -0,0 +1,112 @@ +name: PROD-CI-CD + +# Controls when the workflow will run +on: + # Triggers the workflow on push events but only for the develop branch + push: + branches: main + +permissions: + contents: write + +jobs: + + Publish-Release: + runs-on: ubuntu-latest + steps: + - name: New Release Publish + id: new_publish + uses: release-drafter/release-drafter@v5 + with: + publish : true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + outputs: + release_id: ${{ steps.new_publish.outputs.id }} + release_name: ${{ steps.new_publish.outputs.tag_name }} + + + Deploy-ECS: + needs: Publish-Release + environment: prod + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Amazon ECR + id: login-ecr + run: | + aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v3 + with: + context: ./ + file: ./Dockerfile + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: public.ecr.aws/i9y2d4u3/awards-service:${{ needs.Publish-Release.outputs.release_name }}_${{ needs.Publish-Release.outputs.release_id }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} \ + --query taskDefinition > task-definition.json + + - name: New image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: default + image: public.ecr.aws/i9y2d4u3/awards-service:${{ needs.Publish-Release.outputs.release_name }}_${{ needs.Publish-Release.outputs.release_id }} + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + wait-for-service-stability: true + + - name: Task Definition Variable + id: taskdefintionvar + shell: bash + run: | + echo "task_definition_arn=$(aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} | jq '.[] | .taskDefinitionArn')" >> $GITHUB_OUTPUT + + - name: Task Defintion ARN + run: | + echo "Task Defintion: ${{ steps.taskdefintionvar.outputs.task_definition_arn }}" + + - name: Deploy Amazon ECS task definition using Duplo API + uses: fjogeleit/http-request-action@master + with: + url: 'https://reanfoundation.duplocloud.net/subscriptions/${{ secrets.DUPLO_ID }}/UpdateEcsService' + method: 'POST' + data: '{"TaskDefinition":${{ steps.taskdefintionvar.outputs.task_definition_arn }},"Name": "${{ secrets.SERVICE_NAME }}","Replicas":1, "HealthCheckGracePeriodSeconds": 1200, "DnsPrfx": ""}' + bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }} diff --git a/.github/workflows/uat-ci-cd.yml b/.github/workflows/uat-ci-cd.yml new file mode 100644 index 0000000..bad1fc0 --- /dev/null +++ b/.github/workflows/uat-ci-cd.yml @@ -0,0 +1,153 @@ +# This workflow will trigger pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see: +# https://github.com/actions/labeler + +name: UAT-CI-CD + +# Controls when the workflow will run +on: + # Triggers the workflow on push events but only for the develop branch + + pull_request: + branches: main + + push: + branches: + - 'release/**' + - '!release/aha**' # excludes master + +jobs: + CodeScan-ESLint: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Lint Code Base + uses: docker://ghcr.io/github/super-linter:latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LINTER_RULES_PATH: / + TYPESCRIPT_ES_CONFIG_FILE: .eslintrc.json + VALIDATE_TYPESCRIPT_ES: true + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: main + + Label_Checks: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Check labels + if: ${{ github.event_name == 'pull_request' }} + uses: docker://agilepathway/pull-request-label-checker:latest + with: + one_of: major,minor,patch + repo_token: ${{ secrets.GITHUB_TOKEN }} + + Deploy-ECS: + if: ${{ github.event_name == 'push' }} + environment: uat + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Declare some variables + id: vars + shell: bash + run: | + echo "branch=$(echo ${GITHUB_REF#refs/heads/} | sed "s/\\//-/g")" >> $GITHUB_OUTPUT + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "repo_name=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}')" >> $GITHUB_OUTPUT + + - name: Another step + run: | + echo "Branch: ${{ steps.vars.outputs.branch }}" + echo "Sha: ${{ steps.vars.outputs.sha_short }}" + echo "Repo: ${{ steps.vars.outputs.repo_name }}" + + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v3 + with: + context: ./ + file: ./Dockerfile + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: ${{ steps.login-ecr.outputs.registry }}/awards-service:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} \ + --query taskDefinition > task-definition.json + + - name: New image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: default + image: ${{ steps.login-ecr.outputs.registry }}/awards-service:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }} + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + wait-for-service-stability: true + + - name: Task Definition Variable + id: taskdefintionvar + shell: bash + run: | + # echo "::set-output name=task_definition_arn::$(aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} | jq '.[] | .taskDefinitionArn')" + echo "task_definition_arn=$(aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} | jq '.[] | .taskDefinitionArn')" >> $GITHUB_OUTPUT + + - name: Task Defintion ARN + run: | + echo "Task Defintion: ${{ steps.taskdefintionvar.outputs.task_definition_arn }}" + + - name: Deploy Amazon ECS task definition using Duplo API + uses: fjogeleit/http-request-action@master + with: + url: 'https://reanfoundation.duplocloud.net/subscriptions/${{ secrets.DUPLO_ID }}/UpdateEcsService' + method: 'POST' + data: '{"TaskDefinition":${{ steps.taskdefintionvar.outputs.task_definition_arn }},"Name": "${{ secrets.SERVICE_NAME }}","Replicas":1, "HealthCheckGracePeriodSeconds": 1200, "DnsPrfx": ""}' + bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }} \ No newline at end of file diff --git a/assets/images/stock.badge.images/15-Day Healthy Nutrition Choice.png b/assets/images/stock.badge.images/15-Day Healthy Nutrition Choice.png new file mode 100644 index 0000000..9168a3c Binary files /dev/null and b/assets/images/stock.badge.images/15-Day Healthy Nutrition Choice.png differ diff --git a/assets/images/stock.badge.images/15-Day Medication Adherence.png b/assets/images/stock.badge.images/15-Day Medication Adherence.png new file mode 100644 index 0000000..66bd626 Binary files /dev/null and b/assets/images/stock.badge.images/15-Day Medication Adherence.png differ diff --git a/assets/images/stock.badge.images/15-Day Physical Activity.png b/assets/images/stock.badge.images/15-Day Physical Activity.png new file mode 100644 index 0000000..485a760 Binary files /dev/null and b/assets/images/stock.badge.images/15-Day Physical Activity.png differ diff --git a/assets/images/stock.badge.images/15-Day Vitals.png b/assets/images/stock.badge.images/15-Day Vitals.png new file mode 100644 index 0000000..e06b77b Binary files /dev/null and b/assets/images/stock.badge.images/15-Day Vitals.png differ diff --git a/assets/images/stock.badge.images/30-Day Healthy Nutrition Choice.png b/assets/images/stock.badge.images/30-Day Healthy Nutrition Choice.png new file mode 100644 index 0000000..001ae01 Binary files /dev/null and b/assets/images/stock.badge.images/30-Day Healthy Nutrition Choice.png differ diff --git a/assets/images/stock.badge.images/30-Day Medication Adherence.png b/assets/images/stock.badge.images/30-Day Medication Adherence.png new file mode 100644 index 0000000..143cc58 Binary files /dev/null and b/assets/images/stock.badge.images/30-Day Medication Adherence.png differ diff --git a/assets/images/stock.badge.images/30-Day Physical Activity.png b/assets/images/stock.badge.images/30-Day Physical Activity.png new file mode 100644 index 0000000..01affdf Binary files /dev/null and b/assets/images/stock.badge.images/30-Day Physical Activity.png differ diff --git a/assets/images/stock.badge.images/30-Day Vitals.png b/assets/images/stock.badge.images/30-Day Vitals.png new file mode 100644 index 0000000..15d3ea2 Binary files /dev/null and b/assets/images/stock.badge.images/30-Day Vitals.png differ diff --git a/assets/images/stock.badge.images/7-Day Healthy Nutrition Choice.png b/assets/images/stock.badge.images/7-Day Healthy Nutrition Choice.png new file mode 100644 index 0000000..17e8924 Binary files /dev/null and b/assets/images/stock.badge.images/7-Day Healthy Nutrition Choice.png differ diff --git a/assets/images/stock.badge.images/7-Day Medication Adherence.png b/assets/images/stock.badge.images/7-Day Medication Adherence.png new file mode 100644 index 0000000..5c76e0f Binary files /dev/null and b/assets/images/stock.badge.images/7-Day Medication Adherence.png differ diff --git a/assets/images/stock.badge.images/7-Day Physical Activity.png b/assets/images/stock.badge.images/7-Day Physical Activity.png new file mode 100644 index 0000000..c670eb0 Binary files /dev/null and b/assets/images/stock.badge.images/7-Day Physical Activity.png differ diff --git a/assets/images/stock.badge.images/7-Day Vitals.png b/assets/images/stock.badge.images/7-Day Vitals.png new file mode 100644 index 0000000..48e536e Binary files /dev/null and b/assets/images/stock.badge.images/7-Day Vitals.png differ diff --git a/assets/images/stock.badge.images/Mental health 15-Day Badge.png b/assets/images/stock.badge.images/Mental health 15-Day Badge.png new file mode 100644 index 0000000..e1d7603 Binary files /dev/null and b/assets/images/stock.badge.images/Mental health 15-Day Badge.png differ diff --git a/assets/images/stock.badge.images/Mental health 30-Day Badge.png b/assets/images/stock.badge.images/Mental health 30-Day Badge.png new file mode 100644 index 0000000..4fa044c Binary files /dev/null and b/assets/images/stock.badge.images/Mental health 30-Day Badge.png differ diff --git a/assets/images/stock.badge.images/Mental health 7-Day Badge.png b/assets/images/stock.badge.images/Mental health 7-Day Badge.png new file mode 100644 index 0000000..b2c0dc6 Binary files /dev/null and b/assets/images/stock.badge.images/Mental health 7-Day Badge.png differ diff --git a/entrypoint.sh b/entrypoint.sh index b6d4e4c..94fa6f5 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,12 +2,8 @@ # Add config/creds copying here.. aws s3 cp s3://$S3_CONFIG_BUCKET/$S3_CONFIG_PATH/env.config /app/.env -aws s3 cp s3://$S3_CONFIG_BUCKET/$S3_CONFIG_PATH/careplan.config.json /app/careplan.config.json aws s3 cp s3://$S3_CONFIG_BUCKET/$S3_CONFIG_PATH/seed_data/internal.clients.seed.json /app/seed.data/internal.clients.seed.json aws s3 cp s3://$S3_CONFIG_BUCKET/$S3_CONFIG_PATH/seed_data/default.users.seed.json /app/seed.data/default.users.seed.json -# aws s3 cp s3://$S3_CONFIG_BUCKET/$S3_CONFIG_PATH/seed_data/system.admin.seed.json /app/seed.data/system.admin.seed.json -# aws s3 cp s3://$S3_CONFIG_BUCKET/$S3_CONFIG_PATH/gcp_creds/reancareapi-307085d27fd7.json /app/creds/reancareapi-307085d27fd7.json -# aws s3 cp s3://$S3_CONFIG_BUCKET/$S3_CONFIG_PATH/gcp_creds/reancare_firebase_creds.json /app/creds/reancare_firebase_creds.json cd /app # Add any other scripts here... diff --git a/package-lock.json b/package-lock.json index eeeff41..5c76ec9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2077,7 +2077,8 @@ "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true }, "node_modules/array-flatten": { "version": "1.1.1", @@ -2173,9 +2174,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1295.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1295.0.tgz", - "integrity": "sha512-HVYoFCyfiL8gzL/c0lSRTg8tWBLfqAEDfwzGe338ww/LahpmC6C07S71SBBIvtGq3dpd7IwEobAbubZDijrA0Q==", + "version": "2.1363.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1363.0.tgz", + "integrity": "sha512-M2MZZXehgi/EMQv5GlzRkn3TlhoOYHg2cYdSAAqhjv67WaEG50MjaQy5vRvfN1i8XvB24aJFJ5pCrx69TaCaIg==", "dependencies": { "buffer": "4.9.2", "events": "1.1.1", @@ -2186,7 +2187,7 @@ "url": "0.10.3", "util": "^0.12.4", "uuid": "8.0.0", - "xml2js": "0.4.19" + "xml2js": "0.5.0" }, "engines": { "node": ">= 10.0.0" @@ -2994,18 +2995,6 @@ "node": ">= 8" } }, - "node_modules/date-fns": { - "version": "2.29.3", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", - "integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==", - "engines": { - "node": ">=0.11" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/date-fns" - } - }, "node_modules/dateformat": { "version": "4.6.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", @@ -5687,6 +5676,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, "dependencies": { "argparse": "^2.0.1" }, @@ -8567,26 +8557,23 @@ } }, "node_modules/typeorm": { - "version": "0.3.12", - "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.12.tgz", - "integrity": "sha512-sYSxBmCf1nJLLTcYtwqZ+lQIRtLPyUoO93rHTOKk9vJCyT4UfRtU7oRsJvfvKP3nnZTD1hzz2SEy2zwPEN6OyA==", + "version": "0.3.15", + "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.15.tgz", + "integrity": "sha512-R4JSw8QjDP1W+ypeRz/XrCXIqubrLSnNAzJAp9EQSQIPHTv+YmUHZis8g08lOwFpuhqL9m8jkPSz8GWEKlU/ow==", "dependencies": { "@sqltools/formatter": "^1.2.5", "app-root-path": "^3.1.0", "buffer": "^6.0.3", "chalk": "^4.1.2", "cli-highlight": "^2.1.11", - "date-fns": "^2.29.3", "debug": "^4.3.4", "dotenv": "^16.0.3", "glob": "^8.1.0", - "js-yaml": "^4.1.0", "mkdirp": "^2.1.3", "reflect-metadata": "^0.1.13", "sha.js": "^2.4.11", "tslib": "^2.5.0", "uuid": "^9.0.0", - "xml2js": "^0.4.23", "yargs": "^17.6.2" }, "bin": { @@ -8606,8 +8593,8 @@ "better-sqlite3": "^7.1.2 || ^8.0.0", "hdb-pool": "^0.1.6", "ioredis": "^5.0.4", - "mongodb": "^3.6.0", - "mssql": "^7.3.0", + "mongodb": "^5.2.0", + "mssql": "^9.1.1", "mysql2": "^2.2.5 || ^3.0.1", "oracledb": "^5.1.0", "pg": "^8.5.1", @@ -8720,26 +8707,6 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" }, - "node_modules/typeorm/node_modules/xml2js": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", - "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", - "dependencies": { - "sax": ">=0.6.0", - "xmlbuilder": "~11.0.0" - }, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/typeorm/node_modules/xmlbuilder": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", - "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", - "engines": { - "node": ">=4.0" - } - }, "node_modules/typescript": { "version": "4.9.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", @@ -9123,18 +9090,21 @@ } }, "node_modules/xml2js": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", - "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", + "integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==", "dependencies": { "sax": ">=0.6.0", - "xmlbuilder": "~9.0.1" + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" } }, "node_modules/xmlbuilder": { - "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", - "integrity": "sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", "engines": { "node": ">=4.0" } @@ -10769,7 +10739,8 @@ "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true }, "array-flatten": { "version": "1.1.1", @@ -10835,9 +10806,9 @@ "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==" }, "aws-sdk": { - "version": "2.1295.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1295.0.tgz", - "integrity": "sha512-HVYoFCyfiL8gzL/c0lSRTg8tWBLfqAEDfwzGe338ww/LahpmC6C07S71SBBIvtGq3dpd7IwEobAbubZDijrA0Q==", + "version": "2.1363.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1363.0.tgz", + "integrity": "sha512-M2MZZXehgi/EMQv5GlzRkn3TlhoOYHg2cYdSAAqhjv67WaEG50MjaQy5vRvfN1i8XvB24aJFJ5pCrx69TaCaIg==", "requires": { "buffer": "4.9.2", "events": "1.1.1", @@ -10848,7 +10819,7 @@ "url": "0.10.3", "util": "^0.12.4", "uuid": "8.0.0", - "xml2js": "0.4.19" + "xml2js": "0.5.0" }, "dependencies": { "uuid": { @@ -11452,11 +11423,6 @@ "which": "^2.0.1" } }, - "date-fns": { - "version": "2.29.3", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", - "integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==" - }, "dateformat": { "version": "4.6.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", @@ -13478,6 +13444,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, "requires": { "argparse": "^2.0.1" } @@ -15577,26 +15544,23 @@ } }, "typeorm": { - "version": "0.3.12", - "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.12.tgz", - "integrity": "sha512-sYSxBmCf1nJLLTcYtwqZ+lQIRtLPyUoO93rHTOKk9vJCyT4UfRtU7oRsJvfvKP3nnZTD1hzz2SEy2zwPEN6OyA==", + "version": "0.3.15", + "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.15.tgz", + "integrity": "sha512-R4JSw8QjDP1W+ypeRz/XrCXIqubrLSnNAzJAp9EQSQIPHTv+YmUHZis8g08lOwFpuhqL9m8jkPSz8GWEKlU/ow==", "requires": { "@sqltools/formatter": "^1.2.5", "app-root-path": "^3.1.0", "buffer": "^6.0.3", "chalk": "^4.1.2", "cli-highlight": "^2.1.11", - "date-fns": "^2.29.3", "debug": "^4.3.4", "dotenv": "^16.0.3", "glob": "^8.1.0", - "js-yaml": "^4.1.0", "mkdirp": "^2.1.3", "reflect-metadata": "^0.1.13", "sha.js": "^2.4.11", "tslib": "^2.5.0", "uuid": "^9.0.0", - "xml2js": "^0.4.23", "yargs": "^17.6.2" }, "dependencies": { @@ -15618,20 +15582,6 @@ "version": "2.5.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" - }, - "xml2js": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", - "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", - "requires": { - "sax": ">=0.6.0", - "xmlbuilder": "~11.0.0" - } - }, - "xmlbuilder": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", - "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" } } }, @@ -15923,18 +15873,18 @@ } }, "xml2js": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", - "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", + "integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==", "requires": { "sax": ">=0.6.0", - "xmlbuilder": "~9.0.1" + "xmlbuilder": "~11.0.0" } }, "xmlbuilder": { - "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", - "integrity": "sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==" + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" }, "xtend": { "version": "4.0.2", diff --git a/postman/awards service.postman_collection.json b/postman/awards service.postman_collection.json index 85db54f..0113d2e 100644 --- a/postman/awards service.postman_collection.json +++ b/postman/awards service.postman_collection.json @@ -1,10 +1,9 @@ { "info": { - "_postman_id": "5848c7c3-39b2-41cc-835e-ecac30a028da", + "_postman_id": "f1b0e9a5-9223-4ad2-972c-9446fcab3430", "name": "Awards service", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "5510218", - "_collection_link": "https://solar-water-153775.postman.co/workspace/ReanCare~dff1f95d-5219-4d23-8d2c-af292e5a25ae/collection/5510218-5848c7c3-39b2-41cc-835e-ecac30a028da?action=share&creator=5510218&source=collection_link" + "_exporter_id": "15905052" }, "item": [ { @@ -681,7 +680,7 @@ "exec": [ "try {\r", " var jsonRes = pm.response.json();\r", - " pm.environment.set(\"HEALTH_JOURNEY_EVENT_TYPE_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"VITAL_EVENT_TYPE_ID\", jsonRes.Data.id);\r", "}\r", "catch (error) {\r", " console.log(error.message);\r", @@ -734,7 +733,85 @@ ], "body": { "mode": "raw", - "raw": "{\r\n \"Name\": \"Health Journey\",\r\n \"Description\": \"This event is triggered when a patient marks health journey task as done\"\r\n}\r\n" + "raw": "{\r\n \"Name\": \"Vital\",\r\n \"Description\": \"This event is triggered when a patient record vitals regularily\"\r\n}\r\n" + }, + "url": { + "raw": "{{BASE_URL}}/engine/event-types", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "event-types" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Create mental health event type", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"MENTAL_HEALTH_EVENT_TYPE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Event type is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data.Name).to.not.be.null;\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Name\": \"MentalHealth\",\r\n \"Description\": \"This event is triggered when a patient marks medication consumption as taken or missed\"\r\n}\r\n" }, "url": { "raw": "{{BASE_URL}}/engine/event-types", @@ -2100,7 +2177,7 @@ ], "body": { "mode": "raw", - "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"ReferenceId\": \"{{REFERENCE_ID}}\",\r\n \"Prefix\": \"Mr.\",\r\n \"FirstName\": \"Sachin\",\r\n \"LastName\": \"Tendulkar\",\r\n \"Gender\": \"Male\",\r\n \"BirthDate\": \"1974-04-24\",\r\n \"Email\": \"sachin.tendulkar@gmail.com\",\r\n \"CountryCode\": \"+91\",\r\n \"Phone\": \"1234567890\",\r\n \"OnboardingDate\": \"{{TODAY}}\"\r\n}" + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"ReferenceId\": \"{{REFERENCE_ID}}\",\r\n \"Prefix\": \"Mr.\",\r\n \"FirstName\": \"Sachin\",\r\n \"LastName\": \"Tendulkar\",\r\n \"Gender\": \"Male\",\r\n \"BirthDate\": \"1974-04-24\",\r\n \"Email\": \"sachin.tendulkar@gmail.com\",\r\n \"CountryCode\": \"+91\",\r\n \"Phone\": \"1234567891\",\r\n \"OnboardingDate\": \"{{TODAY}}\"\r\n}" }, "url": { "raw": "{{BASE_URL}}/participants", @@ -2656,7 +2733,7 @@ ], "body": { "mode": "raw", - "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Medication 7-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient takes medication regularly for 7 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{MEDICATION_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract medication data\",\r\n \"Description\": \"Extract medication data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract medication data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Medication\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"Any\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting medication data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Medication\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Medication 7-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient takes medication regularly for 7 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{MEDICATION_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract medication data\",\r\n \"Description\": \"Extract medication data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract medication data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Medication\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"All\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting medication data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Medication\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" }, "url": { "raw": "{{BASE_URL}}/engine/schema", @@ -3678,7 +3755,7 @@ ], "body": { "mode": "raw", - "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Medication 15-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient takes medication regularly for 15 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{MEDICATION_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract medication data\",\r\n \"Description\": \"Extract medication data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract medication data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Medication\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"Any\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting medication data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Medication\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Medication 15-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient takes medication regularly for 15 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{MEDICATION_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract medication data\",\r\n \"Description\": \"Extract medication data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract medication data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Medication\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"All\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting medication data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Medication\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" }, "url": { "raw": "{{BASE_URL}}/engine/schema", @@ -4700,7 +4777,7 @@ ], "body": { "mode": "raw", - "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Medication 30-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient takes medication regularly for 30 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{MEDICATION_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract medication data\",\r\n \"Description\": \"Extract medication data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract medication data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Medication\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"Any\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting medication data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Medication\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Medication 30-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient takes medication regularly for 30 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{MEDICATION_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract medication data\",\r\n \"Description\": \"Extract medication data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract medication data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Medication\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"All\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting medication data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Medication\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" }, "url": { "raw": "{{BASE_URL}}/engine/schema", @@ -8716,186 +8793,9846 @@ ] } ] - } - ] - } - ] - }, - { - "name": "Get context for participant / reference id", - "item": [ - { - "name": "Get schema instance by id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "try {\r", - " var jsonRes = pm.response.json();\r", - " pm.environment.set(\"SCHEMA_INSTANCE_ID\", jsonRes.Data.id);\r", - "}\r", - "catch (error) {\r", - " console.log(error.message);\r", - "}\r", - "\r", - "pm.test(\"Request is successfull\", function () {\r", - " pm.response.to.have.status(200);\r", - " var jsonRes = pm.response.json();\r", - " pm.expect(jsonRes.Status).to.eql('success');\r", - "});\r", - "\r", - "pm.test(\"Schema instance is returned\", function () {\r", - " var jsonRes = pm.response.json();\r", - " pm.expect(jsonRes.Data).to.have.property('id');\r", - " pm.expect(jsonRes.Data).to.have.property('Client');\r", - " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", - " pm.expect(jsonRes.Data).to.have.property('Name');\r", - " pm.expect(jsonRes.Data).to.have.property('Description');\r", - " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", - " pm.expect(jsonRes.Data).to.have.property('RootNodeId');\r", - "});\r", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text" - }, - { - "key": "x-api-key", - "value": "{{API_KEY}}", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Medication 7 Day Badge Rule\",\r\n \"Description\": \"This rule represents logical steps involved in awarding a badge for consecutive 7 days.\",\r\n \"ParentNodeId\": \"{{SCHEMA_ROOT_NODE_ID}}\",\r\n \"Action\": {\r\n \"ActionType\": \"{{AWARD_BADGE_EVENT_TYPE}}\",\r\n \"Name\": \"Medication 7-Days Badge\",\r\n \"Description\": \"This rule represents logical steps involved in awarding a badge for consecutive 7 days.\",\r\n \"Params\": {\r\n \"Message\": \"Award medication 7-days badge.\",\r\n \"Action\": \"{{AWARD_BADGE_EVENT_TYPE}}\",\r\n \"NextNodeId\": null,\r\n \"Extra\": {}\r\n }\r\n }\r\n}" - }, - "url": { - "raw": "{{BASE_URL}}/engine/schema-instances/{{SCHEMA_INSTANCE_ID}}", - "host": [ - "{{BASE_URL}}" - ], - "path": [ - "engine", - "schema-instances", - "{{SCHEMA_INSTANCE_ID}}" - ] - }, - "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." - }, - "response": [] - } - ] - }, - { - "name": "Get participant badges", - "item": [ - { - "name": "Get participant by reference id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "try {\r", - " var jsonRes = pm.response.json();\r", - " pm.environment.set(\"PARTICIPANT_ID\", jsonRes.Data.id);\r", - "}\r", - "catch (error) {\r", - " console.log(error.message);\r", - "}\r", - "\r", - "pm.test(\"Request is successfull\", function () {\r", - " pm.response.to.have.status(200);\r", - " var jsonRes = pm.response.json();\r", - " pm.expect(jsonRes.Status).to.eql('success');\r", - "});\r", - "\r", - "pm.test(\"Schema instance is returned\", function () {\r", - " var jsonRes = pm.response.json();\r", - " pm.expect(jsonRes.Data).to.have.property('id');\r", - " pm.expect(jsonRes.Data).to.have.property('Client');\r", - " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", - " pm.expect(jsonRes.Data).to.have.property('Name');\r", - " pm.expect(jsonRes.Data).to.have.property('Description');\r", - " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", - " pm.expect(jsonRes.Data).to.have.property('RootNodeId');\r", - "});\r", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text" - }, - { - "key": "x-api-key", - "value": "{{API_KEY}}", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{BASE_URL}}/participants/by-reference-id/{{REFERENCE_ID}}", - "host": [ - "{{BASE_URL}}" - ], - "path": [ - "participants", - "by-reference-id", - "{{REFERENCE_ID}}" - ] }, - "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." - }, - "response": [] - }, - { - "name": "Get participant badges", - "event": [ + { + "name": "exercise badges", + "item": [ + { + "name": "Create badge category", + "item": [ + { + "name": "Create badge category", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_CATEGORY_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Exercise\",\r\n \"Description\": \"Badge category for exercise related badges\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badge-categories", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badge-categories" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge category by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badge-categories/{{BADGE_CATEGORY_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badge-categories", + "{{BADGE_CATEGORY_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Schema-7-Day exercise badge", + "item": [ + { + "name": "Create badge", + "item": [ + { + "name": "Create badge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"CategoryId\": \"{{BADGE_CATEGORY_ID}}\",\r\n \"Name\": \"7-Day Physical Activity\",\r\n \"Description\": \"Badge awarded doing exercise for 7-days consistently.\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badges", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/{{BADGE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "{{BADGE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Create schema", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"SCHEMA_ROOT_NODE_ID\", jsonRes.Data.RootNode.id);\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.RootNode.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Exercise 7-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient does physical activity(exercise) for 7 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{EXERCISE_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract exercise data\",\r\n \"Description\": \"Extract exercise data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract exercise data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Exercise\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"Any\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting exercise data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Exercise\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "01 - Get root Node - Extract nutrition data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is retrieved\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "02 - Create next node - Calculate Continuity", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_02_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_01_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Calculate continuity\",\r\n \"Description\": \"This execution step involves calculating the continuity for doing exercise consecutively for 7-days.\",\r\n \"Action\": {\r\n \"ActionType\": \"Process-Data\",\r\n \"Name\": \"Calculate Continuity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Exercise\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Extract-Data:Exercise\",\r\n \"DataActionType\": \"Calculate-Continuity\",\r\n \"KeyDataType\": \"Date\",\r\n \"KeyName\": \"Date\",\r\n \"ValueDataType\": \"Boolean\",\r\n \"ValueName\": \"PhysicalActivityQuestionAns\",\r\n \"Value\": true,\r\n \"Operator\": \"Equal\",\r\n \"ContinuityCount\": 7\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Processing records for 7-day exercise choice continuity\",\r\n \"OutputTag\": \"Calculate-Continuity:Exercise\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 01", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_02_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "03 - Create next node - Extract existing badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_03_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_02_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Get existing badges\",\r\n \"Description\": \"Extract existing 7-day exercise badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract-Badges\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Database\",\r\n \"InputTag\": \"Badge\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Exercise\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"7-Day Physical Activity\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 7-day exercise badges\",\r\n \"OutputTag\": \"Extract-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 02", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_03_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_02_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_02_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "04 - Create next node - Compare badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_04_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_03_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 7-day exercise physical activity.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Compare-Data\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 7-day exercise physical activity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Calculate-Continuity:Exercise\",\r\n \"SecondaryInputTag\": \"Extract-Data:Badge\",\r\n \"DataActionType\": \"Find-Range-Difference\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Exercise\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"7-Day Physical Activity\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Comparing badges and get updated badge list for 7-day exercise physical activity badges.\",\r\n \"OutputTag\": \"Compare-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 03", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_04_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_03_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_03_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "05 - Create next node - Store updated badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_05_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_04_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 7-day exercise physical activity badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Store-Data\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 7-day exercise physical activity badges for the participant.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Compare-Data:Badge\",\r\n \"StorageKeys\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Exercise\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"7-Day Physical Activity\"\r\n },\r\n {\r\n \"Key\": \"BadgeId\",\r\n \"Value\": \"{{BADGE_ID}}\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 7-day exercise physical activity badges\",\r\n \"OutputTag\": \"Store-Data:Badge\",\r\n \"DestinationType\": \"Database\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 04", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_05_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_04_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_04_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get schema by Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema/{{SCHEMA_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema", + "{{SCHEMA_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Schema-15-Day exercise badge", + "item": [ + { + "name": "Create badge", + "item": [ + { + "name": "Create badge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"CategoryId\": \"{{BADGE_CATEGORY_ID}}\",\r\n \"Name\": \"15-Day Physical Activity\",\r\n \"Description\": \"Badge awarded doing exercise for 15-days consistently.\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badges", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/{{BADGE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "{{BADGE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Create schema", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"SCHEMA_ROOT_NODE_ID\", jsonRes.Data.RootNode.id);\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.RootNode.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Exercise 15-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient does physical activity(exercise) for 15 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{EXERCISE_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract exercise data\",\r\n \"Description\": \"Extract exercise data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract exercise data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Exercise\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"Any\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting exercise data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Exercise\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "01 - Get root Node - Extract nutrition data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is retrieved\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "02 - Create next node - Calculate Continuity", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_02_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_01_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Calculate continuity\",\r\n \"Description\": \"This execution step involves calculating the continuity for doing exercise consecutively for 15-days.\",\r\n \"Action\": {\r\n \"ActionType\": \"Process-Data\",\r\n \"Name\": \"Calculate Continuity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Exercise\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Extract-Data:Exercise\",\r\n \"DataActionType\": \"Calculate-Continuity\",\r\n \"KeyDataType\": \"Date\",\r\n \"KeyName\": \"Date\",\r\n \"ValueDataType\": \"Boolean\",\r\n \"ValueName\": \"PhysicalActivityQuestionAns\",\r\n \"Value\": true,\r\n \"Operator\": \"Equal\",\r\n \"ContinuityCount\": 15\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Processing records for 15-day exercise choice continuity\",\r\n \"OutputTag\": \"Calculate-Continuity:Exercise\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 01", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_02_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "03 - Create next node - Extract existing badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_03_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_02_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Get existing badges\",\r\n \"Description\": \"Extract existing 15-day exercise badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract-Badges\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Database\",\r\n \"InputTag\": \"Badge\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Exercise\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"15-Day Physical Activity\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 15-day exercise badges\",\r\n \"OutputTag\": \"Extract-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 02", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_03_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_02_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_02_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "04 - Create next node - Compare badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_04_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_03_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 15-day exercise physical activity.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Compare-Data\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 15-day exercise physical activity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Calculate-Continuity:Exercise\",\r\n \"SecondaryInputTag\": \"Extract-Data:Badge\",\r\n \"DataActionType\": \"Find-Range-Difference\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Exercise\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"15-Day Physical Activity\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Comparing badges and get updated badge list for 15-day exercise physical activity badges.\",\r\n \"OutputTag\": \"Compare-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 03", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_04_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_03_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_03_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "05 - Create next node - Store updated badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_05_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_04_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 15-day exercise physical activity badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Store-Data\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 15-day exercise physical activity badges for the participant.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Compare-Data:Badge\",\r\n \"StorageKeys\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Exercise\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"15-Day Physical Activity\"\r\n },\r\n {\r\n \"Key\": \"BadgeId\",\r\n \"Value\": \"{{BADGE_ID}}\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 15-day exercise physical activity badges\",\r\n \"OutputTag\": \"Store-Data:Badge\",\r\n \"DestinationType\": \"Database\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 04", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_05_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_04_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_04_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get schema by Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema/{{SCHEMA_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema", + "{{SCHEMA_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Schema-30-Day exercise badge", + "item": [ + { + "name": "Create badge", + "item": [ + { + "name": "Create badge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"CategoryId\": \"{{BADGE_CATEGORY_ID}}\",\r\n \"Name\": \"30-Day Physical Activity\",\r\n \"Description\": \"Badge awarded doing exercise for 30-days consistently.\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badges", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/{{BADGE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "{{BADGE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Create schema", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"SCHEMA_ROOT_NODE_ID\", jsonRes.Data.RootNode.id);\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.RootNode.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Exercise 30-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient does physical activity(exercise) for 30 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{EXERCISE_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract exercise data\",\r\n \"Description\": \"Extract exercise data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract exercise data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Exercise\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"Any\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting exercise data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Exercise\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "01 - Get root Node - Extract nutrition data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is retrieved\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "02 - Create next node - Calculate Continuity", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_02_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_01_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Calculate continuity\",\r\n \"Description\": \"This execution step involves calculating the continuity for doing exercise consecutively for 30-days.\",\r\n \"Action\": {\r\n \"ActionType\": \"Process-Data\",\r\n \"Name\": \"Calculate Continuity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Exercise\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Extract-Data:Exercise\",\r\n \"DataActionType\": \"Calculate-Continuity\",\r\n \"KeyDataType\": \"Date\",\r\n \"KeyName\": \"Date\",\r\n \"ValueDataType\": \"Boolean\",\r\n \"ValueName\": \"PhysicalActivityQuestionAns\",\r\n \"Value\": true,\r\n \"Operator\": \"Equal\",\r\n \"ContinuityCount\": 30\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Processing records for 30-day exercise choice continuity\",\r\n \"OutputTag\": \"Calculate-Continuity:Exercise\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 01", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_02_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "03 - Create next node - Extract existing badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_03_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_02_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Get existing badges\",\r\n \"Description\": \"Extract existing 30-day exercise badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract-Badges\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Database\",\r\n \"InputTag\": \"Badge\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Exercise\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"30-Day Physical Activity\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 30-day exercise badges\",\r\n \"OutputTag\": \"Extract-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 02", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_03_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_02_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_02_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "04 - Create next node - Compare badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_04_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_03_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 30-day exercise physical activity.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Compare-Data\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 30-day exercise physical activity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Calculate-Continuity:Exercise\",\r\n \"SecondaryInputTag\": \"Extract-Data:Badge\",\r\n \"DataActionType\": \"Find-Range-Difference\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Exercise\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"30-Day Physical Activity\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Comparing badges and get updated badge list for 30-day exercise physical activity badges.\",\r\n \"OutputTag\": \"Compare-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 03", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_04_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_03_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_03_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "05 - Create next node - Store updated badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_05_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_04_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 30-day exercise physical activity badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Store-Data\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 30-day exercise physical activity badges for the participant.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Compare-Data:Badge\",\r\n \"StorageKeys\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Exercise\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"30-Day Physical Activity\"\r\n },\r\n {\r\n \"Key\": \"BadgeId\",\r\n \"Value\": \"{{BADGE_ID}}\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 30-day exercise physical activity badges\",\r\n \"OutputTag\": \"Store-Data:Badge\",\r\n \"DestinationType\": \"Database\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 04", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_05_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_04_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_04_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get schema by Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema/{{SCHEMA_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema", + "{{SCHEMA_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + } + ] + }, + { + "name": "vital badges", + "item": [ + { + "name": "Create badge category", + "item": [ + { + "name": "Create badge category", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_CATEGORY_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Vital\",\r\n \"Description\": \"Badge category for vital related badges\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badge-categories", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badge-categories" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge category by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badge-categories/{{BADGE_CATEGORY_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badge-categories", + "{{BADGE_CATEGORY_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Schema-7-Day vital badge", + "item": [ + { + "name": "Create badge", + "item": [ + { + "name": "Create badge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"CategoryId\": \"{{BADGE_CATEGORY_ID}}\",\r\n \"Name\": \"7-Day Vitals\",\r\n \"Description\": \"Badge awarded for monitoring body vitals for 7-days consistently.\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badges", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/{{BADGE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "{{BADGE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Create schema", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"SCHEMA_ROOT_NODE_ID\", jsonRes.Data.RootNode.id);\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.RootNode.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Vital Monitoring 7-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient monitor body vitals for 7 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{VITAL_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract vital data\",\r\n \"Description\": \"Extract vital data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract vital data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Vital\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"All\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting vital data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Vital\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "01 - Get root Node - Extract nutrition data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is retrieved\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "02 - Create next node - Calculate Continuity", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_02_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_01_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Calculate continuity\",\r\n \"Description\": \"This execution step involves calculating the continuity for monitoring body vital consecutively for 7-days.\",\r\n \"Action\": {\r\n \"ActionType\": \"Process-Data\",\r\n \"Name\": \"Calculate Continuity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Vital\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Extract-Data:Vital\",\r\n \"DataActionType\": \"Calculate-Continuity\",\r\n \"KeyDataType\": \"Date\",\r\n \"KeyName\": \"Date\",\r\n \"ValueDataType\": \"Float\",\r\n \"ValueName\": \"VitalPrimaryValue\",\r\n \"Operator\": \"Exists\",\r\n \"ContinuityCount\": 7\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Processing records for 7-day body vitals continuity\",\r\n \"OutputTag\": \"Calculate-Continuity:Vital\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 01", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_02_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "03 - Create next node - Extract existing badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_03_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_02_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Get existing badges\",\r\n \"Description\": \"Extract existing 7-day vital monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract-Badges\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Database\",\r\n \"InputTag\": \"Badge\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Vital\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"7-Day Vitals\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 7-day vital monitoring badges\",\r\n \"OutputTag\": \"Extract-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 02", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_03_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_02_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_02_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "04 - Create next node - Compare badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_04_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_03_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 7-day vital monitoring.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Compare-Data\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 7-day vital monitoring\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Calculate-Continuity:Vital\",\r\n \"SecondaryInputTag\": \"Extract-Data:Badge\",\r\n \"DataActionType\": \"Find-Range-Difference\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Vital\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"7-Day Vitals\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Comparing badges and get updated badge list for 7-day vital monitoring badges.\",\r\n \"OutputTag\": \"Compare-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 03", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_04_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_03_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_03_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "05 - Create next node - Store updated badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_05_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_04_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 7-day vital monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Store-Data\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 7-day vital monitoring badges for the participant.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Compare-Data:Badge\",\r\n \"StorageKeys\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Vital\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"7-Day Vitals\"\r\n },\r\n {\r\n \"Key\": \"BadgeId\",\r\n \"Value\": \"{{BADGE_ID}}\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 7-day vital monitoring badges\",\r\n \"OutputTag\": \"Store-Data:Badge\",\r\n \"DestinationType\": \"Database\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 04", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_05_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_04_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_04_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get schema by Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema/{{SCHEMA_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema", + "{{SCHEMA_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Schema-15-Day vital badge", + "item": [ + { + "name": "Create badge", + "item": [ + { + "name": "Create badge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"CategoryId\": \"{{BADGE_CATEGORY_ID}}\",\r\n \"Name\": \"15-Day Vitals\",\r\n \"Description\": \"Badge awarded for monitoring body vitals for 15-days consistently.\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badges", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/{{BADGE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "{{BADGE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Create schema", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"SCHEMA_ROOT_NODE_ID\", jsonRes.Data.RootNode.id);\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.RootNode.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Vital Monitoring 15-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient monitor body vitals for 15 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{VITAL_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract vital data\",\r\n \"Description\": \"Extract vital data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract vital data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Vital\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"All\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting vital data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Vital\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "01 - Get root Node - Extract nutrition data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is retrieved\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "02 - Create next node - Calculate Continuity", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_02_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_01_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Calculate continuity\",\r\n \"Description\": \"This execution step involves calculating the continuity for monitoring body vital consecutively for 15-days.\",\r\n \"Action\": {\r\n \"ActionType\": \"Process-Data\",\r\n \"Name\": \"Calculate Continuity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Vital\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Extract-Data:Vital\",\r\n \"DataActionType\": \"Calculate-Continuity\",\r\n \"KeyDataType\": \"Date\",\r\n \"KeyName\": \"Date\",\r\n \"ValueDataType\": \"Float\",\r\n \"ValueName\": \"VitalPrimaryValue\",\r\n \"Operator\": \"Exists\",\r\n \"ContinuityCount\": 15\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Processing records for 15-day body vitals continuity\",\r\n \"OutputTag\": \"Calculate-Continuity:Vital\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 01", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_02_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "03 - Create next node - Extract existing badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_03_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_02_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Get existing badges\",\r\n \"Description\": \"Extract existing 15-day vital monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract-Badges\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Database\",\r\n \"InputTag\": \"Badge\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Vital\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"15-Day Vitals\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 15-day vital monitoring badges\",\r\n \"OutputTag\": \"Extract-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 02", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_03_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_02_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_02_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "04 - Create next node - Compare badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_04_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_03_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 15-day vital monitoring.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Compare-Data\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 15-day vital monitoring\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Calculate-Continuity:Vital\",\r\n \"SecondaryInputTag\": \"Extract-Data:Badge\",\r\n \"DataActionType\": \"Find-Range-Difference\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Vital\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"15-Day Vitals\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Comparing badges and get updated badge list for 15-day vital monitoring badges.\",\r\n \"OutputTag\": \"Compare-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 03", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_04_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_03_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_03_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "05 - Create next node - Store updated badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_05_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_04_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 15-day vital monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Store-Data\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 15-day vital monitoring badges for the participant.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Compare-Data:Badge\",\r\n \"StorageKeys\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Vital\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"15-Day Vitals\"\r\n },\r\n {\r\n \"Key\": \"BadgeId\",\r\n \"Value\": \"{{BADGE_ID}}\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 15-day vital monitoring badges\",\r\n \"OutputTag\": \"Store-Data:Badge\",\r\n \"DestinationType\": \"Database\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 04", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_05_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_04_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_04_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get schema by Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema/{{SCHEMA_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema", + "{{SCHEMA_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Schema-30-Day vital badge", + "item": [ + { + "name": "Create badge", + "item": [ + { + "name": "Create badge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"CategoryId\": \"{{BADGE_CATEGORY_ID}}\",\r\n \"Name\": \"30-Day Vitals\",\r\n \"Description\": \"Badge awarded for monitoring body vitals for 30-days consistently.\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badges", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/{{BADGE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "{{BADGE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Create schema", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"SCHEMA_ROOT_NODE_ID\", jsonRes.Data.RootNode.id);\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.RootNode.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Vital Monitoring 30-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient monitor body vitals for 30 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{VITAL_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract vital data\",\r\n \"Description\": \"Extract vital data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract vital data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Vital\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"All\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting vital data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:Vital\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "01 - Get root Node - Extract nutrition data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is retrieved\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "02 - Create next node - Calculate Continuity", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_02_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_01_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Calculate continuity\",\r\n \"Description\": \"This execution step involves calculating the continuity for monitoring body vital consecutively for 30-days.\",\r\n \"Action\": {\r\n \"ActionType\": \"Process-Data\",\r\n \"Name\": \"Calculate Continuity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Vital\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Extract-Data:Vital\",\r\n \"DataActionType\": \"Calculate-Continuity\",\r\n \"KeyDataType\": \"Date\",\r\n \"KeyName\": \"Date\",\r\n \"ValueDataType\": \"Float\",\r\n \"ValueName\": \"VitalPrimaryValue\",\r\n \"Operator\": \"Exists\",\r\n \"ContinuityCount\": 30\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Processing records for 30-day body vitals continuity\",\r\n \"OutputTag\": \"Calculate-Continuity:Vital\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 01", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_02_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "03 - Create next node - Extract existing badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_03_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_02_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Get existing badges\",\r\n \"Description\": \"Extract existing 30-day vital monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract-Badges\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Database\",\r\n \"InputTag\": \"Badge\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Vital\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"30-Day Vitals\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 30-day vital monitoring badges\",\r\n \"OutputTag\": \"Extract-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 02", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_03_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_02_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_02_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "04 - Create next node - Compare badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_04_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_03_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 30-day vital monitoring.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Compare-Data\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 30-day vital monitoring\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Calculate-Continuity:Vital\",\r\n \"SecondaryInputTag\": \"Extract-Data:Badge\",\r\n \"DataActionType\": \"Find-Range-Difference\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Vital\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"30-Day Vitals\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Comparing badges and get updated badge list for 30-day vital monitoring badges.\",\r\n \"OutputTag\": \"Compare-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 03", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_04_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_03_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_03_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "05 - Create next node - Store updated badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_05_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_04_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 30-day vital monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Store-Data\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 30-day vital monitoring badges for the participant.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Compare-Data:Badge\",\r\n \"StorageKeys\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"Vital\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"30-Day Vitals\"\r\n },\r\n {\r\n \"Key\": \"BadgeId\",\r\n \"Value\": \"{{BADGE_ID}}\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 30-day vital monitoring badges\",\r\n \"OutputTag\": \"Store-Data:Badge\",\r\n \"DestinationType\": \"Database\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 04", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_05_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_04_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_04_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get schema by Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema/{{SCHEMA_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema", + "{{SCHEMA_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + } + ] + }, + { + "name": "mental health badges", + "item": [ + { + "name": "Create badge category", + "item": [ + { + "name": "Create badge category", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_CATEGORY_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"MentalHealth\",\r\n \"Description\": \"Badge category for mental health related badges\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badge-categories", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badge-categories" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge category by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badge-categories/{{BADGE_CATEGORY_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badge-categories", + "{{BADGE_CATEGORY_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Schema-7-Day mental health badge", + "item": [ + { + "name": "Create badge", + "item": [ + { + "name": "Create badge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"CategoryId\": \"{{BADGE_CATEGORY_ID}}\",\r\n \"Name\": \"Mental health 7-Day Badge\",\r\n \"Description\": \"Badge awarded choosing mental health for 7-days consistently.\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badges", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/{{BADGE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "{{BADGE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Create schema", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"SCHEMA_ROOT_NODE_ID\", jsonRes.Data.RootNode.id);\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.RootNode.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Mental health 7-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient takes chooses mental health monitoring for 7 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{MENTAL_HEALTH_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract mental health data\",\r\n \"Description\": \"Extract mental health data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract mental health data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"MentalHealth\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"Any\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting mental health data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:MentalHealth\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "01 - Get root Node - Extract mental health data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is retrieved\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "02 - Create next node - Calculate Continuity", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_02_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_01_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Calculate continuity\",\r\n \"Description\": \"This execution step involves calculating the continuity for mental health monitoring consecutively for 7-days.\",\r\n \"Action\": {\r\n \"ActionType\": \"Process-Data\",\r\n \"Name\": \"Calculate Continuity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"MentalHealth\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Extract-Data:MentalHealth\",\r\n \"DataActionType\": \"Calculate-Continuity\",\r\n \"KeyDataType\": \"Date\",\r\n \"KeyName\": \"Date\",\r\n \"ValueDataType\": \"Float\",\r\n \"ValueName\": \"Duration\",\r\n \"Operator\": \"Exists\",\r\n \"ContinuityCount\": 7\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Processing records for 7-day mental health continuity\",\r\n \"OutputTag\": \"Calculate-Continuity:MentalHealth\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 01", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_02_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "03 - Create next node - Extract existing badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_03_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_02_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Get existing badges\",\r\n \"Description\": \"Extract existing 7-day mental health monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract-Badges\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Database\",\r\n \"InputTag\": \"Badge\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"MentalHealth\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"Mental health 7-Day Badge\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 7-day 7-Day mental health badges\",\r\n \"OutputTag\": \"Extract-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 02", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_03_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_02_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_02_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "04 - Create next node - Compare badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_04_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_03_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 7-day mental health monitoring.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Compare-Data\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 7-day mental health monitoring\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Calculate-Continuity:MentalHealth\",\r\n \"SecondaryInputTag\": \"Extract-Data:Badge\",\r\n \"DataActionType\": \"Find-Range-Difference\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"MentalHealth\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"Mental health 7-Day Badge\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Comparing badges and get updated badge list for 7-Day mental health monitoring badges.\",\r\n \"OutputTag\": \"Compare-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 03", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_04_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_03_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_03_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "05 - Create next node - Store updated badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_05_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_04_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 7-day mental health monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Store-Data\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 7-day mental health monitoring badges for the participant.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Compare-Data:Badge\",\r\n \"StorageKeys\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"MentalHealth\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"Mental health 7-Day Badge\"\r\n },\r\n {\r\n \"Key\": \"BadgeId\",\r\n \"Value\": \"{{BADGE_ID}}\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 7-day mental health monitoring badges\",\r\n \"OutputTag\": \"Store-Data:Badge\",\r\n \"DestinationType\": \"Database\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 04", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_05_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_04_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_04_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get schema by Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema/{{SCHEMA_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema", + "{{SCHEMA_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Schema-15-Day mental health badge", + "item": [ + { + "name": "Create badge", + "item": [ + { + "name": "Create badge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"CategoryId\": \"{{BADGE_CATEGORY_ID}}\",\r\n \"Name\": \"Mental health 15-Day Badge\",\r\n \"Description\": \"Badge awarded choosing mental health monitoring for 15-days consistently.\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badges", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/{{BADGE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "{{BADGE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Create schema", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"SCHEMA_ROOT_NODE_ID\", jsonRes.Data.RootNode.id);\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.RootNode.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Mental health 15-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient takes chooses mental health monitoring for 15 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{MENTAL_HEALTH_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract mental health data\",\r\n \"Description\": \"Extract mental health data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract mental health data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"MentalHealth\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"Any\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting mental health data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:MentalHealth\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "01 - Get root Node - Extract mental health data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is retrieved\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "02 - Create next node - Calculate Continuity", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_02_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_01_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Calculate continuity\",\r\n \"Description\": \"This execution step involves calculating the continuity for mental health monitoring consecutively for 15-days.\",\r\n \"Action\": {\r\n \"ActionType\": \"Process-Data\",\r\n \"Name\": \"Calculate Continuity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"MentalHealth\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Extract-Data:MentalHealth\",\r\n \"DataActionType\": \"Calculate-Continuity\",\r\n \"KeyDataType\": \"Date\",\r\n \"KeyName\": \"Date\",\r\n \"ValueDataType\": \"Float\",\r\n \"ValueName\": \"Duration\",\r\n \"Operator\": \"Exists\",\r\n \"ContinuityCount\": 15\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Processing records for 15-day mental health monitoring continuity\",\r\n \"OutputTag\": \"Calculate-Continuity:MentalHealth\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 01", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_02_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "03 - Create next node - Extract existing badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_03_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_02_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Get existing badges\",\r\n \"Description\": \"Extract existing 15-day mental health monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract-Badges\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Database\",\r\n \"InputTag\": \"Badge\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"MentalHealth\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"Mental health 15-Day Badge\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 15-day mental health badges\",\r\n \"OutputTag\": \"Extract-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 02", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_03_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_02_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_02_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "04 - Create next node - Compare badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_04_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_03_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 15-day mental health monitoring.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Compare-Data\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 15-day mental health monitoring\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Calculate-Continuity:MentalHealth\",\r\n \"SecondaryInputTag\": \"Extract-Data:Badge\",\r\n \"DataActionType\": \"Find-Range-Difference\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"MentalHealth\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"Mental health 15-Day Badge\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Comparing badges and get updated badge list for 15-Day mental health monitoring.\",\r\n \"OutputTag\": \"Compare-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 03", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_04_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_03_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_03_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "05 - Create next node - Store updated badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_05_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_04_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 15-day mental health monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Store-Data\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 15-day mental health monitoring badges for the participant.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Compare-Data:Badge\",\r\n \"StorageKeys\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"MentalHealth\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"Mental health 15-Day Badge\"\r\n },\r\n {\r\n \"Key\": \"BadgeId\",\r\n \"Value\": \"{{BADGE_ID}}\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 15-day mental health monitoring badges\",\r\n \"OutputTag\": \"Store-Data:Badge\",\r\n \"DestinationType\": \"Database\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 04", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_05_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_04_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_04_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get schema by Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema/{{SCHEMA_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema", + "{{SCHEMA_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Schema-30-Day mental health badge", + "item": [ + { + "name": "Create badge", + "item": [ + { + "name": "Create badge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"BADGE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Participant is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"CategoryId\": \"{{BADGE_CATEGORY_ID}}\",\r\n \"Name\": \"Mental health 30-Day Badge\",\r\n \"Description\": \"Badge awarded choosing mental health monitoring for 30-days consistently.\",\r\n \"ImageUrl\": \"https://e7.pngegg.com/pngimages/626/893/png-clipart-blue-and-white-check-logo-facebook-social-media-verified-badge-logo-vanity-url-blue-checkmark-blue-angle.png\"\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/badges", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get badge by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/{{BADGE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "{{BADGE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Create schema", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_ID\", jsonRes.Data.id);\r", + " pm.environment.set(\"SCHEMA_ROOT_NODE_ID\", jsonRes.Data.RootNode.id);\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.RootNode.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ClientId\": \"{{CLIENT_ID}}\",\r\n \"Name\": \"Mental health 30-Day Badge\",\r\n \"Description\": \"This schema represents a badge award logic when a patient takes chooses mental health monitoring for 30 consecutive days. The patient can keep accumulating these badges.\",\r\n \"Type\": \"Reuse-Existing-Instance\",\r\n \"EventTypeIds\": [\r\n \"{{MENTAL_HEALTH_EVENT_TYPE_ID}}\"\r\n ],\r\n \"RootNode\": {\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Extract mental health data\",\r\n \"Description\": \"Extract mental health data\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract mental health data\",\r\n \"InputParams\": {\r\n \"RecordType\": \"MentalHealth\",\r\n \"SourceType\": \"Database\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"SamplingMethod\",\r\n \"Value\": \"Any\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting mental health data for the given context.\",\r\n \"OutputTag\": \"Extract-Data:MentalHealth\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "01 - Get root Node - Extract mental health data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_01_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is retrieved\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "02 - Create next node - Calculate Continuity", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_02_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_01_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Type\": \"Execution-Node\",\r\n \"Name\": \"Calculate continuity\",\r\n \"Description\": \"This execution step involves calculating the continuity for mental health monitoring consecutively for 30-days.\",\r\n \"Action\": {\r\n \"ActionType\": \"Process-Data\",\r\n \"Name\": \"Calculate Continuity\",\r\n \"InputParams\": {\r\n \"RecordType\": \"MentalHealth\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Extract-Data:MentalHealth\",\r\n \"DataActionType\": \"Calculate-Continuity\",\r\n \"KeyDataType\": \"Date\",\r\n \"KeyName\": \"Date\",\r\n \"ValueDataType\": \"Float\",\r\n \"ValueName\": \"Duration\",\r\n \"Operator\": \"Exists\",\r\n \"ContinuityCount\": 30\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Processing records for 30-day mental health monitoring continuity\",\r\n \"OutputTag\": \"Calculate-Continuity:MentalHealth\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 01", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_02_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_01_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_01_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "03 - Create next node - Extract existing badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_03_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_02_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Get existing badges\",\r\n \"Description\": \"Extract existing 30-day mental health monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Extract-Data\",\r\n \"Name\": \"Extract-Badges\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Database\",\r\n \"InputTag\": \"Badge\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"MentalHealth\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"Mental health 30-Day Badge\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 30-day mental health monitoring badges\",\r\n \"OutputTag\": \"Extract-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 02", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_03_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_02_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_02_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "04 - Create next node - Compare badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_04_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_03_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 30-day mental health monitoring.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Compare-Data\",\r\n \"Name\": \"Compare badges\",\r\n \"Description\": \"Compare calculated badges against existing badges for 30-day mental health monitoring.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Calculate-Continuity:MentalHealth\",\r\n \"SecondaryInputTag\": \"Extract-Data:Badge\",\r\n \"DataActionType\": \"Find-Range-Difference\",\r\n \"Filters\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"MentalHealth\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"Mental health 30-Day Badge\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Comparing badges and get updated badge list for 30-Day mental health monitoring badges.\",\r\n \"OutputTag\": \"Compare-Data:Badge\",\r\n \"DestinationType\": \"Almanac\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 03", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_04_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_03_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_03_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "05 - Create next node - Store updated badges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"NODE_05_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(201);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"ParentNodeId\": \"{{NODE_04_ID}}\",\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 30-day mental health monitoring badges for the participant.\",\r\n \"Type\": \"Execution-Node\",\r\n \"Action\": {\r\n \"ActionType\": \"Store-Data\",\r\n \"Name\": \"Store updated badges\",\r\n \"Description\": \"Store updated 30-day mental health monitoring badges for the participant.\",\r\n \"InputParams\": {\r\n \"RecordType\": \"Badge\",\r\n \"SourceType\": \"Almanac\",\r\n \"InputTag\": \"Compare-Data:Badge\",\r\n \"StorageKeys\": [\r\n {\r\n \"Key\": \"BadgeCategory\",\r\n \"Value\": \"MentalHealth\"\r\n },\r\n {\r\n \"Key\": \"BadgeTitle\",\r\n \"Value\": \"Mental health 30-Day Badge\"\r\n },\r\n {\r\n \"Key\": \"BadgeId\",\r\n \"Value\": \"{{BADGE_ID}}\"\r\n }\r\n ]\r\n },\r\n \"OutputParams\": {\r\n \"Message\": \"Extracting 30-day mental health badges monitoring\",\r\n \"OutputTag\": \"Store-Data:Badge\",\r\n \"DestinationType\": \"Database\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Update next node for node 04", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Node is updated\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ParentNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"Action\": {\r\n \"OutputParams\": {\r\n \"NextNodeId\": \"{{NODE_05_ID}}\"\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/nodes/{{NODE_04_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "nodes", + "{{NODE_04_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get schema by Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema is created\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNode');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + }, + { + "key": "Authorization", + "value": "Bearer {{MODERATOR_USER_JWT}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema/{{SCHEMA_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema", + "{{SCHEMA_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "Get context for participant / reference id", + "item": [ + { + "name": "Get schema instance by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"SCHEMA_INSTANCE_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema instance is returned\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNodeId');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"SchemaId\": \"{{SCHEMA_ID}}\",\r\n \"Name\": \"Medication 7 Day Badge Rule\",\r\n \"Description\": \"This rule represents logical steps involved in awarding a badge for consecutive 7 days.\",\r\n \"ParentNodeId\": \"{{SCHEMA_ROOT_NODE_ID}}\",\r\n \"Action\": {\r\n \"ActionType\": \"{{AWARD_BADGE_EVENT_TYPE}}\",\r\n \"Name\": \"Medication 7-Days Badge\",\r\n \"Description\": \"This rule represents logical steps involved in awarding a badge for consecutive 7 days.\",\r\n \"Params\": {\r\n \"Message\": \"Award medication 7-days badge.\",\r\n \"Action\": \"{{AWARD_BADGE_EVENT_TYPE}}\",\r\n \"NextNodeId\": null,\r\n \"Extra\": {}\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "{{BASE_URL}}/engine/schema-instances/{{SCHEMA_INSTANCE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "engine", + "schema-instances", + "{{SCHEMA_INSTANCE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] + }, + { + "name": "Get participant badges", + "item": [ + { + "name": "Get participant by reference id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"PARTICIPANT_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema instance is returned\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNodeId');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/participants/by-reference-id/{{REFERENCE_ID}}", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "participants", + "by-reference-id", + "{{REFERENCE_ID}}" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + }, + { + "name": "Get participant badges", + "event": [ { "listen": "test", "script": { @@ -9402,6 +19139,92 @@ "response": [] } ] + }, + { + "name": "Badges", + "item": [ + { + "name": "Get badge stock images", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "try {\r", + " var jsonRes = pm.response.json();\r", + " pm.environment.set(\"PARTICIPANT_ID\", jsonRes.Data.id);\r", + "}\r", + "catch (error) {\r", + " console.log(error.message);\r", + "}\r", + "\r", + "pm.test(\"Request is successfull\", function () {\r", + " pm.response.to.have.status(200);\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Status).to.eql('success');\r", + "});\r", + "\r", + "pm.test(\"Schema instance is returned\", function () {\r", + " var jsonRes = pm.response.json();\r", + " pm.expect(jsonRes.Data).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Client');\r", + " pm.expect(jsonRes.Data.Client).to.have.property('id');\r", + " pm.expect(jsonRes.Data).to.have.property('Name');\r", + " pm.expect(jsonRes.Data).to.have.property('Description');\r", + " pm.expect(jsonRes.Data).to.have.property('ValidFrom');\r", + " pm.expect(jsonRes.Data).to.have.property('RootNodeId');\r", + "});\r", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{API_KEY}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{BASE_URL}}/badges/stock-images", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "badges", + "stock-images" + ] + }, + "description": "User login with username/phone/email and password.\n\n'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role." + }, + "response": [] + } + ] } ] } \ No newline at end of file diff --git a/seed.data/how.to.earn.badge.content.seed..json b/seed.data/how.to.earn.badge.content.seed..json new file mode 100644 index 0000000..34e3602 --- /dev/null +++ b/seed.data/how.to.earn.badge.content.seed..json @@ -0,0 +1,62 @@ +[ + { + "Name": "7-Day Medication Adherence", + "HowToEarn": "Earn a badge for every medications you take.\n\n1. Daily Mark your medication as 'Taken' by swiping left in the Medication Reminders.\nYou can also mark the medication as 'taken' in the To Do's.\n\n2. For 7 consistent days take your medications and earn a badge." + }, + { + "Name": "15-Day Medication Adherence", + "HowToEarn": "Earn a badge for every medications you take.\n\n1. Daily Mark your medication as 'Taken' by swiping left in the Medication Reminders.\nYou can also mark the medication as 'taken' in the To Do's.\n\n2. For 15 consistent days take your medications and earn a badge." + }, + { + "Name": "30-Day Medication Adherence", + "HowToEarn": "Earn a badge for every medications you take.\n\n1. Daily Mark your medication as 'Taken' by swiping left in the Medication Reminders.\nYou can also mark the medication as 'taken' in the To Do's.\n\n2. For 30 consistent days take your medications and earn a badge." + }, + { + "Name": "7-Day Healthy Nutrition Choice", + "HowToEarn": "Earn a badge for having health food.\n\n1. Daily Mark Yes on the home screen for the question - Were most of your food choices health today?\n\n2. For 7 consistent days have health food choices and earn a badge." + }, + { + "Name": "15-Day Healthy Nutrition Choice", + "HowToEarn": "Earn a badge for having health food.\n\n1. Daily Mark Yes on the home screen for the question - Were most of your food choices health today?\n\n2. For 15 consistent days have health food choices and earn a badge." + }, + { + "Name": "30-Day Healthy Nutrition Choice", + "HowToEarn": "Earn a badge for having health food.\n\n1. Daily Mark Yes on the home screen for the question - Were most of your food choices health today?\n\n2. For 30 consistent days have health food choices and earn a badge." + }, + { + "Name": "7-Day Physical Activity", + "HowToEarn": "Earn a badge by adding movement to your day.\n\n1. Daily Mark Yes on the home screen for the question - Did you add movement to your day today?\n\n2. For 7 consistent days add movement to your day and earn a badge." + }, + { + "Name": "15-Day Physical Activity", + "HowToEarn": "Earn a badge by adding movement to your day.\n\n1. Daily Mark Yes on the home screen for the question - Did you add movement to your day today?\n\n2. For 15 consistent days add movement to your day and earn a badge." + }, + { + "Name": "30-Day Physical Activity", + "HowToEarn": "Earn a badge by adding movement to your day.\n\n1. Daily Mark Yes on the home screen for the question - Did you add movement to your day today?\n\n2. For 30 consistent days add movement to your day and earn a badge." + }, + { + "Name": "Mental health 7-Day Badge", + "HowToEarn": "Earn a badge by practicing mindfulness and recording your sleep.\n\n1. Daily record your Sleep hours or Mindfulness time in the Mental Well-Being section.\n\n2. For 7 consistent days record your sleep and mindfulness time to earn a badge." + }, + { + "Name": "Mental health 15-Day Badge", + "HowToEarn": "Earn a badge by practicing mindfulness and recording your sleep.\n\n1. Daily record your Sleep hours or Mindfulness time in the Mental Well-Being section.\n\n2. For 15 consistent days record your sleep and mindfulness time to earn a badge." + }, + { + "Name": "Mental health 30-Day Badge", + "HowToEarn": "Earn a badge by practicing mindfulness and recording your sleep.\n\n1. Daily record your Sleep hours or Mindfulness time in the Mental Well-Being section.\n\n2. For 30 consistent days record your sleep and mindfulness time to earn a badge." + }, + { + "Name": "7-Day Vitals", + "HowToEarn": "Earn a badge by recording your daily vitals.\n\n1. Daily record your Vitals to get the badge.\n\n2. For 7 consistent days record your vitals to earn a badge." + }, + { + "Name": "15-Day Vitals", + "HowToEarn": "Earn a badge by recording your daily vitals.\n\n1. Daily record your Vitals to get the badge.\n\n2. For 15 consistent days record your vitals to earn a badge." + }, + { + "Name": "30-Day Vitals", + "HowToEarn": "Earn a badge by recording your daily vitals.\n\n1. Daily record your Vitals to get the badge.\n\n2. For 30 consistent days record your vitals to earn a badge." + } +] diff --git a/seed.data/role.privileges.json b/seed.data/role.privileges.json index a626980..1f29ba8 100644 --- a/seed.data/role.privileges.json +++ b/seed.data/role.privileges.json @@ -18,6 +18,7 @@ "FileResource.GetById", "FileResource.Search", "FileResource.Download", + "FileResource.DownloadByVersion", "Client.Create", "Client.Search", @@ -25,7 +26,9 @@ "Client.Update", "Client.Delete", "Client.GetApiKey", - "Client.RenewApiKey" + "Client.RenewApiKey", + + "Badge.GetStockBadgeImages" ] }, { @@ -46,6 +49,7 @@ "FileResource.GetById", "FileResource.Search", "FileResource.Download", + "FileResource.DownloadByVersion", "Participant.Create", "Participant.Search", @@ -100,7 +104,9 @@ "Redemption.Delete", "Types.GetEventActionTypes", - "Types.GetRoles" + "Types.GetRoles", + + "Badge.GetStockBadgeImages" ] } ] diff --git a/service.config.json b/service.config.json index cc07998..de6b73a 100644 --- a/service.config.json +++ b/service.config.json @@ -1,5 +1,5 @@ { - "SystemIdentifier": "REAN Careplan Service", + "SystemIdentifier": "Awards Service", "Auth" : { "Authentication": "Custom", "Authorization": "Custom" @@ -25,6 +25,6 @@ }, "MaxUploadFileSize": 104857600, "JwtExpiresIn": 2592000, - "Logger" : "Winston", + "Logger" : "Custom", "UseHTTPLogging" : true } diff --git a/service.config.local.json b/service.config.local.json index 98abc43..82ca812 100644 --- a/service.config.local.json +++ b/service.config.local.json @@ -1,5 +1,5 @@ { - "SystemIdentifier": "REAN HealthGuru", + "SystemIdentifier": "Awards Service", "Auth" : { "Authentication": "Custom", "Authorization": "Custom" diff --git a/src/api/awards/badge/badge.controller.ts b/src/api/awards/badge/badge.controller.ts index fcef290..96d76f9 100644 --- a/src/api/awards/badge/badge.controller.ts +++ b/src/api/awards/badge/badge.controller.ts @@ -6,6 +6,7 @@ import { BadgeService } from '../../../database/services/awards/badge.service'; import { ErrorHandler } from '../../../common/handlers/error.handler'; import { BadgeCreateModel, BadgeSearchFilters, BadgeUpdateModel } from '../../../domain.types/awards/badge.domain.types'; import { uuid } from '../../../domain.types/miscellaneous/system.types'; +import { BadgeStockImageService } from '../../../database/services/badge.stock.images/badge.stock.image.service'; /////////////////////////////////////////////////////////////////////////////////////// @@ -15,6 +16,8 @@ export class BadgeController extends BaseController { _service: BadgeService = new BadgeService(); + _badgeStockservice: BadgeStockImageService = new BadgeStockImageService(); + _validator: BadgeValidator = new BadgeValidator(); constructor() { @@ -50,6 +53,17 @@ export class BadgeController extends BaseController { } }; + getAll = async (request: express.Request, response: express.Response) => { + try { + await this.authorize('Badge.GetAll', request, response, false); + const records = await this._service.search({}); + const message = 'Badge records with how to earn content retrieved successfully!'; + ResponseHandler.success(request, response, message, 200, records); + } catch (error) { + ResponseHandler.handleError(request, response, error); + } + }; + update = async (request: express.Request, response: express.Response) => { try { await this.authorize('Badge.Update', request, response); @@ -87,4 +101,18 @@ export class BadgeController extends BaseController { } }; + getStockBadgeImages = async (request: express.Request, response: express.Response): Promise => { + try { + await this.authorize('Badge.GetStockBadgeImages',request, response, false); + + const images = await this._badgeStockservice.getAll(); + const message = 'Badge stock images retrieved successfully!'; + + ResponseHandler.success(request, response, message, 200, images); + + } catch (error) { + ResponseHandler.handleError(request, response, error); + } + }; + } diff --git a/src/api/awards/badge/badge.routes.ts b/src/api/awards/badge/badge.routes.ts index 520660b..4d61786 100644 --- a/src/api/awards/badge/badge.routes.ts +++ b/src/api/awards/badge/badge.routes.ts @@ -15,6 +15,8 @@ export const register = (app: express.Application): void => { const controller = new BadgeController(); router.post('/', authenticator.authenticateClient, authenticator.authenticateUser, controller.create); + router.get('/how-to-earn', authenticator.authenticateClient, controller.getAll); + router.get('/stock-images', authenticator.authenticateClient, controller.getStockBadgeImages); router.get('/search', authenticator.authenticateClient, authenticator.authenticateUser, controller.search); router.get('/:id', authenticator.authenticateClient, authenticator.authenticateUser, controller.getById); router.put('/:id', authenticator.authenticateClient, authenticator.authenticateUser, controller.update); diff --git a/src/api/awards/participant/participant.controller.ts b/src/api/awards/participant/participant.controller.ts index 8103ea0..e90aec9 100644 --- a/src/api/awards/participant/participant.controller.ts +++ b/src/api/awards/participant/participant.controller.ts @@ -4,8 +4,10 @@ import { ParticipantValidator } from './participant.validator'; import { BaseController } from '../../base.controller'; import { ParticipantService } from '../../../database/services/awards/participant.service'; import { ErrorHandler } from '../../../common/handlers/error.handler'; -import { ParticipantCreateModel, ParticipantSearchFilters, ParticipantUpdateModel } from '../../../domain.types/awards/participant.domain.types'; +import { ParticipantBadgeResponseDto, ParticipantCreateModel, ParticipantSearchFilters, ParticipantUpdateModel } from '../../../domain.types/awards/participant.domain.types'; import { uuid } from '../../../domain.types/miscellaneous/system.types'; +import { BadgeService } from '../../../database/services/awards/badge.service'; +import { BadgeResponseDto } from '../../../domain.types/awards/badge.domain.types'; /////////////////////////////////////////////////////////////////////////////////////// @@ -15,11 +17,14 @@ export class ParticipantController extends BaseController { _service: ParticipantService = null; + _badgeService: BadgeService = null; + _validator: ParticipantValidator = null; constructor() { super(); this._service = new ParticipantService(); + this._badgeService = new BadgeService(); this._validator = new ParticipantValidator(); } @@ -117,11 +122,83 @@ export class ParticipantController extends BaseController { try { await this.authorize('Participant.GetBadges', request, response, false); var id: uuid = await this._validator.validateParamAsUUID(request, 'id'); - const result = await this._service.getBadges(id); + const participantBadges = await this._service.getBadges(id); const message = 'Participant badges retrieved successfully!'; + + const participant = await this._service.getById(id); + if (participant === null) { + ErrorHandler.throwNotFoundError(`Participant with Id: ${id} does not exist!`); + } + const clientId = participant.Client?.id; + const allBadges = await this._badgeService.getByClientId(clientId); + const badges = this.classifyAllBadgesByCategory(allBadges); + const classified = this.classifyParticipantBadges(participantBadges, badges); + var result = await this._service.getBadgeImageUrl(participantBadges, classified); + ResponseHandler.success(request, response, message, 200, result); } catch (error) { ResponseHandler.handleError(request, response, error); } }; + + private classifyAllBadgesByCategory = (allBadges: BadgeResponseDto[]) => { + const badges = allBadges.reduce((acc, x) => { + if (!acc[x.Category?.Name]) { + acc[x.Category?.Name] = { + CategoryName: x.Category?.Name, + Badges: {}, + }; + } + acc[x.Category?.Name].Badges[x.Name] = { + BadgeName: x.Name, + Occurrences: 0, + BadgeList: [], + }; + return acc; + }, {}); + return badges; + }; + + private classifyParticipantBadges = (participantBadges: ParticipantBadgeResponseDto[], badges: any) => { + + const badgesByCategoryName = participantBadges.reduce((acc, x) => { + if (!acc[x.Badge?.Category?.Name]) { + acc[x.Badge?.Category?.Name] = []; + } + acc[x.Badge?.Category?.Name].push(x); + return acc; + }, {}); + + for (const key in badgesByCategoryName) { + + const arr = badgesByCategoryName[key]; + const classfiedByBadgeName = arr.reduce((acc, x) => { + if (!acc[x.Badge?.Name]) { + acc[x.Badge?.Name] = []; + } + acc[x.Badge?.Name].push(x); + return acc; + }, {}); + + badges[key] = { + CategoryName: key, + Badges: {}, + }; + + for (const badgeName in classfiedByBadgeName) { + let bArr = classfiedByBadgeName[badgeName] as any[]; + bArr = bArr.sort((a, b) => { + return a.Badge.Name.localeCompare(b.Badge.Name); + }); + const occurrences = bArr.length; + badges[key].Badges[badgeName] = { + BadgeName: badgeName, + Occurrences: occurrences, + BadgeList: bArr, + }; + } + } + return badges; + }; + } diff --git a/src/api/base.validator.ts b/src/api/base.validator.ts index 203d4f9..01e6891 100644 --- a/src/api/base.validator.ts +++ b/src/api/base.validator.ts @@ -4,6 +4,8 @@ import { ErrorHandler } from '../common/handlers/error.handler'; import { uuid } from '../domain.types/miscellaneous/system.types'; +import { DownloadDisposition } from '../domain.types/general/file.resource/file.resource.types'; +import { FileResourceMetadata } from '..//domain.types/general/file.resource/file.resource.types'; ////////////////////////////////////////////////////////////////// @@ -20,4 +22,33 @@ export default class BaseValidator { } }; + getByVersionName = async (request: express.Request): Promise => { + + var disposition = this.getDownloadDisposition(request); + + var metadata: FileResourceMetadata = { + ResourceId : request.params.id, + Version : request.params.version, + Disposition : disposition + }; + + return metadata; + }; + + public getDownloadDisposition(request) { + var disposition = DownloadDisposition.Auto; + if (request.query.disposition) { + if (request.query.disposition === 'inline') { + disposition = DownloadDisposition.Inline; + } + else if (request.query.disposition === 'stream') { + disposition = DownloadDisposition.Stream; + } + else { + disposition = DownloadDisposition.Attachment; + } + } + return disposition; + } + } diff --git a/src/api/client/client.controller.ts b/src/api/client/client.controller.ts index 0185afe..85b6235 100644 --- a/src/api/client/client.controller.ts +++ b/src/api/client/client.controller.ts @@ -71,6 +71,20 @@ export class ClientController extends BaseController { } }; + getByApiKey = async (request: express.Request, response: express.Response) => { + try { + const currentClient = request.currentClient; + const record = await this._service.getByClientCode(currentClient?.Code); + if (record === null) { + ErrorHandler.throwNotFoundError('Api client with code ' + currentClient?.Code?.toString() + ' cannot be found!'); + } + const message = 'Api client retrieved successfully!'; + ResponseHandler.success(request, response, message, 200, record); + } catch (error) { + ResponseHandler.handleError(request, response, error); + } + }; + search = async (request: express.Request, response: express.Response) => { try { await this.authorize('ApiClient.Search', request, response); diff --git a/src/api/client/client.routes.ts b/src/api/client/client.routes.ts index eeac341..5774372 100644 --- a/src/api/client/client.routes.ts +++ b/src/api/client/client.routes.ts @@ -21,8 +21,10 @@ export const register = (app: express.Application): void => { router.get('/search', authenticator.authenticateUser, controller.search); router.get('/:id', authenticator.authenticateUser, controller.getById); + router.get('/', authenticator.authenticateClient, controller.getByApiKey); router.put('/:id', authenticator.authenticateUser, controller.update); router.delete('/:id', authenticator.authenticateUser, controller.delete); + app.use('/api/v1/clients', router); }; diff --git a/src/api/general/file.resource/file.resource.controller.ts b/src/api/general/file.resource/file.resource.controller.ts index 3bf84d6..a2cf51f 100644 --- a/src/api/general/file.resource/file.resource.controller.ts +++ b/src/api/general/file.resource/file.resource.controller.ts @@ -1,30 +1,41 @@ import express from 'express'; +import fs from 'fs'; import { ResponseHandler } from '../../../common/handlers/response.handler'; import { FileResourceService } from '../../../database/services/general/file.resource.service'; import { BaseController } from '../../base.controller'; import { uuid } from '../../../domain.types/miscellaneous/system.types'; -import { ErrorHandler } from '../../../common/handlers/error.handler'; +import { ApiError, ErrorHandler } from '../../../common/handlers/error.handler'; import BaseValidator from '../../base.validator'; import * as mime from 'mime-types'; import { FileResourceCreateModel } from '../../../domain.types/general/file.resource.domain.types'; import { FileUtils } from '../../../common/utilities/file.utils'; import { Loader } from '../../../startup/loader'; import { StorageService } from '../../../modules/storage/storage.service'; +import { FileResourceMetadata } from '../../../domain.types/general/file.resource/file.resource.types'; +import { Authenticator } from '../../../auth/authenticator'; +import path from 'path'; +import { Helper } from '../../../common/helper'; +import { DownloadDisposition } from '../../../domain.types/general/file.resource/file.resource.types'; /////////////////////////////////////////////////////////////////////////////////////// export class FileResourceController extends BaseController { //#region member variables and constructors + _service: FileResourceService = null; - _service: FileResourceService = new FileResourceService(); + _storageService: StorageService = Loader.Container.resolve(StorageService); _validator: BaseValidator = new BaseValidator(); - _storageService: StorageService = Loader.Container.resolve(StorageService); + _authenticator: Authenticator = null; + constructor() { super(); + this._service = new FileResourceService(); + this._authenticator = Loader.Authenticator; + } //#endregion @@ -46,7 +57,7 @@ export class FileResourceController extends BaseController { filename = filename + '_' + timestamp + '.' + ext; var storageKey = 'uploaded/' + dateFolder + '/' + filename; - var key = await this._storageService.upload(request, storageKey); + var key = await this._storageService.upload(storageKey, request); if (!key) { ErrorHandler.throwInternalServerError(`Unable to upload the file!`); } @@ -95,7 +106,7 @@ export class FileResourceController extends BaseController { response.setHeader('Content-type', mimeType as string); this.setResponseHeaders(response, originalFilename, disposition); - var readStream = await this._storageService.download(storageKey); + var readStream = await this._storageService.download(storageKey, ''); if (!readStream) { ErrorHandler.throwInternalServerError(`Unable to download the file!`); } @@ -152,6 +163,79 @@ export class FileResourceController extends BaseController { else { response.setHeader('Content-disposition', 'attachment;filename=' + filename); } + }; + + DownloadByVersion = async (request: express.Request, response: express.Response): Promise => { + try { + request.context = 'FileResource.DownloadByVersion'; + const metadata = await this._validator.getByVersionName(request); + var resource = await this._service.getById(metadata.ResourceId); + + if (resource.Public === false) { + + //NOTE: Please note that this is deviation from regular pattern of + //authentication middleware pipeline. Here we are authenticating client + //and user only when the file resource is not public. + + await this._authenticator.checkAuthentication(request); + await this._authorizer.authorize(request, response); + } + + console.log(`Download request for Resource Id:: ${metadata.ResourceId} + and Version:: ${metadata.Version}`); + const localDestination = await this._service.DownloadByVersion( + metadata.ResourceId, + metadata.Version); + + this.streamToResponse(localDestination, response, metadata); + + } catch (error) { + ResponseHandler.handleError(request, response, error); + } + }; + + private streamToResponse( + localDestination: string, + response: express.Response>, + metadata: FileResourceMetadata) { + + if (localDestination == null) { + throw new ApiError(404, 'File resource not found.'); + } + + var filename = path.basename(localDestination); + var mimetype = metadata.MimeType ?? Helper.getMimeType(localDestination); + if (!mimetype) { + mimetype = 'text/plain'; + } + + this.setDownloadResponseHeaders(response, metadata.Disposition, mimetype, filename); + + var filestream = fs.createReadStream(localDestination); + filestream.pipe(response); + }; + + private setDownloadResponseHeaders( + response: express.Response, + disposition: DownloadDisposition, + mimeType: string, + filename: string) { + + response.setHeader('Content-type', mimeType); + + if (disposition === DownloadDisposition.Attachment) { + response.setHeader('Content-disposition', 'attachment; filename=' + filename); + } + else if (disposition === DownloadDisposition.Inline || + (mimeType === 'image/jpeg' || + mimeType === 'image/png' || + mimeType === 'image/bmp')) { + response.setHeader('Content-disposition', 'inline'); + } + else { + response.setHeader('Content-disposition', 'attachment; filename=' + filename); + } + } //#endregion diff --git a/src/api/general/file.resource/file.resource.routes.ts b/src/api/general/file.resource/file.resource.routes.ts index 362c853..e30ecc5 100644 --- a/src/api/general/file.resource/file.resource.routes.ts +++ b/src/api/general/file.resource/file.resource.routes.ts @@ -15,5 +15,7 @@ export const register = (app: express.Application): void => { router.get('/:id', authenticator.authenticateUser, controller.getById); router.delete('/:id', authenticator.authenticateUser, controller.delete); + router.get('/:id/download-by-version-name/:version', controller.DownloadByVersion); + app.use('/api/v1/file-resources', router); }; diff --git a/src/app.ts b/src/app.ts index 3c2a045..f2a9f71 100644 --- a/src/app.ts +++ b/src/app.ts @@ -13,6 +13,7 @@ import { Seeder } from './startup/seeder'; import { DBConnector } from "./database/database.connector"; import { FactsDBConnector } from "./modules/fact.extractors/facts.db.connector"; import { HttpLogger } from "./logger/HttpLogger"; +import FactsDbClient from "./modules/fact.extractors/facts.db.client"; ///////////////////////////////////////////////////////////////////////// @@ -65,6 +66,7 @@ export default class Application { await DbClient.createDatabase(); await DBConnector.initialize(); + await FactsDbClient.createDatabase(); await FactsDBConnector.initialize(); }; diff --git a/src/common/helper.ts b/src/common/helper.ts index 2dcb1e9..c24575a 100644 --- a/src/common/helper.ts +++ b/src/common/helper.ts @@ -2,6 +2,7 @@ import child_process from 'child_process'; import { Gender } from '../domain.types/miscellaneous/system.types'; import Countries from './miscellaneous/country.codes'; import { TypeUtils } from './utilities/type.utils'; +import mime = require('mime-types'); //////////////////////////////////////////////////////////////////////// @@ -162,4 +163,12 @@ export class Helper { return possiblePhoneNumbers; }; + public static getMimeType = (pathOrExtension: string) => { + var mimeType = mime.lookup(pathOrExtension); + if (!mimeType) { + mimeType = 'text/plain'; + } + return mimeType; + }; + } diff --git a/src/database/database.connector.ts b/src/database/database.connector.ts index af27889..475b83e 100644 --- a/src/database/database.connector.ts +++ b/src/database/database.connector.ts @@ -32,6 +32,8 @@ import { Role } from "./models/user/role.model"; import { Privilege } from "./models/user/privilege.model"; import { SchemaEventType } from "./models/engine/schema.event.type.model"; import { DBLogger } from "./database.logger"; +import { FileResourceVersion } from "./models/general/file.resource.version.model"; +import { BadgeStockImage } from "./models/awards/badge.stock.image.model"; /////////////////////////////////////////////////////////////////////////////////// @@ -89,6 +91,8 @@ class DatabaseConnector { Role, Privilege, SchemaEventType, + FileResourceVersion, + BadgeStockImage, ], migrations : [], subscribers : [], diff --git a/src/database/mappers/awards/badge.mapper.ts b/src/database/mappers/awards/badge.mapper.ts index 2ba2d76..0c0d228 100644 --- a/src/database/mappers/awards/badge.mapper.ts +++ b/src/database/mappers/awards/badge.mapper.ts @@ -26,6 +26,7 @@ export class BadgeMapper { Name : badge.Name, Description: badge.Description, ImageUrl : badge.ImageUrl, + HowToEarn : badge.HowToEarn, CreatedAt : badge.CreatedAt, UpdatedAt : badge.UpdatedAt, }; diff --git a/src/database/mappers/awards/badge.stock.image.mapper.ts b/src/database/mappers/awards/badge.stock.image.mapper.ts new file mode 100644 index 0000000..e17272d --- /dev/null +++ b/src/database/mappers/awards/badge.stock.image.mapper.ts @@ -0,0 +1,23 @@ +import { BadgeStockImageDto } from '../../../domain.types/badge.stock.image/badge.stock.image.dto'; +import { BadgeStockImage } from '../../../database/models/awards/badge.stock.image.model'; + +/////////////////////////////////////////////////////////////////////////////////// + +export class BadgeStockImageMapper { + + static toResponseDto = (badgeStockImage: BadgeStockImage): BadgeStockImageDto => { + if (badgeStockImage == null) { + return null; + } + const dto: BadgeStockImageDto = { + id : badgeStockImage.id, + Code : badgeStockImage.Code, + FileName : badgeStockImage.FileName, + ResourceId : badgeStockImage.ResourceId, + PublicUrl : badgeStockImage.PublicUrl + + }; + return dto; + }; + +} diff --git a/src/database/mappers/awards/participant.group.mapper.ts b/src/database/mappers/awards/participant.group.mapper.ts index 2373a27..81368af 100644 --- a/src/database/mappers/awards/participant.group.mapper.ts +++ b/src/database/mappers/awards/participant.group.mapper.ts @@ -15,6 +15,7 @@ export class ParticipantGroupMapper { const client = ClientMapper.toResponseDto(group.Client); const dto: ParticipantGroupResponseDto = { id : group.id, + ReferenceId : group.ReferenceId, Client : client, Name : group.Name, Description : group.Description, diff --git a/src/database/mappers/general/file.resource.mapper.ts b/src/database/mappers/general/file.resource.mapper.ts index 1c6b4fd..bd5edce 100644 --- a/src/database/mappers/general/file.resource.mapper.ts +++ b/src/database/mappers/general/file.resource.mapper.ts @@ -2,6 +2,9 @@ import { FileResource } from '../../models/general/file.resource.model'; import { FileResourceResponseDto, } from '../../../domain.types/general/file.resource.domain.types'; +import { FileResourceMetadata } from '../../../domain.types/general/file.resource/file.resource.types'; +import { ConfigurationManager } from '../../../config/configuration.manager'; +import { FileResourceVersion } from '../../../database/models/general/file.resource.version.model'; /////////////////////////////////////////////////////////////////////////////////// @@ -20,11 +23,39 @@ export class FileResourceMapper { Public : fileResource.Public, Size : fileResource.Size, Tags : fileResource.Tags, - UploadedBy : fileResource.UploadedBy.id, + UploadedBy : null, CreatedAt : fileResource.CreatedAt, UpdatedAt : fileResource.UpdatedAt, }; return dto; }; + static toFileVersionDto = (fileVersion ?: FileResourceVersion, sanitize = false): FileResourceMetadata => { + + if (fileVersion == null){ + return null; + } + + var url = ConfigurationManager.BaseUrl + '/file-resources/' + fileVersion.ResourceId + '/download-by-version-name/' + fileVersion.Version; + + var v: FileResourceMetadata = { + VersionId : fileVersion.id, + ResourceId : fileVersion.ResourceId, + Version : fileVersion.Version, + FileName : fileVersion.FileName, + MimeType : fileVersion.MimeType, + OriginalName : fileVersion.OriginalFileName, + Size : fileVersion.SizeInKB, + StorageKey : fileVersion.StorageKey, + Url : url + }; + + if (sanitize) { + v.StorageKey = null; + } + + return v; + }; + + } diff --git a/src/database/models/awards/badge.model.ts b/src/database/models/awards/badge.model.ts index 9a2b025..44f733b 100644 --- a/src/database/models/awards/badge.model.ts +++ b/src/database/models/awards/badge.model.ts @@ -40,6 +40,9 @@ export class Badge { @JoinTable() Category: BadgeCategory; + @Column({ type: 'varchar', length: 4096, nullable: true }) + HowToEarn : string; + @CreateDateColumn() CreatedAt : Date; diff --git a/src/database/models/awards/badge.stock.image.model.ts b/src/database/models/awards/badge.stock.image.model.ts new file mode 100644 index 0000000..94f54a3 --- /dev/null +++ b/src/database/models/awards/badge.stock.image.model.ts @@ -0,0 +1,42 @@ +import { IsUUID } from "class-validator"; +import "reflect-metadata"; +import { + Column, + CreateDateColumn, + DeleteDateColumn, + Entity, + PrimaryGeneratedColumn, + UpdateDateColumn, +} from 'typeorm'; + +//////////////////////////////////////////////////////////////////////// + +@Entity({ name: 'badge_stock_images' }) +export class BadgeStockImage { + + @PrimaryGeneratedColumn() + id : number; + + @Column({ type: 'varchar', length: 64, nullable: true }) + Code : string; + + @Column({ type: 'varchar', length: 256, nullable: false }) + FileName : string; + + @Column({ type: 'uuid', nullable: true }) + @IsUUID() + ResourceId : string; + + @Column({ type: 'varchar', length: 2048, nullable: true }) + PublicUrl: string; + + @CreateDateColumn() + CreatedAt : Date; + + @UpdateDateColumn() + UpdatedAt : Date; + + @DeleteDateColumn() + DeletedAt : Date; + +} diff --git a/src/database/models/awards/participant.group.model.ts b/src/database/models/awards/participant.group.model.ts index 1c64749..b59c0ae 100644 --- a/src/database/models/awards/participant.group.model.ts +++ b/src/database/models/awards/participant.group.model.ts @@ -23,6 +23,9 @@ export class ParticipantGroup { @PrimaryGeneratedColumn('uuid') id : string; + @Column({ type: 'varchar', length: 256, nullable: true }) + ReferenceId : string; //This is id of the group in external system + @ManyToOne(() => Client, { nullable: true }) @JoinColumn() Client : Client; diff --git a/src/database/models/general/file.resource.model.ts b/src/database/models/general/file.resource.model.ts index f36d738..5fe6c6d 100644 --- a/src/database/models/general/file.resource.model.ts +++ b/src/database/models/general/file.resource.model.ts @@ -1,4 +1,5 @@ import "reflect-metadata"; +import { FileResourceMetadata } from "../../../domain.types/general/file.resource/file.resource.types"; import { Column, Entity, @@ -6,9 +7,11 @@ import { CreateDateColumn, UpdateDateColumn, DeleteDateColumn, + OneToOne, } from 'typeorm'; import { User } from './../user/user.model'; +import { FileResourceVersion } from "./file.resource.version.model"; //////////////////////////////////////////////////////////////////////// @@ -18,15 +21,26 @@ export class FileResource { @PrimaryGeneratedColumn('uuid') id : string; + @Column({ type: 'varchar', length: 1024, nullable: true }) + OriginalFilename : string; + @Column({ type: 'varchar', length: 1024, nullable: false }) StorageKey : string; - @Column({ type: 'varchar', length: 256, nullable: false }) - OriginalFilename : string; + @OneToOne(() => User) + @Column({ type: 'uuid', nullable: true }) + OwnerUserId : string; + + @OneToOne(() => User) + @Column({ type: 'uuid', nullable: true }) + UploadedByUserId : string; @Column({ type: 'varchar', length: 256, nullable: false }) MimeType : string; + @Column({ type: 'varchar', length: 256, nullable: true }) + Url : string; + @Column({ type: 'boolean', nullable: false, default: false }) Public : boolean; @@ -39,9 +53,15 @@ export class FileResource { @Column({ type: 'uuid', nullable: true }) UploadedBy : User; - @Column('simple-json') + @Column({ type: 'simple-json', nullable: true}) Tags : string[]; + @Column({ type: 'uuid', nullable : true }) + DefaultVersionId: string; + + @Column({ type: 'simple-json', nullable : true }) + DefaultVersion: any; + @CreateDateColumn() CreatedAt : Date; diff --git a/src/database/models/general/file.resource.version.model.ts b/src/database/models/general/file.resource.version.model.ts new file mode 100644 index 0000000..8f793ff --- /dev/null +++ b/src/database/models/general/file.resource.version.model.ts @@ -0,0 +1,53 @@ +import "reflect-metadata"; +import { + Column, + Entity, + PrimaryGeneratedColumn, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + OneToOne, +} from 'typeorm'; + +import { FileResource } from "./file.resource.model"; + +//////////////////////////////////////////////////////////////////////// + +@Entity({ name: 'file_resource_versions' }) +export class FileResourceVersion { + + @PrimaryGeneratedColumn('uuid') + id : string; + + @OneToOne(() => FileResource) + @Column({ type: 'uuid'}) + ResourceId : string; + + @Column({ type: 'uuid', length: 256, nullable: true }) + FileName : string; + + @Column({ type: 'uuid', length: 256, nullable: true }) + OriginalFileName : string; + + @Column({ type: 'varchar', length: 32, nullable: true }) + Version : string; + + @Column({ type: 'varchar', length: 256, nullable: true }) + MimeType : string; + + @Column({ type: 'varchar', length: 512, nullable: true }) + StorageKey : string; + + @Column({ type: 'float', nullable: true }) + SizeInKB : number; + + @CreateDateColumn() + CreatedAt : Date; + + @UpdateDateColumn() + UpdatedAt : Date; + + @DeleteDateColumn() + DeletedAt : Date; + +} diff --git a/src/database/models/user/person.model.ts b/src/database/models/user/person.model.ts index 38ea5db..4f93b7e 100644 --- a/src/database/models/user/person.model.ts +++ b/src/database/models/user/person.model.ts @@ -21,7 +21,7 @@ export class Person { @Column({ type: 'varchar', length: 256, nullable: true }) ReferenceId : string; //This is id of the person in external system - @Column({ type: 'varchar', length: 256, nullable: false }) + @Column({ type: 'varchar', length: 256, nullable: true }) Prefix : string; @Column({ type: 'varchar', length: 256, nullable: false }) diff --git a/src/database/services/awards/badge.service.ts b/src/database/services/awards/badge.service.ts index a732e38..7950f1f 100644 --- a/src/database/services/awards/badge.service.ts +++ b/src/database/services/awards/badge.service.ts @@ -63,12 +63,33 @@ export class BadgeService extends BaseService { } }; + public getByClientId = async (clientId: uuid): Promise => { + try { + var badges = await this._badgeRepository.find({ + where : { + Client : { + id : clientId + } + }, + relations: { + Category: true, + Client : true + } + }); + return badges.map(x => BadgeMapper.toResponseDto(x)); + } catch (error) { + logger.error(error.message); + ErrorHandler.throwInternalServerError(error.message, 500); + } + }; + public search = async (filters: BadgeSearchFilters) : Promise => { try { var search = this.getSearchModel(filters); var { search, pageIndex, limit, order, orderByColumn } = this.addSortingAndPagination(search, filters); const [list, count] = await this._badgeRepository.findAndCount(search); + const searchResults = { TotalCount : count, RetrievedCount : list.length, @@ -116,6 +137,9 @@ export class BadgeService extends BaseService { if (model.ImageUrl != null) { badge.ImageUrl = model.ImageUrl; } + if (model.HowToEarn != null) { + badge.HowToEarn = model.HowToEarn; + } var record = await this._badgeRepository.save(badge); return BadgeMapper.toResponseDto(record); } catch (error) { @@ -144,7 +168,9 @@ export class BadgeService extends BaseService { private getSearchModel = (filters: BadgeSearchFilters) => { var search : FindManyOptions = { - relations : { + relations: { + Category: true, + Client : true }, where : { }, @@ -163,6 +189,7 @@ export class BadgeService extends BaseService { Name : true, Description: true, ImageUrl : true, + HowToEarn : true, CreatedAt : true, UpdatedAt : true, } diff --git a/src/database/services/awards/participant.group.service.ts b/src/database/services/awards/participant.group.service.ts index d27af58..49a9ff2 100644 --- a/src/database/services/awards/participant.group.service.ts +++ b/src/database/services/awards/participant.group.service.ts @@ -39,6 +39,7 @@ export class ParticipantGroupService extends BaseService { const client = await this.getClient(createModel.ClientId); const badge = this._groupRepository.create({ Client : client, + ReferenceId : createModel.ReferenceId, Name : createModel.Name, Description : createModel.Description, ImageUrl : createModel.ImageUrl, @@ -48,7 +49,7 @@ export class ParticipantGroupService extends BaseService { //Keep group context for this participant group const context = this._contextRepository.create({ Type : ContextType.Group, - ReferenceId : record.id, + ReferenceId : record.ReferenceId, Group : record, }); const contextRecord = await this._contextRepository.save(context); @@ -228,6 +229,7 @@ export class ParticipantGroupService extends BaseService { }, select : { id : true, + ReferenceId : true, Client : { id : true, Name : true, diff --git a/src/database/services/awards/participant.service.ts b/src/database/services/awards/participant.service.ts index 9e5cc49..3cbd949 100644 --- a/src/database/services/awards/participant.service.ts +++ b/src/database/services/awards/participant.service.ts @@ -13,6 +13,7 @@ import { uuid } from '../../../domain.types/miscellaneous/system.types'; import { StringUtils } from '../../../common/utilities/string.utils'; import { Context } from '../../models/engine/context.model'; import { ContextType } from '../../../domain.types/engine/engine.types'; +import { BadgeStockImage } from '../../../database/models/awards/badge.stock.image.model'; /////////////////////////////////////////////////////////////////////// @@ -30,6 +31,8 @@ export class ParticipantService extends BaseService { _badgeRepository: Repository = Source.getRepository(Badge); + _badgeStockImageRepository: Repository = Source.getRepository(BadgeStockImage); + //#endregion public create = async (createModel: ParticipantCreateModel) @@ -60,7 +63,7 @@ export class ParticipantService extends BaseService { var record = await this._participantRepository.save(participant); var context = await this._contextRepository.findOne({ - where: { + where : { ReferenceId : createModel.ReferenceId } }); @@ -73,10 +76,10 @@ export class ParticipantService extends BaseService { else { //Keep person context for this participant context = this._contextRepository.create({ - Type: ContextType.Person, + Type : ContextType.Person, ReferenceId : createModel.ReferenceId, Participant : record, - }) + }); const contextRecord = await this._contextRepository.save(context); logger.info(JSON.stringify(contextRecord, null, 2)); } @@ -90,13 +93,13 @@ export class ParticipantService extends BaseService { where : { id : id }, - relations: { - Client: true, + relations : { + Client : true, } }); var context = await this._contextRepository.findOne({ - where: { - ReferenceId: participant.ReferenceId + where : { + ReferenceId : participant.ReferenceId } }); return ParticipantMapper.toResponseDto(participant, context); @@ -112,32 +115,32 @@ export class ParticipantService extends BaseService { where : { ReferenceId : referenceId }, - select: { - id : true, - ReferenceId: true, - Client : { - id : true, - Name : true, - Code : true, - Email: true, + select : { + id : true, + ReferenceId : true, + Client : { + id : true, + Name : true, + Code : true, + Email : true, }, - BirthDate : true, - Prefix : true, - FirstName : true, - LastName : true, - CountryCode : true, - Phone : true, - Email : true, - Gender : true, - OnboardingDate: true, + BirthDate : true, + Prefix : true, + FirstName : true, + LastName : true, + CountryCode : true, + Phone : true, + Email : true, + Gender : true, + OnboardingDate : true, }, - relations: { - Client: true, + relations : { + Client : true, } }); var context = await this._contextRepository.findOne({ - where: { - ReferenceId: participant.ReferenceId + where : { + ReferenceId : participant.ReferenceId } }); return ParticipantMapper.toResponseDto(participant, context); @@ -249,7 +252,6 @@ export class ParticipantService extends BaseService { ErrorHandler.throwInternalServerError(error.message, 500); } }; - public awardBadge = async (id: string, badgeId: uuid, reason: string, acquiredDate = new Date()) : Promise => { @@ -265,10 +267,10 @@ export class ParticipantService extends BaseService { } }); var participantBadge = await this._participantBadgeRepository.create({ - Participant: participant, - Badge: badge, - AcquiredDate: acquiredDate, - Reason : reason + Participant : participant, + Badge : badge, + AcquiredDate : acquiredDate, + Reason : reason }); var record = await this._participantBadgeRepository.save(participantBadge); return record; @@ -286,11 +288,11 @@ export class ParticipantService extends BaseService { id : id } }, - relations: { - Badge: { - Category: true, + relations : { + Badge : { + Category : true, }, - Participant: true, + Participant : true, }, // select: { // Badge : { @@ -309,25 +311,26 @@ export class ParticipantService extends BaseService { // CreatedAt : true, // } }; + const list = await this._participantBadgeRepository.find(search); const participantBadges = list.map(x => { return { - ParticipantId: id, - Badge: { - id : x.Badge.id, - Name: x.Badge.Name, + ParticipantId : id, + Badge : { + id : x.Badge.id, + Name : x.Badge.Name, Description : x.Badge.Description, - Category: { - id: x.Badge.Category.id, - Name: x.Badge.Category.Name, - ImageUrl: x.Badge.Category.ImageUrl, + Category : { + id : x.Badge.Category.id, + Name : x.Badge.Category.Name, + ImageUrl : x.Badge.Category.ImageUrl, }, ImageUrl : x.Badge.ImageUrl, }, - AcquiredDate: x.AcquiredDate, - Reason: x.Reason, - CreatedAt: x.CreatedAt - } + AcquiredDate : x.AcquiredDate, + Reason : x.Reason, + CreatedAt : x.CreatedAt + }; }); return participantBadges; } catch (error) { @@ -373,6 +376,27 @@ export class ParticipantService extends BaseService { return search; }; + + public getBadgeImageUrl =async (participantBadges: ParticipantBadgeResponseDto[], classified: any) => { + + var result = null; + for await (var participantBadge of participantBadges) { + var badgeimage = await this._badgeStockImageRepository.findOne({ + where : { + Code : participantBadge.Badge.Name + } + }); + participantBadge.Badge.ImageUrl = badgeimage.PublicUrl ? badgeimage.PublicUrl: null; + result = { + BadgesByCategory: classified, + BadgeList: participantBadges, + }; + + } + return result; + }; + + //#endregion } diff --git a/src/database/services/badge.stock.images/badge.stock.image.service.ts b/src/database/services/badge.stock.images/badge.stock.image.service.ts new file mode 100644 index 0000000..cafe680 --- /dev/null +++ b/src/database/services/badge.stock.images/badge.stock.image.service.ts @@ -0,0 +1,57 @@ +import { logger } from '../../../logger/logger'; +import { ApiError, ErrorHandler } from '../../../common/handlers/error.handler'; +import { Source } from '../../database.connector'; +import { Repository } from 'typeorm'; +import { BadgeStockImage } from '../../../database/models/awards/badge.stock.image.model'; +import { BadgeStockImageDomainModel } from '../../../domain.types/badge.stock.image/badge.stock.image.domain.model'; +import { BadgeStockImageDto } from '../../../domain.types/badge.stock.image/badge.stock.image.dto'; +import { BadgeStockImageMapper } from '../../../database/mappers/awards/badge.stock.image.mapper'; + +/////////////////////////////////////////////////////////////////////// + +export class BadgeStockImageService { + + //#region Repositories + + _badgeStockRepository: Repository = Source.getRepository(BadgeStockImage); + + //#endregion + + public create = async (createModel: BadgeStockImageDomainModel): Promise => { + try { + const badgeStockImages = this._badgeStockRepository.create({ + Code : createModel.Code, + FileName : createModel.FileName, + ResourceId : createModel.ResourceId, + PublicUrl : createModel.PublicUrl, + + }); + var record = await this._badgeStockRepository.save(badgeStockImages); + return BadgeStockImageMapper.toResponseDto(record); + } catch (error) { + logger.error(error.message); + ErrorHandler.throwInternalServerError(error.message, 500); + } + }; + + getAll = async (): Promise => { + try { + + const foundResults = await this._badgeStockRepository.find(); + + const dtos: BadgeStockImageDto[] = []; + for (const stockImage of foundResults) { + const dto = await BadgeStockImageMapper.toResponseDto(stockImage); + dtos.push(dto); + } + + return dtos; + + } catch (error) { + console.log(error.message); + throw new ApiError(500, error.message); + } + }; + //#endregion + +} diff --git a/src/database/services/engine/schema.instance.service.ts b/src/database/services/engine/schema.instance.service.ts index ec406e1..c694c4e 100644 --- a/src/database/services/engine/schema.instance.service.ts +++ b/src/database/services/engine/schema.instance.service.ts @@ -292,13 +292,13 @@ export class SchemaInstanceService extends BaseService { if (filters.SchemaId) { search.where['Schema'] = { id: '' - } + }; search.where['Schema'].id = filters.SchemaId; } if (filters.ContextId) { search.where['Context'] = { id: '' - } + }; search.where['Context'].id = filters.ContextId; } diff --git a/src/database/services/general/file.resource.service.ts b/src/database/services/general/file.resource.service.ts index 3e0c2c1..10e29fd 100644 --- a/src/database/services/general/file.resource.service.ts +++ b/src/database/services/general/file.resource.service.ts @@ -1,3 +1,4 @@ +import fs from 'fs'; import { FileResource } from '../../models/general/file.resource.model'; import { User } from '../../models/user/user.model'; import { ErrorHandler } from '../../../common/handlers/error.handler'; @@ -12,6 +13,16 @@ import { FindManyOptions, Like, Repository } from 'typeorm'; import { FileResourceMapper } from '../../mappers/general/file.resource.mapper'; import { uuid } from '../../../domain.types/miscellaneous/system.types'; import { logger } from '../../../logger/logger'; +import { FileResourceDto } from '../../../domain.types/general/file.resource/file.resource.dto'; +import { FileResourceMetadata } from '../../../domain.types/general/file.resource/file.resource.types'; +import path from 'path'; +import { Helper } from '../../../common/helper'; +import { FileResourceVersion } from '../../../database/models/general/file.resource.version.model'; +import { FileResourceUploadDomainModel } from '../../../domain.types/general/file.resource/file.resource.domain.model'; +import { ConfigurationManager } from '../../../config/configuration.manager'; +import { TimeUtils } from '../../../common/utilities/time.utils'; +import { StorageService } from '../../../modules/storage/storage.service'; +import { Loader } from '../../../startup/loader'; /////////////////////////////////////////////////////////////////////////////////////////////// @@ -19,10 +30,18 @@ export class FileResourceService { //#region Models + _storageService: StorageService = null; + _fileResourceRepository : Repository = Source.getRepository(FileResource); + _fileResourceVersionRepository : Repository = Source.getRepository(FileResourceVersion); + _userRepository : Repository = Source.getRepository(User); + constructor() { + this._storageService = Loader.Container.resolve(StorageService); + } + //#endregion //#region Publics @@ -60,9 +79,9 @@ export class FileResourceService { where : { id : id }, - relations : { + /*relations : { UploadedBy : true - }, + },*/ select : { id : true, OriginalFilename : true, @@ -74,7 +93,7 @@ export class FileResourceService { Size : true, StorageKey : true, Tags : true, - UploadedBy : { + /*UploadedBy : { id : true, Client : { Name : true @@ -82,7 +101,7 @@ export class FileResourceService { FirstName : true, LastName : true, Prefix : true - }, + },*/ }, }); return FileResourceMapper.toResponseDto(record); @@ -234,6 +253,125 @@ export class FileResourceService { } }; + uploadLocal = async ( + storageKey: string, + sourceLocation: string, + isPublicResource: boolean + ): Promise => { + + var exists = fs.existsSync(sourceLocation); + if (!exists) { + console.log('Source file location does not exist!'); + } + + var existingStorageKey = await this._storageService.exists(storageKey); + if (existingStorageKey !== undefined && existingStorageKey !== null) { + storageKey = existingStorageKey; + } + else { + storageKey = await this._storageService.uploadLocally(storageKey, sourceLocation); + } + + if(!storageKey) { + console.log('Unable to upload file to storage!'); + return null; + } + + var stats = fs.statSync(sourceLocation); + var filename = path.basename(sourceLocation); + + var metadata: FileResourceMetadata = { + Version : '1', + OriginalName : filename, + FileName : filename, + SourceFilePath : null, + MimeType : Helper.getMimeType(sourceLocation), + Size : stats['size'] / 1024, + StorageKey : storageKey, + }; + + var domainModel: FileResourceUploadDomainModel = { + FileMetadata : metadata, + StorageKey : metadata.StorageKey, + FileName : metadata.FileName, + IsMultiResolutionImage : false, + MimeType : Helper.getMimeType(sourceLocation), + Public : isPublicResource, + }; + + var resource = await this._fileResourceRepository.create(domainModel); + var record = await this._fileResourceRepository.save(resource); + + domainModel.FileMetadata.ResourceId = record.id; + var version = await this.addVersion(domainModel.FileMetadata, true); + resource.DefaultVersion = version; + resource.Url = version.Url; + + return resource; + }; + + addVersion = async (metadata: FileResourceMetadata, makeDefaultVersion: boolean): Promise => { + + var fileVersion = { + ResourceId : metadata.ResourceId, + Version : metadata.Version, + FileName : metadata.FileName, + OriginalFileName : metadata.OriginalName, + MimeType : metadata.MimeType, + StorageKey : metadata.StorageKey, + SizeInKB : metadata.Size, + }; + + var record = await this._fileResourceVersionRepository.create(fileVersion); + var version = await this._fileResourceVersionRepository.save(record); + + if (version === null) { + throw new Error('Unable to create version instance in database!'); + } + + if (makeDefaultVersion) { + var resource = await this._fileResourceRepository.findOne({ + where : { + id : metadata.ResourceId + } + }); + if (resource === null) { + throw new Error('Unable to find resource!'); + } + resource.DefaultVersionId = version.id; + //await resource.save(); + } + + return FileResourceMapper.toFileVersionDto(version); + }; + + DownloadByVersion = async (resourceId: string, versionName: string): Promise => { + var downloadFolderPath = await this.generateDownloadFolderPath(); + //var versionMetadata = await this._fileResourceRepo.getVersionByVersionName(resourceId, versionName); + + var versionMetadata = await this._fileResourceVersionRepository.findOne({ + where : { + ResourceId : resourceId, + } + }); + // const versionMetadata_ = FileResourceMapper.toFileVersionDto(versionMetadata); + var localFilePath = path.join(downloadFolderPath, versionMetadata.FileName); + var localDestination = await this._storageService.download(versionMetadata.StorageKey, localFilePath); + return localDestination; + }; + + private generateDownloadFolderPath = async() => { + + var timestamp = TimeUtils.timestamp(new Date()); + var tempDownloadFolder = ConfigurationManager.DownloadTemporaryFolder; + var downloadFolderPath = path.join(tempDownloadFolder, timestamp); + + //Make sure the path exists + await fs.promises.mkdir(downloadFolderPath, { recursive: true }); + + return downloadFolderPath; + }; + //#endregion } diff --git a/src/domain.types/awards/badge.domain.types.ts b/src/domain.types/awards/badge.domain.types.ts index 6bd5e4d..dd2fff0 100644 --- a/src/domain.types/awards/badge.domain.types.ts +++ b/src/domain.types/awards/badge.domain.types.ts @@ -22,25 +22,27 @@ export interface BadgeUpdateModel { Name? : string; Description? : string; ImageUrl? : string; + HowToEarn? : string; } export interface BadgeResponseDto { - id : uuid; - Name : string; - Description: string; - ImageUrl : string; - Category : { - id : uuid; - Name : string; - Description: string; + id : uuid; + Name : string; + Description : string; + ImageUrl : string; + HowToEarn : string; + Category : { + id : uuid; + Name : string; + Description : string; }; Client: { - id : uuid; - Name: string; - Code: string; + id : uuid; + Name : string; + Code : string; }; - CreatedAt: Date; - UpdatedAt: Date; + CreatedAt : Date; + UpdatedAt : Date; } export interface BadgeSearchFilters extends BaseSearchFilters { diff --git a/src/domain.types/awards/participant.group.domain.types.ts b/src/domain.types/awards/participant.group.domain.types.ts index 81e083f..de9ff66 100644 --- a/src/domain.types/awards/participant.group.domain.types.ts +++ b/src/domain.types/awards/participant.group.domain.types.ts @@ -10,6 +10,7 @@ import { export interface ParticipantGroupCreateModel { ClientId : uuid; + ReferenceId? : uuid; Name : string; Description? : string; ImageUrl : string; @@ -18,12 +19,14 @@ export interface ParticipantGroupCreateModel { export interface ParticipantGroupUpdateModel { ClientId : uuid; Name? : string; + ReferenceId? : uuid; Description? : string; ImageUrl? : string; } export interface ParticipantGroupResponseDto { - id : uuid; + id : uuid; + ReferenceId: uuid; Client: { id : uuid; Name: string; @@ -47,6 +50,7 @@ export interface ParticipantGroupResponseDto { export interface ParticipantGroupSearchFilters extends BaseSearchFilters { ClientId? : uuid; + ReferenceId? : uuid; Name? : string; ParticipantId? : uuid; } diff --git a/src/domain.types/badge.stock.image/badge.stock.image.domain.model.ts b/src/domain.types/badge.stock.image/badge.stock.image.domain.model.ts new file mode 100644 index 0000000..da4bcd4 --- /dev/null +++ b/src/domain.types/badge.stock.image/badge.stock.image.domain.model.ts @@ -0,0 +1,7 @@ +export interface BadgeStockImageDomainModel { + id? : number; + Code? : string; + FileName? : string; + ResourceId : string; + PublicUrl? : string; +} diff --git a/src/domain.types/badge.stock.image/badge.stock.image.dto.ts b/src/domain.types/badge.stock.image/badge.stock.image.dto.ts new file mode 100644 index 0000000..922e392 --- /dev/null +++ b/src/domain.types/badge.stock.image/badge.stock.image.dto.ts @@ -0,0 +1,7 @@ +export interface BadgeStockImageDto { + id? : number; + Code? : string; + FileName? : string; + ResourceId : string; + PublicUrl? : string; +} diff --git a/src/domain.types/engine/engine.types.ts b/src/domain.types/engine/engine.types.ts index 07b92cc..fb56128 100644 --- a/src/domain.types/engine/engine.types.ts +++ b/src/domain.types/engine/engine.types.ts @@ -143,6 +143,7 @@ export const ConditionOperandDataTypeList: OperandDataType[] = [ OperandDataType.Boolean, OperandDataType.Text, OperandDataType.Array, + OperandDataType.Object, OperandDataType.Date, ]; diff --git a/src/domain.types/general/file.resource.domain.types.ts b/src/domain.types/general/file.resource.domain.types.ts index cb1d68f..79ed8f8 100644 --- a/src/domain.types/general/file.resource.domain.types.ts +++ b/src/domain.types/general/file.resource.domain.types.ts @@ -4,6 +4,7 @@ import { uuid } from "../miscellaneous/system.types"; export interface FileResourceCreateModel { StorageKey ?: string; MimeType ?: string; + Metadata ?: any; OriginalFilename ?: string; UserId ?: uuid; Size ?: number; diff --git a/src/domain.types/general/file.resource/file.resource.domain.model.ts b/src/domain.types/general/file.resource/file.resource.domain.model.ts new file mode 100644 index 0000000..d937110 --- /dev/null +++ b/src/domain.types/general/file.resource/file.resource.domain.model.ts @@ -0,0 +1,26 @@ +import { FileResourceMetadata, ResourceReference } from "./file.resource.types"; + +export interface FileResourceUploadDomainModel { + FileMetadata : FileResourceMetadata; + OwnerUserId? : string; + UploadedByUserId? : string; + Public? : boolean; + IsMultiResolutionImage? : boolean; + MimeType? : string; + DefaultVersionId? : string; + StorageKey? : string; + FileName? : string; +} + +export interface FileResourceRenameDomainModel { + id? : string, + NewFileName : string; +} + +export interface FileResourceUpdateModel { + FileMetadata? : FileResourceMetadata; + ResourceId : string; + References? : ResourceReference[]; + Tags? : string[]; + IsMultiResolutionImage? : boolean; +} diff --git a/src/domain.types/general/file.resource/file.resource.dto.ts b/src/domain.types/general/file.resource/file.resource.dto.ts new file mode 100644 index 0000000..073c855 --- /dev/null +++ b/src/domain.types/general/file.resource/file.resource.dto.ts @@ -0,0 +1,25 @@ +import { FileResourceMetadata, ResourceReference } from "./file.resource.types"; + +export interface FileResourceDetailsDto { + id? : string; + FileName? : string; + Url? : string; + OwnerUserId? : string; + UploadedByUserId? : string; + IsPublicResource? : boolean; + MimeType? : string; + DefaultVersion? : FileResourceMetadata; + Versions? : FileResourceMetadata[]; + References? : ResourceReference[]; + Tags? : string[]; +} + +export interface FileResourceDto { + id? : string; + FileName? : string; + Url? : string; + OwnerUserId? : string; + IsPublicResource? : boolean; + MimeType? : string; + DefaultVersion? : any; +} diff --git a/src/domain.types/general/file.resource/file.resource.search.types.ts b/src/domain.types/general/file.resource/file.resource.search.types.ts new file mode 100644 index 0000000..a2cd044 --- /dev/null +++ b/src/domain.types/general/file.resource/file.resource.search.types.ts @@ -0,0 +1,29 @@ +import { FileResourceDto } from "./file.resource.dto"; + +////////////////////////////////////////////////////////////////////// + +export interface FileResourceSearchFilters { + OwnerUserId? : string, + UploadedByUserId? : string, + IsPublicResource? : boolean; + ReferenceId? : string; + ReferenceType? : string; + ReferenceKeyword? : string; + Tag? : string; + CreatedDateFrom? : Date; + CreatedDateTo? : Date; + OrderBy? : string; + Order? : string; + PageIndex? : number; + ItemsPerPage? : number; +} + +export interface FileResourceSearchResults { + TotalCount : number; + RetrievedCount : number; + PageIndex : number; + ItemsPerPage : number; + Order : string; + OrderedBy : string; + Items : FileResourceDto[]; +} diff --git a/src/domain.types/general/file.resource/file.resource.types.ts b/src/domain.types/general/file.resource/file.resource.types.ts new file mode 100644 index 0000000..60bed84 --- /dev/null +++ b/src/domain.types/general/file.resource/file.resource.types.ts @@ -0,0 +1,31 @@ +import { Stream } from "stream"; + +export interface ResourceReference { + ItemId : string; + ItemType : string; + Keyword : string; +} + +export enum DownloadDisposition { + Inline = 'inline', + Attachment = 'attachment', + Stream = 'stream', + Auto = 'auto', +} + +export interface FileResourceMetadata { + ResourceId? : string; + VersionId? : string; + Version? : string; + FileName? : string; + OriginalName? : string; + SourceFilePath? : string; + MimeType? : string; + Size? : number; + StorageKey? : string; + IsDefaultVersion? : boolean; + IsPublicResource? : boolean; + Disposition? : DownloadDisposition; + Url? : string; + Stream? : Stream; +} diff --git a/src/modules/engine.execution/execution.types.ts b/src/modules/engine.execution/execution.types.ts index d1a751d..4ba5ba1 100644 --- a/src/modules/engine.execution/execution.types.ts +++ b/src/modules/engine.execution/execution.types.ts @@ -59,29 +59,43 @@ export class CCondition { } export class CContext { + id : uuid; + ReferenceId : uuid; + Type : ContextType; + Participant?: { id : uuid; FirstName: string; LastName : string; }; + ParticipantGroup ?: { id : uuid; Name : string; Description: string; - } + }; + } export class CAction { + id : uuid; + ActionType : EventActionType; + Name : string | undefined; + Description : string | undefined; + ParentNodeId: uuid | undefined; + InputParams : any; + OutputParams: ActionOutputParams; + } export class CNode { @@ -249,6 +263,7 @@ export class CSchemaInstance { Almanac : AlmanacObject[]; CSchemaInstance() { + // } public setCurrent = (instance: CNodeInstance) => { @@ -257,6 +272,6 @@ export class CSchemaInstance { public fetchAlmanacData = (tag: string) => { return this.Almanac.find(x => x.Name === tag); - } + }; } diff --git a/src/modules/engine.execution/rule.converter.ts b/src/modules/engine.execution/rule.converter.ts index 6c1f9f0..616c4a0 100644 --- a/src/modules/engine.execution/rule.converter.ts +++ b/src/modules/engine.execution/rule.converter.ts @@ -1,7 +1,7 @@ import { CompositionOperator, LogicalOperator, OperatorType } from '../../domain.types/engine/engine.types'; import { CCondition, - CRule} from './execution.types'; + CRule } from './execution.types'; export class RuleConverter { @@ -10,30 +10,30 @@ export class RuleConverter { var condition = rule.RootCondition as CCondition; var decision: any = { - conditions: RuleConverter.addCompositeCondition(condition), - event: { - type: rule.Action?.ActionType, - params: rule.Action?.OutputParams + conditions : RuleConverter.addCompositeCondition(condition), + event : { + type : rule.Action?.ActionType, + params : rule.Action?.OutputParams } }; return decision; - } + }; private static addCompositeCondition(condition: CCondition) { - if(condition.OperatorType !== OperatorType.Composition) { + if (condition.OperatorType !== OperatorType.Composition) { throw new Error('Expecting a composite condition!'); } var list = RuleConverter.addChildrenConditions(condition); if (condition.Operator == CompositionOperator.And) { return { all : list - } + }; } else { return { any : list - } + }; } } @@ -58,14 +58,14 @@ export class RuleConverter { } var operator = RuleConverter.translateLogicalOperator(condition.Operator as LogicalOperator); return { - fact: condition.Fact, - operator: operator, - value: condition.Value - } + fact : condition.Fact, + operator : operator, + value : condition.Value + }; } private static translateLogicalOperator(operator: LogicalOperator) { - switch(operator) { + switch (operator) { case LogicalOperator.Equal: { return 'equal'; diff --git a/src/modules/engine.execution/schema.engine.ts b/src/modules/engine.execution/schema.engine.ts index eabe3d0..3ca68db 100644 --- a/src/modules/engine.execution/schema.engine.ts +++ b/src/modules/engine.execution/schema.engine.ts @@ -30,7 +30,7 @@ export class SchemaEngine { logger.info(`Current node : ${currentNodeInstance.Name}`); logger.info(`Current node Id : ${currentNodeInstance.id}`); - while (currentNodeInstance && + while (currentNodeInstance && currentNodeInstance.ExecutionStatus === ExecutionStatus.Pending) { currentNodeInstance = await SchemaEngine.traverse( schemaInstance.Context, @@ -47,7 +47,7 @@ export class SchemaEngine { schemaInstance: CSchemaInstance, currentNodeInstance: CNodeInstance, facts: any - ): Promise { + ): Promise { const processor = Loader.Container.resolve(ProcessorService); @@ -80,8 +80,8 @@ export class SchemaEngine { //Extract data based on the action subject filters const data = await processor.extractData(context.id, action.InputParams, action.OutputParams); schemaInstance.Almanac.push({ - Name: data.Tag, - Data: data.Data + Name : data.Tag, + Data : data.Data }); return SchemaEngine.getNextNode(currentNodeInstance, schemaInstance); } @@ -94,12 +94,12 @@ export class SchemaEngine { } if (dataActionType === DataActionType.CalculateContinuity) { const data = await processor.calculateContinuity( - almanacObject.Data, - action.InputParams as ContinuityInputParams, + almanacObject.Data, + action.InputParams as ContinuityInputParams, action.OutputParams as OutputParams); schemaInstance.Almanac.push({ - Name: data.Tag, - Data: data.Data + Name : data.Tag, + Data : data.Data }); } @@ -118,13 +118,13 @@ export class SchemaEngine { } if (dataActionType === DataActionType.FindRangeDifference) { const data = await processor.compareRanges( - almanacObjectFirst.Data, + almanacObjectFirst.Data, almanacObjectSecond.Data, - action.InputParams as RangeComparisonInputParams, + action.InputParams as RangeComparisonInputParams, action.OutputParams as OutputParams); schemaInstance.Almanac.push({ - Name: data.Tag, - Data: data.Data + Name : data.Tag, + Data : data.Data }); } @@ -138,16 +138,16 @@ export class SchemaEngine { } const added = await processor.storeData(context.id, almanacObject.Data.ToBeAdded, action.InputParams, action.OutputParams); var removedData = null; - if (almanacObject.Data.ToBeRemoved) { + if (almanacObject.Data.ToBeRemoved.length > 0) { const removed = await processor.removeData(context.id, almanacObject.Data.ToBeRemoved, action.InputParams, action.OutputParams); removedData = removed?.Data; } schemaInstance.Almanac.push({ - Name: action.OutputParams.OutputTag, - Data: { - Added : added.Data, - Removed: removedData, + Name : action.OutputParams.OutputTag, + Data : { + Added : added.Data, + Removed : removedData, } }); return SchemaEngine.getNextNode(currentNodeInstance, schemaInstance); @@ -212,8 +212,8 @@ export class SchemaEngine { } private static getNextNode = (currentNodeInstance, schemaInstance) => { - if (currentNodeInstance.Action && - currentNodeInstance.Action.OutputParams && + if (currentNodeInstance.Action && + currentNodeInstance.Action.OutputParams && currentNodeInstance.Action.OutputParams.NextNodeId) { const nextNodeId = currentNodeInstance.Action.OutputParams.NextNodeId; const nodeInstances = schemaInstance.NodeInstances; diff --git a/src/modules/fact.extractors/facts.db.client.ts b/src/modules/fact.extractors/facts.db.client.ts new file mode 100644 index 0000000..430847f --- /dev/null +++ b/src/modules/fact.extractors/facts.db.client.ts @@ -0,0 +1,64 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const mysql = require('mysql2'); +import { logger } from '../../logger/logger'; +import { Config } from '../../database/database.config'; + +//////////////////////////////////////////////////////////////// + +export default class FactsDbClient { + + public static createDatabase = async () => { + try { + const database = `awards_facts`; + const query = `CREATE DATABASE ${database}`; + await FactsDbClient.executeQuery(query); + logger.info(`Database ${database} created successfully!`); + } catch (error) { + logger.error(error.message); + } + }; + + private static executeQuery = (query): Promise => { + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + return new Promise((resolve, reject) => { + try { + const connection = mysql.createConnection({ + host : Config.host, + user : Config.username, + password : Config.password, + }); + + connection.connect(function (err) { + if (err) { + logger.error(err.message); + reject(err); + } + + //logger.log('Connected!'); + connection.query(query, function (err, result) { + if (err) { + logger.error(err.message); + + var str = (result !== undefined && result !== null) ? result.toString() : null; + if (str != null) { + logger.error(str); + } + else { + logger.error(`Query: ${query}`); + } + reject(err); + } + resolve(true); + }); + }); + + } + catch (error) { + logger.error(error.message); + } + }); + + }; + +} \ No newline at end of file diff --git a/src/modules/fact.extractors/facts.db.connector.ts b/src/modules/fact.extractors/facts.db.connector.ts index a6e3764..2387a05 100644 --- a/src/modules/fact.extractors/facts.db.connector.ts +++ b/src/modules/fact.extractors/facts.db.connector.ts @@ -7,6 +7,9 @@ import { BadgeFact } from './models/bedge.facts.model'; import { MedicationFact } from './models/medication.fact.model'; import { DBLogger } from "./../../database/database.logger"; import { NutritionChoiceFact } from "./models/nutrition.choice.fact.model"; +import { ExercisePhysicalActivityFact } from "./models/exercise.physical.activity.fact.model"; +import { VitalFact } from "./models/vital.fact.model"; +import { MentalHealthFact } from "./models/mental.health.fact.model"; /////////////////////////////////////////////////////////////////////////////////// const DATABASE_NAME = `awards_facts`; @@ -28,6 +31,9 @@ class FactsDatabaseConnector { MedicationFact, BadgeFact, NutritionChoiceFact, + ExercisePhysicalActivityFact, + VitalFact, + MentalHealthFact ], migrations : [], subscribers : [], diff --git a/src/modules/fact.extractors/models/exercise.physical.activity.fact.model.ts b/src/modules/fact.extractors/models/exercise.physical.activity.fact.model.ts new file mode 100644 index 0000000..1983098 --- /dev/null +++ b/src/modules/fact.extractors/models/exercise.physical.activity.fact.model.ts @@ -0,0 +1,39 @@ +import "reflect-metadata"; +import { + Column, + Entity, + PrimaryGeneratedColumn, +} from 'typeorm'; + +//////////////////////////////////////////////////////////////////////// + +@Entity({ name: 'exercise_physical_activity_facts' }) +export class ExercisePhysicalActivityFact { + + @PrimaryGeneratedColumn('uuid') + id : string; + + @Column({ type: 'uuid', nullable: false }) + ContextReferenceId : string; + + @Column({ type: 'uuid', nullable: true }) + RecordId : string; + + @Column({ nullable: true, default: false }) + PhysicalActivityQuestionAns: boolean; + + @Column({ nullable: true }) + RecordDate : Date; + + @Column({ nullable: true }) + RecordDateStr : string; + + @Column({ + type : 'varchar', + length : 16, + nullable : false, + default : '+05:30', + }) + RecordTimeZone: string; + +} diff --git a/src/modules/fact.extractors/models/medication.fact.model.ts b/src/modules/fact.extractors/models/medication.fact.model.ts index 4329a39..3931f09 100644 --- a/src/modules/fact.extractors/models/medication.fact.model.ts +++ b/src/modules/fact.extractors/models/medication.fact.model.ts @@ -34,4 +34,12 @@ export class MedicationFact { @Column({ nullable: true }) RecordDateStr : string; + @Column({ + type : 'varchar', + length : 16, + nullable : false, + default : '+05:30', + }) + RecordTimeZone: string; + } diff --git a/src/modules/fact.extractors/models/mental.health.fact.model.ts b/src/modules/fact.extractors/models/mental.health.fact.model.ts new file mode 100644 index 0000000..1bee7fe --- /dev/null +++ b/src/modules/fact.extractors/models/mental.health.fact.model.ts @@ -0,0 +1,45 @@ +import "reflect-metadata"; +import { + Column, + Entity, + PrimaryGeneratedColumn, +} from 'typeorm'; + +//////////////////////////////////////////////////////////////////////// + +@Entity({ name: 'mental_health_facts' }) +export class MentalHealthFact { + + @PrimaryGeneratedColumn('uuid') + id : string; + + @Column({ type: 'uuid', nullable: false }) + ContextReferenceId : string; + + @Column({ type: 'uuid', nullable: true }) + RecordId : string; + + @Column({ type: 'varchar', length: 256, nullable: true }) + Name : string; + + @Column({ nullable: true }) + Duration: number; + + @Column({ type: 'varchar', length: 128, nullable: true }) + Unit : string; + + @Column({ nullable: true }) + RecordDate : Date; + + @Column({ nullable: true }) + RecordDateStr : string; + + @Column({ + type : 'varchar', + length : 16, + nullable : false, + default : '+05:30', + }) + RecordTimeZone: string; + +} diff --git a/src/modules/fact.extractors/models/nutrition.choice.fact.model.ts b/src/modules/fact.extractors/models/nutrition.choice.fact.model.ts index bcfdde4..278d83a 100644 --- a/src/modules/fact.extractors/models/nutrition.choice.fact.model.ts +++ b/src/modules/fact.extractors/models/nutrition.choice.fact.model.ts @@ -28,4 +28,12 @@ export class NutritionChoiceFact { @Column({ nullable: true }) RecordDateStr : string; + @Column({ + type : 'varchar', + length : 16, + nullable : false, + default : '+05:30', + }) + RecordTimeZone: string; + } diff --git a/src/modules/fact.extractors/models/vital.fact.model.ts b/src/modules/fact.extractors/models/vital.fact.model.ts new file mode 100644 index 0000000..9d42c9e --- /dev/null +++ b/src/modules/fact.extractors/models/vital.fact.model.ts @@ -0,0 +1,49 @@ +import { float } from "aws-sdk/clients/cloudfront"; +import "reflect-metadata"; +import { + Column, + Entity, + PrimaryGeneratedColumn, +} from 'typeorm'; + +//////////////////////////////////////////////////////////////////////// + +@Entity({ name: 'vital_facts' }) +export class VitalFact { + + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ type: 'uuid', nullable: false }) + ContextReferenceId: string; + + @Column({ type: 'uuid', nullable: true }) + RecordId: string; + + @Column({ type: 'varchar', length: 256, nullable: true }) + VitalName: string; + + @Column({ nullable: true, default: null }) + VitalPrimaryValue: float; + + @Column({ nullable: true, default: null }) + VitalSecondaryValue: float; + + @Column({ type: 'varchar', length: 16, nullable: true }) + Unit: string; + + @Column({ nullable: true }) + RecordDate: Date; + + @Column({ nullable: true }) + RecordDateStr: string; + + @Column({ + type : 'varchar', + length : 16, + nullable : false, + default : '+05:30', + }) + RecordTimeZone: string; + +} diff --git a/src/modules/processor/providers/implementation/data.comparator.ts b/src/modules/processor/providers/implementation/data.comparator.ts index d856073..2926ac4 100644 --- a/src/modules/processor/providers/implementation/data.comparator.ts +++ b/src/modules/processor/providers/implementation/data.comparator.ts @@ -42,7 +42,7 @@ export class DataComparator implements IDataComparator { if (toBeAdded.length > 0) { for (const r of referenceRange) { const found = toBeAdded.find(x => x.key === r.key); - if (!found) { + if (found) { toBeRemoved.push(r); } } diff --git a/src/modules/processor/providers/implementation/data.extractors/data.extractor.ts b/src/modules/processor/providers/implementation/data.extractors/data.extractor.ts index 064f760..ff4e5b4 100644 --- a/src/modules/processor/providers/implementation/data.extractors/data.extractor.ts +++ b/src/modules/processor/providers/implementation/data.extractors/data.extractor.ts @@ -9,6 +9,9 @@ import { DataExtractionInputParams, OutputParams, ProcessorResult } from '../../ import { MedicationDataExtractor } from './medication.data.extractor'; import { BadgeDataExtractor } from "./badge.data.extractor"; import { NutritionDataExtractor } from "./nutrition.data.extractor"; +import { ExercisePhysicalActivityDataExtractor } from "./exercise.physical.activity.data.extractor"; +import { VitalDataExtractor } from "./vital.data.extractor"; +import { MentalHealthDataExtractor } from "./mental.health.data.extractor"; ////////////////////////////////////////////////////////////////////// @@ -61,6 +64,15 @@ export class DataExtractor implements IDataExtractor { else if (recordType === 'Nutrition') { return new NutritionDataExtractor(); } + else if (recordType === 'Exercise') { + return new ExercisePhysicalActivityDataExtractor(); + } + else if (recordType === 'Vital') { + return new VitalDataExtractor(); + } + else if (recordType === 'MentalHealth') { + return new MentalHealthDataExtractor(); + } return null; }; diff --git a/src/modules/processor/providers/implementation/data.extractors/exercise.physical.activity.data.extractor.ts b/src/modules/processor/providers/implementation/data.extractors/exercise.physical.activity.data.extractor.ts new file mode 100644 index 0000000..13b2d5f --- /dev/null +++ b/src/modules/processor/providers/implementation/data.extractors/exercise.physical.activity.data.extractor.ts @@ -0,0 +1,84 @@ +import { Repository } from "typeorm"; +import { FactsSource } from '../../../../fact.extractors/facts.db.connector'; +import { Context } from "../../../../../database/models/engine/context.model"; +import { DataExtractionInputParams, DataSamplingMethod, OutputParams, ProcessorResult } from '../../../../../domain.types/engine/engine.types'; +import { IExtractor } from "./extractor.interface"; +import { ExercisePhysicalActivityFact } from "../../../../../modules/fact.extractors/models/exercise.physical.activity.fact.model"; + +////////////////////////////////////////////////////////////////////// + +export class ExercisePhysicalActivityDataExtractor implements IExtractor { + + //#region Repositories + + _physicalActivityRepository: Repository = + FactsSource.getRepository(ExercisePhysicalActivityFact); + + //#endregion + + public extract = async ( + context: Context, + inputParams: DataExtractionInputParams, + outputParams: OutputParams) => { + + const filters = inputParams.Filters ?? {}; + var samplingMethod = filters['SamplingMethod'] as DataSamplingMethod; + if (!samplingMethod) { + samplingMethod = DataSamplingMethod.Any; + } + + const records = await this._physicalActivityRepository.find({ + where : { + ContextReferenceId : context.ReferenceId + }, + }); + + const groupedRecords = records.reduce((acc, obj) => { + const key = obj.RecordDateStr; + if (!acc[key]) { + acc[key] = []; + } + acc[key].push(obj); + return acc; + }, {}); + + const dayStats: { Day: string; Passed: boolean;}[] = []; + if (samplingMethod === DataSamplingMethod.Any) { + for (var grKey of Object.keys(groupedRecords)) { + const arr = groupedRecords[grKey]; + const passed = arr.some(obj => obj.PhysicalActivityQuestionAns === true); // Check only for one record per day + dayStats.push({ + Day : grKey, + Passed : passed, + }); + } + } + else { + for (var grKey of Object.keys(groupedRecords)) { + const arr = groupedRecords[grKey]; + const passed = arr.every(obj => obj.PhysicalActivityQuestionAns === true); // Check all records for the day + dayStats.push({ + Day : grKey, + Passed : passed, + }); + } + } + + const sorted = dayStats.sort((a, b) => Date.parse(a.Day) - Date.parse(b.Day)); + const transformed = sorted.map(x => { + return { + key : new Date(x.Day), + value : x.Passed, + }; + }); + + const result: ProcessorResult = { + Success : true, + Tag : outputParams.OutputTag, + Data : transformed + }; + + return result; + }; + +} diff --git a/src/modules/processor/providers/implementation/data.extractors/medication.data.extractor.ts b/src/modules/processor/providers/implementation/data.extractors/medication.data.extractor.ts index f32b8a6..7d690f2 100644 --- a/src/modules/processor/providers/implementation/data.extractors/medication.data.extractor.ts +++ b/src/modules/processor/providers/implementation/data.extractors/medication.data.extractor.ts @@ -21,7 +21,7 @@ export class MedicationDataExtractor implements IExtractor { const filters = inputParams.Filters ?? {}; var samplingMethod = filters['SamplingMethod'] as DataSamplingMethod; if (!samplingMethod) { - samplingMethod = DataSamplingMethod.Any; + samplingMethod = DataSamplingMethod.All; } const records = await this._medicationRepository.find({ diff --git a/src/modules/processor/providers/implementation/data.extractors/mental.health.data.extractor.ts b/src/modules/processor/providers/implementation/data.extractors/mental.health.data.extractor.ts new file mode 100644 index 0000000..b9ca920 --- /dev/null +++ b/src/modules/processor/providers/implementation/data.extractors/mental.health.data.extractor.ts @@ -0,0 +1,83 @@ +import { Repository } from "typeorm"; +import { FactsSource } from '../../../../fact.extractors/facts.db.connector'; +import { Context } from "../../../../../database/models/engine/context.model"; +import { DataExtractionInputParams, DataSamplingMethod, OutputParams, ProcessorResult } from '../../../../../domain.types/engine/engine.types'; +import { IExtractor } from "./extractor.interface"; +import { MentalHealthFact } from "../../../../../modules/fact.extractors/models/mental.health.fact.model"; + +////////////////////////////////////////////////////////////////////// + +export class MentalHealthDataExtractor implements IExtractor { + + //#region Repositories + + _mentalHealthRepository: Repository = FactsSource.getRepository(MentalHealthFact); + + //#endregion + + public extract = async ( + context: Context, + inputParams: DataExtractionInputParams, + outputParams: OutputParams) => { + + const filters = inputParams.Filters ?? {}; + var samplingMethod = filters['SamplingMethod'] as DataSamplingMethod; + if (!samplingMethod) { + samplingMethod = DataSamplingMethod.Any; + } + + const records = await this._mentalHealthRepository.find({ + where : { + ContextReferenceId : context.ReferenceId + }, + }); + + const groupedRecords = records.reduce((acc, obj) => { + const key = obj.RecordDateStr; + if (!acc[key]) { + acc[key] = []; + } + acc[key].push(obj); + return acc; + }, {}); + + const dayStats: { Day: string; Passed: boolean;}[] = []; + if (samplingMethod === DataSamplingMethod.Any) { + for (var grKey of Object.keys(groupedRecords)) { + const arr = groupedRecords[grKey]; + const passed = arr.some(obj => obj.Duration != null); // Check only for one record per day + dayStats.push({ + Day : grKey, + Passed : passed, + }); + } + } + else { + for (var grKey of Object.keys(groupedRecords)) { + const arr = groupedRecords[grKey]; + const passed = arr.every(obj => obj.Duration != null); // Check all records for the day + dayStats.push({ + Day : grKey, + Passed : passed, + }); + } + } + + const sorted = dayStats.sort((a, b) => Date.parse(a.Day) - Date.parse(b.Day)); + const transformed = sorted.map(x => { + return { + key : new Date(x.Day), + value : x.Passed, + }; + }); + + const result: ProcessorResult = { + Success : true, + Tag : outputParams.OutputTag, + Data : transformed + }; + + return result; + }; + +} diff --git a/src/modules/processor/providers/implementation/data.extractors/vital.data.extractor.ts b/src/modules/processor/providers/implementation/data.extractors/vital.data.extractor.ts new file mode 100644 index 0000000..ffec3a2 --- /dev/null +++ b/src/modules/processor/providers/implementation/data.extractors/vital.data.extractor.ts @@ -0,0 +1,84 @@ +import { Repository } from "typeorm"; +import { FactsSource } from '../../../../fact.extractors/facts.db.connector'; +import { Context } from "../../../../../database/models/engine/context.model"; +import { DataExtractionInputParams, DataSamplingMethod, OutputParams, ProcessorResult } from '../../../../../domain.types/engine/engine.types'; +import { IExtractor } from "./extractor.interface"; +import { VitalFact } from "../../../../../modules/fact.extractors/models/vital.fact.model"; + +////////////////////////////////////////////////////////////////////// + +export class VitalDataExtractor implements IExtractor { + + //#region Repositories + + _vitalFactRepository: Repository = + FactsSource.getRepository(VitalFact); + + //#endregion + + public extract = async ( + context: Context, + inputParams: DataExtractionInputParams, + outputParams: OutputParams) => { + + const filters = inputParams.Filters ?? {}; + var samplingMethod = filters['SamplingMethod'] as DataSamplingMethod; + if (!samplingMethod) { + samplingMethod = DataSamplingMethod.Any; + } + + const records = await this._vitalFactRepository.find({ + where : { + ContextReferenceId : context.ReferenceId + }, + }); + + const groupedRecords = records.reduce((acc, obj) => { + const key = obj.RecordDateStr; + if (!acc[key]) { + acc[key] = []; + } + acc[key].push(obj); + return acc; + }, {}); + + const dayStats: { Day: string; Passed: boolean;}[] = []; + if (samplingMethod === DataSamplingMethod.Any) { + for (var grKey of Object.keys(groupedRecords)) { + const arr = groupedRecords[grKey]; + const passed = arr.some(obj => obj.VitalPrimaryValue !== null); // Check only for one record per day + dayStats.push({ + Day : grKey, + Passed : passed, + }); + } + } + else { + for (var grKey of Object.keys(groupedRecords)) { + const arr = groupedRecords[grKey]; + const passed = arr.every(obj => obj.VitalPrimaryValue !== null); // Check all records for the day + dayStats.push({ + Day : grKey, + Passed : passed, + }); + } + } + + const sorted = dayStats.sort((a, b) => Date.parse(a.Day) - Date.parse(b.Day)); + const transformed = sorted.map(x => { + return { + key : new Date(x.Day), + value : x.Passed, + }; + }); + + const result: ProcessorResult = { + Success : true, + Tag : outputParams.OutputTag, + Data : transformed + }; + + return result; + }; + +} diff --git a/src/modules/processor/providers/implementation/data.processor.ts b/src/modules/processor/providers/implementation/data.processor.ts index aa27cba..e56f048 100644 --- a/src/modules/processor/providers/implementation/data.processor.ts +++ b/src/modules/processor/providers/implementation/data.processor.ts @@ -145,32 +145,83 @@ export class DataProcessorr implements IDataProcessor { //#region Private methods getConsecutiveOccurrences = ( - records: any[], predicate: PredicateType, options: ContinuityInputParams) => { - let count = 0; + records: any[], + predicate: PredicateType, + options: ContinuityInputParams, + uniqueKeys = true) => { + const foundBundles = []; var bundle = []; const numOccurrences: number = options.ContinuityCount; const valueName = 'value'; // Pl. check this again... - for (let i = 0; i < records.length; i++) { - if (predicate( - records[i], - valueName, - options.Operator, - options.Value, - options.SecondaryValue)) { - count++; - bundle.push(records[i]); - if (count === numOccurrences) { - foundBundles.push(bundle); + //Sort records in ascending order of the key + var sortedRecords = records.sort((a, b) => { return a.key - b.key; }); + + if (!uniqueKeys) { + + let count = 0; + + for (let i = 0; i < sortedRecords.length; i++) { + + const record = sortedRecords[i]; + + if (predicate( + record, + valueName, + options.Operator, + options.Value, + options.SecondaryValue)) { + + count++; + bundle.push(record); + + if (count === numOccurrences) { + foundBundles.push(bundle); + count = 0; + bundle = []; + } + + } else { count = 0; bundle = []; } - } else { - count = 0; - bundle = []; + } + } else { + var bundleKeySet = new Set(); + + for (let i = 0; i < sortedRecords.length; i++) { + + const record = sortedRecords[i]; + const recordKey = record.key; + + if (predicate( + record, + valueName, + options.Operator, + options.Value, + options.SecondaryValue)) { + + if (bundleKeySet.has(recordKey)) { + continue; + } + + bundleKeySet.add(recordKey); + bundle.push(record); + + if (bundleKeySet.size === numOccurrences) { + foundBundles.push(bundle); + bundle = []; + bundleKeySet = new Set(); + } + } + else { + bundle = []; + bundleKeySet = new Set(); + } } } + return foundBundles; }; diff --git a/src/modules/storage/interfaces/file.storage.service.interface.ts b/src/modules/storage/interfaces/file.storage.service.interface.ts index 82c7afa..d510392 100644 --- a/src/modules/storage/interfaces/file.storage.service.interface.ts +++ b/src/modules/storage/interfaces/file.storage.service.interface.ts @@ -3,11 +3,11 @@ export interface IFileStorageService { exists(storageKey: string): Promise; - upload(inputStream, storageKey: string): Promise; + upload(storageKey: string, inputStream): Promise; - download(storageKey: string): Promise; + download(storageKey: string, localFilePath: string): Promise; - uploadLocally(storageKey: string, localFilePath?: string): Promise; + uploadLocally(storageKey: string, localFilePath?: string): Promise; downloadLocally(storageKey: string, localFilePath: string): Promise; diff --git a/src/modules/storage/providers/aws.s3.file.storage.service.ts b/src/modules/storage/providers/aws.s3.file.storage.service.ts index f6ddde8..ee58d09 100644 --- a/src/modules/storage/providers/aws.s3.file.storage.service.ts +++ b/src/modules/storage/providers/aws.s3.file.storage.service.ts @@ -28,13 +28,14 @@ export class AWSS3FileStorageService implements IFileStorageService { } }; - upload = async (inputStream: any, storageKey: string): Promise => { + upload = async (storageKey: string, inputStream: any): Promise => { try { + const fileContent = fs.readFileSync(inputStream); var s3 = this.getS3Client(); const params = { Bucket : process.env.STORAGE_BUCKET, Key : storageKey, - Body : inputStream //Request stream piped directly + Body : fileContent //Request stream piped directly }; var stored = await s3.upload(params).promise(); logger.info(JSON.stringify(stored, null, 2)); @@ -42,10 +43,11 @@ export class AWSS3FileStorageService implements IFileStorageService { } catch (error) { logger.error(error.message); + return null; } }; - uploadLocally = async (storageKey: string, localFilePath: string): Promise => { + uploadLocally = async (storageKey: string, localFilePath: string): Promise => { try { const fileContent = fs.readFileSync(localFilePath); @@ -64,17 +66,40 @@ export class AWSS3FileStorageService implements IFileStorageService { } catch (error) { logger.error(error.message); + return null; } }; - download = async (storageKey: string): Promise => { + download = async (storageKey: string, localFilePath?: string): Promise => { try { const s3 = this.getS3Client(); const params = { Bucket : process.env.STORAGE_BUCKET, Key : storageKey, }; - return s3.getObject(params).createReadStream(); + var file = fs.createWriteStream(localFilePath); + + return new Promise((resolve, reject) => { + s3.getObject(params).createReadStream() + .on('end', () => { + + //var st = fs.existsSync(localFilePath); + + var stats = fs.statSync(localFilePath); + var count = 0; + while (stats.size === 0 && count < 5) { + setTimeout(() => { + stats = fs.statSync(localFilePath); + }, 3000); + count++; + } + return resolve(localFilePath); + }) + .on('error', (error) => { + return reject(error); + }) + .pipe(file); + }); } catch (error) { logger.error(error.message); diff --git a/src/modules/storage/providers/custom.file.storage.service.ts b/src/modules/storage/providers/custom.file.storage.service.ts index 7d43516..39db952 100644 --- a/src/modules/storage/providers/custom.file.storage.service.ts +++ b/src/modules/storage/providers/custom.file.storage.service.ts @@ -28,7 +28,7 @@ export class CustomFileStorageService implements IFileStorageService { } }; - upload = async (inputStream: any, storageKey: string): Promise => { + upload = async (storageKey: string, inputStream: any): Promise => { return new Promise((resolve, reject) => { try { var storagePath = FileUtils.getStoragePath(); @@ -46,13 +46,14 @@ export class CustomFileStorageService implements IFileStorageService { }); } catch (error) { + logger.error("Unable to create file resource!"); logger.error(error.message); - reject("Unable to create file resource!"); + reject(null); } }); }; - uploadLocally = async (storageKey: string, localFilePath: string): Promise => { + uploadLocally = async (storageKey: string, localFilePath: string): Promise => { try { const fileContent = fs.readFileSync(localFilePath); const location = path.join(this._storagePath, storageKey); diff --git a/src/modules/storage/storage.service.ts b/src/modules/storage/storage.service.ts index 63926b4..53781e9 100644 --- a/src/modules/storage/storage.service.ts +++ b/src/modules/storage/storage.service.ts @@ -12,19 +12,19 @@ export class StorageService { return await this._storageService.exists(storageKey); } - upload = async (inputStream, storageKey: string): Promise => { - return await this._storageService.upload(inputStream, storageKey); + upload = async (storageKey: string, inputStream): Promise => { + return await this._storageService.upload(storageKey, inputStream); } - download = async (storageKey: string): Promise => { - return await this._storageService.download(storageKey); + download = async (storageKey: string, localFilePath?: string): Promise => { + return await this._storageService.download(storageKey, localFilePath); } - uploadLocally = async (storageKey: string, localFilePath?: string): Promise => { + uploadLocally = async (storageKey: string, localFilePath?: string): Promise => { return await this._storageService.uploadLocally(storageKey, localFilePath); } - downloadLocally = async (storageKey: string, localFilePath: string): Promise => { + downloadLocally = async (storageKey: string, localFilePath?: string): Promise => { return await this._storageService.downloadLocally(storageKey, localFilePath); } diff --git a/src/startup/router.ts b/src/startup/router.ts index 2b8c814..96c0f01 100644 --- a/src/startup/router.ts +++ b/src/startup/router.ts @@ -14,6 +14,8 @@ import { register as registerIncomingEventRoutes } from '../api/engine/incoming. import { register as registerIncomingEventTypeRoutes } from '../api/engine/incoming.event.type/incoming.event.type.routes'; import { register as registerSchemaInstanceRoutes } from '../api/engine/schema.instance/schema.instance.routes'; import { register as registerTypesRoutes } from '../api/types/types.routes'; +import { register as registerFileResourceRoutes } from '../api/general/file.resource/file.resource.routes'; + //////////////////////////////////////////////////////////////////////////////////// @@ -50,6 +52,7 @@ export class Router { registerIncomingEventRoutes(this._app); registerSchemaInstanceRoutes(this._app); registerTypesRoutes(this._app); + registerFileResourceRoutes(this._app); resolve(true); diff --git a/src/startup/seeder.ts b/src/startup/seeder.ts index f923427..d8a1997 100644 --- a/src/startup/seeder.ts +++ b/src/startup/seeder.ts @@ -1,10 +1,9 @@ import fs from "fs"; import path from "path"; -import { Helper } from "../common/helper"; import { logger } from "../logger/logger"; import * as RolePrivilegesList from '../../seed.data/role.privileges.json'; +import * as seedHowToEarnBadgeContent from '../../seed.data/how.to.earn.badge.content.seed..json'; import { UserService } from '../database/services/user/user.service'; -import { ClientService } from '../database/services/client/client.service'; import { UserCreateModel } from "../domain.types/user/user.domain.types"; import { Gender } from "../domain.types/miscellaneous/system.types"; import { RoleService } from "../database/services/user/role.service"; @@ -14,6 +13,12 @@ import { RoleCreateModel } from "../domain.types/user/role.domain.types"; import { ClientResponseDto } from "../domain.types/client/client.domain.types"; import { FileUtils } from "../common/utilities/file.utils"; import { StringUtils } from "../common/utilities/string.utils"; +import { BadgeStockImageDomainModel } from "../domain.types/badge.stock.image/badge.stock.image.domain.model"; +import { BadgeStockImageService } from "../database/services/badge.stock.images/badge.stock.image.service"; +import { ClientService } from "../database/services/client/client.service"; +import { Loader } from "./loader"; +import { BadgeService } from "../database/services/awards/badge.service"; +import { BadgeUpdateModel } from "../domain.types/awards/badge.domain.types"; ////////////////////////////////////////////////////////////////////////////// @@ -29,6 +34,17 @@ export class Seeder { _fileResourceService: FileResourceService = null; + _badgeStockImageService: BadgeStockImageService = new BadgeStockImageService(); + + _badgeService: BadgeService = new BadgeService(); + + constructor () { + + this._fileResourceService = Loader.Container.resolve(FileResourceService); + + } + + public seed = async (): Promise => { try { await this.createTempFolders(); @@ -36,6 +52,8 @@ export class Seeder { const clients = await this.seedInternalClients(); await this.seedRolePrivileges(); await this.seedDefaultUsers(clients); + await this.seedBadgeStockImages(); + await this.seedHowToEarnBadgeContent(); } catch (error) { logger.error(error.message); } @@ -182,4 +200,80 @@ export class Seeder { logger.info('Seeded default roles successfully!'); }; + private seedBadgeStockImages = async () => { + + var images = await this._badgeStockImageService.getAll(); + if (images.length > 0) { + return; + } + + var destinationStoragePath = 'assets/images/stock.badge.images/'; + var sourceFilePath = path.join(process.cwd(), "./assets/images/stock.badge.images/"); + + var files = fs.readdirSync(sourceFilePath); + var imageFiles = files.filter((f) => { + return path.extname(f).toLowerCase() === '.png'; + }); + + for await (const fileName of imageFiles) { + + var sourceLocation = path.join(sourceFilePath, fileName); + var storageKey = destinationStoragePath + fileName; + + var uploaded = await this._fileResourceService.uploadLocal( + storageKey, + sourceLocation, + true); + + if (!uploaded) { + continue; + } + + var domainModel: BadgeStockImageDomainModel = { + Code : fileName.replace('.png', ''), + FileName : fileName, + ResourceId : uploaded.id, + PublicUrl : uploaded.DefaultVersion.Url + }; + + var badgeStockImage = await this._badgeStockImageService.create(domainModel); + if (!badgeStockImage) { + logger.info('Error occurred while seeding badge stock images!'); + } + } + }; + + public seedHowToEarnBadgeContent = async () => { + + logger.info('Seeding how to earn content for badges...'); + + const arr = seedHowToEarnBadgeContent['default']; + //console.log(JSON.stringify(arr, null, 2)); + + for (let i = 0; i < arr.length; i++) { + + const filters = { + Name : arr[i]['Name'] + }; + + const existingRecord = await this._badgeService.search(filters); + //console.log(JSON.stringify(existingRecord, null, 2)); + + if (existingRecord.Items.length > 0) { + + const entity = existingRecord.Items[0]; + const model: BadgeUpdateModel = { + HowToEarn : arr[i]['HowToEarn'], + ClientId : entity.Client.id, + CategoryId : entity.Category.id + }; + + var record = await this._badgeService.update(entity.id, model); + var str = JSON.stringify(record, null, ' '); + logger.info(str); + } + + } + }; + }