-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with Create Patient FHIR API payload in Firely .NET SDK #2657
Comments
Can you explain how you got to display the serialized Patient? Because when I copy your code excluding the line with This leads me to believe that the actual error is in your fhirService or its Execute method. Can you detail the code that is in the fhirService? Are you using the FhirClient to send the Patient to the Epic sandbox? Or maybe the display in the sandbox environment uses a wrong serializer instead of showing the raw data. |
yes the 'json' after string json = serializer.SerializeToString(newPatient); produces the correct payload for Create patient.
I should be able to send the json in the place of 'newPatient' but it is expecting 'Patient' class object as parameter.
still no luck |
Below is my FHIR Service code
|
I don't see the Execute method in your FhirService. There must be something wrong in there. If I try it without a FhirService and just do
everything works fine. You could try and debug further by working with a public endpoint such as |
Below is the Execute method in my Custom FHIR Service
|
It works fine. And it actually does exactly as you have specified you wanted. If you do still get errors, like the OperationOutcome you mentioned in the beginning, there's something wrong on the server side. |
I'm not even able to create a Patient itself with my payload. May be now you have the total context of my problem, let me reiterate. I'm using the Firely .Net SDK (R4, Version 5.4.0.)
This payload has appended "value" before every property. When I use this payload, the API Returns 'unstructured format' error. Now, as I mentioned above, I used FhirJsonSerializer , to serialize my payload. This now gives me a string (JSON) value with a mandatory input 'resourceType': 'Patient' included in the JSON.
Now, I'm unable to pass this input to the Execute method as it expects a Patient type Resource. I tried DeSerializing the JSON to Patient Type again. It again appends the "value" before every property. Do I need to include any ParseSettings in my FHIR Service to resolve this? I'm unable to do so. I cannot try any other open FHIR sources as we're considering EPIC Sandbox as standard and all other APIs work fine. Please let me know if any further info is needed. |
The Create method on the FhirClient does indeed expect a FHIR resource as argument, not a string. One reason is that it will use the resource type to setup the correct URL to send the resource to. Then with the other settings the SDK's serialization is used to create the actual payload. I do not know how you get the serialization of the payload that you show in the first block, with the value attributes in it. That is not coming from the SDK's serializer. So that is not the payload that the FhirClient has created, but possibly a view you get from the sandbox on the data, instead of the raw request payload. Make sure to inspect the actual raw request body. If you have not left out any details of your code (other than real data), it should work. However, if you have other things in your FhirService that could influence serialization or how the request is sent, then please mention them here. Try the request on the public server: https://server.fire.ly/R4, and see what its response is. Another idea: does the Epic api accept JSON data at all? The OperationOutcome you mentioned is in XML format, and mentions something about structural errors. Remove your JSON preference from the FhirClient settings, and see if that helps. Thousands of implementations use the SDK, and there is nothing wrong with the FhirClient or the serialization. |
@mbaltus Adding this Could you please answer two more questions of mine?
|
Glad that it works now! I can answer only the first of your additional questions, since I do not know the details of generating an Epic token. Maybe there's more information on the Epic documentation site on the steps for that, or you could ask on StackOverflow for help. The answer to the first question is: there is already a library for R5 - Hl7.Fhir.R5. The main parts of the library are the same as for Hl7.Fhir.R4. For example, the communication using the FhirClient will be the same. |
I'm trying to create a patient in the EPIC Sandbox using the below API Url
https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/Patient
I'm using the firely .Net Sdk for EPIC FHIR API Integration. I'm using the Patient.Create (R4).
In Postman, I'm able to create a patient using the below sample payload from the Sandbox environment itself.
But the Firely SDK Patient Class generates the below payload:
Please find the code below(ignore the hardcodes) I'm using to create a patient
For resolving the issue, I tried the below code as well
Still, I'm unable to create a patient as its giving the below error:
The text was updated successfully, but these errors were encountered: