How to create a valid OBX segment in java using HAPI? - java

I want to generate just the OBX segment in a HL7 message in this format.
OBX|6|CE|59783-1^Status in immunization series^LN|**5**|||||||F
where no. 5 is the Series no.
problem is when ever I try to decode this line with a HL7 decoder. it results in something like this.
Vaccine funding program eligibility category
V07 - VFC Eligibility-Local-specific Eligibility
Vaccine purchased with
null -
vaccine type
107 - DTaP
Date vaccine information statement published
-
Date vaccine information statement presented
-
Status in immunization series
Here is my source code:
obx.getSetIDOBX().setValue(String.valueOf(obxSetId));
obx.getValueType().setValue("CE");
obx.getObservationIdentifier().getIdentifier().setValue("59783-1");
obx.getObservationIdentifier().getText().setValue("Status in immunization series");
obx.getObservationIdentifier().getNameOfCodingSystem().setValue("LN");
obx.getObservationSubID().setValue(String.valueOf(immunizationData.getSeries().toString()));
obx.getObservationResultStatus().setValue("F");
where obx is the reference to the OBX jar in hapi structures.

I suspect that the receiver of the message is complaining about the missing observation value (OBX.5). You specified a data type for the observation value (value type, OBX.2), but OBX.5 in your message does not contain a value of data type CE - it is empty.

Related

Read a text File which has numeric columns (like -10.0, -9.9, +9.9 etc.) through Apache Flink

I have requirement where I need to read a file which is generated by another application and file has 201 numeric column name like: -10.0, -9.9, -9.8, -9.7 .......0.....+9.7, +9.8, +9.9, +10.0 so total I have 201 columns in the file. I am reading many files through Flink but file has string type column name and I am creating an model Object with the attributes as columns name available in file as below
DataSet<Person>> csvInput = env.readCsvFile("file:///path/to/my/textfile")
.pojoType(Person.class, "name", "age", "zipcode");
above code will ready file and Person object will be populated with the values available in the File.
I am facing challenge in new requirement where file columns name is numeric and in Java I cannot create a variable with numeric value along with decimal like -10.0 etc.
like private String -10.0 not allowed in java
I am seeking for a solution, could any one please help me out here.

How to use Binance API, simple GET price by ticker

I would like to get only one pair from the response. And I can't really understand how I should pass my parameter.
Instructions say:
Symbol price ticker
GET /api/v3/ticker/price
Latest price for a symbol or symbols.
Weight: 1 for a single symbol; 2 when the symbol parameter is omitted
Parameters:
Name Type Mandatory Description
symbol STRING NO -
If the symbol is not sent, prices for all symbols will be returned in an array."
I'm able to get all symbols in the response body, but can't get a single one.
I have already tried (in Postman) these endpoints:
https://api.binance.com/api/v3/ticker/price/btcusdt
https://api.binance.com/api/v3/ticker/price/symbol=btcusdt
https://api.binance.com/api/v3/ticker/price/?symbol=btcusdt
Here is the link to entire API:
https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#24hr-ticker-price-change-statistics
So, which endpoint is correct? postman result
https://api.binance.com/api/v3/ticker/price/?symbol=btcusdt
You must use Query without /
and Binance's /api/v3/ticker/price endpoint need symbol query as Upper case.
so you must request as below
https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT
You can you this API link to get all pairs only current price and symbols:
https://www.binance.com/api/v3/ticker/price
This for specific symbol and price:
https://www.binance.com/api/v3/ticker/price?symbol=BNBBTC
This for all pairs with full info:
https://api.binance.com/api/v3/exchangeInfo
This for 1 pair full info:
https://api.binance.com/api/v3/exchangeInfo?symbol=BNBBTC
Here is Binance API Detail pages:
https://binance-docs.github.io/apidocs/spot/en
https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md
Is there a chance to send more queries at once like for example
BTCUSDT and ETHUSDT ?
When I am trying various combinations I get a reply of:
{"code":-1104,"msg":"Not all sent parameters were read; read '1' parameter(s) but was sent '2'."}

How to convert string to MarketDataIncrementalRefresh in QUICKFIX in Java?

I am working on the Stock and Exchange Markets. I have a situation like : I need to take a string from the log and convert it to "Message" type Object. As per this link I have tried using all the three methods of the "MessageUtils" class in JAVA. But my String is being stripped to a Message class type object with unique tags. But as my string is "MarketDataIncrementalRefresh" type I want each every tag to be present in the Message.
For example : I am providing the following string to "MessageUtils.parse()" method.
8=FIX.4.2|9=00795|35=W|49=TT_PRICE|56=SAP0094X|34=2392|52=20170623-04:41:33.375|55=CL|48=00A0HR00CLZ|10455=CLQ7|167=FUT|207=CME|15=USD|262=MDRQ-751|200=201708|18210=1|387=12292|268=24|269=0|290=1|270=4290|271=33|269=0|290=2|270=4289|271=34|269=0|290=3|270=4288|271=40|269=0|290=4|270=4287|271=38|269=0|290=5|270=4286|271=46|269=0|290=6|270=4285|271=53|269=0|290=7|270=4284|271=46|269=0|290=8|270=4283|271=66|269=0|290=9|270=4282|271=48|269=0|290=10|270=4281|271=64|269=1|290=1|270=4291|271=21|269=1|290=2|270=4292|271=40|269=1|290=3|270=4293|271=48|269=1|290=4|270=4294|271=83|269=1|290=5|270=4295|271=62|269=1|290=6|270=4296|271=46|269=1|290=7|270=4297|271=34|269=1|290=8|270=4298|271=55|269=1|290=9|270=4299|271=31|269=1|290=10|270=4300|271=128|269=2|270=4291|271=1|269=4|270=4280|269=7|270=4292|269=8|270=4277|10=044|
But what I am getting is this:
8=FIX.4.2|9=192|35=W|34=2|49=TT_PRICE|52=20170622-14:16:23.685|56=SAP0094X|15=USD|48=00A0HR00GCZ|55=GC|167=FUT|200=201708|207=CME|262=MDRQ-21|268=25|269=0|270=12510|271=24|290=1|387=121890|10455=GCQ7|18210=1|10=036|
As you can observe only unique tags are present in the String. But I want each and every tag , no matter how many times it exists in the provided string.
Please can anyone help me doing this in JAVA. It will be really appreciable.
Below is the code I am using for converting :
MessageUtils mu = new MessageUtils();
Session session = Session.lookupSession(sessionID);
Message msg = MessageUtils.parse(new DefaultMessageFactory(), null, str);
// Message msg = new Message(str, false); //This can also be used for converting
System.out.println(msg.toString());
The other thread says:
MessageUtils.parse(MessageFactory messageFactory, DataDictionary dataDictionary, java.lang.String messageString)
And your code says:
Message msg = MessageUtils.parse(new DefaultMessageFactory(), null, str);
So you need to fix your data dictionary and pass it to the parse method instead of passing 'null'
I think the problem is as follows. There's a repeating group that starts with tag 286 (NoMDEntries). The order of fields in a repeating group should be strict, i.e. the same order as the definition of the repeating group. See Market Data - Snapshot/Full Refresh or the data dictionnary supplied by QuickFIX/J (FIX42.xml).
The 268 tag should be followed by 269 and then 270. I am seeing in your message string: |268=24|269=0|290=1|270=4290| which is the incorrect order of tags. That is probably the reason why the message is truncated by MessageUtils.parse.
As a test you could try to manually correct the order in the string and try parsing that to see if that gives the correct message.

How to get a CardHolder Name

I am trying to read a smart card and i have been able to get some data from the smart card. The issue i am facing now is how to get the CardHolder name from the smart card.
i have
if(emv_is_tag_present(0x5F20) >=0){
tagDataLength = emv_get_tag_data(0x5F20, tagData, tagData.length);
if(debug)Log.d(APP_TAG, "Carder "+ tagDataLength);
appState.trans.setuserName(StringUtil.toString(AppUtil.removeTailF(ByteUtil.bcdToAscii(tagData,0, tagDataLength))));
}
I do not really know the format to use in getting this field from the card while trying to use 5F20 Cardholder Name Indicates cardholder name according to ISO 7813 Card ans 2-26 '70' or '77' 2 26 primitive which i got from here
This is the output i am getting 3030303030333830D160222101..but, whenever i try to convert that into a String...it gives back 00000380Ñ`"! which is not really the name of the Cardholder.
Reading through the document (which link is posted there), i am not sure if i am using the correct format in getting my data. cos, in the document, i have ans 2-26. I do not really understand what it means.
Tag 5F20 - CARD HOLDER NAME, if CARD returning the value of this tag, value will be hex string - Hex value of ASCII characters , what you need to do is to convert value to string and you will get the value personalized in the card.
in the document, i have ans 2-26. I do not really understand what it means.
sometimes we avoid to personalize card holder name inside the card and then we personalize " /" - space followed by / = 2 char. It is the minimum value for tag 5F20 defined in different EMV specification. Max value is 26 therefore 2-26 used for Tag 5F20.
Hope this information will help you..

Extracting packed data using regular expressions

I have data in a database in the format below:
a:19:{s:9:"raceclass";a:5:{i:0;a:1:{i:0;s:7:"250cc B";}i:1;a:1:{i:1;s:6:"OPEN B";}i:2;a:1:{i:2;s:9:"Plus 25 B";}i:3;a:1:{i:3;s:8:"Vet 30 B";}i:4;a:1:{i:4;s:7:"Vintage";}}s:9:"firstname";a:1:{i:0;a:1:{i:0;s:5:"James";}}s:12:"middle_FIELD";a:1:{i:0;a:1:{i:0;s:1:"R";}}s:8:"lastname";a:1:{i:0;a:1:{i:0;s:9:"Slaughter";}}s:5:"email";a:1:{i:0;a:1:{i:0;s:29:"jslaughter#xtrememxseries.com";}}s:8:"address1";a:1:{i:0;a:1:{i:0;s:18:"21 DiMartino Court";}}s:4:"city";a:1:{i:0;a:1:{i:0;s:6:"Walden";}}s:5:"state";a:1:{i:0;a:1:{i:0;s:8:"New York";}}s:3:"zip";a:1:{i:0;a:1:{i:0;s:5:"12586";}}s:7:"country";a:1:{i:0;a:1:{i:0;s:13:"United States";}}s:6:"gender";a:1:{i:0;a:1:{i:0;s:4:"Male";}}s:3:"dob";a:1:{i:0;a:1:{i:0;s:10:"06/04/1974";}}s:5:"phone";a:1:{i:0;a:1:{i:0;s:12:"845-713-4421";}}s:5:"skill";a:1:{i:0;a:1:{i:0;s:12:" AMATEUR (B)";}}s:11:"ridernumber";a:1:{i:0;a:1:{i:0;s:2:"69";}}s:8:"bikemake";a:1:{i:0;a:1:{i:0;s:3:"HON";}}s:8:"enginecc";a:1:{i:0;a:1:{i:0;s:3:"450";}}s:9:"amanumber";a:1:{i:0;a:1:{i:0;s:7:"1094649";}}s:10:"amaexpdate";a:1:{i:0;a:1:{i:0;s:5:"03/12";}}}
How can I write a regular expression to manipulate the above string to get data in the following format?:
raceclass - 250cc B, OPEN B, Plus 25 B, Vet30, Vintage
firstname - James
middle_FIELD - R
address1 = 21 DiMartino Court
city - walden
state - New york
zip - 12586
country - United States
gender - Male
dob - 06/04/1974
phone - 845-713-4421
skill - AMATEUR (B)
ridernumber - 69
bikemake - HON
enginecc - 450
amanumber - 1094649
amaexpdate - 03/12
This data isn't suitable for a regular expression. You should use a proper parser with a proper grammar for handling this string. There are several good options for that in Java, such as ANTLR.
Alternatively, if that is not an option it looks like you only want to handle things between "". Take a look at the java class Scanner. You should be able to get something working with that. Just look through the string and look for a ". If found start to gather text into a buffer. Once you have found another " ignore tokens until you have found the next " or the end of the input text.

Categories