{"id":23421086,"url":"https://github.com/nhsdigital/canql","last_synced_at":"2025-10-30T07:20:34.060Z","repository":{"id":46147146,"uuid":"40002488","full_name":"NHSDigital/canql","owner":"NHSDigital","description":"Congenital Anomaly Natural Query Language","archived":false,"fork":false,"pushed_at":"2025-02-07T10:03:14.000Z","size":321,"stargazers_count":0,"open_issues_count":3,"forks_count":4,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-04-12T07:15:55.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NHSDigital.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2015-07-31T11:35:05.000Z","updated_at":"2025-02-07T10:03:13.000Z","dependencies_parsed_at":"2023-01-25T23:01:42.467Z","dependency_job_id":null,"html_url":"https://github.com/NHSDigital/canql","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fcanql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fcanql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fcanql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fcanql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NHSDigital","download_url":"https://codeload.github.com/NHSDigital/canql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248578799,"owners_count":21127713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-23T02:13:58.901Z","updated_at":"2025-10-30T07:20:29.011Z","avatar_url":"https://github.com/NHSDigital.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CANQL [![Build Status](https://github.com/NHSDigital/canql/workflows/Test/badge.svg)](https://github.com/NHSDigital/canql/actions?query=workflow%3Atest) [![Gem Version](https://badge.fury.io/rb/canql.svg)](https://rubygems.org/gems/canql)\n\nCongenital Anomaly Natural Query Language (CANQL) is a [Treetop](http://treetop.rubyforge.org/)-driven Domain Specific Language (DSL) used by the NHS Digital (NHS-D) National Congenital Anomaly and Rare Disease Registration Service (NCARDRS) to identify cohorts of cases.\n\nUsed for analysis, research and day-to-day operations to empower non-technical users to write sophisticated human readable queries without the need to know or understand the underlying datastore and/or schema.\n\nCANQL is decoupled from the specifics of the NCARDRS systems by producing an intermediate representation, known as Disease Intermediate Representation (DIR). This allows us to:\n\n1. implement separate DIR adapters for different datastores (e.g. SQL and NoSQL datastores);\n2. utilize the same DIR adapters for different but over-lapping DSLs, including Tumour Natural Query Language ([TNQL](https://github.com/NHSDigital/tnql)) ; and\n3. pass DIR queries to non-ruby backend systems using any simple format like JSON.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'canql'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install canql\n\n## Usage\n\nHere is a simple example showing a CANQL query of all male cases in south west registration region:\n\n```ruby\nrequire 'canql'\nrequire 'json'\n\nquery = 'All Male South West Cases'\nparser = Canql::Parser.new(query)\n\nif parser.valid?\n  puts JSON.dump(parser.meta_data)\nend\n```\n\nwould output:\n\n```json\n{\"results.subject\":{\"equals\":\"case\"},\"patient.sex\":{\"equals\":\"1\"},\"patient.registry\":{\"equals\":\"84\"}}\n```\n      and booking at hospital RGT01 and delivery at addenbrookes trust\nThe parser is case insensitive. An example of an almost fully involved CANQL query is:\n\n\u003e First 27 Male Liveborn Thames Primary Cases Due between 20/06/2015 and 25/06/2015 and Born on 22/06/2015 and that Died on 07/07/2015 with Suspected Prenatal Q20 Anomalies and Booking at hospital RGT01 and Delivery at addenbrookes trust and Postnatal Tests and Missing Postcode and Date of Birth and QA Action and Unprocessed paediatric records and hes records and Mother Born between 01/10/1990 and 10/01/1999 and who Died on 01/08/2015 with Populated Postcode and NHS Number\n\nPlease see the tests for many more examples.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\n1. Fork it ( https://github.com/NHSDigital/canql/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fcanql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhsdigital%2Fcanql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fcanql/lists"}