hapifhir / hapi-fhir

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

_cascade=delete isn't working #2500

Open patrick-werner opened 3 years ago

patrick-werner commented 3 years ago

Describe the bug Patrick Werner: Just tried to use ?_cascade=delete with hapi (jpastarter) 5.3.0, which isn't working.

I tried it with DiagnosticReports and Observations {{baseurl}}/DiagnosticReport/24591/?_cascade=delete

Patrick Werner: This only deletes the DR, not the Observation. HAPI returns: "succesful deleted 1 resource(s)"

To Reproduce Steps to reproduce the behavior:

  1. create Observations
  2. create a DiagnosticReport linking to these Observations
  3. DELETE [baseURL]/DiagnosticReport/[ID]?_cascade=delete isn't working

Expected behavior Diagnostic Report AND Observations are deleted

Environment (please complete the following information):

patrick-werner commented 3 years ago

zulip thread: https://chat.fhir.org/#narrow/stream/179167-hapi/topic/_cascade.3Ddelete.20isn't.20working

JohannesOehm commented 3 years ago

It seems, this also applies for the cascade/expunge-combination: https://chat.fhir.org/#narrow/stream/179167-hapi/topic/JPA.20Server.20-.20Cascade.20Delete.20with.20Expunge/near/230875113

dmuylwyk commented 3 years ago

@patrick-werner, I've observed something similar: the response only identifies the one resource (e.g. DR in your case) but does not identify the resources to which the delete was cascaded (e.g. OBS in your case). However, the logs did show the delete being cascaded, and all of the expected resources were deleted.

Is this what you are observing or are the Observations truly not deleted?

Attn. @KevinDougan-SmileCDR as I understand he is working on the issue I've described.

jamesagnew commented 3 years ago

Also, are you able to replicate this on hapi.fhir.org?

I tested cascade deletes for a demo about a week ago and it was working for me..

patrick-werner commented 3 years ago

@patrick-werner, I've observed something similar: the response only identifies the one resource (e.g. DR in your case) but does not identify the resources to which the delete was cascaded (e.g. OBS in your case). However, the logs did show the delete being cascaded, and all of the expected resources were deleted.

Is this what you are observing or are the Observations truly not deleted?

Attn. @KevinDougan-SmileCDR as I understand he is working on the issue I've described.

no in our case the Observations were still on the server.

patrick-werner commented 3 years ago

Also, are you able to replicate this on hapi.fhir.org?

I tested cascade deletes for a demo about a week ago and it was working for me..

Tested it on the public server, still failing. I also created a test case for you @jamesagnew @dmuylwyk : http://hapi.fhir.org/baseR4/DiagnosticReport/2004297

If i try to cascade delete the DR, only the DR is deleted, not the observations.

patrick-werner commented 2 years ago

Also, are you able to replicate this on hapi.fhir.org?

I tested cascade deletes for a demo about a week ago and it was working for me.. @jamesagnew @dmuylwyk

Yes. And i am still able to reproduce it. Steps to reproduce:

DELETE: http://hapi.fhir.org/baseR4/DiagnosticReport/2004297?_cascade=delete

GET: http://hapi.fhir.org/baseR4/Observation/2004286

The observations aren't deleted.

Same for a local jpa-starter server(config: allow_cascading_deletes: true, enforce_referential_integrity_on_delete: true)

patrick-werner commented 2 years ago

@jamesagnew @dmuylwyk

i created a test case for this issue, which reproduced the issue: https://github.com/hapifhir/hapi-fhir/blob/6eb23162f3122b618e3d7bf6e4fedc8ebdb2133f/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderCascadeDeleteR4Test.java

MCoderIndia commented 1 year ago

@patrick-werner is this solve or it is still open?

G-2-Z commented 1 year ago

@MCoderIndia I observed this recently.