|
From what I've seen (in the last five minutes, by Googling 'HL7' and 'HL7 PID' - you have heard of Google, I presume), each message segment is on a separate line. Each segment consists of fields separated by a '|' character. This page[^] defines the PID segment. This page[^] defines the data type of a person name.
So - you're looking for a line starting 'PID'. Now look through that line for '|' characters. The patient name is between the 5th and 6th '|'.
I'd probably use a regex, like:
^PID(\|[^|]*){4}\|([^|]+)\|.+$
so the patient name field ends up in match #2. With Boost.Regex, this looks like this (using an example message segment I found on the web):
boost::regex rePID("^PID(\\|[^|]*){4}\\|([^|]*)\\|.*$");
boost::smatch match;
if (boost::regex_match(std::string("PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOPE^JOHN^^^^|19480203|M||B|254 E238ST^^EUCLID^OH^44123^USA||(216)731-4359|||M|NON|400003403~1129086|"),
match, rePID))
{
std::cout << match[2] << endl;
}
else
{
cerr << "No match" << endl;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
in VC++, is there any boost::regex class or namespace?
sorry, but i am not getting what u r written.
|
|
|
|
|
Boost is a third-party set of libraries - see Boost[^] and Boost.Regex[^].
If you're using VC++ 2008, you should have regular expressions in std::tr1::regex[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
what it means:-
boost::regex rePID("^PID(\\|[^|]*){4}\\|([^|]*)\\|.*$");
and in if condition
if (boost::regex_match(std::string("PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOPE^JOHN^^^^|19480203|M||B|254 E238ST^^EUCLID^OH^44123^USA||(216)731-4359|||M|NON|400003403~1129086|"),
match, rePID))
{
std::cout << match[2] << endl;
}
|
|
|
|
|
Abhijit D. Babar wrote: boost::regex rePID("^PID(\\|[^|]*){4}\\|([^|]*)\\|.*$");
That's declaring a regular expression object. I'm not even going to try explaining what regex syntax is - I presumed that as you used the word 'parse' you'd have some appreciation of regular expressions - have a look at some[^] regex[^] tutorials[^].
Abhijit D. Babar wrote: if (boost::regex_match(std::string("PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOPE^JOHN^^^^|19480203|M||B|254 E238ST^^EUCLID^OH^44123^USA||(216)731-4359|||M|NON|400003403~1129086|"),
match, rePID))
{
std::cout << match[2] << endl;
}
Does the regex in rePID match the string I provided? If so, then the patient name is in the second regex capture, which can be accessed using match[2].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thanks for your reply.
This method works fine. Like this, instead of doing coding is there any free Toolkit which give directly the segment or data field user want? Because we can parse message as you show above, but it is very complex to make string for every data filed and in future if HL7 message format will change, we have to change our code syntax also. So if inbuilt parser or toolkit is available then i think work will be more simple.
Thanks in advance....
modified on Saturday, April 18, 2009 9:15 AM
|
|
|
|
|
Abhijit D. Babar wrote: This method works fine. Like this, instead of doing coding is there any free Toolkit which give directly the segment or data field user want?
I seem to remember mentioning Google[^] before...didn't sink in, did it.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello guys,
I want to split a string into substrings using strtok(). The code is
#include "stdafx.h"
#using <mscorlib.dll>
#include <iostream>
#include <string>
#include <stdio.h>
using namespace System;
using namespace std;
char str2list(char* str, char** list, const char* delimiters)
{
for (char c = 0; c < sizeof(list) / sizeof(char*); c++)
{
list[c] = strtok(str, delimiters);
if (list[c] == NULL) break;
}
return c;
}
int _tmain()
{
char** arglist;
arglist = new char*[16];
char* exmp = "I have a problem!";
str2list(exmp, arglist, " ");
for (char c = 0; c < sizeof(arglist) / sizeof(char*); c++)
{
cout << arglist[c] << endl;
}
delete[] arglist;
return 0;
}
</stdio.h></string></iostream></mscorlib.dll>
When I try to execute the program a runtime error occurs saying that there is a null-reference exception in the line list[c] = strtok(str, delimiters); . To ensure that there is enough free memory I even used the new operator.
Does anyone have an idea why this doesn't work?
Thanks and best wishes.
|
|
|
|
|
Austrian_Programmer wrote: When I try to execute the program a runtime error occurs saying that there is a null-reference exception in the line list[c] = strtok(str, delimiters);. To ensure that there is enough free memory I even used the new operator.
That's because (although exmp is a char* ), it's pointing at a string stored in read-only memory (string literals are read-only). strtok needs to write to it. It can't, so you get a runtime exception. Change
char* exmp = "I have a problem!";
to
char exmp[] = "I have a problem!";
and the crash goes away, because now you've allocated a read/write character array and initialised it from the (read-only) string literal.
There are many other issues as well, however:
- Look at the
strtok documentation[^] - you only pass in str on the first call to strtok for that string - the rest of the time, you pass in NULL . - The loop condition in
str2list is all wrong. list is a char** , so sizeof(list)/sizeof(char*) will be equal to 1. If you want to be safe with respect to the size of list , you need to explicitly pass it in - C/C++ doesn't pass around array sizes with arrays. - Similarly, the loop condition in _tmain is wrong (although this problem goes away if you take note of the next point).
- There's no point using
new when you have a fixed array size - declaring arglist with char* arglist[16]; will work just as well. - I'm...interested that you use
char as the type of the loop variables - Although the for loop in
str2list may compile with the compiler you're using, it won't with VS2008 (and possibly won't with earlier compilers), and isn't compliant with the C++ standard - going by the standard, your loop variable isn't accessible outside the loop. - You return the number of tokens in the list from
str2list ...and then don't use it. Mmmmm.
Anyway - here's my fixed (I think) version of your code.
#include <iostream>
#include <string.h>
using namespace std;
int str2list(char* str, char** list, int maxTokenCount, const char* delimiters)
{
for (int c = 0; c<maxtokencount;> {
list[c] = strtok(str, delimiters);
if (list[c] == NULL) return c;
str = 0;
}
}
int main()
{
char* arglist[16] = {0};
char exmp[] = "I have a problem!";
const int numToks = str2list(exmp, arglist, 16, " ");
for (int c = 0; c < numToks; c++)
{
cout << arglist[c] << endl;
}
return 0;
}
[edit]Just for laughs, I did a version using STL and C++ classes, for those of us who like type-safety and nice things like that. It is special cased for the situation where the separator is a space (you can alter that by playing with locales and facets, but that's an exercise for the reader), but anyway.
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;
vector<string> split(string const& exmp)
{
istringstream s(exmp);
return vector<string>(istream_iterator<string>(s), istream_iterator<string>());
}
int main()
{
string exmp = "I have a problem!";
const vector<string> toks = split(exmp);
copy(toks.begin(), toks.end(), ostream_iterator<string>(cout, "\n"));
return 0;
} [/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
modified on Saturday, April 18, 2009 11:11 AM
|
|
|
|
|
Thanks for the answer.
I've done a lot of microprocessor programming in the last time and there I use char whenever possible (it's the smallest type and working without causing any troubles). However, that's pure C and there are (I know) a few differences to C++. Normally I use C++ for game programming and mathematical things and that's more or less the first time I do something with strings in C++, so this is all in all just a try.
|
|
|
|
|
Austrian_Programmer wrote: Normally I use C++ for game programming and mathematical things and that's more or less the first time I do something with strings in C++, so this is all in all just a try.
That's cool - if you're starting out with C++ on a desktop platform, I really would recommend learning about the Standard Template Library - it makes (some) things a lot easier, especially managing strings and arrays (or vectors, which is the closest thing to an array in STL)..
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
What technologies/libraries/protocols I need to study to develop a video system similar to skype or
MSN messenger? I prefer coding in C++.
To be more specific:
How do I capture the video feed from the webcam? And how do I play it back?
How do I capture sound? And how do I play it back?
How do I stream it over the internet? Do I use sockets?
|
|
|
|
|
Hiigara wrote: What technologies/libraries/protocols I need to study to develop a video system
SIP & RTP is common protocol for VoIP. That so many system follows. Skype is more sophisticated peer to peer protocol.
If you are looking for developing server for video conferencing then there is already open source Voip server called Asterisk[^].
Hiigara wrote: I prefer coding in C++.
C++ is good to work if you choose java then java (Java Media Framework) give you more easy API to handle video/audio streaming.
I have no knowledge of .Net technology.
For more detail of Viop software & library you can refer here[^].
Do not trust a computer...
Always check what computer is doing
regards,
Divyang Mithaiwala
Software Engineer
modified on Saturday, April 18, 2009 1:49 AM
|
|
|
|
|
DirectShow in the Windows SDK.
XAudio/Dsound in the DirectXSDK
or you can just use a plain WaveIn/Out API to record the sound for you.
Yes, you need sockets.
|
|
|
|
|
I have an application that uses a ISA card to control motion of flight simulator. The ISA card is controlled by C++ classes inside MFC Application. I recently decide to package the ISA card C++ control class into it's own DLL. This will enable me to use other manufacture motion cards at a later date. However, After placing the code into a DLL and change the application to load the library DLL and at start up. I find the application is not performing as fast as it use to? How much overhead does a DLL really add? Is it possible that DLL is my problem here? Where does the dll get it's runtime priority? Is it from the calling appication or do i have to sent it myself.
Scott
732-300-9956
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
ScotDolan wrote: Where does the dll get it's runtime priority? Is it from the calling appication or do i have to sent it myself.
DLLs don't have a priority - threads and processes do. So, yes, the priority of the DLL's code will come from the calling app.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
if your program's performance isn't what it used to be, then you must have changed something. Assuming all the functions and data structures remained the same, it must be related to compiler/linker settings, e.g. maybe your EXE was and still is optimized, but your new DLL is not? I suggest you compare the DLL settings with the current or previous EXE settings.
|
|
|
|
|
Hello everyone. I come from a Delphi background to VC++ 2008. I have searched the board and articles for my "problem" but to no avail. I hope someone out there can help me with this even tho it may sound like a very dumb question. The entire problem could probably be resolved with a different approach but this is what I have so far so feel free to modify/suggest whatever you feel may help.
1. after a button is clicked, a do ... while loop is started
2. in the middle of the loop, webBrowser is "told" to do a webBrowser->Navigate
3. an url keeping variable is updated by incrementing one of the integers needed to get the right url
4. integer variable is incremented
5. loop keeps going up and webBrowser navigates again (this time to a different address) until the integer variable = user specified number
This loop can, based on user input, be executed 10+ times or so, basically telling the webbrowser to navigate to 10 different urls.
The problem is - the loop will prevent the webbrowser to fully finish loading the site and at the end it manages to navigate to 1 url only.
I understand that I need to use the DocumentCompleted event on the webBrowser.
The question is: how do I combine the loop with the event?
Is there backgroundworker or some other component I should use?
I hope I provided enough info for the answer. Feel free to ask for more details/code if needed.
|
|
|
|
|
You're going to be hosting the web browser in some window - a dialog or a view. You'll need a class for that window. Add a method to construct the url and tell the web browser to navigate to the url. Call that method from your dialog's OnInitDialog method (presuming you're using a dialog). Add the counter as a private data member of that class. Increment the counter in the DocumentCompleted event handler and call the navigate method you wrote earlier from there (as well as from OnInitDialog). The while loop is effectively subsumed into the window's message loop.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you very much.
I did as you said and I got what I was looking for.

|
|
|
|
|
Excellent! That's always the desired outcome
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
Just so that I understand the dervied base concept
Is the only difference between these 2 peices of code the way the code is executed
and Storage lay'ed out
class A : public B, C
{
}
class A
{
class B;
class C:
}
In this first case base class B gets created then C the dervied class A
in the second A gets created then B then C
functionally these 2 peices of code couls act alike ???
thankx
|
|
|
|
|
There's a big difference between multiple inheritance and nested class definition (BTW your second piece of code as it stands would hardly compile), I believe.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ForNow wrote: Just so that I understand the dervied base concept
Your understanding is not accurate/complete. Again, I strongly urge you to do more studying starting with materials that are targeting beginners.
|
|
|
|
|
thought I did apperantly not I have been using Bjarne Stroustrup Book
seems like the best one I'll do more reading
|
|
|
|
|