18.4. New task walkthrough: CORE-10 example

(2018-09-28.)

18.4.1. Basics

  • Starting point: checked out and happily compiling.
  • Understand the task.
  • Start with the .rst file.

18.4.2. Client

  • create class in tasks/.
  • find a similar task, or failing that something simple!
  • copy/paste/edit header
  • at some point should run qmake, as it’s a new Q_OBJECT.
  • copy/paste/edit .cpp file, then start to think
  • choose tablename
  • in constructor: is it anonymous? Does it have a clinician? Does it have a respondent?
  • for very simple tasks like this, can often just use a N_QUESTIONS format, with questions numbered 1 to N_QUESTIONS, and fieldname named q1 to q<whatever>.
  • diversion: update the task factory, meaning update inittasks.cpp to initialize the task (create the table(s), etc.) during app startup.
  • back to main task
  • work through calculations
  • build editor()
  • add it to one or more menus; see menu/
  • set the minimum server version; do this for the task, not the whole CamCOPS client; this means creating a task function minimumServerVersion()
  • bump the client version in camcopsversion.cpp
  • and changelog.rst and all the other things it says in camcopsversion.cpp

18.4.3. XML

  • at some point, will want an xstring; create the .xml file. Since this task is freely available, put it in server/camcops_server/extra_strings.

18.4.4. Docs

  • update docs all-tasks list
  • update docs category task list
  • special for CORE-10: remove from “prohibited” list
  • from the docs/ directory, re-run create_all_autodocs.py --make --destroy_first
  • check the docs build: from the docs/ directory, run rebuild_docs.py or make html
    • you may need to add new autogenerated files in docs/source/autodoc/ to the Git repository

18.4.5. Server

  • create Python file: camcops_server/tasks/core10.py
  • work through, mirroring calculations on client
  • check with PyCharm
  • create database revision using server/tools/create_database_migration.py; this will create a new file in server/camcops_server/alembic/versions. Review this manually!
  • note that the revision doesn’t contain the new task! So delete it, then…
  • edit tasks/__init__.py to load the task
  • create database migration (again…)
  • manually review the database migration for sanity
  • migration file will need adding to Git repository manually
  • upgrade the test database with camcops upgrade_db ...
  • launch server

18.4.6. Final

  • Test
  • Commit!
  • When pushed to Github, the live docs will auto-update.