Keep Module Help #1477
Replies: 5 comments 5 replies
-
It is not for anyone who was ever pregnant. To only export mothers (regardless of when the child was born), try this: {
"name": "Mothers",
"remarks": [
"Keep only women who ever had children."
],
"states": {
"Initial": {
"type": "Initial",
"conditional_transition": [
{
"transition": "Keep",
"condition": {
"condition_type": "And",
"conditions": [
{
"condition_type": "Attribute",
"attribute": "number_of_children",
"operator": "is not nil"
},
{
"condition_type": "Attribute",
"attribute": "number_of_children",
"operator": ">=",
"value": 1
}
]
}
},
{
"transition": "Terminal"
}
]
},
"Terminal": {
"type": "Terminal"
},
"Keep": {
"type": "Terminal"
}
},
"gmf_version": 2
} |
Beta Was this translation helpful? Give feedback.
-
Thanks! I am trying the code for the number_of_children as you have written, this should be good for my use case. I couldn't get it to work at first, but when I dropped the "-a 15-50" requirement it worked, albeit a little differently than I had expected. It failed to generate one of my 3 patients. Does that mean that in 1000 attempts it did not generate one single person who gave birth? That seems incredibly unlikely. |
Beta Was this translation helpful? Give feedback.
-
Interesting. Ok, I have perhaps honed in on what might have been going wrong when I was originally trying different keep modules. I am using a module override for pregnancy.json. All it does is add some Long Acting Reversible Contraceptive (LARC) procedures at the end, directly postpartum. If I run synthea with the module override (-d) without the keep_module (-k) it works Is it possible the module overrides mess up the keep module logic somehow or should I keep investigating to see if something else is happening? (I see this warning on the keep module page: "Note also that this uses a reduced version of the module framework to run through the module. The "keep module" should primarily include Initial, Terminal, and Simple states, with transitions using whatever logic is needed to select patients. Use of other state types may produce unexpected results.") so maybe the module overrides are preventing the pregnancy module from being in this "reduced" version at all - perhaps overrides could be added to the reduced version without too much trouble?) |
Beta Was this translation helpful? Give feedback.
-
I am using the -d, not the other thing you mention. do the modules from the localModuleDir (-d option) get loaded and used in the "reduced version" that the keep module uses though? I am afraid that because my localModuleDir contains a "pregnancy.json" (my updated version for the additional LARC procedures) that the normal pregnancy.json from the jar is not loaded (which is generally good, since my intention is to replace it) and then maybe no pregnancy module is used for testing the keep_module in the "reduced version" I am not great with Java, but from the Java I think I can see the People being created for the CriteriaCheck with these lines from /src/main/java/org/mitre/synthea/engine/Generator.java: this.modulePredicate = getModulePredicate();
But I am not sure what the values here are for getModulePredicate. Perhaps thats causing my new pregnancy module to not be loaded for the CriteriaCheck? private Predicate getModulePredicate() { |
Beta Was this translation helpful? Give feedback.
-
Well it looks like it was specifically breaking because I was storing my keep_module and module overrides in the same folder. Both are valid JSON "modules" I guess, so when I called the -d option, it was loading both pregnancy.json and keep_module.json as modules, when it needed to just be loading pregnancy.json and then later finding the keep_module in a separate directory to be loaded specially. Sorry about the deeper confusions on my part. Perhaps a quick note about this in the Keep-Patients-Module wiki could prevent future mistakes like mine (however unlikely it may be I guess) |
Beta Was this translation helpful? Give feedback.
-
I am having trouble getting a Keep Module to generate any patients at all. Is the Keep Patients Module generally working?
I am simply trying to select any patient that gets pregnant, using the following keep_module and command line:
Java Command: java -jar synthea-with-dependencies.jar -c synthea_settings -p 3 -g F -d StudyOverrides/ -k StudyOverrides/keep_module.json -a 15-50 California Los Angeles
StudyOverrides/keep_module.json:
{
"name": "keep",
"remarks": [
"A module that only keeps patients who give birth"
],
"states": {
"Initial": {
"type": "Initial",
"conditional_transition": [
{
"transition": "Keep",
"condition": {
"condition_type": "Attribute",
"attribute": "pregnant",
"operator": "==",
"value": true
}
},
{
"transition": "Terminal"
}
]
},
"Terminal": {
"type": "Terminal"
},
"Keep": {
"type": "Terminal"
}
},
"gmf_version": 2
}
result:
java.lang.RuntimeException: Failed to produce a matching patient after 1000 attempts. Ensure that it is possible for all requested demographics to meet the criteria. (e.g., make sure there is no age restriction that conflicts with a requested condition, such as limiting age to 0-18 and requiring all patients have a condition that only onsets after 55.) If you are confident that the constraints are possible to satisfy but rare, consider increasing the value in config setting `generate.max_attempts_to_keep_patient`
I tried following these examples:
Examples
Additional Note: I am using full history
exporter.years_of_history = 0
Beta Was this translation helpful? Give feedback.
All reactions