use of org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method addRestResourceRow.
private Row addRestResourceRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<Element> t, CapabilityStatementComparison comparison) {
Row r = gen.new Row();
rows.add(r);
r.getCells().add(gen.new Cell(null, null, "resource", null, null));
CapabilityStatementRestResourceComponent left = t.hasLeft() ? (CapabilityStatementRestResourceComponent) t.getLeft() : null;
CapabilityStatementRestResourceComponent right = t.hasRight() ? (CapabilityStatementRestResourceComponent) t.getRight() : null;
r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getType() : "", null, null), left != null ? left.getType() : null, right != null ? right.getType() : null, true));
r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getDocumentation() : "", null, null), left != null ? left.getDocumentation() : null, right != null ? right.getDocumentation() : null, true));
r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getType() : "", null, null), left != null ? left.getType() : null, right != null ? right.getType() : null, false));
r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getDocumentation() : "", null, null), left != null ? left.getDocumentation() : null, right != null ? right.getDocumentation() : null, true));
r.getCells().add(cellForMessages(gen, t.getMessages()));
return r;
}
use of org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method compareRestResources.
private void compareRestResources(CapabilityStatementRestComponent left, CapabilityStatementRestComponent right, StructuralMatch<Element> combined, CapabilityStatementRestComponent union, CapabilityStatementRestComponent intersection, CapabilityStatement csU, CapabilityStatement csI, CapabilityStatementComparison res, String path) {
List<CapabilityStatementRestResourceComponent> matchR = new ArrayList<>();
for (CapabilityStatementRestResourceComponent l : left.getResource()) {
CapabilityStatementRestResourceComponent r = findInList(right.getResource(), l);
if (r == null) {
union.getResource().add(l);
combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this item", path)));
} else {
matchR.add(r);
CapabilityStatementRestResourceComponent cdM = mergeRestResource(l, r);
CapabilityStatementRestResourceComponent cdI = intersectRestResource(l, r);
union.getResource().add(cdM);
intersection.getResource().add(cdI);
StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
compareRestResource(sm, l, r, path, res, cdM, cdI);
combined.getChildren().add(sm);
}
}
for (CapabilityStatementRestResourceComponent r : right.getResource()) {
if (!matchR.contains(r)) {
union.getResource().add(r);
combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this concept", path), r));
}
}
}
use of org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementRenderer method render.
public boolean render(XhtmlNode x, CapabilityStatement conf) throws FHIRFormatError, DefinitionException, IOException {
x.h2().addText(conf.getName());
addMarkdown(x, conf.getDescription());
if (conf.getRest().size() > 0) {
CapabilityStatementRestComponent rest = conf.getRest().get(0);
XhtmlNode t = x.table(null);
addTableRow(t, "Mode", rest.getMode().toString());
addMarkdown(addTableRow(t, "Description"), rest.getDocumentation());
addTableRow(t, "Transaction", showOp(rest, SystemRestfulInteraction.TRANSACTION));
addTableRow(t, "System History", showOp(rest, SystemRestfulInteraction.HISTORYSYSTEM));
addTableRow(t, "System Search", showOp(rest, SystemRestfulInteraction.SEARCHSYSTEM));
boolean hasVRead = false;
boolean hasPatch = false;
boolean hasDelete = false;
boolean hasHistory = false;
boolean hasUpdates = false;
for (CapabilityStatementRestResourceComponent r : rest.getResource()) {
hasVRead = hasVRead || hasOp(r, TypeRestfulInteraction.VREAD);
hasPatch = hasPatch || hasOp(r, TypeRestfulInteraction.PATCH);
hasDelete = hasDelete || hasOp(r, TypeRestfulInteraction.DELETE);
hasHistory = hasHistory || hasOp(r, TypeRestfulInteraction.HISTORYTYPE);
hasUpdates = hasUpdates || hasOp(r, TypeRestfulInteraction.HISTORYINSTANCE);
}
t = x.table(null);
XhtmlNode tr = t.tr();
tr.th().b().tx("Resource Type");
tr.th().b().tx("Profile");
tr.th().b().attribute("title", "GET a resource (read interaction)").tx("Read");
if (hasVRead)
tr.th().b().attribute("title", "GET past versions of resources (vread interaction)").tx("V-Read");
tr.th().b().attribute("title", "GET all set of resources of the type (search interaction)").tx("Search");
tr.th().b().attribute("title", "PUT a new resource version (update interaction)").tx("Update");
if (hasPatch)
tr.th().b().attribute("title", "PATCH a new resource version (patch interaction)").tx("Patch");
tr.th().b().attribute("title", "POST a new resource (create interaction)").tx("Create");
if (hasDelete)
tr.th().b().attribute("title", "DELETE a resource (delete interaction)").tx("Delete");
if (hasUpdates)
tr.th().b().attribute("title", "GET changes to a resource (history interaction on instance)").tx("Updates");
if (hasHistory)
tr.th().b().attribute("title", "GET changes for all resources of the type (history interaction on type)").tx("History");
XhtmlNode profCell = null;
boolean hasProf = false;
boolean hasSupProf = false;
for (CapabilityStatementRestResourceComponent r : rest.getResource()) {
tr = t.tr();
tr.td().addText(r.getType());
// Show profiles
profCell = tr.td();
hasProf = r.hasProfile();
hasSupProf = r.hasSupportedProfile();
if ((!hasProf) && (!hasSupProf)) {
profCell.nbsp();
} else if (hasProf) {
profCell.ah(r.getProfile()).addText(r.getProfile());
if (hasSupProf) {
profCell.br();
profCell.addText("Additional supported profiles:");
for (CanonicalType sp : r.getSupportedProfile()) {
profCell.br();
profCell.nbsp().nbsp();
profCell.ah(sp.getValue()).addText(sp.getValue());
}
}
} else {
// Case of only supported profiles
profCell.addText("Supported profiles:");
for (CanonicalType sp : r.getSupportedProfile()) {
profCell.br();
profCell.nbsp().nbsp();
profCell.ah(sp.getValue()).addText(sp.getValue());
}
}
// Show capabilities
tr.td().addText(showOp(r, TypeRestfulInteraction.READ));
if (hasVRead)
tr.td().addText(showOp(r, TypeRestfulInteraction.VREAD));
tr.td().addText(showOp(r, TypeRestfulInteraction.SEARCHTYPE));
tr.td().addText(showOp(r, TypeRestfulInteraction.UPDATE));
if (hasPatch)
tr.td().addText(showOp(r, TypeRestfulInteraction.PATCH));
tr.td().addText(showOp(r, TypeRestfulInteraction.CREATE));
if (hasDelete)
tr.td().addText(showOp(r, TypeRestfulInteraction.DELETE));
if (hasUpdates)
tr.td().addText(showOp(r, TypeRestfulInteraction.HISTORYINSTANCE));
if (hasHistory)
tr.td().addText(showOp(r, TypeRestfulInteraction.HISTORYTYPE));
}
}
return true;
}
use of org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent in project org.hl7.fhir.core by hapifhir.
the class OpenApiGenerator method generateSearch.
private void generateSearch(CapabilityStatementRestResourceComponent r) {
OperationWriter op = makePathResType(r).operation("get");
op.summary("Search all resources of type " + r.getType() + " based on a set of criteria");
op.operationId("search" + r.getType());
opOutcome(op.responses().defaultResponse());
ResponseObjectWriter resp = op.responses().httpResponse("200");
resp.description("the resource being returned");
if (isJson())
resp.content("application/fhir+json").schemaRef(specRef() + "/fhir.schema.json#/definitions/Bundle");
if (isXml())
resp.content("application/fhir+xml").schemaRef(specRef() + "/Bundle.xsd");
// todo: how do we know that these apply?
op.paramRef("#/components/parameters/format");
op.paramRef("#/components/parameters/pretty");
op.paramRef("#/components/parameters/summary");
op.paramRef("#/components/parameters/elements");
Set<String> set = new HashSet<>();
for (CapabilityStatementRestResourceSearchParamComponent spc : r.getSearchParam()) {
if (!set.contains(spc.getName())) {
set.add(spc.getName());
ParameterWriter p = op.parameter(spc.getName());
p.in(ParameterLocation.query).description(spc.getDocumentation());
p.schema().type(getSchemaType(spc.getType()));
if (spc.hasDefinition()) {
SearchParameter sp = context.fetchResource(SearchParameter.class, spc.getDefinition());
if (sp != null) {
p.description(sp.getDescription());
}
}
}
}
}
use of org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent 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