Does not work with dynamic object class properties unfortunately:

Class User.DO Extends %Persistent
{

Property MyProp As %DynamicObject;

/// do ##class(User.DO).Test()
ClassMethod Test()
{
    do ..%KillExtent()
    // 11 = $length({"prop":""}.%ToJSON())
    for len = 100, $$$MaxStringLength - 11, $$$MaxStringLength - 11 + 1 {
        set sc = ..Create(len)
        write "len: ", len, " result: ", $case($$$ISOK(sc), $$$YES: "OK", : "ERROR: " _ $system.Status.GetErrorText(sc)), !
        quit:$$$ISERR(sc)
    }
}

ClassMethod Create(len) As %Status
{
    set obj = ..%New()
    do obj.MyProp.%Set("prop", ..GetStream(len), "stream")
    set sc = obj.%Save()
    quit sc
}

ClassMethod GetStream(len) As %Stream.TmpCharacter
{
    set chunk = 1000000
    set stream = ##class(%Stream.TmpCharacter).%New()
    for i=1:chunk:len-chunk {
        do stream.Write($tr($j("", chunk)," ", 0))		
    }
    do stream.Write($tr($j("", len#chunk)," ", 0))
    quit stream
}

}

Results in:

len: 100 result: OK
len: 3641133 result: OK
len: 3641134 result: ERROR: ERROR #5002: ObjectScript error: <MAXSTRING>%GetSerial+1^%Library.DynamicAbstractObject.1 [%GetSerial+1^%Library.DynamicAbstractObject.1:XF]

Same issue if there are several short properties in dynamic object with total length > 3641144 characters.

We need something like:

Property MyProp As %DynamicObject(STORAGE="stream");

Yes, well, you explicitly set your error in:

do {
$$$ASSERT(0) // Subclass Responsibility
Set tSC = $$$EnsError($$$EnsErrNotImplemented,$$$CurrentClass,$$$CurrentMethod)
} while (0)
Exit
Quit tSC
Trap
Set $ZT="",tSC=$$$EnsSystemError
Goto Exit
} 

You need to remove that.

Also Patient info should be in SDA already, so you can remove:

Set target.Patient.Name=source.GetValueAt("PID:5")
Set target.Patient.BirthGender=source.GetValueAt("PID:8")

You need to create HS.SDA3.Container object in Transform method before using it. Something like this:

Class Hosiptal.SDA3.DataTrans Extends Ens.DataTransform
{

ClassMethod Transform(source As EnsLib.HL7.Message, ByRef target As HS.SDA3.Container, aux) As %Status
{
    #Dim sc As %Status = $$$OK
    Set sc =  ##class(HS.Gateway.HL7.HL7ToSDA3).GetSDA(source, .xml)
    Quit:$$$ISERR(sc) sc
    Set target = ##class(HS.SDA3.Container).%New()
    Set sc = target.InitializeXMLParse(.xml)
    Quit sc
}

}

If I'm using an objectgenerator, is there a way to check the compile flags and have it behave differently based on which flags are set?

A very exciting way to introduce some unexpected behavior down the line.

What is your use case?

And as a tangent, is there a list somewhere of what compile flags there are?

Sure:

do $system.OBJ.ShowFlags()
do $system.OBJ.ShowQualifiers()

If you get access error on Linux:

javaldx failed! Warning: failed to read path from javaldx LibreOffice 7.3 - Fatal Error: The application cannot be started. User installation could not be completed.
LibreOffice user installation could not be processed due to missing access rights. Please make sure that you have sufficient access rights for the following location and restart LibreOffice.

Add this to LibreOffice parameters:

set args($i(args)) = "-env:UserInstallation=file:///tmp/libreofficehome/"

where /tmp/libreofficehome is any empty folder InterSystems IRIS has write access to.