OHSUCMP / coach

web application frontend for OHSU HTN U18 grant
2 stars 0 forks source link

improve auditing around vitals writeback failures #181

Closed mattStorer closed 4 months ago

mattStorer commented 4 months ago

the audit table shows vital writebacks to Epic as succeeding, but in the logs we see that some fail. fix this.

for example, these entries from the audit table:

image

correspond to these logs:

2024-03-08 08:46:22.042 [http-nio-50000-exec-33] INFO  e.o.c.c.service.BloodPressureService [BloodPressureService.java:124] attempting writeback of BP 130mmHg/80mmHg (id unknown) using strategy PATIENT
2024-03-08 08:46:22.127 [http-nio-50000-exec-33] ERROR e.o.c.c.f.t.EpicVendorTransformer [EpicVendorTransformer.java:58] caught ForbiddenOperationException attempting to transact Observation - HTTP 403 Forbidden - skipping -
ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException: HTTP 403 Forbidden
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException.newInstance(BaseServerResponseException.java:310)
    at ca.uhn.fhir.rest.client.impl.BaseClient.invokeClient(BaseClient.java:376)
    at ca.uhn.fhir.rest.client.impl.GenericClient$BaseClientExecutable.invoke(GenericClient.java:541)
    at ca.uhn.fhir.rest.client.impl.GenericClient$CreateInternal.execute(GenericClient.java:693)
    at ca.uhn.fhir.rest.client.impl.GenericClient$CreateInternal.execute(GenericClient.java:648)
    at edu.ohsu.cmp.coach.service.FHIRService.transact(FHIRService.java:209)
    at edu.ohsu.cmp.coach.fhir.transform.EpicVendorTransformer.writeRemote(EpicVendorTransformer.java:54)
    at edu.ohsu.cmp.coach.service.BloodPressureService.create(BloodPressureService.java:129)
    at edu.ohsu.cmp.coach.controller.VitalsController.create(VitalsController.java:95)
mattStorer commented 4 months ago

this is resolved. 400 Bad Request and 403 Unauthorized exceptions extended RuntimeException, which wasn't getting bubbled up to the calling function where audits took place. added a line of code to do that, now those exceptions are getting logged as intended.

here's an example in POC of writing a BP twice, where it succeeds the first time, and fails the second:

image