Showing posts with label c sharp. Show all posts
Showing posts with label c sharp. Show all posts
Thursday, June 6, 2013
Sorting by last modified date of files
private static void GetFileDates()
{
DirectoryInfo di = new DirectoryInfo(_path);
FileSystemInfo[] files = di.GetFileSystemInfos();
var orderedFiles = files.OrderBy(f => f.LastWriteTime);
FileSystemInfo first = (FileSystemInfo)orderedFiles.First();
FileSystemInfo last = (FileSystemInfo)orderedFiles.Last();
_startDate = first.LastWriteTime.ToString();
_stopDate = last.LastWriteTime.ToString();
}
Friday, May 17, 2013
Asynchronous write and read using InTheHand 32Feet Bluetooth serial communications
With the connection all ready opened:
public class MyAsyncInfo
{
public Byte[] ByteArray { get; set; }
public Stream MyStream { get; set; }
public MyAsyncInfo(Byte[] array, Stream stream)
{
ByteArray = array;
MyStream = stream;
}
}
private void CASMonitor_SendData()
{
byte[] data = new byte[4];
data[0] = 0x58;
data[1] = 0x30;
data[2] = 0x39;
data[3] = 0x0D;
try
{
stream.BeginWrite(data, 0, data.Length, WriteComplete, null);
}
catch (Exception ee)
{
MessageBox.Show("Error: Sending, Verify Bluetooth Connection");
}
}
private void WriteComplete(IAsyncResult ar)
{
try
{
stream.EndWrite(ar);
byte[] DeviceBuffer = new byte[100];
DeviceBuffer.Initialize();
Stream DeviceStream = null;
DeviceStream = btClient.GetStream();
DeviceStream.Flush();
DeviceStream.BeginRead(DeviceBuffer, 0, DeviceBuffer.Length, DeviceReadComplete, new MyAsyncInfo(DeviceBuffer, DeviceStream));
}
catch (Exception ex)
{
MessageBox.Show("write error");
}
}
private void DeviceReadComplete(IAsyncResult r)
{
int numbytes = 0;
MyAsyncInfo info = r.AsyncState as MyAsyncInfo;
try
{
numbytes = info.MyStream.EndRead(r);
}
catch (Exception ex)
{
MessageBox.Show("Error: Readcomplete ex " + ex.Message);
return;
}
string msg = System.Text.Encoding.Default.GetString(info.ByteArray, 0, numbytes);
if ((info.ByteArray[0] == 'X') && (info.ByteArray[1] == '0') && (info.ByteArray[2] == '9') && (numbytes == 24))
{
ProcessDataProc(msg, numbytes);
}
else
{
if (_retryCnt < 3)
{
CASMonitor_SendData();
return;
}
}
return;
}
public class MyAsyncInfo
{
public Byte[] ByteArray { get; set; }
public Stream MyStream { get; set; }
public MyAsyncInfo(Byte[] array, Stream stream)
{
ByteArray = array;
MyStream = stream;
}
}
private void CASMonitor_SendData()
{
byte[] data = new byte[4];
data[0] = 0x58;
data[1] = 0x30;
data[2] = 0x39;
data[3] = 0x0D;
try
{
stream.BeginWrite(data, 0, data.Length, WriteComplete, null);
}
catch (Exception ee)
{
MessageBox.Show("Error: Sending, Verify Bluetooth Connection");
}
}
private void WriteComplete(IAsyncResult ar)
{
try
{
stream.EndWrite(ar);
byte[] DeviceBuffer = new byte[100];
DeviceBuffer.Initialize();
Stream DeviceStream = null;
DeviceStream = btClient.GetStream();
DeviceStream.Flush();
DeviceStream.BeginRead(DeviceBuffer, 0, DeviceBuffer.Length, DeviceReadComplete, new MyAsyncInfo(DeviceBuffer, DeviceStream));
}
catch (Exception ex)
{
MessageBox.Show("write error");
}
}
private void DeviceReadComplete(IAsyncResult r)
{
int numbytes = 0;
MyAsyncInfo info = r.AsyncState as MyAsyncInfo;
try
{
numbytes = info.MyStream.EndRead(r);
}
catch (Exception ex)
{
MessageBox.Show("Error: Readcomplete ex " + ex.Message);
return;
}
string msg = System.Text.Encoding.Default.GetString(info.ByteArray, 0, numbytes);
if ((info.ByteArray[0] == 'X') && (info.ByteArray[1] == '0') && (info.ByteArray[2] == '9') && (numbytes == 24))
{
ProcessDataProc(msg, numbytes);
}
else
{
if (_retryCnt < 3)
{
CASMonitor_SendData();
return;
}
}
return;
}
Labels:
.NET,
.net compact,
BeginRead,
BeginWrite,
Bluetooth,
c sharp,
c#,
EndRead,
EndWrite,
read,
serial communications,
stream,
write
Friday, January 25, 2013
c# fixed position in strings
I had to update how the characters in a string were positioned. Previously the fields in the string were variable length without any delimiters.
Like this: LastName,FirstNameMrnAccountNumberRegDate
The requirements had changed. There was a need to have each field start in a know position and space fill any unused positions in that field.
Like this: LastName, FirstName MRN AccountNumber RegDate
I seem to remember in COBOL there was some kind of FILLER command. Something along the lines of
FILLER(30) that would add 30 spaces.
Back to C# I went about this using char arrays. Each field would have a char array, the number of elements in each char array would be equal to the field size. A method gets called to space fill the arrays. Next the string data is loaded element by element into the char arrays. This is easy code since a c# string is an array of characters. The last step is to combine the char arrays into one string. I used the string(char) constructor and the string.format methods to complete this.
Like this: LastName,FirstNameMrnAccountNumberRegDate
The requirements had changed. There was a need to have each field start in a know position and space fill any unused positions in that field.
Like this: LastName, FirstName MRN AccountNumber RegDate
I seem to remember in COBOL there was some kind of FILLER command. Something along the lines of
FILLER(30) that would add 30 spaces.
Back to C# I went about this using char arrays. Each field would have a char array, the number of elements in each char array would be equal to the field size. A method gets called to space fill the arrays. Next the string data is loaded element by element into the char arrays. This is easy code since a c# string is an array of characters. The last step is to combine the char arrays into one string. I used the string(char) constructor and the string.format methods to complete this.
string LastName = "Clause"; string FirstName = "Santa"; string MRN = "0000007xx"; string PatComCode = "378"; DateTime RegDate = DateTime.Now; string noteCode2 = string.Empty; string name = string.Format("{0}, {1}", LastName, FirstName); char[] nameArray = new char[29]; spaceFillArray(ref nameArray); char[] mrnArray = new char[7]; spaceFillArray(ref mrnArray); char[] acctArray = new char[9]; spaceFillArray(ref acctArray); char[] regDtArray = new char[10]; spaceFillArray(ref regDtArray); stringToArray(ref nameArray,name); stringToArray(ref mrnArray,MRN); stringToArray(ref acctArray,PatComCode); stringToArray(ref regDtArray,RegDate.ToString("MM/dd/yyyy")); noteCode2 = buidPatInfoString(nameArray,mrnArray,acctArray,regDtArray);
private void spaceFillArray(ref char[] info) { for (int i = 0; i < info.Length; i++) { info[i] = ' '; } } private void stringToArray(ref char[] info, string inString) { for(int i = 0; i < inString.Length; i++) { if (i == info.Length) break; info[i] = inString[i]; } } private string buidPatInfoString(char[] name, char[] mrn, char[] acct, char[] regDt) { string ret = string.Empty; string partA = new string(name); string partB = new string(mrn); string partC = new string(acct); string partD = new string(regDt); ret = string.Format("{0}{1}{2}{3}",partA,partB,partC,partD); return ret;}
Friday, January 4, 2013
Bluetooth c# code sample
Here's a quick code sample of how to scan for Bluetooth devices and display some properties of that device. This was deployed to a Motorola hand held device. The framework is the Compact Framework and the Bluetooth functionality is made possible by the InTheHand.Net.Personal API.
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using InTheHand.Net;
using InTheHand.Net.Sockets;
using InTheHand.Windows;
namespace SmartDeviceProject2
{
public partial class Form1 : Form
{
private BluetoothClient _btc;
private BluetoothDeviceInfo[] _peers;
public Form1()
{
InitializeComponent();
this.devicesListBox.Items.Clear();
_btc = new BluetoothClient();
_peers = _btc.DiscoverDevices();
deviceInfoLbl.Text = string.Empty;
}
private void scanButton_Click(object sender, EventArgs e)
{
deviceInfoLbl.Text = string.Empty;
this.devicesListBox.DisplayMember = "DeviceName";
this.devicesListBox.ValueMember = null;
this.devicesListBox.DataSource = _peers;
}
private void devicesListBox_SelectedIndexChanged(object sender, EventArgs e)
{
deviceInfoLbl.Text = getDeviceInfo(devicesListBox.SelectedIndex);
}
private string getDeviceInfo(int index)
{
string ret = string.Empty;
try
{
string connectedText = "No";
if (_peers[index].Connected)
connectedText = "Yes";
ret = string.Format("Device Name: {0}\nDevice Address: {1}\nDevice Class: {2}\nConnected: {3} ",
_peers[index].DeviceName,
_peers[index].DeviceAddress.ToString(),
_peers[index].ClassOfDevice.ToString(),
connectedText);
}
catch (Exception e)
{
deviceInfoLbl.Text = string.Empty;
return ret;
}
return ret;
}
}
}
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using InTheHand.Net;
using InTheHand.Net.Sockets;
using InTheHand.Windows;
namespace SmartDeviceProject2
{
public partial class Form1 : Form
{
private BluetoothClient _btc;
private BluetoothDeviceInfo[] _peers;
public Form1()
{
InitializeComponent();
this.devicesListBox.Items.Clear();
_btc = new BluetoothClient();
_peers = _btc.DiscoverDevices();
deviceInfoLbl.Text = string.Empty;
}
private void scanButton_Click(object sender, EventArgs e)
{
deviceInfoLbl.Text = string.Empty;
this.devicesListBox.DisplayMember = "DeviceName";
this.devicesListBox.ValueMember = null;
this.devicesListBox.DataSource = _peers;
}
private void devicesListBox_SelectedIndexChanged(object sender, EventArgs e)
{
deviceInfoLbl.Text = getDeviceInfo(devicesListBox.SelectedIndex);
}
private string getDeviceInfo(int index)
{
string ret = string.Empty;
try
{
string connectedText = "No";
if (_peers[index].Connected)
connectedText = "Yes";
ret = string.Format("Device Name: {0}\nDevice Address: {1}\nDevice Class: {2}\nConnected: {3} ",
_peers[index].DeviceName,
_peers[index].DeviceAddress.ToString(),
_peers[index].ClassOfDevice.ToString(),
connectedText);
}
catch (Exception e)
{
deviceInfoLbl.Text = string.Empty;
return ret;
}
return ret;
}
}
}
Labels:
.NET,
.net compact,
Bluetooth,
c sharp,
c#,
handheld devices,
mobile development,
Motorola,
Visual Studio
Friday, December 7, 2012
c sharp enum examples
Using enumeration in your code is a quick way to make your code
more readable.
Declare a new type
private enum _medTypes { newMed, changeMed, stopMed };
//newMed =0, changedMed = 1, stopMed =2
Declare a variable of your new type
private _medTypes _medType;
Converting an int to your new type
_medType = (_medTypes)int.Parse(Request.QueryString["medType"]);
Testing your new type
if (_medType == _medTypes.newMed || _medType == _medTypes.changeMed)
switch(_medType)
{
case _medTypes.newMed:
msgSpan.InnerHtml = @"Meds written since ED Reg date default as new. " +
"To exclude a medication from appearing on the discharge note the user needs to uncheck the new box.";
medsGridView.Columns[0].Visible = true;
break;
case _medTypes.changeMed:
msgSpan.InnerHtml = @"Medication changes must be made in LMR.";
medsGridView.Columns[1].Visible = true;
break;
case _medTypes.stopMed:
msgSpan.InnerHtml = @"Meds discontinued since the ED Reg date are displayed below.";
medsGridView.Columns[2].Visible = true;
break;
default:
break;
}
Thursday, November 15, 2012
c# Generic List sorting
Here's a quick code snip of sorting a generic list of object, by a DateTime object property in descending order.
1. Your class has to inherit IComparable
2. Implement IComparable's CompareTo method
3. After your generic list of objects is built, then call the lists .Sort method.
In this code I needed the LmrMed's serviceDate sorted in descending order. The Sort method does not create a new list, it changes the order of the nodes in the current list.
I found this article helpful in learning about c# generic list sorting: http://www.codedigest.com/Articles/CSHARP/84_Sorting_in_Generic_List.aspx
1. Your class has to inherit IComparable
2. Implement IComparable's CompareTo method
3. After your generic list of objects is built, then call the lists .Sort method.
In this code I needed the LmrMed's serviceDate sorted in descending order. The Sort method does not create a new list, it changes the order of the nodes in the current list.
I found this article helpful in learning about c# generic list sorting: http://www.codedigest.com/Articles/CSHARP/84_Sorting_in_Generic_List.aspx
public class LmrMed : IComparable<LmrMed>
{
public int recId { get; set; }
public string medText { get; set; }
public DateTime? startDate { get; set; }
public DateTime? endDate { get; set; }
public DateTime serviceDate { get; set; }
public LmrMed(int recId, string medText, DateTime startDate, DateTime endDate, DateTime serviceDate)
{
this.recId = recId;
this.medText = medText;
this.startDate = startDate;
this.endDate = endDate;
this.serviceDate = serviceDate;
}
public int CompareTo(LmrMed lm)
{
return lm.serviceDate.CompareTo(this.serviceDate);
}
List<LmrMed> lmrMeds = GetMeds(_mrn);
lmrMeds.Sort();
Tuesday, October 30, 2012
asp.net Using WebHandler to generate images on Server Side and send to Client
I had to create dynamic 2D Data Matrix bar code images on the server and send to the client for MeadCo printing. Found out you can do this by using Web Handlers.
This is a simple example, the value of the bar code is
hardcoded. Since you can pass query
strings from the client to the handler, there is the possibility of creating
dynamic barcodes. This I will be doing
using this prototype as a framework.
WebHandler:
<%@ WebHandler Language="C#" Class="ImageHandler" %>
using System;
using System.Web;
using System.IO;
using System.Drawing;
public class ImageHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//NOTE: You can get parameters from the client using Query Strings
IEC16022Sharp.DataMatrix dm = new IEC16022Sharp.DataMatrix("<00007>"00007>);
context.Response.ContentType = "image/bmp";
using (Bitmap image = dm.Image)
{
using (MemoryStream ms = new MemoryStream())
{
image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
ms.WriteTo(context.Response.OutputStream);
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
Client code:
The code below shows embedded html being generated (This is
used for printing). The option is there
just to place an img element within the html document and set it’s src attribute
to the name of your handler.
Labels:
.NET,
2D barcode,
ASP.NET,
barcode,
Bitmap,
c sharp,
c#,
code,
Data Matrix,
handlers,
html,
Images,
javaScript,
Visual Studio,
VS2010,
Web Development,
WebHandler
Wednesday, October 17, 2012
JSON serialize with c# deserialize with javascript via pop up window
I created a modal window pop up that shows search results in a gridview. In this gridview there is a checkbox for each row returned. The user can select any rows they want by checking the associated checkbox. One way to send the user's selected data back to the parent window is to use JSON. Below are code snips on how to to do this.
The c# code serializes the generic list of Icd9 objects into a JSON string. This new JSON string is sent to a hidden input on the client side. Upon unload of this child window, the window return value is set to the value of the hidden input that was populated on server side. The parent window client code then evals the returned window value. Once this has been done the value is copied to collection of Icd9 objects. I for loop my way though this collection accessing the Name and Code properties.
Note: This works in IE. I think IE is only browser that supports showModalDialog
This should work in other browsers if you use winodow.open etc.
The c# code serializes the generic list of Icd9 objects into a JSON string. This new JSON string is sent to a hidden input on the client side. Upon unload of this child window, the window return value is set to the value of the hidden input that was populated on server side. The parent window client code then evals the returned window value. Once this has been done the value is copied to collection of Icd9 objects. I for loop my way though this collection accessing the Name and Code properties.
Note: This works in IE. I think IE is only browser that supports showModalDialog
This should work in other browsers if you use winodow.open etc.
Class:
public class Icd9
{
public string Name { get; set; }
public string Code { get; set; }
public Icd9(string name, string code)
{
this.Code = code;
this.Name = name;
}
}
Child Window:
Server side:
using System.Web.Script.Serialization;
...
List<CommonTasks.Icd9> selectedCodes = new List<CommonTasks.Icd9>();
for (int i = 0; i < icdGridView.Rows.Count; i++)
{
GridViewRow row = icdGridView.Rows[i];
bool isChecked = ((CheckBox)row.FindControl("selectedRowCb")).Checked;
if (isChecked)
{
selectedCodes.Add(new CommonTasks.Icd9(icdGridView.Rows[i].Cells[2].Text, icdGridView.Rows[i].Cells[1].Text));
}
}
JavaScriptSerializer js = new JavaScriptSerializer();
string str = js.Serialize(selectedCodes);
hdnIcd.Value = str;
...
Client:
function setWindow_return() {
var selectedCodes = document.getElementById("hdnIcd");
window.returnValue = selectedCodes.value;
}
Parent Window:
Client:
function GetIcd9()
{
var searchText = document.getElementById("f129").value;
var url = "Icd.aspx?searchText=" + searchText;
if (searchText.length==0)
alert(" no value retrieved ");
else {
var results =
window.showModalDialog(url,"","center:yes;dialogWidth:775px;dialogHeight:480px;resizable:no;status:no;;help:no");
if(results.length > 0)
{
var data = eval(results);
if(data.length > 0)
{
var icd9Text = "";
var icd9Code = "";
for(i=0; i < data.length; i++)
{
icd9Text += data[i].Name + " ";
icd9Code += data[i].Code + ",";
}
document.getElementById("petsText").value += icd9Text;
document.getElementById("hidIcd9Code").value += icd9Code;
}
}
}
}
Labels:
.NET,
Browser,
c sharp,
c#,
deserialize,
IE,
javaScript,
JSON,
serialize,
showModalDialog,
window.returnValue
Tuesday, October 9, 2012
Production Issue! Patient Vitals Documentation: XSL Transform
Last week there was serious production issue that I had to fix. The issue was patients acute (critical) vital signs were not showing up on patient documentation.
The analyst found out acute vital signs would not show up if there was more than one set of acute vital signs. In their testing, they found out if you only have one set of acute vital signs then the acute vital signs would show up.
Here's a very simple diagram of how Emergency Documentation system flows:
Database <---> dll <---> web service <---> .Net website
I had a lot of places to look.
I found a method that had an XML transform. This transform was converting XML returned by a stored procedure into HTML. In debugging the web application I determined that the acute vitals data 'went missing' in the code below.
Code from private method in web service:
For XML clause in the select statement from the stored procedure:
FOR XML PATH('Vitals'),root('Visit')
I needed a lesson in XSLT but first I had to understand the business rules.
The users did not want to see any acute vital column headers in the patient documentation if there was no acute vitals taken. Examples below:
The analyst found out acute vital signs would not show up if there was more than one set of acute vital signs. In their testing, they found out if you only have one set of acute vital signs then the acute vital signs would show up.
Here's a very simple diagram of how Emergency Documentation system flows:
Database <---> dll <---> web service <---> .Net website
I had a lot of places to look.
I found a method that had an XML transform. This transform was converting XML returned by a stored procedure into HTML. In debugging the web application I determined that the acute vitals data 'went missing' in the code below.
Code from private method in web service:
XmlReader reader = XmlReader.Create(new StringReader(xml)); StringBuilder output = new StringBuilder(); XmlWriter writer = XmlWriter.Create(output); XslCompiledTransform Xsl = new XslCompiledTransform(); Xsl.Load(xslFile); Xsl.Transform(reader, writer); html = output.ToString(0, output.Length); return html.Substring(html.IndexOf("));
For XML clause in the select statement from the stored procedure:
FOR XML PATH('Vitals'),root('Visit')
I needed a lesson in XSLT but first I had to understand the business rules.
The users did not want to see any acute vital column headers in the patient documentation if there was no acute vitals taken. Examples below:
![]() |
| Vitals Table without Acute Data |
![]() |
| Vitals Table with Acute Data |
A team leader here told me the XSL file could have a bug in it. He also said that I could debug these XSL files in Visual Studio. I did some online research to find out what XSL files and what transforming is. XML transforms is a way of converting XML data to: Another XML, HTML, or other text. I can see how handy this would be.
In debugging the XSL I found that there was a variable called accuteV. If this variable contained the value of "on" then the extra acute columns would be rendered in the html output. This variable was being set in a For-Each statement. While debugging, I noticed if there was more than one row being returned with acute data, the accuteV variable would no longer contain any value. It was like accuteV went out of scope!
I did more online research and found out that variables in XSLT are immutable! They can only be assigned to once. Turns out that XSLT is a function language. The original developer had treated this as a procedural language.
This bug of assigning a value to a variable within a For-Each explained why acute data would show up when there was only one row of acute data, but would disappear if more than one row of acute data.
A very strange bug is very easily explained with some knowledge of how XLST works.
Now knowing the exact problem the challenge was to fix it quickly with little code changes as possible.
I tried a few workarounds with setting the variable The goal was not to change any other part of the XSL. I wanted all the existing code to remain the same. I did not have time to become a XSL expert and did not want to take ownership of this file either. I tried to add an 'and' to the if statement checking if acuteV was all ready 'on'. I also tried to store the sum of the lengths of the acute nodes in question. Neither of these worked. I was stuck.
Lucky for me the same team leader who had lead me to the XSL was working on this as well. His found a solution to find out if there's any acute data anywhere in the XML, and only assign 'on' to acuteV once. This solution worked like a charm! Big Thank yous were given and Hi Fives all around.
Original XLS snip:
<xsl:variable name="acuteV" > <xsl:for-each select="Visit/Vitals/Acute"> <xsl:if test="string-length(Aline)>0 or string-length(CVP)>0 or string-length(ICP)>0 or string-length(ET)>0 or string-length(FI)>0"> <xsl:text>on</xsl:text> </xsl:if> </xsl:for-each> </xsl:variable>
Fixed XLS full file:
XML:
xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.stylusstudio.com/xquery">
<xsl:variable name="WeGotData" >
<xsl:for-each select="Visit/Vitals/Acute">
<xsl:value-of select='concat(Aline,CVP,ICP,ET,FI)'/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="acuteV">
<xsl:choose>
<xsl:when test="$WeGotData!=''">
<xsl:text>on</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>off</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="cols">
<xsl:choose>
<xsl:when test="$acuteV='on'">
<xsl:text>13</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>8</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:attribute-set name="borders">
<xsl:attribute name="style">border-bottom:solid 1px;border-right:solid 1px;</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="bordersWithColspan">
<xsl:attribute name="colspan"><xsl:value-of select="$cols"></xsl:value-of></xsl:attribute>
<xsl:attribute name="style">border-bottom:solid 1px;border-right:solid 1px;</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="markinError">
<xsl:attribute name="style">text-align:center;text-decoration:line-through;</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="/">
<html>
<head/>
<body style="font-size:9pt;font-family:Verdana;">
<div style="text-align: none;">
<br/>
<table align="none" style="border-style: none;border-width: 0pt;background-color:transparent;font-family:Verdana;" cellspacing="1pt">
<tbody>
<tr>
<td style="border-style: none;border-width: 2pt;padding: 2pt;vertical-align: middle;">
<span style="font-size: 10.5pt;font-weight: bold;">
Vitals/Progress Notes
</span>
</td>
</tr>
</tbody>
</table>
<br/>
<table style="border-style:none;border-color:black;border-collapse:collapse;background-color:transparent;font-family:Verdana;" cellpadding="0" cellspacing="0" >
<tbody >
<tr >
<td style="border-style: solid;border-width: 1px;width:60pt;padding: 0pt;vertical-align: middle;">
<div style="text-align: left;">
<span style="font-size: 9pt;font-weight: bold;">
Event Time
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size: 9pt;font-weight: bold;">
Temp
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size: 9pt;font-weight: bold;">
P
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size: 9pt;font-weight: bold;">
BP
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size: 9pt;font-weight: bold;">
RR
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size: 9pt;font-weight: bold;">
Sat
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size:9pt;font-weight: bold;">
Pain
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size:9pt;font-weight: bold;">
Pupils
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size: 9pt;font-weight: bold;">
GCS
</span>
</div>
</td>
<xsl:if test="$acuteV='on'">
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size:9pt;font-weight: bold;">
A-line
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size:9pt;font-weight: bold;">
CVP
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size:9pt;font-weight: bold;">
ICP
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size:9pt;font-weight: bold;">
ET C02
</span>
</div>
</td>
<td style="border-style: solid;border-width: 1px;padding: 0pt;vertical-align: middle;">
<div style="text-align: center;">
<span style="font-size:9pt;font-weight: bold;">
FiO2
</span>
</div>
</td>
</xsl:if>
</tr>
<xsl:for-each select="Visit/Vitals">
<xsl:choose>
<xsl:when test="Type='NOTE'">
<tr>
<td style="border-right: solid 1px;border-bottom: solid 1px; border-left:solid 1px; width:60pt;">
<div style="text-align: left; font-size:9pt">
<xsl:variable name="lastDate" select="DateTimeTaken/Date"/>
<xsl:if test="not(preceding-sibling::Vitals[DateTimeTaken/Date=$lastDate])">
<xsl:value-of select="DateTimeTaken/Date"/>
<br/>
</xsl:if>
<xsl:value-of select="DateTimeTaken/Time"/>
</div>
</td>
<td xsl:use-attribute-sets="bordersWithColspan" >
<div style="text-align: left;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="ProgressNote"/>
</div>
<xsl:if test="IsDeleted='1'" >
<div style="text-align: left;font-size:9pt">
<xsl:value-of select="ErrorReason"/>
</div>
</xsl:if>
</td>
</tr>
</xsl:when>
<xsl:when test="Type='ED' or Type='TRIAGE'">
<tr>
<td >
<xsl:choose>
<xsl:when test="string-length(ProgressNote)>0 or string-length(ErrorReason)>0" >
<xsl:attribute name="style">border-left:solid 1px;border-bottom:none;border-right:solid 1px</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">border-left:solid 1px;border-right: solid 1px;border-bottom:solid 1px;width:60pt;</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<div style="text-align: left;font-size:9pt">
<xsl:variable name="lastDate" select="DateTimeTaken/Date"/>
<xsl:if test="not(preceding-sibling::Vitals[DateTimeTaken/Date=$lastDate])">
<xsl:value-of select="DateTimeTaken/Date"/>
<br/>
</xsl:if>
<xsl:value-of select="DateTimeTaken/Time"/>
<xsl:if test="Type='TRIAGE'">(T)</xsl:if>
</div>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(Temp/Temp)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="Temp/Temp"/>
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(Pulse/Pulse)>0 or string-length(Pulse/Rhythm)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="Pulse/Pulse" />
<xsl:if test="'string=length(Pulse/Rhythm>0'">
<br/>
<xsl:value-of select="Pulse/Rhythm" />
</xsl:if>
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(BP/High)>0 or string-length(BP/Low)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="BP/High"/>
<xsl:if test="string-length(BP/High) >0">
<xsl:text> / </xsl:text>
</xsl:if>
<xsl:value-of select="BP/Low"/>
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(RespRate/RespRate)" >
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="RespRate/RespRate" />
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(Sat/SaO2)>0 or string-length(Sat/RA)>0 or string-length(Sat/Liters>0)" >
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="Sat/SaO2" />
<xsl:if test="string-length(Sat/Liters)>0">
<br/>
<xsl:value-of select="concat(Sat/Liters,'L')"/>
</xsl:if>
<xsl:if test="string-length(Sat/RA)>0">
<br/>
<xsl:value-of select="Sat/RA" />
</xsl:if>
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(Pain/Level)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="Pain/Level" />
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td style="border-right: solid 1px;border-bottom:solid 1px;">
<xsl:choose>
<xsl:when test="string-length(Pupils/LeftPupils)>0 or string-length(Pupils/RightPupils)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:if test="string-length(Pupils/Leftmm) >0">
<xsl:text>L:</xsl:text>
<xsl:value-of select="concat(Pupils/Leftmm,substring(Pupils/LeftPupils,1,1))" />
</xsl:if>
<br/>
<xsl:if test="string-length(Pupils/Rightmm) >0">
<xsl:text> R:</xsl:text>
<xsl:value-of select="concat(Pupils/Rightmm,substring(Pupils/RightPupils,1,1))"/>
</xsl:if>
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="GCS/Score>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="substring(GCS/EyeOpening,1,1)" />
<xsl:text>,</xsl:text>
<xsl:value-of select="substring(GCS/VerbalResponse,1,1)" />
<xsl:text>,</xsl:text>
<xsl:value-of select="substring(GCS/Motor,1,1)"/>
<xsl:text>=</xsl:text>
<xsl:value-of select="GCS/Score"/>
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<xsl:if test="$acuteV='on'">
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(Acute/Aline)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="Acute/Aline" />
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(Acute/CVP)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="Acute/CVP" />
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(Acute/ICP)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="Acute/ICP" />
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(Acute/ET)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="Acute/ET" />
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
<td xsl:use-attribute-sets="borders" >
<xsl:choose>
<xsl:when test="string-length(Acute/FI)>0">
<div style="text-align: center;font-size:9pt">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-align:center;text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<xsl:value-of select="Acute/FI" />
</div>
</xsl:when>
<xsl:otherwise>
<span> </span>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:if>
<xsl:if test="string-length(ProgressNote)>0 or string-length(ErrorReason)>0" >
<tr>
<td style="border-left:solid 1px black; border-bottom:solid 1px;border-right:solid 1px;"> </td>
<td xsl:use-attribute-sets="bordersWithColspan" >
<xsl:if test="string-length(ProgressNote)>0" >
<div style="font-size:9pt;">
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-decoration:line-through</xsl:attribute>
</xsl:if>
<xsl:value-of select="ProgressNote" />
</div>
</xsl:if>
<xsl:if test="string-length(ErrorReason)>0" >
<div style="font-size:9pt;">
<xsl:value-of select="ErrorReason" />
</div>
</xsl:if>
</td>
</tr>
</xsl:if>
</tr>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</tbody>
</table>
<br/>
<table align="none" style="border-style: none;border-width: 0pt;background-color:transparent;" cellspacing="1pt">
<tbody>
<tr>
<td style="border-style: none;border-width: 2pt;padding: 2pt;vertical-align: middle;">
<div style="font-size: 10pt;font-weight: bold;">
Details:
</div>
</td>
</tr>
</tbody>
</table>
<table style="background-color:transparent;font-family:Verdana;font-size:9pt">
<xsl:for-each select="Visit/Vitals">
<tr>
<td>
<div>
<xsl:if test="IsDeleted='1'" >
<xsl:attribute name="style">text-decoration:line-through;font-size:9pt</xsl:attribute>
</xsl:if>
<span style="font-size: 9pt;font-style: italic">
Event Time:
</span>
<xsl:value-of select="DateTimeTaken/Date"/>
<xsl:text> </xsl:text>
<xsl:value-of select="DateTimeTaken/Time"/>
<br/>
<span style="font-size: 9pt;font-style: italic;">
Time Recorded:
</span>
<xsl:value-of select="DateTimeRecorded"/>
<br/>
<span style="font-size: 9pt;font-style: italic;">
Entered By:
</span>
<xsl:value-of select="username"/>
<xsl:choose>
<xsl:when test="Type='ED' or Type='TRIAGE'">
<xsl:if test="string-length(BP) > 0">
<div style="text-align: none;">
<span style="font-size: 9pt;font-style: italic;">
BP:
</span>
<xsl:value-of select="BP/High" />
<xsl:text>/</xsl:text>
<xsl:value-of select="BP/Low" />
<xsl:if test="string-length(BP/Site) > 0">
<xsl:text> Site:</xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="BP/Site"/>
</xsl:if>
<xsl:if test="string-length(BP/Position) > 0">
<xsl:text> Position: </xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="BP/Position"/>
</xsl:if>
</div>
</xsl:if>
<xsl:if test="string-length(Temp/Temp) > 0">
<div style="text-align: none;">
<span style="font-size: 9pt;font-style: italic;">
Temp:
</span>
<xsl:value-of select="Temp/Temp"/>
<xsl:if test="string-length(Temp/Site) > 0">
<xsl:text> Site: </xsl:text>
<xsl:value-of select="Temp/Site"/>
</xsl:if>
</div>
</xsl:if>
<xsl:if test="string-length(Pain/Level) > 0">
<div style="text-align: none;">
<span style="font-size: 9pt;font-style: italic;">
Pain Scale:
</span>
<xsl:value-of select="Pain/Scale"/>
<xsl:text> - </xsl:text>
<xsl:value-of select="Pain/Level" />
</div>
</xsl:if>
<xsl:if test="string-length(Pupils/LeftPupils) >0">
<div style="text-align: none;">
<span style="font-size: 9pt;font-style: italic;">
Pupils:
</span>
<xsl:text>Left: </xsl:text>
<xsl:value-of select="Pupils/LeftPupils"/>
<xsl:text> </xsl:text>
<xsl:value-of select="Pupils/Leftmm"/>
<xsl:text> mm</xsl:text>
<xsl:text> Right: </xsl:text>
<xsl:value-of select="Pupils/RightPupils"/>
<xsl:text> </xsl:text>
<xsl:value-of select="Pupils/Rightmm"/>
<xsl:if test="string-length(Pupils/RightPupils) >0">
<xsl:text> mm</xsl:text>
</xsl:if>
</div>
</xsl:if>
<xsl:if test="string-length(GCS/Type) > 0">
<div style="text-align: none;">
<span style="font-size: 9pt;font-style: italic;">
Glasgow Coma Scale:
</span>
<xsl:if test="string-length(GCS/EyeOpening) > 0">
<xsl:text>Eye Opening: </xsl:text>
<xsl:value-of select="GCS/EyeOpening" />
</xsl:if>
<xsl:if test="string-length(GCS/VerbalResponse) > 0">
<xsl:text> Verbal: </xsl:text>
<xsl:value-of select="GCS/VerbalResponse" />
</xsl:if>
<xsl:if test="string-length(GCS/Motor) > 0">
<xsl:text> Motor: </xsl:text>
<xsl:value-of select="GCS/Motor" />
</xsl:if>
<xsl:if test="string-length(GCS/Score) > 0">
<xsl:text> Score: </xsl:text>
<xsl:value-of select="GCS/Score" />
</xsl:if>
</div>
</xsl:if>
</xsl:when>
</xsl:choose>
</div>
<br/>
</td>
</tr>
</xsl:for-each>
</table>
<br/>
<br/>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML:
<Visit> <Vitals> <Type>ED</Type> <DateTimeTaken> <datetimetaken>2012-10-09T10:08:00</datetimetaken> <Date>10/09/2012</Date> <Time>10:08</Time> </DateTimeTaken> <DateTimeRecorded>10/09/2012 10:09</DateTimeRecorded> <BP> <High>110</High> <Low>180</Low> <Site></Site> <Position></Position> <Deferred></Deferred> </BP> <Temp> <Temp>99.0</Temp> <Site>Temporal</Site> <Deferred></Deferred> </Temp> <RespRate> <RespRate>11</RespRate> <Deferred></Deferred> </RespRate> <Pulse> <Pulse>11</Pulse> <Rhythm></Rhythm> <Deferred></Deferred> </Pulse> <Sat> <SaO2>1</SaO2> <Liters></Liters> <RA></RA> </Sat> <Pain> <Level>4</Level> <Scale>Numeric</Scale> <Deferred></Deferred> </Pain> <Pupils> <LeftPupils>Brisk</LeftPupils> <Leftmm>1</Leftmm> <RightPupils>Brisk</RightPupils> <Rightmm>1</Rightmm> </Pupils> <GCS> <Score>6</Score> <Type>adult</Type> <EyeOpening>4 - Spontaneous</EyeOpening> <VerbalResponse>1 - None</VerbalResponse> <Motor>1 - None</Motor> </GCS> <Acute> <Aline></Aline> <CVP></CVP> <ICP></ICP> <ET></ET> <FI></FI> </Acute> <username>Jay Tarantino, MD-Attending</username> <ProgressNote></ProgressNote> <ErrorReason></ErrorReason> <IsDeleted>0</IsDeleted> <UserId>jmt67</UserId> <vitalsid>140</vitalsid> </Vitals> <Vitals> <Type>ED</Type> <DateTimeTaken> <datetimetaken>2012-10-09T10:27:00</datetimetaken> <Date>10/09/2012</Date> <Time>10:27</Time> </DateTimeTaken> <DateTimeRecorded>10/09/2012 10:28</DateTimeRecorded> <BP> <High>111</High> <Low>1</Low> <Site>LeftArm</Site> <Position>Sitting</Position> <Deferred></Deferred> </BP> <Temp> <Temp>111.0</Temp> <Site>Temporal</Site> <Deferred></Deferred> </Temp> <RespRate> <RespRate>1</RespRate> <Deferred></Deferred> </RespRate> <Pulse> <Pulse>11</Pulse> <Rhythm>Regular</Rhythm> <Deferred></Deferred> </Pulse> <Sat> <SaO2>1</SaO2> <Liters></Liters> <RA>RA</RA> </Sat> <Pain> <Level>4</Level> <Scale>Numeric</Scale> <Deferred></Deferred> </Pain> <Pupils> <LeftPupils>Brisk</LeftPupils> <Leftmm>1</Leftmm> <RightPupils>Brisk</RightPupils> <Rightmm>1</Rightmm> </Pupils> <GCS> <Score>6</Score> <Type>adult</Type> <EyeOpening>4 - Spontaneous</EyeOpening> <VerbalResponse>1 - None</VerbalResponse> <Motor=""> 1 - None</Motor> </GCS> <Acute> <Aline>110/80</Aline> <CVP></CVP> <ICP></ICP> <ET></ET> <FI></FI> </Acute> <username>Jay Test, MD-Attending</username> <ProgressNote></ProgressNote> <ErrorReason></ErrorReason> <IsDeleted>0</IsDeleted> <UserId>fake</UserId> <vitalsid>141</vitalsid> </Vitals> </Visit>
Labels:
.NET,
c sharp,
c#,
code,
html,
transforms,
Web Development,
XML,
XSL,
XSLT
Subscribe to:
Posts (Atom)




