All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencds.cqf.processor.LibraryProcessor Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package org.opencds.cqf.processor;

import java.util.Map;

import org.apache.commons.io.FilenameUtils;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.opencds.cqf.parameter.RefreshLibraryParameters;
import org.opencds.cqf.utilities.IOUtils.Encoding;
import org.opencds.cqf.utilities.LogUtils;
import org.opencds.cqf.utilities.ResourceUtils;

import ca.uhn.fhir.context.FhirContext;

public interface LibraryProcessor {
    public static final String ResourcePrefix = "library-";   
    public static String getId(String baseId) {
        return ResourcePrefix + baseId;
    }

    public static Boolean bundleLibraryDependencies(String path, FhirContext fhirContext, Map resources,
            Encoding encoding) {
        Boolean shouldPersist = true;
        try {
            Map dependencies = ResourceUtils.getDepLibraryResources(path, fhirContext, encoding);
            String currentResourceID = FilenameUtils.getBaseName(path);
            for (IAnyResource resource : dependencies.values()) {
                resources.putIfAbsent(resource.getId(), resource);

                // NOTE: Assuming dependency library will be in directory of dependent.
                String dependencyPath = path.replace(currentResourceID, resource.getId().replace("Library/", ""));
                bundleLibraryDependencies(dependencyPath, fhirContext, resources, encoding);
            }
        } catch (Exception e) {
            shouldPersist = false;
            LogUtils.putException(path, e);
        }
        return shouldPersist;
    }

    public Boolean refreshLibraryContent(RefreshLibraryParameters params);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy