use of org.akaza.openclinica.bean.odmbeans.RangeCheckBean in project OpenClinica by OpenClinica.
the class MetadataUnit method getItemRangeCheck.
public static List<RangeCheckBean> getItemRangeCheck(String func, String constraint, String errorMessage, String muOid) {
// at this time only supports one measurement unit for a RangeCheck,
// and it is the same as its item unit
ArrayList<ElementRefBean> unitRefs = new ArrayList<ElementRefBean>();
ElementRefBean unit = new ElementRefBean();
unit.setElementDefOID(muOid);
unitRefs.add(unit);
List<RangeCheckBean> rcs = new ArrayList<RangeCheckBean>();
// final String[] odmComparator = { "LT", "LE", "GT", "GE", "EQ", "NE",
// "IN", "NOTIN" };
String[] s = func.split("\\(");
RangeCheckBean rc = new RangeCheckBean();
if (s[0].equalsIgnoreCase("range")) {
String[] values = s[1].split("\\,");
String smaller = values[0];
String larger = values[1].trim();
larger = larger.substring(0, larger.length() - 1);
rc.setComparator("GE");
rc.setSoftHard(constraint);
rc.getErrorMessage().setText(errorMessage);
rc.setCheckValue(smaller);
rc.setMeasurementUnitRefs(unitRefs);
rcs.add(rc);
rc = new RangeCheckBean();
rc.setComparator("LE");
rc.setSoftHard(constraint);
rc.getErrorMessage().setText(errorMessage);
rc.setCheckValue(larger);
rc.setMeasurementUnitRefs(unitRefs);
rcs.add(rc);
} else {
rc = new RangeCheckBean();
String value = s[1].trim();
value = value.substring(0, value.length() - 1);
if (s[0].equalsIgnoreCase("gt")) {
rc.setComparator("GT");
} else if (s[0].equalsIgnoreCase("lt")) {
rc.setComparator("LT");
} else if (s[0].equalsIgnoreCase("gte")) {
rc.setComparator("GE");
} else if (s[0].equalsIgnoreCase("lte")) {
rc.setComparator("LE");
} else if (s[0].equalsIgnoreCase("ne")) {
rc.setComparator("NE");
} else if (s[0].equalsIgnoreCase("eq")) {
rc.setComparator("EQ");
}
rc.setSoftHard(constraint);
rc.getErrorMessage().setText(errorMessage);
rc.setCheckValue(value);
rc.setMeasurementUnitRefs(unitRefs);
rcs.add(rc);
}
return rcs;
}
use of org.akaza.openclinica.bean.odmbeans.RangeCheckBean in project OpenClinica by OpenClinica.
the class MetaDataReportBean method addItemDef.
public void addItemDef(boolean isStudy, String currentIndent) {
StringBuffer xml = this.getXmlOutput();
String indent = this.getIndent();
ArrayList<ItemDefBean> items = (ArrayList<ItemDefBean>) odmstudy.getMetaDataVersion().getItemDefs();
String ODMVersion = this.getODMVersion();
for (ItemDefBean item : items) {
xml.append(currentIndent + "<ItemDef OID=\"" + StringEscapeUtils.escapeXml(item.getOid()) + "\" Name=\"" + StringEscapeUtils.escapeXml(item.getName()) + "\" DataType=\"" + item.getDateType() + "\"");
int len = item.getLength();
if (len > 0) {
xml.append(" Length=\"" + len + "\"");
}
len = item.getSignificantDigits();
if (len > 0) {
xml.append(" SignificantDigits=\"" + len + "\"");
}
xml.append(" SASFieldName=\"" + this.getSasNameValidator().getValidName(item.getPreSASFieldName()) + "\"");
if (item.getComment().length() > 0) {
xml.append(" Comment=\"" + StringEscapeUtils.escapeXml(item.getComment()) + "\"");
}
if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
xml.append(" OpenClinica:FormOIDs=\"" + item.getFormOIDs() + "\"");
}
boolean hasNode = false;
// add question
TranslatedTextBean t = item.getQuestion().getQuestion();
if (t != null && t.getText() != null && t.getText().length() > 0) {
if (!hasNode) {
hasNode = true;
xml.append(">");
xml.append(nls);
}
if ("oc1.3".equalsIgnoreCase(ODMVersion)) {
String qn = item.getQuestion().getQuestionNumber();
if (qn != null && qn.length() > 0) {
xml.append(currentIndent + indent + "<Question OpenClinica:QuestionNumber=\"" + item.getQuestion().getQuestionNumber() + "\">");
} else {
xml.append(currentIndent + indent + "<Question>");
}
} else {
xml.append(currentIndent + indent + "<Question>");
}
xml.append(nls);
xml.append(currentIndent + indent + indent + "<TranslatedText>");
xml.append(nls);
xml.append(currentIndent + indent + indent + StringEscapeUtils.escapeXml(t.getText()));
xml.append(nls);
xml.append(currentIndent + indent + indent + "</TranslatedText>");
xml.append(nls);
xml.append(currentIndent + indent + "</Question>");
xml.append(nls);
}
// add MeasurementUnitRef
String muRefOid = item.getMeasurementUnitRef().getElementDefOID();
if (muRefOid != null && muRefOid.length() > 0) {
if (!hasNode) {
hasNode = true;
xml.append(">");
xml.append(nls);
}
xml.append(currentIndent + indent + this.measurementUnitRefString(muRefOid));
xml.append(nls);
}
// add RangeCheck
if (item.getRangeCheck() != null) {
ArrayList<RangeCheckBean> rcs = (ArrayList<RangeCheckBean>) item.getRangeCheck();
for (RangeCheckBean rc : rcs) {
if (rc.getComparator().length() > 0) {
if (!hasNode) {
hasNode = true;
xml.append(">");
xml.append(nls);
}
xml.append(currentIndent + indent + "<RangeCheck Comparator=\"" + StringEscapeUtils.escapeXml(rc.getComparator()) + "\" SoftHard=\"" + rc.getSoftHard() + "\">");
xml.append(nls);
xml.append(currentIndent + indent + indent + "<CheckValue>" + StringEscapeUtils.escapeXml(rc.getCheckValue()) + "</CheckValue>");
xml.append(nls);
// supported
if (muRefOid != null && muRefOid.length() > 0) {
xml.append(currentIndent + indent + indent + this.measurementUnitRefString(muRefOid));
xml.append(nls);
}
xml.append(currentIndent + indent + indent + "<ErrorMessage><TranslatedText>" + StringEscapeUtils.escapeXml(rc.getErrorMessage().getText()) + "</TranslatedText></ErrorMessage>");
xml.append(nls);
xml.append(currentIndent + indent + "</RangeCheck>");
xml.append(nls);
}
}
}
// add CodeListRef
String clOid = item.getCodeListOID();
if (clOid != null && clOid.length() > 0) {
if (!hasNode) {
hasNode = true;
xml.append(">");
xml.append(nls);
}
xml.append(currentIndent + indent + "<CodeListRef CodeListOID=\"" + StringEscapeUtils.escapeXml(clOid) + "\"/>");
xml.append(nls);
}
// add MultiSelectListRef
if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
if (item.getMultiSelectListRef() != null) {
String mslOid = item.getMultiSelectListRef().getElementDefOID();
if (mslOid != null && mslOid.length() > 0) {
if (!hasNode) {
hasNode = true;
xml.append(">");
xml.append(nls);
}
// xml.append(currentIndent + indent +
// "<OpenClinica:MultiSelectListRef OpenClinica:MultiSelectListID=\""
xml.append(currentIndent + indent + "<OpenClinica:MultiSelectListRef MultiSelectListID=\"" + StringEscapeUtils.escapeXml(mslOid) + "\"/>");
xml.append(nls);
}
}
}
// add ItemDetails for oc1.3
if ("oc1.3".equals(ODMVersion)) {
if (!hasNode) {
hasNode = true;
xml.append(">");
xml.append(nls);
}
this.addItemDetails(item.getItemDetails(), currentIndent + indent);
}
if (hasNode) {
xml.append(currentIndent + "</ItemDef>");
xml.append(nls);
hasNode = false;
} else {
xml.append("/>");
xml.append(nls);
}
}
}
Aggregations