Assistance with Reporting Using Existing Definitions

I would like to do the following via inbuilt cohort definitions or data definitions without having to revert to SQL. I already have my cohort of patients

  1. What types of encounters they have

  2. How many visits grouped by encounter type

@mseaton @mksd

Hi @ssmusoke ,

It has been few months since I looked into the Reporting module so I am not 100% confident, but here is what I would do:

I would create a report with a PatientDataSetDefinition filtered with your cohort definition to display one line per patient.

  1. What types of encounters they have

In order to list the encounter types per patient I think you have to create a EncounterTypeForPatientDataDefinition to retrieve the Encounter Types of a Patient. There is the EncounterTypeDataDefinition but it is not a “per patient” definition, so I am not sure that can be used on your PatientDataSetDefinition.

@mseaton is this above correct?

  1. How many visits grouped by encounter type

Do you want this to be ‘per patient’, ie, in the same report as in point 1? Or is this another report such as one line per encounter type?

Hope the above makes sense.


@ssmusoke, if you need high performance, then I would likely advise writing a custom PatientDataDefinition or using a SqlPatientDataDefinition.

You can achieve the “What encounter types a patient has” by:

  1. Using an EncountersForPatientDataDefinition - this will give you a List of all Encounters for the patient
  2. Running this through a CollectionConverter which uses a PropertyConverter on each element of the List

For achieving the “How many encounters grouped by encounter type”, you could reuse query #1 above, and run it through a different CollectionConverter (which you would need to write), which returned a Map from Encounter Type name -> Integer.