use of org.hl7.fhir.r4b.model.Library in project cqf-ruler by DBCG.
the class DataOperationsProvider method dataRequirements.
@Operation(name = "$data-requirements", idempotent = true, type = Measure.class)
public Library dataRequirements(@IdParam IdType theId, @OperationParam(name = "startPeriod") String startPeriod, @OperationParam(name = "endPeriod") String endPeriod, RequestDetails theRequestDetails) throws InternalErrorException, FHIRException {
Measure measure = read(theId, theRequestDetails);
Library library = getLibraryFromMeasure(measure, theRequestDetails);
if (library == null) {
throw new RuntimeException("Could not load measure library.");
}
// TODO: Pass startPeriod and endPeriod as parameters to the data requirements operation
return processDataRequirements(measure, library, theRequestDetails);
}
use of org.hl7.fhir.r4b.model.Library in project cqf-ruler by DBCG.
the class DataOperationsProvider method getLibraryFromMeasure.
public Library getLibraryFromMeasure(Measure measure, RequestDetails theRequestDetails) {
Iterator<Reference> var6 = measure.getLibrary().iterator();
String libraryIdOrCanonical = null;
// use the first library
while (var6.hasNext() && libraryIdOrCanonical == null) {
Reference ref = var6.next();
if (ref != null) {
libraryIdOrCanonical = ref.getReference();
}
}
Library library = read(new IdType(libraryIdOrCanonical), theRequestDetails);
if (library == null) {
library = search(Library.class, Searches.byCanonical(libraryIdOrCanonical), theRequestDetails).firstOrNull();
}
return library;
}
use of org.hl7.fhir.r4b.model.Library in project cqf-ruler by DBCG.
the class DataOperationsProvider method createLibraryManager.
private LibraryManager createLibraryManager(Library library, RequestDetails theRequestDetails) {
JpaLibraryContentProvider jpaLibraryContentProvider = jpaLibraryContentProviderFactory.create(theRequestDetails);
Bundle libraryBundle = new Bundle();
List<Library> listLib = fetchDependencyLibraries(library, theRequestDetails);
listLib.add(library);
listLib.forEach(lib -> {
Bundle.BundleEntryComponent component = new Bundle.BundleEntryComponent();
component.setResource(lib);
libraryBundle.addEntry(component);
});
LibraryContentProvider bundleLibraryProvider = new BundleFhirLibraryContentProvider(this.getFhirContext(), libraryBundle, adapterFactory, libraryVersionSelector);
List<LibraryContentProvider> sourceProviders = Lists.newArrayList(bundleLibraryProvider, jpaLibraryContentProvider);
return libraryManagerFactory.create(sourceProviders);
}
use of org.hl7.fhir.r4b.model.Library in project cqf-ruler by DBCG.
the class DataOperationsProvider method fetchDependencyLibraries.
private List<Library> fetchDependencyLibraries(Library library, RequestDetails theRequestDetails) {
Map<String, Library> resources = new HashMap<>();
List<Library> queue = new ArrayList<>();
queue.add(library);
while (!queue.isEmpty()) {
Library current = queue.get(0);
queue.remove(0);
visitLibrary(current, queue, resources, theRequestDetails);
}
return new ArrayList<>(resources.values());
}
use of org.hl7.fhir.r4b.model.Library in project cqf-ruler by DBCG.
the class Session method resolveCdsHooksPlanDefinition.
// For library use
public CarePlan resolveCdsHooksPlanDefinition(RequestDetails theRequest, Context context, PlanDefinition planDefinition, String patientId) {
CarePlanBuilder carePlanBuilder = new CarePlanBuilder();
RequestGroupBuilder requestGroupBuilder = new RequestGroupBuilder().buildStatus().buildIntent();
// links
if (planDefinition.hasRelatedArtifact()) {
List<Extension> extensions = new ArrayList<>();
for (RelatedArtifact relatedArtifact : planDefinition.getRelatedArtifact()) {
AttachmentBuilder attachmentBuilder = new AttachmentBuilder();
ExtensionBuilder extensionBuilder = new ExtensionBuilder();
if (relatedArtifact.hasDisplay()) {
// label
attachmentBuilder.buildTitle(relatedArtifact.getDisplay());
}
if (relatedArtifact.hasUrl()) {
// url
attachmentBuilder.buildUrl(relatedArtifact.getUrl());
}
if (relatedArtifact.hasExtension()) {
// type
attachmentBuilder.buildExtension(relatedArtifact.getExtension());
}
extensionBuilder.buildUrl("http://example.org");
extensionBuilder.buildValue(attachmentBuilder.build());
extensions.add(extensionBuilder.build());
}
requestGroupBuilder.buildExtension(extensions);
}
resolveActions(theRequest, planDefinition, planDefinition.getAction(), context, patientId, requestGroupBuilder, new ArrayList<>());
CarePlanActivityBuilder carePlanActivityBuilder = new CarePlanActivityBuilder();
carePlanActivityBuilder.buildReferenceTarget(requestGroupBuilder.build());
carePlanBuilder.buildActivity(carePlanActivityBuilder.build());
return carePlanBuilder.build();
}
Aggregations