use of org.hl7.fhir.dstu2.model.DataElement in project org.hl7.fhir.core by hapifhir.
the class TurtleTests method test_dataelement_labtestmaster_example.
@Test
public void test_dataelement_labtestmaster_example() throws FileNotFoundException, IOException, Exception {
System.out.println("dataelement-labtestmaster-example.ttl");
new Turtle().parse(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\dataelement-labtestmaster-example.ttl"));
}
use of org.hl7.fhir.dstu2.model.DataElement in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method doRemoveFromMaps.
/**
* Removes the given SubmodelElement from the maps.
*
* @param element The desired SubmodelElement
* @param reference The reference to the desired SubmodelElement
* @param referable The corresponding referable
*/
@SuppressWarnings("java:S2629")
private void doRemoveFromMaps(AASSubmodelElementType element, Reference reference, Referable referable) {
try {
LOG.debug("doRemoveFromMaps: remove SubmodelElement {}", AasUtils.asString(reference));
if (submodelElementOpcUAMap.containsKey(reference)) {
submodelElementOpcUAMap.remove(reference);
LOG.debug("doRemoveFromMaps: remove SubmodelElement from submodelElementOpcUAMap: {}", AasUtils.asString(reference));
}
if (element instanceof AASPropertyType) {
AASPropertyType prop = (AASPropertyType) element;
if (submodelElementAasMap.containsKey(prop.getValueNode().getNodeId())) {
submodelElementAasMap.remove(prop.getValueNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Property NodeId {}", prop.getValueNode().getNodeId());
}
} else if (element instanceof AASRangeType) {
AASRangeType range = (AASRangeType) element;
if (submodelElementAasMap.containsKey(range.getMinNode().getNodeId())) {
submodelElementAasMap.remove(range.getMinNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Range Min NodeId {}", range.getMinNode().getNodeId());
}
if (submodelElementAasMap.containsKey(range.getMaxNode().getNodeId())) {
submodelElementAasMap.remove(range.getMaxNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Range Max NodeId {}", range.getMaxNode().getNodeId());
}
} else if (element instanceof AASOperationType) {
AASOperationType oper = (AASOperationType) element;
if (submodelElementAasMap.containsKey(oper.getOperationNode().getNodeId())) {
submodelElementAasMap.remove(oper.getOperationNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Operation NodeId {}", oper.getOperationNode().getNodeId());
}
} else if (element instanceof AASBlobType) {
AASBlobType blob = (AASBlobType) element;
if (submodelElementAasMap.containsKey(blob.getValueNode().getNodeId())) {
submodelElementAasMap.remove(blob.getValueNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Blob NodeId {}", blob.getValueNode().getNodeId());
}
} else if (element instanceof AASMultiLanguagePropertyType) {
AASMultiLanguagePropertyType mlp = (AASMultiLanguagePropertyType) element;
if (submodelElementAasMap.containsKey(mlp.getValueNode().getNodeId())) {
submodelElementAasMap.remove(mlp.getValueNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove AASMultiLanguageProperty NodeId {}", mlp.getValueNode().getNodeId());
}
} else if (element instanceof AASReferenceElementType) {
AASReferenceElementType refElem = (AASReferenceElementType) element;
NodeId nid = refElem.getValueNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
LOG.debug("doRemoveFromMaps: remove AASReferenceElement NodeId {}", nid);
}
} else if (element instanceof AASRelationshipElementType) {
AASRelationshipElementType relElem = (AASRelationshipElementType) element;
NodeId nid = relElem.getFirstNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
LOG.debug("doRemoveFromMaps: remove AASRelationshipElement First NodeId {}", nid);
}
nid = relElem.getSecondNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
LOG.debug("doRemoveFromMaps: remove AASRelationshipElement Second NodeId {}", nid);
}
if ((relElem instanceof AASAnnotatedRelationshipElementType) && (referable instanceof AnnotatedRelationshipElement)) {
AnnotatedRelationshipElement annRelElem = (AnnotatedRelationshipElement) referable;
for (DataElement de : annRelElem.getAnnotations()) {
doRemoveFromMaps(reference, de);
}
}
} else if (element instanceof AASEntityType) {
AASEntityType ent = (AASEntityType) element;
if ((ent.getGlobalAssetIdNode() != null) && (ent.getGlobalAssetIdNode().getKeysNode() != null)) {
NodeId nid = ent.getGlobalAssetIdNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
LOG.debug("doRemoveFromMaps: remove Entity GlobalAssetId NodeId {}", nid);
}
}
if (submodelElementAasMap.containsKey(ent.getEntityTypeNode().getNodeId())) {
submodelElementAasMap.remove(ent.getEntityTypeNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Entity EntityType NodeId {}", ent.getEntityTypeNode().getNodeId());
}
} else if (referable instanceof SubmodelElementCollection) {
SubmodelElementCollection sec = (SubmodelElementCollection) referable;
for (SubmodelElement se : sec.getValues()) {
doRemoveFromMaps(reference, se);
}
}
// Capability and File are currently not relevant here
} catch (Exception ex) {
LOG.error("doRemoveFromMaps Exception", ex);
throw ex;
}
}
use of org.hl7.fhir.dstu2.model.DataElement in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method createAnnotatedRelationshipElement.
/**
* Creates an Annotated Relationship Element.
*
* @param aasRelElem The AAS Annotated Relationship Element
* @param submodel The corresponding Submodel as parent object of the data element
* @param relElemRef The AAS reference to the AnnotatedRelationshipElement
* @param nodeId The desired NodeId for the node to be created
* @return The create UA Annotated Relationship Element
* @throws StatusException If the operation fails
*/
private AASRelationshipElementType createAnnotatedRelationshipElement(AnnotatedRelationshipElement aasRelElem, Submodel submodel, Reference relElemRef, NodeId nodeId) throws StatusException {
AASRelationshipElementType retval = null;
try {
AASAnnotatedRelationshipElementType relElemNode = createInstance(AASAnnotatedRelationshipElementType.class, nodeId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAnnotatedRelationshipElementType.getNamespaceUri(), aasRelElem.getIdShort()).toQualifiedName(getNamespaceTable()), LocalizedText.english(aasRelElem.getIdShort()));
// Annotations
for (DataElement de : aasRelElem.getAnnotations()) {
addAasDataElement(relElemNode.getAnnotationNode(), de, submodel, relElemRef, false);
}
retval = relElemNode;
} catch (Exception ex) {
LOG.error("createAnnotatedRelationshipElement Exception", ex);
throw ex;
}
return retval;
}
use of org.hl7.fhir.dstu2.model.DataElement in project kindling by HL7.
the class ProfileGenerator method generateElementDefinition.
private void generateElementDefinition(StructureDefinition source, ElementDefinition ed, ElementDefinition parent) throws Exception {
String id = ed.getPath().replace("[x]", "X");
if (id.length() > 64)
id = id.substring(0, 64);
if (!id.contains("."))
// throw new Exception("Don't generate data element for root of resources or types");
return;
if (!ed.hasType())
// throw new Exception("Don't generate data element for reference elements");
return;
if (Utilities.existsInList(ed.getType().get(0).getCode(), "Element", "BackboneElement"))
// throw new Exception("Don't generate data element for elements that are not leaves");
return;
StructureDefinition de;
if (des.containsKey(id)) {
de = des.get("de-" + id);
// do it again because we now have more information to generate with
de.getSnapshot().getElement().clear();
de.getExtension().clear();
} else {
de = new StructureDefinition();
de.setId("de-" + id);
des.put(id, de);
de.setUrl("http://hl7.org/fhir/StructureDefinition/" + de.getId());
if (de.getId().contains("."))
definitions.addNs(de.getUrl(), "Data Element " + ed.getPath(), definitions.getSrcFile(id.substring(0, id.indexOf("."))) + "-definitions.html#" + id);
if (dataElements != null)
dataElements.addEntry().setResource(de).setFullUrl(de.getUrl());
}
if (!de.hasMeta())
de.setMeta(new Meta());
de.getMeta().setLastUpdatedElement(new InstantType(genDate));
de.setVersion(version.toCode());
de.setName(ed.getPath());
de.setStatus(PublicationStatus.DRAFT);
de.setExperimental(true);
de.setTitle(de.getName());
de.setDate(genDate.getTime());
de.setPublisher("HL7 FHIR Standard");
de.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
de.setDescription("Data Element for " + ed.getPath());
de.setPurpose("Data Elements are defined for each element to assist in questionnaire construction etc");
de.setFhirVersion(version);
de.setKind(StructureDefinitionKind.LOGICAL);
de.setType("DataElement");
de.setAbstract(false);
de.setType(de.getName());
de.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
de.setDerivation(TypeDerivationRule.SPECIALIZATION);
de.getMapping().addAll(source.getMapping());
ElementDefinition ted = ed.copy();
de.getSnapshot().addElement(ted);
ted.makeBase();
}
use of org.hl7.fhir.dstu2.model.DataElement in project kindling by HL7.
the class Publisher method produceDictionary.
private void produceDictionary(Dictionary d) throws Exception {
if (web)
return;
String src = TextFile.fileToString(page.getFolders().templateDir + "template-dictionary.html");
String file = d.getSource();
String prefix = d.getIg() != null ? d.getIg().getCode() + File.separator : "";
String filename = prefix + d.getId();
XmlParser xml = new XmlParser();
Bundle dict = (Bundle) xml.parse(new CSFileInputStream(file));
src = page.processPageIncludes(filename + ".html", src, "page", null, dict, null, "Dictionary", null, null, null);
// before we save this page out, we're going to figure out what it's index
// is, and number the headers if we can
TextFile.stringToFile(src, page.getFolders().dstDir + filename + ".html");
src = addSectionNumbers(filename + ".html", filename, src, null, d.getIg() != null ? 1 : 0, null, d.getIg());
TextFile.stringToFile(src, page.getFolders().dstDir + filename + ".html");
src = TextFile.fileToString(page.getFolders().templateDir + "template-dictionary.html").replace("<body>", "<body style=\"margin: 10px\">");
src = page.processPageIncludesForBook(filename + ".html", src, "page", dict, null, null);
cachePage(filename + ".html", src, d.getId(), true);
xml.setOutputStyle(OutputStyle.PRETTY);
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + filename + ".xml");
xml.compose(s, dict);
s.close();
xml.setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + filename + ".canonical.xml");
xml.compose(s, dict);
s.close();
cloneToXhtml(filename, "Source for Dictionary" + d.getName(), false, "dict-instance", "Dictionary", null, null);
IParser json = new JsonParser().setOutputStyle(OutputStyle.PRETTY);
s = new FileOutputStream(page.getFolders().dstDir + filename + ".json");
json.compose(s, dict);
s.close();
json = new JsonParser().setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + filename + ".canonical.json");
json.compose(s, dict);
s.close();
jsonToXhtml(filename, "Source for Dictionary" + d.getName(), resource2Json(dict), "dict-instance", "Dictionary", null, null);
ttlToXhtml(filename, "Source for Dictionary" + d.getName(), resource2Ttl(dict), "dict-instance", "Dictionary", null, null);
throw new Error("must be redone");
// for (BundleEntryComponent e : dict.getEntry()) {
// produceDictionaryProfile(d, file, filename, (DataElement) e.getResource(), d.getIg());
// }
}
Aggregations