use of org.hl7.fhir.r4b.model.DataRequirement in project org.hl7.fhir.core by hapifhir.
the class LibraryRenderer method render.
public boolean render(XhtmlNode x, ResourceWrapper lib) throws FHIRFormatError, DefinitionException, IOException {
PropertyWrapper authors = lib.getChildByName("author");
PropertyWrapper editors = lib.getChildByName("editor");
PropertyWrapper reviewers = lib.getChildByName("reviewer");
PropertyWrapper endorsers = lib.getChildByName("endorser");
if ((authors != null && authors.hasValues()) || (editors != null && editors.hasValues()) || (reviewers != null && reviewers.hasValues()) || (endorsers != null && endorsers.hasValues())) {
boolean email = hasCT(authors, "email") || hasCT(editors, "email") || hasCT(reviewers, "email") || hasCT(endorsers, "email");
boolean phone = hasCT(authors, "phone") || hasCT(editors, "phone") || hasCT(reviewers, "phone") || hasCT(endorsers, "phone");
boolean url = hasCT(authors, "url") || hasCT(editors, "url") || hasCT(reviewers, "url") || hasCT(endorsers, "url");
x.h2().tx("Participants");
XhtmlNode t = x.table("grid");
if (authors != null) {
for (BaseWrapper cd : authors.getValues()) {
participantRow(t, "Author", cd, email, phone, url);
}
}
if (authors != null) {
for (BaseWrapper cd : editors.getValues()) {
participantRow(t, "Editor", cd, email, phone, url);
}
}
if (authors != null) {
for (BaseWrapper cd : reviewers.getValues()) {
participantRow(t, "Reviewer", cd, email, phone, url);
}
}
if (authors != null) {
for (BaseWrapper cd : endorsers.getValues()) {
participantRow(t, "Endorser", cd, email, phone, url);
}
}
}
PropertyWrapper artifacts = lib.getChildByName("relatedArtifact");
if (artifacts != null && artifacts.hasValues()) {
x.h2().tx("Related Artifacts");
XhtmlNode t = x.table("grid");
boolean label = false;
boolean display = false;
boolean citation = false;
for (BaseWrapper ra : artifacts.getValues()) {
label = label || ra.has("label");
display = display || ra.has("display");
citation = citation || ra.has("citation");
}
for (BaseWrapper ra : artifacts.getValues()) {
renderArtifact(t, ra, lib, label, display, citation);
}
}
PropertyWrapper parameters = lib.getChildByName("parameter");
if (parameters != null && parameters.hasValues()) {
x.h2().tx("Parameters");
XhtmlNode t = x.table("grid");
boolean doco = false;
for (BaseWrapper p : parameters.getValues()) {
doco = doco || p.has("documentation");
}
for (BaseWrapper p : parameters.getValues()) {
renderParameter(t, p, doco);
}
}
PropertyWrapper dataRequirements = lib.getChildByName("dataRequirement");
if (dataRequirements != null && dataRequirements.hasValues()) {
x.h2().tx("Data Requirements");
for (BaseWrapper p : dataRequirements.getValues()) {
renderDataRequirement(x, (DataRequirement) p.getBase());
}
}
PropertyWrapper contents = lib.getChildByName("content");
if (contents != null) {
x.h2().tx("Contents");
boolean isCql = false;
int counter = 0;
for (BaseWrapper p : contents.getValues()) {
Attachment att = (Attachment) p.getBase();
renderAttachment(x, att, isCql, counter, lib.getId());
isCql = isCql || (att.hasContentType() && att.getContentType().startsWith("text/cql"));
counter++;
}
}
return false;
}
use of org.hl7.fhir.r4b.model.DataRequirement in project eCRNow by drajer-health.
the class ValueSetServiceImpl method createPlanDefinitionAction.
@Override
public void createPlanDefinitionAction(TriggerDefinition triggerDefinition) {
List<DataRequirement> datareqs = triggerDefinition.getData();
Set<ValueSet> grouperToValueSets = new HashSet<>();
Set<ValueSet> grouperToCovidValueSets = new HashSet<>();
for (DataRequirement d : datareqs) {
DataRequirementCodeFilterComponent codeFilter = d.getCodeFilterFirstRep();
logger.debug(" Getting Value Set List for Grouper {}", codeFilter.getValueSet());
List<CanonicalType> valueSetIdList = ApplicationUtils.getValueSetListFromGrouper(codeFilter.getValueSet());
logger.debug(" Size of valueSetIdList = {}", ((valueSetIdList == null) ? "Null" : valueSetIdList.size()));
grouperToValueSets = ApplicationUtils.getValueSetByIds(valueSetIdList);
logger.debug(" Size of Value Sets for Grouper : {}", grouperToValueSets.size());
grouperToCovidValueSets = ApplicationUtils.getCovidValueSetByIds(valueSetIdList);
logger.debug(" Size of Covid Value Sets for Grouper : {}", grouperToCovidValueSets.size());
}
DataRequirement dataRequirement = triggerDefinition.getDataFirstRep();
DataRequirementCodeFilterComponent codeFilter = dataRequirement.getCodeFilterFirstRep();
List<CanonicalType> valueSetIdList = ApplicationUtils.getValueSetListFromGrouper(codeFilter.getValueSet());
Set<ValueSet> valueSets = ApplicationUtils.getValueSetByIds(valueSetIdList);
ValueSet valuSetGrouper = ApplicationUtils.getValueSetGrouperFromId(codeFilter.getValueSet());
String path = dataRequirement.getType() + "." + codeFilter.getPath();
logger.debug(" Trigger Path to Grouper Map {} , Grouper {}", path, valuSetGrouper == null ? "NULL" : valuSetGrouper.getId());
ValueSetSingleton.getInstance().getTriggerPathToValueSetsMap().put(path, valueSets);
if (ValueSetSingleton.getInstance().getTriggerPathToGrouperMap().containsKey(path)) {
logger.debug(" Found Path in Grouper Map for {}", path);
if (Boolean.FALSE.equals(ApplicationUtils.isSetContainsValueSet(ValueSetSingleton.getInstance().getTriggerPathToGrouperMap().get(path), valuSetGrouper))) {
ValueSetSingleton.getInstance().getTriggerPathToGrouperMap().get(path).add(valuSetGrouper);
}
} else {
logger.debug(" Did not Find Path in Grouper Map for {}", path);
Set<ValueSet> vs = new HashSet<>();
vs.add(valuSetGrouper);
ValueSetSingleton.getInstance().getTriggerPathToGrouperMap().put(path, vs);
}
if (valuSetGrouper != null) {
logger.debug(" Adding Grouper Id {} to map", codeFilter.getValueSet());
ValueSetSingleton.getInstance().addGrouperToValueSetMap(valuSetGrouper.getId(), grouperToValueSets);
ValueSetSingleton.getInstance().addGrouperToCovidValueSetMap(valuSetGrouper.getId(), grouperToCovidValueSets);
}
}
use of org.hl7.fhir.r4b.model.DataRequirement in project CRD by HL7-DaVinci.
the class QuestionnairePackageOperation method addLibraryDependencies.
/*
* Recursively add all of the libraries dependencies related by the "depends-on" type.
*/
private void addLibraryDependencies(Library library, List<String> bundleContents, Bundle questionnaireBundle) {
List<RelatedArtifact> relatedArtifacts = library.getRelatedArtifact();
for (RelatedArtifact relatedArtifact : relatedArtifacts) {
// only add the depends-on artifacts
if (relatedArtifact.getType() == RelatedArtifactType.DEPENDSON) {
String relatedArtifactReferenceString = relatedArtifact.getResource();
String[] referenceParts = relatedArtifactReferenceString.split("/");
String id = referenceParts[1];
Resource referencedLibraryResource = null;
// look in the map and retrieve it instead of looking it up on disk if found
if (resources.containsKey(id)) {
referencedLibraryResource = resources.get(id);
} else {
referencedLibraryResource = fileStore.getFhirResourceByIdAsFhirResource("R4", "Library", id, baseUrl);
resources.put(id, referencedLibraryResource);
}
// only add the library if not already in the bundle
if (!bundleContents.contains(referencedLibraryResource.getId())) {
BundleEntryComponent referencedLibraryBundleEntry = new BundleEntryComponent();
referencedLibraryBundleEntry.setResource(referencedLibraryResource);
questionnaireBundle.addEntry(referencedLibraryBundleEntry);
bundleContents.add(referencedLibraryResource.getId());
// recurse through the libraries...
addLibraryDependencies((Library) referencedLibraryResource, bundleContents, questionnaireBundle);
}
}
}
// grab all of the ValueSets in the DataRequirement
List<DataRequirement> dataRequirements = library.getDataRequirement();
for (DataRequirement dataRequirement : dataRequirements) {
List<DataRequirement.DataRequirementCodeFilterComponent> codeFilters = dataRequirement.getCodeFilter();
for (DataRequirement.DataRequirementCodeFilterComponent codeFilter : codeFilters) {
String valueSetUrl = codeFilter.getValueSet();
Resource valueSetResource = null;
// look in the map and retrieve it instead of looking it up on disk if found
if (resources.containsKey(valueSetUrl)) {
valueSetResource = resources.get(valueSetUrl);
} else {
valueSetResource = fileStore.getFhirResourceByUrlAsFhirResource("R4", "ValueSet", valueSetUrl, baseUrl);
resources.put(valueSetUrl, valueSetResource);
}
addResourceToBundle(valueSetResource, bundleContents, questionnaireBundle);
}
}
}
Aggregations