hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.03k stars 1.33k forks source link

UI shows a count/total that includes deleted resources #2008

Open seanmcilvenna opened 4 years ago

seanmcilvenna commented 4 years ago

Describe the bug In the UI, when looking at the list of resources (on the left), it shows a little colored bubble next to each resource that indicates how many instances of that resource exist on the server. It appears that the number which shows there includes deleted resources, and I don't think it should.

To Reproduce Open the UI and take note of the number of resources for the FHIR server. Delete one of the resources. Compare the number before and after, and it doesn't seem to have changed.

If using a MySQL database, you can run this query: select * from hfj_resource join hfj_forced_id on hfj_forced_id.resource_pid = hfj_resource.res_id where hfj_resource.RES_DELETED_AT IS NULL and res_type = 'StructureDefinition'; This will tell you have many undeleted resources exist on the server. The bubble/count in the UI should match that number.

This query includes deleted resources, which seems to be what the bubble/count currently represents: select * from hfj_resource join hfj_forced_id on hfj_forced_id.resource_pid = hfj_resource.res_id where res_type = 'StructureDefinition';

Expected behavior The count/bubble should not include deleted resources.

Environment (please complete the following information):

seanmcilvenna commented 4 years ago

image

elavy-harris commented 2 years ago

I found (using Smile CDR v2022.11.PRE-13) that Bundle.total includes the deleted entries in a search for all Resources of a type. If I subsequently do a search with ?_total=accurate, then do a search without _total, Bundle.total remains accurate.

I suspect that HAPI maintains a counter somewhere, updating it for creates but not deletes and that the counter is updated when a request for an accurate total is made.