synthetichealth / synthea

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

International adaptation - finding providers error #933

Open maciejtarsa opened 3 years ago

maciejtarsa commented 3 years ago

Hi,

I am working on adapting Synthea to the population of New Zealand. I am coming across the following error, but only for some patients. Below is an example of generating 10 patients.

Running with options:
Population: 10
Seed: 1631006839172
Provider Seed:1631006839172
Reference Time: 1631006839172
Location: Auckland
Min Age: 0
Max Age: 140
6 -- Lore422 Rutherford999 (4 y/o F) Epsom South, Auckland 
2 -- Pei116 McKenzie376 (11 y/o F) Epsom Central-South, Auckland 
1 -- Lea264 Langworth352 (13 y/o F) Shelly Park, Auckland 
3 -- Marni913 Altenwerth646 (20 y/o F) Waitakere Ranges South, Auckland 
4 -- Louis204 Mante251 (50 y/o M) Northcross, Auckland 
8 -- Benita195 Lowe577 (44 y/o F) Henderson East, Auckland 
5 -- Branden904 Beatty507 (59 y/o M) Manly East, Auckland DECEASED
7 -- Tommy814 Predovic534 (65 y/o M) Gulf Islands, Auckland 
10 -- Veronica155 Kuhic920 (3 y/o F) Waiuku Central, Auckland 
9 -- Ammie189 Rolfson709 (57 y/o F) Karaka Lakes, Auckland 
java.lang.RuntimeException: Unable to find provider: ambulatory
        at org.mitre.synthea.world.agents.Person.setProvider(Person.java:631)
        at org.mitre.synthea.world.agents.Person.setProvider(Person.java:643)
        at org.mitre.synthea.world.agents.Person.getProvider(Person.java:621)
        at org.mitre.synthea.world.agents.Person.encounterStart(Person.java:510)
        at org.mitre.synthea.modules.EncounterModule.createEncounter(EncounterModule.java:142)
        at org.mitre.synthea.engine.State$Encounter.process(State.java:835)
        at org.mitre.synthea.engine.State.run(State.java:186)
        at org.mitre.synthea.engine.Module.process(Module.java:367)
        at org.mitre.synthea.engine.Module.process(Module.java:379)
        at org.mitre.synthea.engine.Module.process(Module.java:330)
        at org.mitre.synthea.engine.Generator.updatePerson(Generator.java:677)
        at org.mitre.synthea.engine.Generator.createPerson(Generator.java:654)
        at org.mitre.synthea.engine.Generator.generatePerson(Generator.java:467)
        at org.mitre.synthea.engine.Generator.lambda$run$3(Generator.java:357)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:831)
Records: total=10, alive=9, dead=1

Sometimes the error relates to finding providers for ambulatory, sometimes wellness. At times all 10 patients are created with no issues.

I have a suspicion this is the result of only having 83 hospitals listed (I copied the same data for primary and urgent care). I did make sure that all states are represented.

Any suggestions where this is coming from?

jawalonoski commented 3 years ago
  1. Check that latitude and longitude of the provider.
  2. Check the latitude and longitude of the locations in the zip codes file.

If the locations and the hospitals/providers are not close enough, this will happen. Where "close enough" is actually quite forgiving.

Maybe one or two were entered incorrectly or accidentally got reversed or something. That is usually the culprit.

maciejtarsa commented 3 years ago

Thanks for your quick response.

Do you know off the top of your head how 'close enough' it has to be? Some of the locations in New Zealand can be quite far away. I suspect this is the case of not having enough provider locations. I am hoping to find some time to add medical centres/etc at some point to test this.

As a test, I generated 12,000 patients and this error affected just under 5%.

jawalonoski commented 3 years ago

You can adjust this here:

https://github.com/synthetichealth/synthea/blob/440c0a46c3c05c47f11d04e695ea81dcd4adfbd5/src/main/resources/synthea.properties#L188-L190

However, the comments are wrong, the units are not "kilometers", they are in "degrees" of latitude and longitude.

So, the default on the master branch is 32 degrees of latitude and longitude, which is quite massive.

You can see how it is used below. Basically it searches within an eighth of a degree of the person, and continues to double that range, until either it finds a matching provider or hits the maximum range.

https://github.com/synthetichealth/synthea/blob/440c0a46c3c05c47f11d04e695ea81dcd4adfbd5/src/main/java/org/mitre/synthea/world/agents/Provider.java#L246-L267

maciejtarsa commented 3 years ago

Thanks for the explanation. I looked at my providers and zipcodes as you originally suggested and indeed found a number of mistakes, e.g. something in the north of the country has coordinates in the south. I used Python's GeoPy to find coordinates based on locations' names - seems it wasn't as successful as I thought.

However, given that range, it should still find a provider. E.g. I have a location that instead of being (-36.77, 174.74), is (-43.56, 172.67). I'll keep at it and report if I manage to find a solution. Thanks for your help so far.

jawalonoski commented 3 years ago

Also, it has to be in the right "state", so even if it is nearby, the patients won't cross "state" borders to visit that provider.

Finally, please consider contributing your final results to the Synthea International repository: https://github.com/synthetichealth/synthea-international. We do not currently have data for New Zealand.

maciejtarsa commented 3 years ago

I will certainly contribute to the international repository. I am just checking through some of the locations to make them a bit more accurate.

Interestingly, I wanted to check whether other international locations are working without similar errors. I found about 5 out of 100 generated patients were coming up with errors in finding providers. I tested a couple of states in the UK, Norway and France.