use of org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent in project eCRNow by drajer-health.
the class PlanDefinitionProcessor method processTriggerDefinitions.
private void processTriggerDefinitions(List<TriggerDefinition> tdlist, AbstractAction act) {
if (tdlist != null && !tdlist.isEmpty()) {
for (TriggerDefinition triggerDefinition : tdlist) {
if (triggerDefinition.getType() != TriggerType.NAMEDEVENT && triggerDefinition.getType() != TriggerType.PERIODIC && triggerDefinition.hasData()) {
logger.info(" Identified Data Trigger for Act {}", act.getActionId());
List<DataRequirement> dr = triggerDefinition.getData();
for (DataRequirement d : dr) {
// Create ActionData object
ActionData ad = new ActionData();
ad.setTriggerType(triggerDefinition.getType());
ad.setFhirDataType(FHIRAllTypes.valueOf(d.getType().toUpperCase()));
if (d.hasProfile())
ad.setProfiles(d.getProfile());
if (d.hasCodeFilter()) {
DataRequirementCodeFilterComponent cf = d.getCodeFilterFirstRep();
if (cf.hasPath()) {
ad.setPath(d.getType() + "." + cf.getPath());
logger.info(" Evaluation Path = {}", ad.getPath());
}
if (cf.hasValueSet())
ad.setValueSet(cf.getValueSetElement());
}
act.addActionData(ad);
}
} else if (triggerDefinition.getType() == TriggerType.PERIODIC) {
if (triggerDefinition.hasTimingTiming()) {
Timing t = triggerDefinition.getTimingTiming();
if (t.hasRepeat()) {
TimingSchedule ts = getTimingSchedule(t, triggerDefinition.getType());
if (ts != null) {
act.addTimingData(ts);
}
}
} else {
// Not handling the others for eCR
}
} else {
// Ignore other types for eCR
}
}
}
}
use of org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent in project org.hl7.fhir.core by hapifhir.
the class DataRenderer method renderDataRequirement.
public void renderDataRequirement(XhtmlNode x, DataRequirement dr) throws FHIRFormatError, DefinitionException, IOException {
XhtmlNode tbl = x.table("grid");
XhtmlNode tr = tbl.tr();
XhtmlNode td = tr.td().colspan("2");
td.b().tx("Type");
td.tx(": ");
StructureDefinition sd = context.getWorker().fetchTypeDefinition(dr.getType().toCode());
if (sd != null && sd.hasUserData("path")) {
td.ah(sd.getUserString("path")).tx(dr.getType().toCode());
} else {
td.tx(dr.getType().toCode());
}
if (dr.hasProfile()) {
td.tx(" (");
boolean first = true;
for (CanonicalType p : dr.getProfile()) {
if (first)
first = false;
else
td.tx(" | ");
sd = context.getWorker().fetchResource(StructureDefinition.class, p.getValue());
if (sd != null && sd.hasUserData("path")) {
td.ah(sd.getUserString("path")).tx(sd.present());
} else {
td.tx(p.asStringValue());
}
}
td.tx(")");
}
if (dr.hasSubject()) {
tr = tbl.tr();
td = tr.td().colspan("2");
td.b().tx("Subject");
if (dr.hasSubjectReference()) {
renderReference(td, dr.getSubjectReference());
} else {
renderCodeableConcept(td, dr.getSubjectCodeableConcept());
}
}
if (dr.hasCodeFilter() || dr.hasDateFilter()) {
tr = tbl.tr().backgroundColor("#efefef");
tr.td().tx("Filter");
tr.td().tx("Value");
}
for (DataRequirementCodeFilterComponent cf : dr.getCodeFilter()) {
tr = tbl.tr();
if (cf.hasPath()) {
tr.td().tx(cf.getPath());
} else {
tr.td().tx("Search on " + cf.getSearchParam());
}
if (cf.hasValueSet()) {
td = tr.td();
td.tx("In ValueSet ");
render(td, cf.getValueSetElement());
} else {
boolean first = true;
td = tr.td();
td.tx("One of these codes: ");
for (Coding c : cf.getCode()) {
if (first)
first = false;
else
td.tx(", ");
render(td, c);
}
}
}
for (DataRequirementDateFilterComponent cf : dr.getDateFilter()) {
tr = tbl.tr();
if (cf.hasPath()) {
tr.td().tx(cf.getPath());
} else {
tr.td().tx("Search on " + cf.getSearchParam());
}
render(tr.td(), cf.getValue());
}
if (dr.hasSort() || dr.hasLimit()) {
tr = tbl.tr();
td = tr.td().colspan("2");
if (dr.hasLimit()) {
td.b().tx("Limit");
td.tx(": ");
td.tx(dr.getLimit());
if (dr.hasSort()) {
td.tx(", ");
}
}
if (dr.hasSort()) {
td.b().tx("Sort");
td.tx(": ");
boolean first = true;
for (DataRequirementSortComponent p : dr.getSort()) {
if (first)
first = false;
else
td.tx(" | ");
td.tx(p.getDirection() == SortDirection.ASCENDING ? "+" : "-");
td.tx(p.getPath());
}
}
}
}
use of org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent in project org.hl7.fhir.core by hapifhir.
the class DataRenderer method renderDataRequirement.
public void renderDataRequirement(XhtmlNode x, DataRequirement dr) throws FHIRFormatError, DefinitionException, IOException {
XhtmlNode tbl = x.table("grid");
XhtmlNode tr = tbl.tr();
XhtmlNode td = tr.td().colspan("2");
td.b().tx("Type");
td.tx(": ");
StructureDefinition sd = context.getWorker().fetchTypeDefinition(dr.getType().toCode());
if (sd != null && sd.hasUserData("path")) {
td.ah(sd.getUserString("path")).tx(dr.getType().toCode());
} else {
td.tx(dr.getType().toCode());
}
if (dr.hasProfile()) {
td.tx(" (");
boolean first = true;
for (CanonicalType p : dr.getProfile()) {
if (first)
first = false;
else
td.tx(" | ");
sd = context.getWorker().fetchResource(StructureDefinition.class, p.getValue());
if (sd != null && sd.hasUserData("path")) {
td.ah(sd.getUserString("path")).tx(sd.present());
} else {
td.tx(p.asStringValue());
}
}
td.tx(")");
}
if (dr.hasSubject()) {
tr = tbl.tr();
td = tr.td().colspan("2");
td.b().tx("Subject");
if (dr.hasSubjectReference()) {
renderReference(td, dr.getSubjectReference());
} else {
renderCodeableConcept(td, dr.getSubjectCodeableConcept());
}
}
if (dr.hasCodeFilter() || dr.hasDateFilter()) {
tr = tbl.tr().backgroundColor("#efefef");
tr.td().tx("Filter");
tr.td().tx("Value");
}
for (DataRequirementCodeFilterComponent cf : dr.getCodeFilter()) {
tr = tbl.tr();
if (cf.hasPath()) {
tr.td().tx(cf.getPath());
} else {
tr.td().tx("Search on " + cf.getSearchParam());
}
if (cf.hasValueSet()) {
td = tr.td();
td.tx("In ValueSet ");
render(td, cf.getValueSetElement());
} else {
boolean first = true;
td = tr.td();
td.tx("One of these codes: ");
for (Coding c : cf.getCode()) {
if (first)
first = false;
else
td.tx(", ");
render(td, c);
}
}
}
for (DataRequirementDateFilterComponent cf : dr.getDateFilter()) {
tr = tbl.tr();
if (cf.hasPath()) {
tr.td().tx(cf.getPath());
} else {
tr.td().tx("Search on " + cf.getSearchParam());
}
render(tr.td(), cf.getValue());
}
if (dr.hasSort() || dr.hasLimit()) {
tr = tbl.tr();
td = tr.td().colspan("2");
if (dr.hasLimit()) {
td.b().tx("Limit");
td.tx(": ");
td.tx(dr.getLimit());
if (dr.hasSort()) {
td.tx(", ");
}
}
if (dr.hasSort()) {
td.b().tx("Sort");
td.tx(": ");
boolean first = true;
for (DataRequirementSortComponent p : dr.getSort()) {
if (first)
first = false;
else
td.tx(" | ");
td.tx(p.getDirection() == SortDirection.ASCENDING ? "+" : "-");
td.tx(p.getPath());
}
}
}
}
use of org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent 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);
}
}
Aggregations