Patient Counts on Non-Standard Concepts?

What would it take to augment Achilles so that it calculates person counts for non-standard concepts and source concepts; and have those values flow into achilles_result_concept_count? I may be able to draft a solution and submitting a pull request, but I need some guidance.

Parts look pretty straight forward. There are existing SQL that generate person counts for standard concepts (for example for conditions here). Adapting that for condition_source_concept_id would be easy - but it would need its own numbering system.

From there, I’d have basic questions such as:

  1. Can I pick a suffix of 40 for person counts of *_source_concept_id? For example, 440, 640, 840 for conditions, procedures, and observations, respectively? If not, what is a good numeric suffix to use?
  2. How should such new scripts in inst/sql/sql_server/analyses be added to the workflow (e.g. so that they are executed from R)? I’m not clear on which R function calls those scripts.
  3. Where should de-duplication be done (since some source concepts are also standard concepts)?
  4. What is the proper way to take that output and incorporate it into the WebAPI for achilles_result_concept_count? Is it simply a matter of adding the new analysis_ids to its script?

Are there other needed tasks (or stumbling blocks) to watch out for?