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

org.hl7.cql.model.SystemModelInfoProvider Maven / Gradle / Ivy

Go to download

The model library for the Clinical Quality Language Java reference implementation

There is a newer version: 3.23.0
Show newest version
package org.hl7.cql.model;

import java.io.IOException;
import org.hl7.elm_modelinfo.r1.ModelInfo;
import org.hl7.elm_modelinfo.r1.serializing.ModelInfoReaderFactory;

public class SystemModelInfoProvider implements ModelInfoProvider {
    private NamespaceManager namespaceManager;

    public void setNamespaceManager(NamespaceManager namespaceManager) {
        this.namespaceManager = namespaceManager;
    }

    private boolean isSystemModelIdentifier(ModelIdentifier modelIdentifier) {
        if (namespaceManager != null && namespaceManager.hasNamespaces()) {
            return modelIdentifier.getId().equals("System")
                    && (modelIdentifier.getSystem() == null
                            || modelIdentifier.getSystem().equals("urn:hl7-org:elm-types:r1"));
        }

        return modelIdentifier.getId().equals("System");
    }

    public ModelInfo load(ModelIdentifier modelIdentifier) {
        if (isSystemModelIdentifier(modelIdentifier)) {
            try {
                return ModelInfoReaderFactory.getReader("application/xml")
                        .read(SystemModelInfoProvider.class.getResourceAsStream(
                                "/org/hl7/elm/r1/system-modelinfo.xml"));
            } catch (IOException e) {
                // Do not throw, allow other providers to resolve
            }
        }

        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy