synthetichealth / synthea

Synthetic Patient Population Simulator
https://synthetichealth.github.io/synthea
Apache License 2.0
2.19k stars 655 forks source link

Generate only patients that went through a specific Encounter or Procedure #1509

Open TaisKha opened 2 months ago

TaisKha commented 2 months ago

Requested Feature

Hello. We need to generate only patients that had a surgery - ideally insertion of a pacemaker. (Or if not possible with the pacemaker, then at least any surgery). So, for example, I have found this module https://github.com/synthetichealth/synthea/blob/76f2925bbcb098c34413b4c1e245d8664d7251d7/src/main/resources/modules/heart/chf_lvad.json#L59 and would like to generate the patients that went through the "Surgical encounter". Or from the same module, I would like to filter out patients that went through Procedure "LVAD insertion" https://github.com/synthetichealth/synthea/blob/76f2925bbcb098c34413b4c1e245d8664d7251d7/src/main/resources/modules/heart/chf_lvad.json#L15.

I guess I need to use Keep module feature, but I cannot figure it out how to structure the JSON file in a way that it does what I want.

How can I achieve such a filtering? Is there a module for the pacemaker insertion?

dehall commented 1 month ago

This isn't documented anywhere but because of how the health record entries are modeled in Synthea, you can also use the "Active Condition" logic to also represent "Procedure Performed". You might want something like this for your keep module:

{
  "name": "Generated Keep Module",
  "states": {
    "Initial": {
      "type": "Initial",
      "name": "Initial",
      "conditional_transition": [
        {
          "transition": "Keep",
          "condition": {
            "condition_type": "And",
            "conditions": [
              {
                "condition_type": "Active Condition",
                "codes": [
                  {
                    "system": "SNOMED-CT",
                    "code": "232967006",
                    "display": "Implantation of left ventricular assist device (procedure)"
                  }
                ]
              }
            ]
          }
        },
        {
          "transition": "Terminal"
        }
      ]
    },
    "Terminal": {
      "type": "Terminal",
      "name": "Terminal"
    },
    "Keep": {
      "type": "Terminal",
      "name": "Keep"
    }
  },
  "gmf_version": 2
}

(created using the customizer at https://synthetichealth.github.io/spt/#/customizer )