use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project org.hl7.fhir.core by hapifhir.
the class TerminologyClientR5 method read.
@Override
public CanonicalResource read(String type, String id) {
Class<Resource> t;
try {
// todo: do we have to deal with any resource renaming? Use cases are limited...
t = (Class<Resource>) Class.forName("org.hl7.fhir.r5.model." + type);
} catch (ClassNotFoundException e) {
throw new FHIRException("Unable to fetch resources of type " + type + " in R5");
}
org.hl7.fhir.r5.model.Resource r5 = client.read(t, id);
if (r5 != null) {
throw new FHIRException("Unable to convert resource " + Utilities.pathURL(getAddress(), type, id) + " to R5 (internal representation)");
}
if (!(r5 instanceof CanonicalResource)) {
throw new FHIRException("Unable to convert resource " + Utilities.pathURL(getAddress(), type, id) + " to R5 canonical resource (internal representation)");
}
return (CanonicalResource) r5;
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project org.hl7.fhir.core by hapifhir.
the class ADLImporter method execute.
private void execute() throws Exception {
// load config
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
adlConfig = builder.parse(new FileInputStream(config)).getDocumentElement();
// load ADL
builder = factory.newDocumentBuilder();
adl = builder.parse(new FileInputStream(source)).getDocumentElement();
check("root", adl.getNamespaceURI(), "http://schemas.openehr.org/v1", "Wrong namespace for ADL XML");
check("root", adl.getNodeName(), "archetype", "Wrong XML for ADL XML");
check("root", XMLUtil.getNamedChild(adl, "adl_version").getTextContent(), "1.4", "unsupported ADL version");
String id = XMLUtil.getFirstChild(XMLUtil.getNamedChild(adl, "archetype_id")).getTextContent().split("\\.")[1];
// create structure definition
StructureDefinition sd = new StructureDefinition();
sd.setId(id);
// populate metadata
Element description = XMLUtil.getNamedChild(adl, "description");
Element details = XMLUtil.getNamedChild(description, "details");
sd.setDescription(XMLUtil.getNamedChild(details, "purpose").getTextContent());
sd.setCopyright(XMLUtil.getNamedChild(details, "copyright").getTextContent());
sd.setPurpose("Use:\r\n" + XMLUtil.getNamedChild(details, "use").getTextContent() + "\r\n\r\nMisuse:\r\n" + XMLUtil.getNamedChild(details, "misuse").getTextContent());
List<Element> set = new ArrayList<Element>();
XMLUtil.getNamedChildren(details, "keywords", set);
for (Element e : set) sd.addKeyword().setDisplay(e.getTextContent());
String status = XMLUtil.getNamedChild(description, "lifecycle_state").getTextContent();
if ("CommitteeDraft".equals(status) || "AuthorDraft".equals(status))
sd.setStatus(PublicationStatus.DRAFT);
else
throw new Exception("Unknown life cycle state " + XMLUtil.getNamedChild(description, "lifecycle_state").getTextContent());
// load texts from ontology
Element ontology = XMLUtil.getNamedChild(adl, "ontology");
Element term_definitions = XMLUtil.getNamedChild(ontology, "term_definitions");
set.clear();
XMLUtil.getNamedChildren(term_definitions, "items", set);
for (Element item : set) {
processTextItem(item);
}
// load data and protocol
Element definition = XMLUtil.getNamedChild(adl, "definition");
NodeTreeEntry root = new NodeTreeEntry();
root.setTypeName(XMLUtil.getNamedChild(definition, "rm_type_name").getTextContent());
root.setAtCode(XMLUtil.getNamedChild(definition, "node_id").getTextContent());
root.setName(generateToken(root.getAtCode(), true));
sd.setName(root.getName());
root.setCardinality(readCardinality("root", XMLUtil.getNamedChild(definition, "occurrences")));
set.clear();
XMLUtil.getNamedChildren(definition, "attributes", set);
for (Element item : set) {
// we're actually skipping this level - we don't care about data protocol etc.
// XMLUtil.getNamedChild(XMLUtil.getNamedChild(item, "children"), "attributes");
Element attributes = item;
loadChildren(root.getAtCode(), root, attributes);
}
dumpChildren("", root);
genElements(sd, root.getName(), root);
// save
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dest), sd);
System.out.println("done. saved as " + dest);
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project org.hl7.fhir.core by hapifhir.
the class TerminologyClientR2 method read.
@Override
public CanonicalResource read(String type, String id) {
Class<Resource> t;
try {
// todo: do we have to deal with any resource renaming? Use cases are limited...
t = (Class<Resource>) Class.forName("org.hl7.fhir.dstu2.model." + type);
} catch (ClassNotFoundException e) {
throw new FHIRException("Unable to fetch resources of type " + type + " in R2");
}
org.hl7.fhir.dstu2.model.Resource r2 = client.read(t, id);
if (r2 == null) {
throw new FHIRException("Unable to fetch resource " + Utilities.pathURL(getAddress(), type, id));
}
org.hl7.fhir.r5.model.Resource r5 = VersionConvertorFactory_10_50.convertResource(r2);
if (r5 != null) {
throw new FHIRException("Unable to convert resource " + Utilities.pathURL(getAddress(), type, id) + " to R5 (internal representation)");
}
if (!(r5 instanceof CanonicalResource)) {
throw new FHIRException("Unable to convert resource " + Utilities.pathURL(getAddress(), type, id) + " to R5 canonical resource (internal representation)");
}
return (CanonicalResource) r5;
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method funcExists.
private List<Base> funcExists(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
List<Base> result = new ArrayList<Base>();
// R2 - can't use ElementUtil
result.add(new BooleanType(!focus.isEmpty()));
return result;
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method parse.
// --- public API -------------------------------------------------------
/**
* Parse a path for later use using execute
*
* @param path
* @return
* @throws PathEngineException
* @throws Exception
*/
public ExpressionNode parse(String path) throws FHIRLexerException {
FHIRLexer lexer = new FHIRLexer(path);
if (lexer.done())
throw lexer.error("Path cannot be empty");
ExpressionNode result = parseExpression(lexer, true);
if (!lexer.done())
throw lexer.error("Premature ExpressionNode termination at unexpected token \"" + lexer.getCurrent() + "\"");
result.check();
return result;
}
Aggregations