i'm trying to find, is there any library available that convert NCPDP format message to XML format in java?. In Mirth Connect tool, there's direct option to convert NCPDP to XML using this lines:
var serializationProperties = SerializerFactory.getDefaultSerializationProperties('NCPDP');
SerializerFactory.getSerializer('NCPDP', serializationProperties, null).toXML(ncpdpmessage);
and Mirth Connect giving this functionality, so they have use some api or library in backend to convert NCPDP to XML. i want to do same, but in java.
Any help appreciated.
Mirth Connect uses its own implementation of NCPDP serializer. You may find it in datatype-ncpdp-shared.jar in the \extensions\datatype-ncpdp folder.
In short, the NCPDPSerializer.toXml() code does the following:
NCPDPReader ncpdpReader = new NCPDPReader(serializationSegmentDelimiter, serializationGroupDelimiter, serializationFieldDelimiter);
StringWriter stringWriter = new StringWriter();
XMLPrettyPrinter serializer = new XMLPrettyPrinter(stringWriter);
ncpdpReader.setContentHandler(serializer);
ncpdpReader.parse(new InputSource(new StringReader(source)));
return stringWriter.toString();
So if you want to utilize the same you probably need all other related Mirth libraries. Since NCPDPReader extends SAXParser and does not rely on any other Mirth packages you may try to build your own library based on that. (Check copyrights and license notes before you start doing so.) You may also try to find other NCPDP Java parser such as JParser.