Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/lib/mavis_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ def self.progress_bar(total)
require_relative "mavis_cli/teams/add_programme"
require_relative "mavis_cli/teams/create_sessions"
require_relative "mavis_cli/teams/list"
require_relative "mavis_cli/teams/onboard"
require_relative "mavis_cli/vaccination_records/generate_fhir"
require_relative "mavis_cli/vaccination_records/sync"
31 changes: 22 additions & 9 deletions app/lib/mavis_cli/generate/cohort_imports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,41 @@ module MavisCLI
module Generate
class CohortImports < Dry::CLI::Command
desc "Generate cohort imports"
option :patients,

option :team_workgroup,
aliases: ["-w"],
default: "A9A5A",
desc: "Workgroup of team to generate consents for"

option :programme_types,
aliases: ["-p"],
default: [],
desc:
"Programme type to generate consents for (hpv, menacwy, td_ipv, etc)"

option :patient_count,
aliases: ["-c"],
type: :integer,
required: true,
default: 10,
desc: "Number of patients to create"
option :ods_code,
type: :string,
default: "A9A5A",
desc: "ODS code of the organisation to use for the cohort import"

def call(patients:, ods_code:)
def call(team_workgroup:, programme_types:, patient_count:)
MavisCLI.load_rails

patient_count = patients.to_i
team = Team.find_by!(workgroup: team_workgroup)
programmes = Programme.where(type: programme_types)
patient_count = patient_count.to_i

progress_bar = MavisCLI.progress_bar(patient_count)

puts "Generating cohort import for ods code #{ods_code} with" \
puts "Generating cohort import for team #{team_workgroup} with" \
" #{patient_count} patients..."

result =
::Generate::CohortImports.call(
ods_code:,
team:,
programmes:,
patient_count:,
progress_bar:
)
Expand Down
31 changes: 31 additions & 0 deletions app/lib/mavis_cli/teams/onboard.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

module MavisCLI
module Teams
class Onboard < Dry::CLI::Command
desc "Onboard a new team"

argument :path,
required: true,
desc: "The path to the onboarding configuration file"

def call(path:)
MavisCLI.load_rails

config = YAML.safe_load(File.read(path))

onboarding = Onboarding.new(config)

if onboarding.valid?
onboarding.save!
else
onboarding.errors.full_messages.each { |message| puts message }
end
end
end
end

register "teams" do |prefix|
prefix.register "onboard", Teams::Onboard
end
end
5 changes: 4 additions & 1 deletion config/onboarding/coventry-training.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
organisation:
ods_code: RYG

team:
workgroup: coventrytraining
name: Coventry and Warwickshire Partnership NHS Trust
email: example@covwarkpt.nhs.uk
phone: 07700 900815
ods_code: RYG
careplus_venue_code: CWPTSI
privacy_notice_url: https://www.covwarkpt.nhs.uk/download.cfm?ver=8286
privacy_policy_url: https://www.covwarkpt.nhs.uk/privacy
Expand Down
5 changes: 4 additions & 1 deletion config/onboarding/hertfordshire-training.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
organisation:
ods_code: RY4

team:
workgroup: hertfordshiretraining
name: Hertfordshire and East Anglia Community School Age Immunisation Service
email: hct.csaisherts@nhs.net
phone: 0300 555 5055
ods_code: RY4
careplus_venue_code: UNUSED
privacy_notice_url: https://www.hct.nhs.uk/privacy
privacy_policy_url: https://www.hct.nhs.uk/privacy
Expand Down
5 changes: 4 additions & 1 deletion config/onboarding/leicestershire-training.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
organisation:
ods_code: RT5

team:
workgroup: leicestershiretraining
name: Leicestershire Partnership Trust School Aged Immunisation Service
email: lpt.sais@nhs.net
phone: 0300 3000 007
ods_code: RT5
careplus_venue_code: UNUSED
privacy_notice_url: https://www.leicspart.nhs.uk/privacy-policy/
privacy_policy_url: https://www.leicspart.nhs.uk/privacy-policy/
Expand Down
40 changes: 40 additions & 0 deletions config/onboarding/rollover-training.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
organisation:
ods_code: RLVTRN

team:
workgroup: rollovertraining
name: Rollover Training
email: rollover@example.com
phone: 01234 567890
careplus_venue_code: ROLLOVER
privacy_notice_url: https://www.example.com/privacy-notice
privacy_policy_url: https://www.example.com/privacy-policy

programmes: [flu, hpv, menacwy, td_ipv]

subteams:
generic:
name: Rollover Training
email: rollover@example.com
phone: 01234 567890

users:
- email: nurse.rollover@example.com
password: nurse.rollover@example.com
given_name: Nurse
family_name: ROLLOVER

schools:
generic:
- 115529 # primary
- 131806 # primary
- 145212 # primary
- 118853 # primary
- 145482 # secondary
- 137236 # secondary
- 136642 # secondary
- 135970 # secondary

clinics:
generic:
- name: Rollover Training Hospital
4 changes: 3 additions & 1 deletion config/onboarding/smoke-test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
organisation:
ods_code: Y90128

team:
name: XXX SMOKE TEST XXX
email: england.mavis@nhs.net
phone: "03003112233"
ods_code: Y90128
careplus_venue_code: SMOKE
privacy_policy_url: https://example.com/privacy

Expand Down
6 changes: 3 additions & 3 deletions docs/managing-teams.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ clinics:

[config-onboarding]: /config/onboarding

### Rake task
### Command

Once the file has been written you can use the `onboard` Rake task to set everything up in the service.
Once the file has been written you can use the `onboard` command to set everything up in the service.

```sh
$ bundle exec rails onboard[path/to/configuration.yaml]
$ bin/mavis teams onboard path/to/configuration.yaml
```

If any validation errors are detected in the file they will be output and nothing will be processed, only if the file is completely valid will anything be processed.
Expand Down
Loading