Custom Error Handling for the Substitution parameter of MedicationRequest

28 views
Skip to first unread message

Tyler Y

unread,
Jul 18, 2019, 6:50:54 AM7/18/19
to HAPI FHIR
Hello,

I am working on a Create MedicationRequest, using the Hapi Fhir JPA Server. For the optional parameter Substitution, I want to throw custom error exceptions when invalid input is set to it during the POST request. But it seems like whenever there is invalid input for the Substitution parameter, the MedicationRequest just pretends like there was no input for that parameter (MedicationRequest.hasSubstitution() is not true). Does anyone have any suggestions?

Thanks

James Agnew

unread,
Jul 18, 2019, 8:27:13 AM7/18/19
to Tyler Y, HAPI FHIR
What kind of invalid input do you mean? If you mean just plain invalid FHIR content, you could use the RequestValidatingInterceptor to accomplish this. If it's valid FHIR but invalid because of business rules you have, you could also write a custom interceptor to throw a PreconditionFailedException or similar.

Looking at the source for RequestValidatingInterceptor might be useful if you go that route.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/5b327119-465b-42c0-8849-ab4a321e9100%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tyle...@gmail.com

unread,
Jul 23, 2019, 7:53:37 AM7/23/19
to HAPI FHIR
Thank you for your suggestions James. The substitution field has a parameter allowedBoolean, and I was trying to thrown an exception when this parameter was missing or when a string was put instead.


On Thursday, July 18, 2019 at 8:27:13 AM UTC-4, James Agnew wrote:
What kind of invalid input do you mean? If you mean just plain invalid FHIR content, you could use the RequestValidatingInterceptor to accomplish this. If it's valid FHIR but invalid because of business rules you have, you could also write a custom interceptor to throw a PreconditionFailedException or similar.

Looking at the source for RequestValidatingInterceptor might be useful if you go that route.

Cheers,
James

On Thu, Jul 18, 2019 at 6:50 AM Tyler Y <tyle...@gmail.com> wrote:
Hello,

I am working on a Create MedicationRequest, using the Hapi Fhir JPA Server. For the optional parameter Substitution, I want to throw custom error exceptions when invalid input is set to it during the POST request. But it seems like whenever there is invalid input for the Substitution parameter, the MedicationRequest just pretends like there was no input for that parameter (MedicationRequest.hasSubstitution() is not true). Does anyone have any suggestions?

Thanks

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages