I have many examples of doing this, as we have Operations that write and read data from MS SQL using stored procedures.

You said your problem is with the email, how is the email defined within the Message Data Class?

Typically I create a Message Data Class for the Parameters of the Stored Procedure and use that Message Data Class to send to my EnsLib.SQL.OutboundAdapter which is using the Message Class to map to the Class Method that sends the Execution call to the Stored Procedure on MS SQL.

If you need more help, feel free to reach out.

I tried that however the zrwrite r4Patient.toString() didn't properly parse out the transaction

DEVCLIN>set patient = {"resourceType":"Bundle","type":"searchset","total":1,"link":[{"relation":"self","url":"https://ihismufhirnp.osumc.edu/fhir-poc/api/FHIR/R4/Patient?identifier=OSUMRN|415012765"}],"entry":[{"link":[{"relation":"self","url":"https://ihismufhirnp.osumc.edu/fhir-poc/api/FHIR/R4/Patient/efz6cSnh6If5cehlzObXZuO7BwSc77oXLYSL-92FLdec3"}],"fullUrl":"https://ihismufhirnp.osumc.edu/fhir-poc/api/FHIR/R4/Patient/efz6cSnh6If5cehlzObXZuO7BwSc77oXLYSL-92FLdec3","resource":{"resourceType":"Patient","id":"efz6cSnh6If5cehlzObXZuO7BwSc77oXLYSL-92FLdec3","extension":[{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.172.3.7.10.698084.130.768080.39128","code":"male","display":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.172.3.7.10.698084.130.768080.35144","code":"male","display":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCode":"248153007","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-sex"},{"valueCodeableConcept":{"coding":[{"system":"http://loinc.org","code":"LA29518-0","display":"he/him/his/his/himself"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/calculated-pronouns-to-use-for-text"}],"identifier":[{"use":"usual","type":{"text":"CEID"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.3.688884.100","value":"OSRDR3259GL4948"},{"use":"usual","type":{"text":"EPI"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.5.737384.0","value":"E4377"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.2.698084","value":"Z5151278"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TCPNfJueZx8Fjvm4g.lzD.vutNNRpQMfDXDRXJVlKkpcB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"efz6cSnh6If5cehlzObXZuO7BwSc77oXLYSL-92FLdec3"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.2.698084","value":"  Z5151278"},{"use":"usual","type":{"text":"OSUMRN"},"system":"urn:oid:1.2.840.114350.1.13.172.2.7.5.737384.100","value":"415012765"},{"use":"usual","type":{"text":"WPRINTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.2.878082","value":"2545814"}],"active":true,"name":[{"use":"official","text":"Case Stontest","family":"Stontest","given":["Case"]},{"use":"usual","text":"Case Stontest","family":"Stontest","given":["Case"]}],"gender":"male","birthDate":"1995-02-27","deceasedBoolean":false,"managingOrganization":{"reference":"Organization/eQi5EjSoIVOTHT0BXoZ4mNA3","display":"WILSON HEALTH"}},"search":{"mode":"match"}}]}

DEVCLIN>set r4Patient = ##class(HS.FHIRModel.R4.Patient).fromDao(patient)

DEVCLIN>zwrite r4Patient.toString()
"{""resourceType"":""Bundle"",""link"":[{}]}"

DEVCLIN>

I attempted that..

DEVCLIN>set patient = {"resourceType":"Bundle","type":"searchset","total":1,"link":[{"relation":"self","url":"https://ihismufhirnp.osumc.edu/fhir-poc/api/FHIR/R4/Patient?identifier=OSUMRN|415012765"}],"entry":[{"link":[{"relation":"self","url":"https://ihismufhirnp.osumc.edu/fhir-poc/api/FHIR/R4/Patient/efz6cSnh6If5cehlzObXZuO7BwSc77oXLYSL-92FLdec3"}],"fullUrl":"https://ihismufhirnp.osumc.edu/fhir-poc/api/FHIR/R4/Patient/efz6cSnh6If5cehlzObXZuO7BwSc77oXLYSL-92FLdec3","resource":{"resourceType":"Patient","id":"efz6cSnh6If5cehlzObXZuO7BwSc77oXLYSL-92FLdec3","extension":[{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.172.3.7.10.698084.130.768080.39128","code":"male","display":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.172.3.7.10.698084.130.768080.35144","code":"male","display":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCode":"248153007","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-sex"},{"valueCodeableConcept":{"coding":[{"system":"http://loinc.org","code":"LA29518-0","display":"he/him/his/his/himself"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/calculated-pronouns-to-use-for-text"}],"identifier":[{"use":"usual","type":{"text":"CEID"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.3.688884.100","value":"OSRDR3259GL4948"},{"use":"usual","type":{"text":"EPI"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.5.737384.0","value":"E4377"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.2.698084","value":"Z5151278"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TCPNfJueZx8Fjvm4g.lzD.vutNNRpQMfDXDRXJVlKkpcB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"efz6cSnh6If5cehlzObXZuO7BwSc77oXLYSL-92FLdec3"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.2.698084","value":"  Z5151278"},{"use":"usual","type":{"text":"OSUMRN"},"system":"urn:oid:1.2.840.114350.1.13.172.2.7.5.737384.100","value":"415012765"},{"use":"usual","type":{"text":"WPRINTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.172.3.7.2.878082","value":"2545814"}],"active":true,"name":[{"use":"official","text":"Case Stontest","family":"Stontest","given":["Case"]},{"use":"usual","text":"Case Stontest","family":"Stontest","given":["Case"]}],"gender":"male","birthDate":"1995-02-27","deceasedBoolean":false,"managingOrganization":{"reference":"Organization/eQi5EjSoIVOTHT0BXoZ4mNA3","display":"WILSON HEALTH"}},"search":{"mode":"match"}}]}

DEVCLIN>set r4Patient = ##class(HS.FHIRModel.R4.Patient).fromDao(patient)

DEVCLIN>zwrite r4Patient.toString()
"{""resourceType"":""Bundle"",""link"":[{}]}"

DEVCLIN>

I did not have any luck with either option within the DTL editor..

<INVALID OREF>Transform+16^osuwmc.Epic.FHIR.DTL.ResponsePatientSearch.1 -- logged as '-' number - @' set iter = target.name.list.%GetIterator()'

What I am trying to do is take the R4.PatientResponse and return it into a Data Class Structure format for those that are within my Team who can't read FHIR response or know how to code around it to use to update an HL7 message.

I tried taking the R4.PatientResponse and transforming it into a Record Map data class structure without success.

I was a part of a presentation at #Ready2025 very similar to what you are looking for. At Ready 2025, I worked with @John Goodgame , @Justin Owens, @Julio Rodriguez to present a Change Control Audit (Stealth Control) in which a task queries for changes and inserts the data into SQL tables that could be alerted or queried on.

When it is posted look for a session named...Partnering for Success Collaborative Innovations in Interoperability

@John Goodgame is talking with Product to see if this could be included, or might be publishing the code somewhere for others to use.