use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project CRD by HL7-DaVinci.
the class GitHubFileStore method getCqlRule.
public CqlRule getCqlRule(String topic, String fhirVersion) {
logger.info("GitHubFileStore::getCqlRule(): " + topic + "/" + fhirVersion);
// load CQL files needed for the CRD Rule
HashMap<String, byte[]> cqlFiles = new HashMap<>();
String rulePath = config.getGitHubConfig().getRulePath();
String examplesPath = config.getGitHubConfig().getExamplesPath();
String mainCqlLibraryName = topic + "Rule";
String mainCqlFile = findGitHubFile(topic, fhirVersion, mainCqlLibraryName, FileStore.CQL_EXTENSION);
if (mainCqlFile == null) {
logger.warn("GitHubFileStore::getCqlRule(): failed to find main CQL file");
} else {
String mainCqlFilePath = rulePath + topic + "/" + fhirVersion + "/files/" + mainCqlFile;
try {
InputStream inputStream = connection.getFile(mainCqlFilePath);
if (inputStream == null) {
// look for the main cql file in the examples path as well
mainCqlFilePath = examplesPath + topic + "/" + fhirVersion + "/files/" + mainCqlFile;
inputStream = connection.getFile(mainCqlFilePath);
}
cqlFiles.put(mainCqlFile, IOUtils.toByteArray(inputStream));
logger.info("GitHubFileStore::getCqlRule(): added mainCqlFile: " + mainCqlFile);
} catch (IOException e) {
logger.warn("GitHubFileStore::getCqlRule(): failed to open main cql file: " + e.getMessage());
}
}
String helperCqlFile = findGitHubFile(FileStore.SHARED_TOPIC, fhirVersion, FileStore.FHIR_HELPERS_FILENAME, FileStore.CQL_EXTENSION);
if (helperCqlFile == null) {
logger.warn("GitHubFileStore::getCqlRule(): failed to find FHIR helper CQL file");
} else {
String helperCqlFilePath = rulePath + "Shared/" + fhirVersion + "/files/" + helperCqlFile;
try {
InputStream inputStream = connection.getFile(helperCqlFilePath);
if (inputStream == null) {
// look for the helper cql file in the examples path as well
helperCqlFilePath = examplesPath + "Shared/" + fhirVersion + "/files/" + helperCqlFile;
inputStream = connection.getFile(helperCqlFilePath);
}
cqlFiles.put(helperCqlFile, IOUtils.toByteArray(inputStream));
logger.info("GitHubFileStore::getCqlRule(): added helperCqlFile: " + helperCqlFile);
} catch (IOException e) {
logger.warn("GitHubFileStore::getCqlRule(): failed to open file FHIR helper cql file: " + e.getMessage());
}
}
return new CqlRule(mainCqlLibraryName, cqlFiles, fhirVersion);
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project CRD by HL7-DaVinci.
the class Metadata method buildCapabilityStatement.
/**
* Builds the CapabilityStatement describing the Coverage Requirements Discovery Reference
* Implementation.
*
* @return CapabilityStatement - the CapabilityStatement.
*/
private CapabilityStatement buildCapabilityStatement(String baseUrl) {
CapabilityStatement metadata = new CapabilityStatement();
metadata.setTitle("Da Vinci Coverage Requirements Discovery (CRD) Reference Implementation");
metadata.setStatus(PublicationStatus.DRAFT);
metadata.setExperimental(true);
Calendar calendar = Calendar.getInstance();
calendar.set(2019, 4, 28, 0, 0, 0);
metadata.setDate(calendar.getTime());
metadata.setPublisher("Da Vinci");
metadata.setKind(CapabilityStatementKind.INSTANCE);
CapabilityStatementSoftwareComponent software = new CapabilityStatementSoftwareComponent();
software.setName("https://github.com/HL7-DaVinci/CRD");
metadata.setSoftware(software);
CapabilityStatementImplementationComponent implementation = new CapabilityStatementImplementationComponent();
implementation.setDescription(metadata.getTitle());
implementation.setUrl(baseUrl + "metadata");
metadata.setImplementation(implementation);
metadata.setFhirVersion(FHIRVersion._4_0_1);
metadata.addFormat("json");
metadata.addExtension("http://hl7.org/fhir/StructureDefinition/capabilitystatement-websocket", new StringType("/fhir/r4"));
metadata.addImplementationGuide("https://build.fhir.org/ig/HL7/davinci-crd/index.html");
CapabilityStatementRestComponent rest = new CapabilityStatementRestComponent();
rest.setMode(RestfulCapabilityMode.SERVER);
CapabilityStatementRestSecurityComponent security = new CapabilityStatementRestSecurityComponent();
security.setCors(true);
rest.setSecurity(security);
// Library Resource
CapabilityStatementRestResourceComponent library = new CapabilityStatementRestResourceComponent();
library.setType("Library");
library.addInteraction().setCode(TypeRestfulInteraction.READ);
library.addInteraction().setCode(TypeRestfulInteraction.SEARCHTYPE);
library.addInteraction().setCode(TypeRestfulInteraction.CREATE);
rest.addResource(library);
// Questionnaire Resource
CapabilityStatementRestResourceComponent questionnaire = new CapabilityStatementRestResourceComponent();
questionnaire.setType("Questionnaire");
questionnaire.addInteraction().setCode(TypeRestfulInteraction.READ);
questionnaire.addInteraction().setCode(TypeRestfulInteraction.SEARCHTYPE);
questionnaire.addInteraction().setCode(TypeRestfulInteraction.CREATE);
CapabilityStatementRestResourceOperationComponent questionnairePackageOperation = new CapabilityStatementRestResourceOperationComponent();
questionnairePackageOperation.setName("questionnaire-package");
questionnairePackageOperation.setDefinition("http://hl7.org/fhir/us/davinci-dtr/OperationDefinition/Questionnaire-package");
questionnairePackageOperation.setDocumentation("Retrieve the Questionnaire(s), Libraries, and Valuesets for a given order and coverage. This operation is to support HL7 DaVinci DTR.");
questionnaire.addOperation(questionnairePackageOperation);
rest.addResource(questionnaire);
// QuestionnaireResponse Resource
CapabilityStatementRestResourceComponent questionnaireResponse = new CapabilityStatementRestResourceComponent();
questionnaireResponse.setType("QuestionnaireResponse");
questionnaireResponse.addInteraction().setCode(TypeRestfulInteraction.READ);
questionnaireResponse.addInteraction().setCode(TypeRestfulInteraction.SEARCHTYPE);
questionnaireResponse.addInteraction().setCode(TypeRestfulInteraction.CREATE);
rest.addResource(questionnaireResponse);
// ValueSet Resource
CapabilityStatementRestResourceComponent valueset = new CapabilityStatementRestResourceComponent();
valueset.setType("ValueSet");
valueset.addInteraction().setCode(TypeRestfulInteraction.READ);
valueset.addInteraction().setCode(TypeRestfulInteraction.SEARCHTYPE);
valueset.addInteraction().setCode(TypeRestfulInteraction.CREATE);
// ValueSet $expand Operator
CapabilityStatementRestResourceOperationComponent expandOperator = new CapabilityStatementRestResourceOperationComponent();
expandOperator.setName("expand");
expandOperator.setDefinition("http://hl7.org/fhir/OperationDefinition/ValueSet-expand");
expandOperator.setDocumentation("Only works at the ValueSet type level with a 'url' query parameter. Will only return expansions that are pre-cached on this server.");
valueset.addOperation(expandOperator);
rest.addResource(valueset);
metadata.addRest(rest);
return metadata;
}
Aggregations