Skip to content

Commit

Permalink
Condition broker impl
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliouzbett committed Mar 8, 2023
1 parent 4231135 commit 77e3344
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ private void prepareEncounterMessage(@NotNull EventMetadata metadata) {
} else {
log.error("ONE OF THE REFERENCES WAS NULL");
}

this.processBrokers(encounter);
}

public String getResourceUuid(String resourceUrl) {
Expand Down Expand Up @@ -254,4 +256,30 @@ private Bundle.BundleEntryComponent getConditionBundleComponent(Condition condit

return bundleEntryComponent;
}

private void processBrokers(@Nonnull Encounter encounter) {
log.error("encounter {}", encounter);
Bundle bundle = new Bundle();
this.processThroughBrokers(encounter, bundle);

List<Class<? extends InteropBroker>> brokers = new ArrayList<>(ClassUtils.getInteropBrokers());
log.error("Num of brokers :: {}", brokers.size());
log.error("Brokers :: {}", brokers);
brokers.forEach(broker -> {
InteropBroker newInstanceBroker;
try {
newInstanceBroker = broker.getDeclaredConstructor().newInstance();
}
catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
log.error("Unable to instantiate {} broker class", broker.getSimpleName());
throw new RuntimeException(e);
}
// Publish to enabled connectors
List<Condition> conditions = newInstanceBroker.processEncounter(encounter);
log.error("Conditions {}", conditions);
conditions.forEach(condition -> bundle.addEntry(getConditionBundleComponent(condition)));
log.error("++++++++");
System.out.println("Resources:: " + getFhirContext().newJsonParser().encodeResourceToString(bundle));
});
}
}

0 comments on commit 77e3344

Please sign in to comment.