GithubHelp home page GithubHelp logo

brianpos / fhir-net-web-api Goto Github PK

View Code? Open in Web Editor NEW
26.0 3.0 13.0 94.73 MB

.NET FHIR webapi and netapicore facade library

License: Other

Batchfile 0.01% C# 99.99% HTML 0.01%
fhir fhir-server

fhir-net-web-api's People

Contributors

brianpos avatar cknaap avatar ewoutkramer avatar lstratman avatar marcovisserfurore avatar mharthoorn avatar mmsmits avatar tiloc avatar wmrutten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fhir-net-web-api's Issues

Facade server only processes first entry in Bundle resource POST

Our implementation of the facade server only processes the first entry in a Bundle POST request. By process, I mean the server returns 500 and during debugging the handling only happens for the first entry before it breaks.

I've gone through the code and am pretty convinced it's something we've done because a fresh clone of this repo processes bundles fine. I have spent an embarrassingly long time on this to no avail :) I was hoping someone could point out what I'm missing.

FHIR Bundle POST (via Postman):

{
    "resourceType": "Bundle",
    "meta": {
        "lastUpdated": "2023-05-08T08:44:57.076Z"
    },
    "type": "batch",
    "entry": [
        {
            "request": {
                "method": "POST",
                "url": "Condition"
            },
            "resource": {
                "resourceType": "Observation",
                "meta": {
                    "profile": [
                        "http://hl7.org/fhir/uv/eyecare/StructureDefinition/observation-iop"
                    ]
                },
                "status": "final",
                "category": [
                    {
                        "coding": [
                            {
                                "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                                "code": "exam",
                                "display": "Exam"
                            }
                        ]
                    }
                ],
                "code": {
                    "coding": [
                        {
                            "system": "http://snomed.info/sct",
                            "code": "41633001",
                            "display": "Intraocular pressure"
                        }
                    ]
                },
                "subject": {
                    "reference": "Patient/x.x.28219",
                    "type": "Patient"
                },
                "encounter": {
                    "reference": "Encounter/x.x.130792",
                    "type": "Encounter"
                },
                "effectiveDateTime": "2013-03-27T13:13:46+11:00",
                "valueQuantity": {
                    "value": 17,
                    "unit": "mmHg",
                    "system": "http://unitsofmeasure.org",
                    "code": "mm[Hg]"
                },
                "bodySite": {
                    "coding": [
                        {
                            "system": "http://snomed.info/sct",
                            "code": "18944008",
                            "display": "Right eye structure"
                        }
                    ]
                },
                "method": {
                    "coding": [
                        {
                            "system": "http://snomed.info/sct",
                            "code": "389152008",
                            "display": "Goldmann applanation tonometry"
                        }
                    ]
                }
            }
        },
        {
            "request": {
                "method": "POST",
                "url": "Observation"
            },
            "resource": {
                "resourceType": "Condition",
                "meta": {
                    "profile": [
                        "http://hl7.org/fhir/uv/eyecare/StructureDefinition/condition-base"
                    ]
                },
                "clinicalStatus": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
                            "code": "active",
                            "display": "Active"
                        }
                    ],
                    "text": "Active"
                },
                "verificationStatus": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status",
                            "code": "confirmed",
                            "display": "Confirmed"
                        }
                    ]
                },
                "category": [
                    {
                        "coding": [
                            {
                                "system": "http://terminology.hl7.org/CodeSystem/condition-category",
                                "code": "encounter-diagnosis",
                                "display": "Encounter Diagnosis"
                            }
                        ]
                    }
                ],
                "subject": {
                    "reference": "Patient/x.x.28219",
                    "type": "Patient"
                },
                "encounter": {
                    "reference": "Encounter/x.x.130792",
                    "type": "Encounter"
                },
                "onsetDateTime": "2023-05-08T08:44:57.075Z",
                "recordedDate": "2023-05-08T08:44:57.075Z",
                "code": {
                    "coding": [
                        {
                            "system": "http://snomed.info/sct",
                            "code": "414875008",
                            "display": "Nonexudative age-related macular degeneration"
                        }
                    ],
                    "text": "Geographic atrophy"
                },
                "bodySite": [
                    {
                        "coding": [
                            {
                                "system": "http://snomed.info/sct",
                                "code": "18944008",
                                "display": "Right eye structure"
                            },
                            {
                                "system": "http://snomed.info/sct",
                                "code": "264209008",
                                "display": "Subfoveal"
                            }
                        ],
                        "text": "Subfoveal right eye"
                    }
                ]
            }
        }
    ]
}

Server log:

info: Hl7.Fhir.WebApi.FhirR4Controller[0]
POST: https://8f3b-223-25-113-49.ngrok-free.app/
System.Threading.Tasks.Task1[Hl7.Fhir.Model.Resource]
crit: Hl7.Fhir.WebApi.FhirExceptionFilter[0]
      Unhandled exception in the Server
      System.AggregateException: One or more errors occurred. (Object reference
not set to an instance of an object.)
       ---> System.NullReferenceException: Object reference not set to an instan
ce of an object.
         at Hl7.Fhir.Utility.AnnotatedExtensions.Annotation[A](IAnnotated annota
ted)
         at Hl7.Fhir.WebApi.BatchOperationProcessing1.ProcessBatchEntry(ModelBa
seInputs1 request, Bundle outcome, Dictionary2 mappedResourceIds, EntryCompone
nt entry)
at Hl7.Fhir.WebApi.BatchOperationProcessing1.ProcessBatch(ModelBaseInp
uts1 request, Bundle batch)
--- End of inner exception stack trace ---
![image 2](https://github.com/brianpos/fhir-net-web-api/assets/121207588/64721a1b-b77c-424a-acad-e4294551c8b6)

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCa
nceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, Cancella
tionToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at bpvip_resources.SystemService1.ProcessBatch(ModelBaseInputs1 reque
st, Bundle batch) in C:\Users\sanro.admin\Desktop\bpvip-server\bpvip-resources\S
ystemService.cs:line 95
at Hl7.Fhir.WebApi.FhirR4Controller.ProcessBatch(Bundle batch)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfI
ActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecuto
r executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<Inv
okeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask
1 actionResultValueTask)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<Inv
okeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task l
astTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Reth
row(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next
(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Invo
keInnerFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextE
xceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, Stat
e next, Scope scope, Object state, Boolean isCompleted)
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
      Executed action Hl7.Fhir.WebApi.FhirR4Controller.ProcessBatch (Hl7.Fhir.R4
.WebApi.AspNetCore) in 3771.1764ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'Hl7.Fhir.WebApi.FhirR4Controller.ProcessBatch (Hl7.Fhir
.R4.WebApi.AspNetCore)'
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HMR5DSVO3DE5", Request id "0HMR5DSVO3DE5:00000002": An unh
andled exception was thrown by the application.
      System.AggregateException: One or more errors occurred. (Object reference
not set to an instance of an object.)
       ---> System.NullReferenceException: Object reference not set to an instan
ce of an object.
         at Hl7.Fhir.Utility.AnnotatedExtensions.Annotation[A](IAnnotated annota
ted)
         at Hl7.Fhir.WebApi.BatchOperationProcessing1.ProcessBatchEntry(ModelBa
seInputs1 request, Bundle outcome, Dictionary2 mappedResourceIds, EntryCompone
nt entry)
at Hl7.Fhir.WebApi.BatchOperationProcessing1.ProcessBatch(ModelBaseInp
uts1 request, Bundle batch)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCa
nceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, Cancella
tionToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at bpvip_resources.SystemService1.ProcessBatch(ModelBaseInputs1 reque
st, Bundle batch) in C:\Users\sanro.admin\Desktop\bpvip-server\bpvip-resources\S
ystemService.cs:line 95
at Hl7.Fhir.WebApi.FhirR4Controller.ProcessBatch(Bundle batch)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfI
ActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecuto
r executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<Inv
okeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`
1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<Inv
okeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task l
astTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Reth
row(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next
(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Invo
keInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextE
xceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, Stat
e next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(Exce
ptionContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State&
next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextRe
sourceFilter()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(Reso
urceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State&
next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilter
PipelineAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync

g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync
g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequ
estTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(
HttpContext context)
at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddlewa
![image 2](https://github.com/brianpos/fhir-net-web-api/assets/121207588/c58714cb-cee9-40cd-a8f0-1df9b95a0d7e)

re.InvokeCore(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.
ProcessRequests[TContext](http://ihttpapplication%601%20application/)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 POST https://8f3b-223-25-113-49.ngrok-free.app/
application/json 5836 - 500 0 - 3845.3013ms

Attachment (possibly relevant missing method in Task? - see highlighted in blue at bottom of image)

https://drive.google.com/file/d/1O7KL9yZsf4IKjVZNn6rwAleA6zhPjVb6/view?usp=sharing

Support the prefer headers

http://hl7.org/implement/standards/fhir/search.html#errors

  • Prefer: handling=strict: Client requests that the server return an error for any unknown or unsupported parameter
  • Prefer: handling=lenient: Client requests that the server ignore any unknown or unsupported parameter

http://hl7.org/implement/standards/fhir/http.html#prefer

  • Prefer: return=minimal
  • Prefer: return=representation
  • Prefer: return=OperationOutcome

http://hl7.org/implement/standards/fhir/async.html#3.1.6.2.0.1

  • Prefer: respond-async

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.