Stream: dotnet
Topic: AuditEvent Validation
Larry Richardson (May 03 2018 at 15:24):
I have a .NetCore API Service that is using the Hl7.Fhir.Stu3 nuget. In the Controller, I have a simple post method :
public async Task<IActionResult> AuditEvent([FromBody]AuditEvent auditEvent) , and I am hitting it with a Postman Post request, with the body being a copy of https://www.hl7.org/fhir/auditevent-example.json.html.
The output, clearly from AuditEvent validation, is
{
"errors": {
"RecordedElement": [
"Element with min. cardinality 1 cannot be null"
],
"Text.StatusElement": [
"Element with min. cardinality 1 cannot be null"
],
"Agent[0].RequestorElement": [
"Element with min. cardinality 1 cannot be null"
],
"Agent[1].RequestorElement": [
"Element with min. cardinality 1 cannot be null"
]
},
"isValid": false
}
Larry Richardson (May 03 2018 at 15:25):
#noob alert on this, its my first Fhir interface, but I have plenty of experience in interfaces and JSON .Looking for a way to create the JSON that will comply with the AuditEvent validation.
Larry Richardson (May 03 2018 at 15:30):
The goal here is to stand up a AuditEvent service that will be used by a Fhir interface, and some other internal interfaces, to create a central store for auditing.
I have checked that the same JSON against http://vonk.fire.ly/AuditEvent/$validate does seem to work.
Edit: Put some simple code up on https://github.com/looyvillelarry/Fhir.Audit
Brian Postlethwaite (May 03 2018 at 22:04):
Your issue is that the default json serializers don't work with the fhir models, as the default serializers have no way of handling extensions (and other reasons)
You might want to have a look at another project that I have that does this
https://github.com/brianpos/FhirFederator/tree/master/Hl7.Fhir.NetCoreApi
Bit stale now as I've refactored it lots internally since then, but you can at least see the filters and formatters and style of generic controller that I use.
Larry Richardson (May 04 2018 at 16:54):
Thanks so much Brian. That was the piece I was missing!
Last updated: Apr 12 2022 at 19:14 UTC