use of gov.cms.qpp.conversion.model.TemplateId in project qpp-conversion-tool by CMSgov.
the class AciSectionEncoder method encodeChildren.
/**
* Encodes the children of the given section
*
* @param children child nodes of the given section
* @param measurementsWrapper wrapper that holds the measurements of a section
*/
private void encodeChildren(List<Node> children, JsonWrapper measurementsWrapper) {
JsonWrapper childWrapper;
for (Node currentChild : children) {
childWrapper = new JsonWrapper();
TemplateId templateId = currentChild.getType();
if (TemplateId.REPORTING_PARAMETERS_ACT != templateId) {
JsonOutputEncoder childEncoder = encoders.get(templateId);
if (childEncoder != null) {
childEncoder.encode(childWrapper, currentChild);
measurementsWrapper.putObject(childWrapper);
} else {
Detail detail = Detail.forErrorCode(ErrorCode.ENCODER_MISSING);
detail.setPath(currentChild.getPath());
addValidationError(detail);
}
}
}
}
use of gov.cms.qpp.conversion.model.TemplateId in project qpp-conversion-tool by CMSgov.
the class ClinicalDocumentEncoder method encodeMeasurementSets.
/**
* Method for encoding each child measurement set
*
* @param childMapByTemplateId object that represents the document's children
* @return encoded measurement sets
*/
private JsonWrapper encodeMeasurementSets(Map<TemplateId, Node> childMapByTemplateId) {
JsonWrapper measurementSetsWrapper = new JsonWrapper();
JsonWrapper childWrapper;
JsonOutputEncoder sectionEncoder;
for (Node child : childMapByTemplateId.values()) {
TemplateId childType = child.getType();
try {
childWrapper = new JsonWrapper();
sectionEncoder = encoders.get(childType);
sectionEncoder.encode(childWrapper, child);
measurementSetsWrapper.putObject(childWrapper);
} catch (NullPointerException exc) {
String message = "An unexpected error occured for " + child.getType();
throw new EncodeException(message, exc);
}
}
return measurementSetsWrapper;
}
use of gov.cms.qpp.conversion.model.TemplateId in project qpp-conversion-tool by CMSgov.
the class EncoderTest method decodeTemplateIds.
/**
* decodeTemplateIds for each TemplateId in the list ensure that it exists in
* the registry.
* @throws Exception
*/
@Test
void decodeTemplateIds() throws Exception {
Registry<OutputEncoder> registry = new Registry<>(new Context(), Encoder.class);
for (TemplateId templateId : templateIds) {
OutputEncoder encoder = registry.get(templateId);
assertWithMessage(templateId + " returned node should not be null").that(encoder).isNotNull();
}
}
use of gov.cms.qpp.conversion.model.TemplateId in project qpp-conversion-tool by CMSgov.
the class QrdaDecoderEngine method getDecoder.
/**
* Retrieve a permitted {@link Decoder}. {@link #scope} is used to determine which DECODERS are allowable.
*
* @param templateId string representation of a would be decoder's template id
* @return decoder that corresponds to the given template id
*/
private QrdaDecoder getDecoder(TemplateId templateId) {
QrdaDecoder qppDecoder = decoders.get(templateId);
if (qppDecoder != null) {
if (scope == null) {
return qppDecoder;
}
Decoder decoder = qppDecoder.getClass().getAnnotation(Decoder.class);
TemplateId template = decoder == null ? TemplateId.DEFAULT : decoder.value();
return !scope.contains(template) ? null : qppDecoder;
}
return null;
}
use of gov.cms.qpp.conversion.model.TemplateId in project qpp-conversion-tool by CMSgov.
the class QrdaDecoderEngine method containsClinicalDocumentTemplateId.
/**
* Checks whether the element has a child {@code templateId} element that is the Clinical Document {@link TemplateId}.
*
* @param rootElement The element to check.
* @return True or false.
*/
private boolean containsClinicalDocumentTemplateId(Element rootElement) {
boolean containsTemplateId = false;
List<Element> clinicalDocumentChildren = rootElement.getChildren(TEMPLATE_ID, rootElement.getNamespace());
for (Element currentChild : clinicalDocumentChildren) {
TemplateId templateId = getTemplateId(currentChild);
if (templateId == TemplateId.CLINICAL_DOCUMENT) {
containsTemplateId = true;
break;
}
}
return containsTemplateId;
}
Aggregations