-
Notifications
You must be signed in to change notification settings - Fork 2
Expose Failed Patient Transfers via Status #1486
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| import care.smith.fts.api.ConsentedPatientBundle; | ||
| import care.smith.fts.api.TransportBundle; | ||
| import care.smith.fts.api.cda.BundleSender.Result; | ||
| import care.smith.fts.cda.TransferProcessStatus.Step; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import java.time.LocalDateTime; | ||
| import java.util.HashMap; | ||
|
|
@@ -151,10 +152,17 @@ private Flux<ConsentedPatientBundle> selectDataForPatient(ConsentedPatient patie | |
| return process | ||
| .dataSelector() | ||
| .select(patient) | ||
| .doOnError(e -> logError("select data", patient.identifier(), e)); | ||
| .onErrorResume(e -> handlePatientError(patient.identifier(), Step.SELECT_DATA, e)); | ||
| } | ||
|
|
||
| private void logError(String step, String patientIdentifier, Throwable e) { | ||
| private <T> Mono<T> handlePatientError(String patientId, Step step, Throwable e) { | ||
| logError(step, patientId, e); | ||
| status.updateAndGet( | ||
| s -> s.incSkippedBundles().addFailedPatient(patientId, step, e.getMessage())); | ||
| return Mono.empty(); | ||
| } | ||
|
|
||
| private void logError(Step step, String patientIdentifier, Throwable e) { | ||
| var msg = "[Process {}] Failed to {} for patient {}. {}"; | ||
| log.error( | ||
| msg, processId(), step, patientIdentifier, log.isDebugEnabled() ? e : e.getMessage()); | ||
|
|
@@ -171,25 +179,26 @@ private Flux<PatientContext<TransportBundle>> deidentify( | |
|
|
||
| private Mono<PatientContext<TransportBundle>> deidentifyForPatient( | ||
| ConsentedPatientBundle bundle) { | ||
| var patientId = bundle.consentedPatient().identifier(); | ||
| return process | ||
| .deidentificator() | ||
| .deidentify(bundle) | ||
| .doOnError(e -> logError("deidentify bundle", bundle.consentedPatient().identifier(), e)) | ||
| .map(t -> new PatientContext<>(t, bundle.consentedPatient())); | ||
| .map(t -> new PatientContext<>(t, bundle.consentedPatient())) | ||
| .onErrorResume(e -> handlePatientError(patientId, Step.DEIDENTIFY, e)); | ||
| } | ||
|
|
||
| private Flux<Result> sendBundles(Flux<PatientContext<TransportBundle>> deidentification) { | ||
| return deidentification | ||
| .flatMap(this::sendBundleForPatient, config.maxSendConcurrency) | ||
| .doOnNext(b -> status.updateAndGet(TransferProcessStatus::incSentBundles)) | ||
| .onErrorContinue((e, r) -> status.updateAndGet(TransferProcessStatus::incSkippedBundles)); | ||
| .doOnNext(b -> status.updateAndGet(TransferProcessStatus::incSentBundles)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was the onErrorContinue removed here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The This approach is also safer — |
||
| } | ||
|
|
||
| private Mono<Result> sendBundleForPatient(PatientContext<TransportBundle> b) { | ||
| var patientId = b.consentedPatient().identifier(); | ||
| return process | ||
| .bundleSender() | ||
| .send(b.data()) | ||
| .doOnError(e -> logError("send bundle", b.consentedPatient().identifier(), e)); | ||
| .onErrorResume(e -> handlePatientError(patientId, Step.SEND_BUNDLE, e)); | ||
| } | ||
|
|
||
| private void onComplete() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The step string should come from the step enum.