Moving OBX above NTE - mirth

I have successfully managed to move NTE after PID to the end of the message using the code
var nteGroup = getSegmentsAfter(msg,msg.PID,'NTE',true);
for (var i = nteGroup.length-1; i >= 0; i--) {
delete msg.children()[nteGroup[i].childIndex()];
msg.insertChildAfter(msg.OBX[msg.OBX.length()-1],nteGroup[i]);
}
But having difficulty moving the NTE below each OBX group.
Currently it is
PV1
NTE
ORC
OBR
NTE
NTE
NTE
NTE
OBX
Would like it to be
PV1
ORC
OBR
OBX
NTE
NTE
NTE
NTE
NTE
Happy to share HL7 message if needed

Referencing https://www.mirthproject.org/community/forums/showthread.php?t=220406
The code solution is to do the following:
var nteGroup = '';
var nte_count = 0;
for each( seg in msg.children()) {
if(seg.name == 'NTE')
{
nteGroup += seg.toString();//may need to add '\n'
delete msg['NTE'][nte_count++];
}
msg += nteGroup;//may need to add '\n' on front and/or back
}

Related

Flutter list stores values using for loop, but loses these values when used outside the loop

I am trying to read data from a firebase real time database and store it in a list to use in my flutter app.
As seen in the code below, I start by creating a reference to the database. I also create some global variables, where "itemName" stores the name of the item in the database, "itemID" stores the id of each item in the database and "itemNames" is a list of all the item names in the database.
The "activate listeners" method listens to the database, and returns any values if they are changed. Each item ID starts with a J, and continues onto J1, J2, J3 etc. Hence I am using a for loop to access all the item IDs.
The issue I am having is that the itemNames are successfully being stored in the itemNames list, and can be see when I print the list within the for loop (The first print line).
However, when I try print the list value OUTSIDE the for loop, it prints an empty list for loop (second print line).
So in other words, the list is not retaining the elements added to it during the for loop.
Any help would be much appreciated!
final DatabaseReference _dbRef = FirebaseDatabase.instance.ref();
late StreamSubscription _dailySpecialStream;
//Stores the description of each menu item in the DB
String itemName = "";
String itemID = "";
List<String> itemNames = [];
//"Listens for any changes being made to the DB, and updates our app in real time"
void _activateListeners() {
for (int i = 0; i <= 10; i++) {
itemID = "J$i";
_dailySpecialStream =
_dbRef.child("menuItem/$itemID/itemName").onValue.listen((event) {
itemName = event.snapshot.value.toString();
itemNames.addAll([itemName]);
print(itemNames);
});
}
print(itemNames);
}
That is the expected behavior. Data is loaded from Firebase (and most modern cloud APIs) asynchronously, and while that is happening your main code continues to run.
You can most easily see this by placing some print statements:
print('before starting to load data');
for (int i = 0; i <= 10; i++) {
itemID = "J$i";
_dailySpecialStream =
_dbRef.child("menuItem/$itemID/itemName").onValue.listen((event) {
print('loaded data: %i');
});
}
print('after starting to load data');
If you run this, you'll see something like:
before starting to load data
after starting to load data
loaded data: 0
loaded data: 1
loaded data: 2
loaded data: 3
...
So as you can see the after print statement that is lowest in your code, actually printed before any of the data was loaded. This is probably not what you expected, but explains perfectly why the print statement you had outside the loop doesn't print the data: it hasn't been loaded yet!
The solution for this type of problem is always the same: you have to make sure the code that requires the data is inside the callback, or it is called from there, or it is otherwise synchronized.
A simple way to do the latter is by using get() instead of onValue, and then use await on the Future that is returns:
print('before starting to load data');
for (int i = 0; i <= 10; i++) {
itemID = "J$i";
_dailySpecial = await _dbRef.child("menuItem/$itemID/itemName").get();
print('loaded data %i: ${_dailySpecial.value}');
}
print('after starting to load data');
Now with this, the print statements will be in the order you expected.

SAPUI5 - Clearing valueState of input fields in ui.table

I'm having troubles resetting the valueState of input fields contained in a table cell. I'm clearing the model so the data is reset but the valueState is set on the view so it persists.
I've tried getting the input field byId and setting the value state as "None" but that doesn't affect the cells of the table.
Does anyone have an idea of how this can be achieved?
Image of cell with value state "Error"
If you really don't want to work with data model, you can just loop over the table and set the ValueState to None.
Code Example:
var aRows, aCells;
aRows = this.byId("table.id").getRows();
for ( var i = 0; aRows.length; i++) {
aCells = aRows[i].getCells();
for ( var j = 0; aCells.length; j++) {
if ( aCells[j] is an input element ) {
aCells[j].setValueState(sap.ui.core.ValueState.None);
}
}
}

Is it possible to count character in TYPO3 RTE?

Is there a way to count the number of character in the RTE ?
By default, it count the number of words but can we change that ?
I've read all the docs and haven't find anything.
The original version of HTMLArea does not support this feature. TYPO3 comes with a modified version of HTMLArea, where the word count feature has been implemented for some years ago.
I had a look into the source code of TYPO3s RTE HTMLArea and the word count is hardcoded and not configurable.
A possibility to add the char count is to modify the shipped version of HTMLArea.
Open the file \typo3\sysext\rtehtmlarea\htmlarea\htmlarea.js and replace the function updateWordCount with the following.
updateWordCount: function() {
var wordCount = 0;
if (this.getEditor().getMode() == 'wysiwyg') {
// Get the html content
var text = this.getEditor().getHTML();
if (!Ext.isEmpty(text)) {
// Replace html tags with spaces
text = text.replace(HTMLArea.RE_htmlTag, ' ');
// Replace html space entities
text = text.replace(/ | /gi, ' ');
// Remove numbers and punctuation
text = text.replace(HTMLArea.RE_numberOrPunctuation, '');
// Get the number of word
wordCount = text.length;
}
}
// Update the word count of the status bar
this.statusBarWordCount.dom.innerHTML = wordCount + ' ' + ( wordCount == 1 ? 'char' : 'chars');
},
Please note, that this is a quick and dirty solution which does not repect translation of the words "char" and "chars".
If you modify htmlarea.js, keep in mind that you manually have to update your changes after each TYPO3 core update.
If you use TYPO3 7 you have to use this modifed script from the previos answer:
updateWordCount: function() {
var wordCount = 0;
if (this.getEditor().getMode() == 'wysiwyg') {
// Get the html content
var text = this.getEditor().getHTML();
if (!Ext.isEmpty(text)) {
// Replace html tags with spaces
text = text.replace(HTMLArea.RE_htmlTag, ' ');
// Replace html space entities
text = text.replace(/ | /gi, ' ');
// Remove numbers and punctuation
text = text.replace(HTMLArea.RE_numberOrPunctuation, '');
// Get the number of word
wordCount = text.length;
}
}
// Update the word count of the status bar
this.statusBarWordCount.innerHTML = wordCount + ' ' + ( wordCount == 1 ? 'char' : 'chars');
},
i had to remove .dom from the following line:
this.statusBarWordCount.dom.innerHTML

Log Fiddler Requests to Database Real-time

Is there any way to log all requests ongoing to a database or can you only log snapshots to a database?
The following example relies upon OLEDB 4.0 which is not available for 64bit processes. You can either select another data provider (e.g. SQLServer) or you can force Fiddler to run in 32bit mode.
Add the following to the Rules file to create a new menu item.
// Log the currently selected sessions in the list to a database.
// Note: The DB must already exist and you must have permissions to write to it.
public static ToolsAction("Log Selected Sessions")
function DoLogSessions(oSessions: Fiddler.Session[]){
if (null == oSessions || oSessions.Length < 1){
MessageBox.Show("Please select some sessions first!");
return;
}
var strMDB = "C:\\log.mdb";
var cnn = null;
var sdr = null;
var cmd = null;
try
{
cnn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strMDB);
cnn.Open();
cmd = new OleDbCommand();
cmd.Connection = cnn;
for (var x = 0; x < oSessions.Length; x++){
var strSQL = "INSERT into tblSessions ([ResponseCode],[URL]) Values (" +
oSessions[x].responseCode + ", '" + oSessions[x].url + "')";
cmd.CommandText = strSQL;
cmd.ExecuteNonQuery();
}
}
catch (ex){
MessageBox.Show(ex);
}
finally
{
if (cnn != null ){
cnn.Close();
}
}
}
Note: To use the Database Objects in Fiddler 2.3.9 and below, you'll need to add system.data to the References list inside Tools | Fiddler Options | Extensions | Scripting. In 2.3.9.1 and later, this reference will occur automatically.
Then, list the new import at the top of your rules script:
import System.Data.OleDb;
see FiddlerScript CookBook

Devart Oracle Entity Framework 4.1 performance

I want to know why Code fragment 1 is faster than Code 2 using POCO's with Devart DotConnect for Oracle.
I tried it over 100000 records and Code 1 is way faster than 2. Why? I thought "SaveChanges" would clear the buffer making it faster as there is only 1 connection. Am I wrong?
Code 1:
for (var i = 0; i < 100000; i++)
{
using (var ctx = new MyDbContext())
{
MyObj obj = new MyObj();
obj.Id = i;
obj.Name = "Foo " + i;
ctx.MyObjects.Add(obj);
ctx.SaveChanges();
}
}
Code 2:
using (var ctx = new MyDbContext())
{
for (var i = 0; i < 100000; i++)
{
MyObj obj = new MyObj();
obj.Id = i;
obj.Name = "Foo " + i;
ctx.MyObjects.Add(obj);
ctx.SaveChanges();
}
}
The first code snippet works faster as the same connection is taken from the pool every time, so there are no performance losses on its re-opening.
In the second case 100000 objects gradually are added to the context. A slow snapshot-based tracking is used (if no dynamic proxy). This leads to the detection if any changes in any of cached objects occured on each SaveChanges(). More and more time is spent by each subsequent iteration.
We recommend you to try the following approach. It should have a better performance than the mentioned ones:
using (var ctx = new MyDbContext())
{
for (var i = 0; i < 100000; i++)
{
MyObj obj = new MyObj();
obj.Id = i;
obj.Name = "Foo " + i;
ctx.MyObjects.Add(obj);
}
ctx.SaveChanges();
}
EDIT
If you use an approach with executing large number of operations within one SaveChanges(), it will be useful to configure additionally the Entity Framework behaviour of Devart dotConnect for Oracle provider:
// Turn on the Batch Updates mode:
var config = OracleEntityProviderConfig.Instance;
config.DmlOptions.BatchUpdates.Enabled = true;
// If necessary, enable the mode of re-using parameters with the same values:
config.DmlOptions.ReuseParameters = true;
// If object has a lot of nullable properties, and significant part of them are not set (i.e., nulls), omitting explicit insert of NULL-values will decrease greatly the size of generated SQL:
config.DmlOptions.InsertNullBehaviour = InsertNullBehaviour.Omit;
Only some options are mentioned here. The full list of them is available in our article:
http://www.devart.com/blogs/dotconnect/index.php/new-features-of-entity-framework-support-in-dotconnect-providers.html
Am I wrong to assume that when SaveChanges() is called, all the
objects in cache are stored to DB and the cache is cleared, so each
loop is independent?
SaveChanges() sends and commits all changes to database, but change tracking is continued for all entities which are attached to the context. And new SaveChanges, if snapshot-based change tracking is used, will start a long process of checking (changed or not?) the values of each property for each object.