Is it Xades?

I've done Xades signing, but not with RSA algorithms. Still, might be useful for you. Drop me your GitHub username if you need the code.

To add Xades support I used a reference implementation in .Net - read the Xades docs on how it's supposed to work, then decompiled .Net libraries to see how it all actually works, and recreated it in ObjectScript.

Are you sure about:

Property PatientId As %Stream.FileCharacter;
Property PatientName As %Stream.FileCharacter;

Both of these fields are less than 3 641 144 characters in size, so

Property PatientId As %VarString;
Property PatientName As %VarString;

Would probably work.

You can add ToStream() method to your class to provide serialization, if you need to (Or just add JSON or XML adaptors to generate XML or JSON (de)serializations automatically).