Skip to content

Commit

Permalink
Merge pull request #3 from awell-health/baseline-datapoints
Browse files Browse the repository at this point in the history
baseline datapoints, tracks
  • Loading branch information
bejoinka authored Apr 27, 2024
2 parents 3d8ece9 + 076fdea commit a6c6e32
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .jest/setup.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { config } from 'dotenv'

Check warning on line 1 in .jest/setup.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
config()
process.env.INPUT_AWELL_ENVIRONMENT = 'development'
import '../src/environment'
const setup = async () => {
process.env.GITHUB_REPOSITORY = 'awell-health/example-source-control'
process.env.GITHUB_SHA = 'abc123'
process.env.INPUT_AWELL_ENVIRONMENT = 'local'
}

export default setup
5 changes: 0 additions & 5 deletions __tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ describe('config', () => {
it('should complete three activities', async () => {
expect(case1.activities.length).toBe(3)
})
it('should validate three steps', async () => {
expect(
case1.validate.filter(v => v.type === ActivityType.STEP).length
).toBe(3)
})
it('should validate careflow complete', async () => {
expect(
case1.validate.filter(v => v.type === ActivityType.CAREFLOW).length
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 35 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion example-careflow-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ cases:
action: COMPLETE
- type: step
name: PHQ-9 over 10
action: COMPLETE
action: DISCARDED
- type: careflow
action: COMPLETE
- type: step
name: Baseline Datapoint
action: ACTIVATE
- type: track
name: triggered by a datapoint
action: ACTIVATE
baseline_datapoints:
- definition_id: aqhlL6q_ywoY
value: any string will do...
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "action-validate",
"description": "GitHub action for careflow validation",
"version": "0.0.1",
"version": "1.0.0-beta2",
"author": "",
"private": true,
"homepage": "https://github.com/awell-health/action-validate",
Expand Down
29 changes: 27 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export enum ActivityType {
FORM = 'form',
CHECKLIST = 'checklist',
CAREFLOW = 'careflow',
STEP = 'step'
STEP = 'step',
TRACK = 'track'
}

const ActivityTypeSchema = z
Expand Down Expand Up @@ -62,21 +63,45 @@ const ValidateStepConfigSchema = z.object({
name: z.string(),
action: z.nativeEnum(ActivityAction)
})
const ValidateTrackConfigSchema = z.object({
type: z.literal(ActivityType.TRACK),
name: z.string(),
action: z.nativeEnum(ActivityAction)
})

const ValidateCareflowConfigSchema = z.object({
type: z.literal(ActivityType.CAREFLOW),
action: z.nativeEnum(ActivityAction)
})
const ValidateConfigSchema = z.union([
ValidateStepConfigSchema,
ValidateTrackConfigSchema,
ValidateCareflowConfigSchema
])

const BaselineDatapointSchema = z.object({
definition_id: z.string(),
value: z.string()
})

const PathwayCaseConfigSchema = z.object({
title: z.string(),
description: z.string(),
overwrite: z.boolean().optional().default(true),
activities: z.array(ActivitiesConfigSchema),
validate: z.array(ValidateConfigSchema)
validate: z.array(ValidateConfigSchema),
baseline_datapoints: z
.array(BaselineDatapointSchema)
.optional()
.default([])
.transform(d => {
return d.map(b => {
return {
data_point_definition_id: b.definition_id,
value: b.value
}
})
})
})

const ConfigSchema = z.object({
Expand Down
15 changes: 13 additions & 2 deletions src/test-pathway-case/pathway-case-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
} from '../config'
import * as core from '@actions/core'
import controller from '../abort'
import { ActivityAction, ActivityStatus } from '../gql/types'
import {
ActivityAction,
ActivityObjectType,
ActivityStatus
} from '../gql/types'
import { handleActivity } from './handle-activity'
import { ActiveActivity } from './active-activity'
import { validateActivities } from './validate-activities'
Expand All @@ -26,7 +30,11 @@ export const runPathwayCase = (careflowId: string) => {
const sdk = getClient(controller.signal)
try {
await sdk.StartPreview({
input: { pathway_id: careflowId, pathway_case_id: pathwayCase.id }
input: {
pathway_id: careflowId,
pathway_case_id: pathwayCase.id,
baseline_info: config.baseline_datapoints
}
})
let activities: Activities = []

Expand Down Expand Up @@ -73,6 +81,9 @@ export const runPathwayCase = (careflowId: string) => {
const isActive = (activity: Activities[0]) =>
activity.status === ActivityStatus.Active &&
activity.indirect_object !== null &&
// we don't want to handle evaluated rules or reminders
activity.indirect_object?.type !== ActivityObjectType.EvaluatedRule &&
activity.indirect_object?.type !== ActivityObjectType.Reminder &&
Object.values(ActivityType)
.map(toActivityObjectType)
.includes(activity.object.type)
Expand Down
3 changes: 3 additions & 0 deletions src/test-pathway-case/validate-activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const validateActivities = (
if (v.type === ActivityType.STEP && a.object.name !== v.name) {
return false
}
if (v.type === ActivityType.TRACK && a.object.name !== v.name) {
return false
}
return true
})
if (!activityToValidate) {
Expand Down

0 comments on commit a6c6e32

Please sign in to comment.