HL7 - Parsing Specimen Source (OBR-15) using nHapi in c# - c#

I was wondering if any wonderful person with experience of using nHAPI in C# would be able to help a newbie out with the OBR-15 field (Specimen Source) of an HL7 message? I've dug around and I can't find any documentation online to help me out, so I'd be grateful for any suggestions.
My problem is, I can't find the correct method for filling the OBR-15 field using nHAPI. I'm hoping to send an OBR segment that looks like this (I've removed data from all other fields except OBR15, so my actually message isn't as bare as this):
OBR|1||||||||||||||T034^Blood||||||||||||||||||||
I've tried every way possible to form this field with no success. I'm always getting an ampersand that appears in the front everything I'm sending, which means that the field is unreadable in downstream applications:
OBR|1||||||||||||||&T034^^^^^^&Blood||||||||||||||||||||
My OBR-15 code snippet (I've just kept the relevant stuff in here, as otherwise this section would be massive):
using System;
using System.Collections.Generic;
using System.Web.Services;
using NHapi.Model.V24.Message;
using NHapi.Model.V24.Segment;
using NHapi.Model.V24.Group;
using System.Data;
using System.Text;
using NHapi.Base.Parser;
using NHapi.Model.V24.Datatype;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Data.SqlClient;
namespace HL7WebService
{
public class HL7Reporting : System.Web.Services.WebService
{
private ORU_R01 Create_ORU_R01(Dictionary <string,string> reportData, int reportNumber)
{
ORU_R01 oruR01 = new ORU_R01();
// lots of stuff removed for clarity
ORU_R01_ORDER_OBSERVATION oruR01OrderObs = oruR01.GetPATIENT_RESULT().GetORDER_OBSERVATION(1);
OBR obr = oruR01OrderObs.OBR;
// OBR-15 Specimen Source
obr.SpecimenSource.SpecimenSourceNameOrCode.Text.Value = "T034";
obr.SpecimenSource.SpecimenRole.Text.Value = "Blood";
// lots of other stuff removed for clarity
return oruR01;
}
}
}
I'm using nHapi (v2.5.0.6) and visual studio 2015. If I've missed anything out or you require any further information, just let me know and I'll provide it. Thanks!

I solved it by declaring OBR-15 the following way:
obr.SpecimenSource.SpecimenSourceNameOrCode.Identifier.Value = "T034";
obr.SpecimenSource.Additives.Value = "Blood";

Related

Ambiguous reference between 'Microsoft.Azure.Devices.Client.Message' and 'Microsoft.Azure.Devices.Message

I am new to c# and was using some references to code. I added a few methods that use Microsoft.Azure.Devices.Client while some methods use Microsoft.Azure.Devices. Now the message class ambiguous references and I need both the using statements. What can I do now?
the error message is:
"'Message' is an ambiguous reference between 'Microsoft.Azure.Devices.Client.Message' and 'Microsoft.Azure.Devices.Message'"
The code is:
using System;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices;
using Microsoft.Azure.Devices.Shared;
using Microsoft.Azure.Devices.Provisioning.Client;
using Microsoft.Azure.Devices.Common.Exceptions;
using Microsoft.Azure.Devices.Provisioning.Client.Transport;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
the message class is used as shown here:
var message = new Message(Encoding.ASCII.GetBytes(messageString));
I tried using Client.Message, but it does not work. I use python and am new to c# and am not sure how it works.
Can somebody explain in some detail, the solution?
"'Message' is an ambiguous reference between 'Microsoft.Azure.Devices.Client.Message' and 'Microsoft.Azure.Devices.Message'"
It means that both Microsoft.Azure.Devices.Client and Microsoft.Azure.Devices have a class called Message; you've imported both namespaces so C# is no longer certain what you mean when you say Message
Either remove one of the namespaces, or fully qualify Message by adding the full namespace before the name, depending on which Message class you intend to use (I can't tell either, because both of them have constructors that take a byte)
var cmessage = new Microsoft.Azure.Devices.Client.Message(...);
var dmessage = new Microsoft.Azure.Devices.Message(...);
If you'll be typing either of them a lot, you can use an alias for one or the other (if you stop importing one namespace because all you needed out of it is the message class) or both (if you carry on importing both namespaces):
using ClientMessage = Microsoft.Azure.Devices.Client.Message;
using DeviceMessage = Microsoft.Azure.Devices.Message;
Then you can say:
var cmessage = new ClientMessage(...);
var dmessage = new DeviceMessage(...);

How to change State/Status in CRM 2013 using c#

How do I change State and/or Status of an entity in CRM 2013 using C#?
Neither CRM 2011's SetStateRequest nor the earlier SetStateDynamicEntityRequest are being recognized.
Searching online didn't seem to help either... Am I missing a namespace or something?
Thanks in advance
Namespaces:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Discovery;
using Microsoft.Xrm.Sdk.Messages;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Web.Services.Protocols;
The function:
private void changeUserStatus(Guid userId, IOrganizationService service, int state)
{
SetStateRequest setStateRequest = new SetStateRequest
{
EntityMoniker = new EntityReference("systemuser", userId),
State = new OptionSetValue(state),
Status = new OptionSetValue(-1),
};
service.Execute(setStateRequest);
}
IMPORTANT: My SetStateRequest is NOT recognized by visual studio 2012, so unlike the above example it's not highlighted and actually red underlined with the "the type or namespace not found" message displayed when hovering
Edit: I see the question got downvoted and I'm sorry if I'm missing something but I really have no more information to provide apart from the fact that I've spent 4 hours yesterday looking for this online (including stackoverflow) without any avail. I may be using the wrong search criteria or looking in the wrong places, but if that's the case could anyone at least point me in the right direction? I'm a beginner on all of this (both stackoverflow and crm2013) and I'm kind of stuck on this. Thanks again
You are not referencing microsoft.crm.sdk.proxy.dll and its namespace Microsoft.Crm.Sdk.Messages
so the code will be
using Microsoft.Crm.Sdk.Messages;
Another thing, be sure that the int values for State and Status are valid for the entity (in your case systemuser)

Take String from Clipboard? No assembly reference?

If the current (most recent) item in the clipboard is a string, I want to take the string from the clipboard, and put each word in an array (just a simple loop which eliminates spaces and newlines, to take just words from the string). Then I simply want to print each item in the array (let's say each separated by a newline for testing purposes) to the terminal.
This is super easy, simple, etc. My trouble is that I cannot seem to find/use the Clipboard class that is built in to C#! Here is what I am using as my assembly references:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Object;
using System.Windows.Clipboard;
Note that the System.Windows.Clipboard; gets a red underline, because it is not lining up. Why could this be? http://msdn.microsoft.com/en-us/library/system.windows.clipboard.aspx shows the clipboard class information.
It's probably a fault on my end, but is it otherwise possible I have not set my paths correctly or something? I just installed Visual Studio 2012 For Desktop SP3 (although, I have had VS2012 for Web for quite some time, and it works properly).
System.Windows.Clipboard is a class and not a namespace, there is no point putting a class into a using directive.
The compiler error message should tell you the same.
First of all you must add a reference to System.Windows.Forms in your application. Go to Project -> Add reference, select System.Windows.Forms from .NET tab in the window that just opened. You must avoid the ThreadStateException by applying the STAThread attribute to your Main() function. Then you can use the Clipboard functions without any problems.
using System;
using System.Windows.Forms;
class Program {
[STAThread]
static void Main(string[] args) {
Clipboard.SetText("this is in clipboard now");
}
}
i hope this will help you
http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/
it shows how to use the Clipboard functions in C# console application
You don't need this line: using System.Windows.Clipboard; using statements are for namespaces, and Clipboard is a class. That class is provided from the assembly PresentationCore.dll, and since you have WPF project, your project already has a reference to it.
You should have reference to System.Windows namespace only it has Class Clipboard in it.
You can set and get data from there
System.Windows.Clipboard.SetData();
You'll need a namespace declaration:
using System.Windows.Forms;
OR for WPF:
using System.Windows;
To copy an exact string
var dataObject = System.Windows.Clipboard.GetDataObject();
string text= dataObject.GetData("UnicodeText", true).ToString();

Not able To find A Class in A namespace In c#

I am extracting images from pdf in c#.
Someone has suggested that use Aspose namespace which is a third party namespace.
I have downloaded the aspose and included in my project as a reference.But the problem is i am not able to find the class PdfExtractor which is used to extract images.
I am sharing the link in which some one has suggested to use aspose and also sharing my code.
This is a link
and my code in which i just include aspose
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Aspose;
using Aspose.Pdf;
using Aspose.Pdf.Devices;
using Aspose.Pdf.DOM;
using Aspose.Pdf.Generator;
using Aspose.Pdf.InteractiveFeatures;
using Aspose.Pdf.Structure;
using Aspose.Pdf.Text;
namespace Imageget
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
And The class which is suggested in the link is PdfExtractor i am also sharing its code below so one can not waste his time to go to link.
PdfExtractor objExtractor = new PdfExtractor();
//bind input pdf file
objExtractor.BindPdf("input.pdf");
//extract image with specific mode
objExtractor.ExtractImage(ExtractImageMode.Default);
//check if images extracted and save them one by one
while (objExtractor.HasNextImage()) {
objExtractor.GetNextImage(DateTime.Now.Ticks.ToString() + ".jpg");
}
A first sight at google told me that you might need to add namespace:
Aspose.Pdf.Facades
Check out here and see the tree at the left.
and don;t forget to look at my comment at the top, it always help to find the namespace of class if i am unable to find it.
hope it helps!

How can I learn Enterprise Library 4.0?

I'm trying to learn the Enterprise Library. I found this useful code sample to get data from a SQL database. But I tried to send data via a parameter. I'm also using the UPDATE, DELETE, and SAVE methods. Can you give me a similar sample? I'm using Enterprise Library 4.0.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
namespace WebApplicationForEnterpirires
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Database objdbase = DatabaseFactory.CreateDatabase("connectionString");
DataSet ds = objdbase.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetProducts");
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
}
You might find these handy
http://msdn.microsoft.com/en-us/magazine/cc188705.aspx
http://msdn.microsoft.com/en-us/magazine/cc188702.aspx
and this >>one<< which targets your situation directly (I think). Although I think what you want to do there, is pass the DbCommand object into your ExecuteDataSet method.
First of all. Go to Microsoft download center for downloading Hand-on Labs. The Hand-on Labs has all you need in side (tutorial doc, sample code, exercise...etc). Just follow each steps with tutorial of every block. Then you could totally understand how to use the Enterprise Library in just few days.
Also, check out the new Developer's Guide. It incldues code sampels in both C# and VB.
Happy learning!
Have you tried this. This gives an example on how you can use the enterprise lib. to get DataSet passing a parameter.

Categories