There are two great WRC best practice articles Ensemble Orphaned Messages | InterSystems Developer Community | Best
and the delete helper post DeleteHelper - A Class to Help with Deleting Referenced Persistent Classes (intersystems.com)
InterSystems IRIS for Health™ is the world’s first and only data platform engineered specifically for the rapid development of healthcare applications to manage the world’s most critical data. It includes powerful out-of-the-box features: transaction processing and analytics, an extensible healthcare data model, FHIR-based solution development, support for healthcare interoperability standards, and more. All enabling developers to realize value and build breakthrough applications, fast. Learn more.