use of org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestComponent in project org.hl7.fhir.core by hapifhir.
the class Conformance10_50 method convertConformance.
public static org.hl7.fhir.dstu2.model.Conformance convertConformance(org.hl7.fhir.r5.model.CapabilityStatement src, BaseAdvisor_10_50 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance();
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
if (src.hasUrlElement())
tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement()));
if (src.hasVersionElement())
tgt.setVersionElement(String10_50.convertString(src.getVersionElement()));
if (src.hasNameElement())
tgt.setNameElement(String10_50.convertString(src.getNameElement()));
if (src.hasStatus())
tgt.setStatusElement(Enumerations10_50.convertConformanceResourceStatus(src.getStatusElement()));
if (src.hasExperimental())
tgt.setExperimentalElement(Boolean10_50.convertBoolean(src.getExperimentalElement()));
if (src.hasDate())
tgt.setDateElement(DateTime10_50.convertDateTime(src.getDateElement()));
if (src.hasPublisherElement())
tgt.setPublisherElement(String10_50.convertString(src.getPublisherElement()));
for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) tgt.addContact(convertConformanceContactComponent(t));
if (src.hasDescription())
tgt.setDescription(src.getDescription());
if (src.hasPurpose())
tgt.setRequirements(src.getPurpose());
if (src.hasCopyright())
tgt.setCopyright(src.getCopyright());
if (src.hasKind())
tgt.setKindElement(convertConformanceStatementKind(src.getKindElement()));
if (src.hasSoftware())
tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware()));
if (src.hasImplementation())
tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
if (src.hasFhirVersion())
tgt.setFhirVersion(src.getFhirVersion().toCode());
if (src.hasExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"))
tgt.setAcceptUnknown(org.hl7.fhir.dstu2.model.Conformance.UnknownContentCode.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").getValue().primitiveValue()));
for (org.hl7.fhir.r5.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue());
for (CapabilityStatementRestComponent r : src.getRest()) for (CapabilityStatementRestResourceComponent rr : r.getResource()) for (org.hl7.fhir.r5.model.CanonicalType t : rr.getSupportedProfile()) tgt.addProfile(Reference10_50.convertCanonicalToReference(t));
for (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent t : src.getRest()) tgt.addRest(convertConformanceRestComponent(t));
for (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementMessagingComponent t : src.getMessaging()) tgt.addMessaging(convertConformanceMessagingComponent(t));
for (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementDocumentComponent t : src.getDocument()) tgt.addDocument(convertConformanceDocumentComponent(t));
return tgt;
}
use of org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestComponent in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method compareRests.
private void compareRests(List<CapabilityStatementRestComponent> left, List<CapabilityStatementRestComponent> right, StructuralMatch<Element> combined, List<CapabilityStatementRestComponent> union, List<CapabilityStatementRestComponent> intersection, CapabilityStatement csU, CapabilityStatement csI, CapabilityStatementComparison res, String path) {
List<CapabilityStatementRestComponent> matchR = new ArrayList<>();
for (CapabilityStatementRestComponent l : left) {
CapabilityStatementRestComponent r = findInList(right, l);
if (r == null) {
union.add(l);
combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this item", path)));
} else {
matchR.add(r);
CapabilityStatementRestComponent cdM = merge(l, r, res);
CapabilityStatementRestComponent cdI = intersect(l, r, res);
union.add(cdM);
intersection.add(cdI);
StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
compare(sm, l, r, path + ".where(mode='" + l.getMode() + "')", res);
combined.getChildren().add(sm);
compareRestSecurity(l, r, sm, cdM.getSecurity(), cdI.getSecurity(), csU, csI, res, path + ".security");
compareRestResources(l, r, sm, cdM, cdI, csU, csI, res, path + ".resource");
compareSearchParams(combined, l.getSearchParam(), r.getSearchParam(), path, res, cdM.getSearchParam(), cdI.getSearchParam());
compareOperations(combined, l.getOperation(), r.getOperation(), path, res, cdM.getOperation(), cdI.getOperation());
compareItemPropertyList(sm, "compartment", l.getCompartment(), r.getCompartment(), path, res, cdM.getCompartment(), cdI.getCompartment(), IssueSeverity.ERROR);
}
}
for (CapabilityStatementRestComponent r : right) {
if (!matchR.contains(r)) {
union.add(r);
combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this concept", path), r));
}
}
}
use of org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestComponent 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.CapabilityStatementRestComponent 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.CapabilityStatementRestComponent 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