本文整理汇总了Java中ca.uhn.hl7v2.parser.Parser.parse方法的典型用法代码示例。如果您正苦于以下问题:Java Parser.parse方法的具体用法?Java Parser.parse怎么用?Java Parser.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca.uhn.hl7v2.parser.Parser
的用法示例。
在下文中一共展示了Parser.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
@Override
public void init(String hl7Body) throws HL7Exception {
if (hl7Body.startsWith("MSH")) {
int index = 0;
for (int i = 0; i < 11; i++)
index = hl7Body.indexOf('|', index + 1);
int tmp = index + 1;
String tmph = hl7Body.substring(0, tmp);
index = hl7Body.indexOf('|', index + 1);
if (hl7Body.substring(tmp, index).trim().length() == 0)
hl7Body = tmph + "2.3" + hl7Body.substring(index);
}
Parser p = new PipeParser();
p.setValidationContext(new NoValidation());
msg = (ORU_R01) p.parse(hl7Body.replaceAll("\n", "\r\n"));
}
示例2: invalidMessageReutrnsApplicationReject
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
@Test
@Ignore
@DirtiesContext
public void invalidMessageReutrnsApplicationReject() throws Exception {
standardHL7XMLEndpoint.expectedMessageCount(1);
t5XMLEndpoint.expectedMessageCount(1);
String invalidHL7Input = "MSH|^~\\&|SendingApplication|SendingFacility|ReceivingApplication|ReceivingFacility|20120530112345||ORU^R01^ORU_R01|9879790003|P|2.6|||NE|AL|USA|ASCII|EN^English^ISO639||IHE_PCD_ORU_R01^IHE PCD^1.3.6.1.4.1.19376.1.6.1.1.1^ISO\n"
+ "PID|||HO2009001^^^NIST^PI||Hon^Albert^^^^^L|Adams^^^^^^L|19610101|M|||15 N Saguaro^^Tucson^AZ^85701\n"
+ "PV1||I|ICU^2^23\n"
+ "OBR|1|||44616-1^Pulse oximetry panel ^LN|||20120512031234||||||||||||||||||F|||||||||||||||||||252465000^Pulse oximetry^SCT|7087005^Intermittent^SCT\n"
+ "NTE|1||This comment refers to all the results in the battery\n"
+ "OBX||||||35-125||99||R|||20120530112340|||AMEAS^auto-measurement^MDC|0123456789ABCDEF^Pulse_Oximeter_Vendor_X^0123456789ABCDEF^EUI-64||49521004^left ear structure^SCT\n"
+ "NTE|1||This is a comment about pulse";
String response = minaTemplate.requestBody((Object)invalidHL7Input, String.class);
Parser parser = new PipeParser();
ACK responseMessage = (ACK)parser.parse(response);
assertEquals(AcknowledgmentCode.AR.name(), responseMessage.getMSA().getAcknowledgmentCode().getValue());
}
示例3: validMessageIsConverted
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
@Test
public void validMessageIsConverted() throws Exception {
@SuppressWarnings("resource")
HapiContext context = new DefaultHapiContext();
context.setModelClassFactory(new DefaultModelClassFactory());
Parser parser = context.getPipeParser();
ORU_R01 originalMessage = (ORU_R01) parser.parse(hl7Input);
Document xmlDocument = converter.getXML(originalMessage);
XMLHelper.prettyPrintDocument(xmlDocument, System.out);
assertEquals(
"1.11.2.3",
stringXPath(
"/t5:PCD_01_Message/Patient_Result/Order_Observations/MDS/VMD/CHAN/Metric/Observation/@hierarchy",
xmlDocument));
}
示例4: parseACKError
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
private String parseACKError(String response) throws HL7Exception {
Parser parser = new GenericParser();
Object parsedMsg = parser.parse(response);
if (!(parsedMsg instanceof ACK)) {
return "Message response received in unsupported format: " + parsedMsg.getClass();
}
ACK msg = (ACK)parsedMsg;
if (msg.getMSA()!=null && msg.getMSA().getAcknowledgmentCode()!=null &&
"AA".equalsIgnoreCase(msg.getMSA().getAcknowledgmentCode().getValue())) {
return null;
}
String err = "Failed to register new patient:\n";
if (msg.getERR()!=null && msg.getERR().getErr3_HL7ErrorCode()!=null) {
if (msg.getERR().getErr3_HL7ErrorCode().getCwe1_Identifier()!=null) {
err += msg.getERR().getErr3_HL7ErrorCode().getCwe1_Identifier().getValue() + "\n";
}
if (msg.getERR().getErr3_HL7ErrorCode().getCwe2_Text()!=null) {
err += msg.getERR().getErr3_HL7ErrorCode().getCwe2_Text().getValue() + "\n";
}
}
return err;
}
示例5: read
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
/**
* Reads an ORU_R01 HL7 file
*
* @param text
* ISO-8559-1 String
* @param readWithValidation
* True for parsing with validation, False for parsing without validation
* @return The ORU_R01 message
* @throws HL7Exception
*/
public ORU_R01 read(String text, boolean readWithValidation) throws HL7Exception{
Parser p = new PipeParser();
if (readWithValidation) {
p.setValidationContext(new ElexisValidation());
} else {
p.setValidationContext(new NoValidation());
}
Message hl7Msg = p.parse(text);
if (hl7Msg instanceof ORU_R01) {
return (ORU_R01) hl7Msg;
} else {
addError(MessageFormat.format(
Messages.getString("HL7_ORU_R01.Error_WrongMsgType"), hl7Msg.getName())); //$NON-NLS-1$
}
return null;
}
示例6: init
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
@Override
public void init(String hl7Body) throws HL7Exception {
// if (hl7Body.startsWith("MSH")) {
// int index = 0;
// for (int i = 0; i < 11; i++) {
// index = hl7Body.indexOf('|', index + 1);
// }
// int tmp = index + 1;
// String tmph = hl7Body.substring(0, tmp);
// index = hl7Body.indexOf('|', index + 1);
// if (hl7Body.substring(tmp, index).trim().length() == 0) {
// hl7Body = tmph + "2.3" + hl7Body.substring(index);
// }
// }
Parser p = new PipeParser();
p.setValidationContext(new NoValidation());
hl7Body=hl7Body.replace("|P||", "|P|2.3|"); //If there is no version code in MHL lab hl7 file, add default 2.3 here. Otherwise it will fail on parsing.
msg = (ORU_R01) p.parse(hl7Body.replaceAll("\n", "\r\n"));
}
示例7: init
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
public void init(String hl7Body)
throws HL7Exception
{
Parser p = new PipeParser();
this.msg = ((ORU_R01)p.parse(hl7Body.replaceAll("\n", "\r\n")));
p.setValidationContext(new NoValidation());
ArrayList labs = getMatchingHL7Labs(hl7Body);
this.headers = new ArrayList<String>();
for (int i = 0; i < labs.size(); i++)
{
this.msg = ((ORU_R01)p.parse(((String)labs.get(i)).replaceAll("\n", "\r\n")));
ORU_R01_RESPONSE pat_res = this.msg.getRESPONSE();
ORU_R01_ORDER_OBSERVATION obsr = pat_res.getORDER_OBSERVATION();
this.pat_23 = pat_res.getPATIENT();
this.obrseg = obsr.getOBR();
this.obxseg = obsr.getOBSERVATION().getOBX();
}
}
示例8: init
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
public void init(String hl7Body) throws HL7Exception, EncodingNotSupportedException {
hl7Body = preProcess(hl7Body);
Parser parser = new GenericParser();
parser.setValidationContext(new NoValidation());
Message m = parser.parse(hl7Body);
if (!(m instanceof ORU_R01)) {
throw new HL7Exception("Unsupported message type: " + m.getName() + ". Expected ORU^R01 ver 2.2");
}
ORU_R01 message = (ORU_R01) m;
int commentReps = message.getPATIENT_RESULT().getORDER_OBSERVATION().currentReps("NTE");
if (commentReps < 2) {
throw new HL7Exception("Expected at least 2 comments in the NTE field.");
}
this.message = message;
}
示例9: validHL7IsConvertedAndAckIsSent
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
@Ignore
@Test
@DirtiesContext
public void validHL7IsConvertedAndAckIsSent() throws Exception {
standardHL7XMLEndpoint.expectedMessageCount(1);
t5XMLEndpoint.expectedMessageCount(1);
String hl7Input = "MSH|^~\\&|SendingApplication|SendingFacility|ReceivingApplication|ReceivingFacility|20120530112345||ORU^R01^ORU_R01|9879790003|P|2.6|||NE|AL|USA|ASCII|EN^English^ISO639||IHE_PCD_ORU_R01^IHE PCD^1.3.6.1.4.1.19376.1.6.1.1.1^ISO\r"
+ "PID|||HO2009001^^^NIST^PI||Hon^Albert^^^^^L|Adams^^^^^^L|19610101|M|||15 N Saguaro^^Tucson^AZ^85701\r"
+ "PV1||I|ICU^2^23\r"
+ "OBR|1|||44616-1^Pulse oximetry panel ^LN|||20120512031234||||||||||||||||||F|||||||||||||||||||252465000^Pulse oximetry^SCT|7087005^Intermittent^SCT\r"
+ "NTE|1||This comment refers to all the results in the battery\r"
+ "OBX|1|NM|8889-8^Heart Rate by Oximetry^LN^149530^ MDC_PULS_OXIM_PULS_RATE^MDC|1.11.2.3|55|{beats}/min^beats per minute^UCUM|35-125||99||R|||20120530112340|||AMEAS^auto-measurement^MDC|0123456789ABCDEF^Pulse_Oximeter_Vendor_X^0123456789ABCDEF^EUI-64||49521004^left ear structure^SCT\n"
+ "NTE|1||This is a comment about pulse";
Parser parser = new PipeParser();
ORU_R01 originalMessage = (ORU_R01)parser.parse(hl7Input);
String encodedHL7 = parser.encode(originalMessage);
String response = minaTemplate.requestBody((Object)encodedHL7, String.class);
ACK responseMessage = (ACK)parser.parse(response);
assertEquals(AcknowledgmentCode.AA.name(), responseMessage.getMSA().getAcknowledgmentCode().getValue());
standardHL7XMLEndpoint.assertIsSatisfied();
t5XMLEndpoint.assertIsSatisfied();
ORU_R01 outputStandardXMLMessage = (ORU_R01)parseXMLExchange(standardHL7XMLEndpoint.getReceivedExchanges().get(0));
assertEquals(originalMessage.getMSH().getMessageType().getName(), outputStandardXMLMessage.getMSH().getMessageType().getName());
assertEquals(originalMessage.getMSH().getMessageControlID().getValue(), outputStandardXMLMessage.getMSH().getMessageControlID().getValue());
}
示例10: validWaveformMessageConverted
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
@Test
public void validWaveformMessageConverted() throws Exception {
@SuppressWarnings("resource")
HapiContext context = new DefaultHapiContext();
context.setModelClassFactory(new DefaultModelClassFactory());
Parser parser = context.getPipeParser();
ORU_R01 originalMessage = (ORU_R01) parser.parse(hl7WaveformInput);
Document xmlDocument = converter.getXML(originalMessage);
XMLHelper.prettyPrintDocument(xmlDocument, System.out);
NodeList nodes = null;
nodes = nodeListXPath("/t5:PCD_01_Message/Patient_Result/Order_Observations", xmlDocument);
assertEquals(2, nodes.getLength());
nodes = nodeListXPath("/t5:PCD_01_Message/Patient_Result/Order_Observations[1]/MDS", xmlDocument);
assertEquals(1, nodes.getLength());
nodes = nodeListXPath("/t5:PCD_01_Message/Patient_Result/Order_Observations[1]/MDS/VMD/CHAN/Metric", xmlDocument);
assertEquals(2, nodes.getLength());
nodes = nodeListXPath("/t5:PCD_01_Message/Patient_Result/Order_Observations[1]/MDS/VMD/CHAN/Metric[1]/*", xmlDocument);
assertEquals(3, nodes.getLength());
nodes = nodeListXPath("/t5:PCD_01_Message/Patient_Result/Order_Observations[1]/MDS/VMD/CHAN/Metric[1]/Facet", xmlDocument);
assertEquals(2, nodes.getLength());
String obsId = stringXPath("/t5:PCD_01_Message/Patient_Result/Order_Observations[1]/MDS/VMD/CHAN/Metric[1]/Observation[@hierarchy='1.1.1.1001']/ObsIdentifier", xmlDocument);
assertEquals("MDC_ECG_LEAD_I", obsId);
}
示例11: parseRSP_K23
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
private Identifier parseRSP_K23(String response) throws HL7Exception {
Parser parser = new GenericParser();
Object parsedMsg = parser.parse(response);
if (!(parsedMsg instanceof RSP_K23)) {
return null;
}
RSP_K23 msg = (RSP_K23)parsedMsg;
int numIds = msg.getQUERY_RESPONSE().getPID().getPid3_PatientIdentifierListReps();
if (numIds < 1) {
return null;
}
String id = msg.getQUERY_RESPONSE().getPID().getPatientIdentifierList(0).getCx1_IDNumber().getValue();
String assigningAuthority = null;
if (msg.getQUERY_RESPONSE().getPID().getPatientIdentifierList(0).getAssigningAuthority().getNamespaceID()!=null) {
assigningAuthority = msg.getQUERY_RESPONSE().getPID().getPatientIdentifierList(0).getAssigningAuthority().getNamespaceID().getValue();
}
String assigningAuthorityId = null;
if (msg.getQUERY_RESPONSE().getPID().getPatientIdentifierList(0).getAssigningAuthority().getUniversalID()!=null) {
assigningAuthorityId = msg.getQUERY_RESPONSE().getPID().getPatientIdentifierList(0).getAssigningAuthority().getUniversalID().getValue();
}
String assigningAuthorityIdType = null;
if (msg.getQUERY_RESPONSE().getPID().getPatientIdentifierList(0).getAssigningAuthority().getUniversalIDType()!=null) {
assigningAuthorityIdType = msg.getQUERY_RESPONSE().getPID().getPatientIdentifierList(0).getAssigningAuthority().getUniversalIDType().getValue();
}
return new Identifier(id, new AssigningAuthority(assigningAuthority, assigningAuthorityId, assigningAuthorityIdType));
}
示例12: read
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
/**
* Reads an ORU_R01 HL7 file
*
* @param text
* ISO-8559-1 String
* @return
* @throws HL7Exception
*/
public ORU_R01 read(String text) throws HL7Exception{
Parser p = new PipeParser();
p.setValidationContext(new ElexisValidation());
Message hl7Msg = p.parse(text);
if (hl7Msg instanceof ORU_R01) {
return (ORU_R01) hl7Msg;
} else {
addError(MessageFormat.format(
Messages.getString("HL7_ORU_R01.Error_WrongMsgType"), hl7Msg.getName())); //$NON-NLS-1$
}
return null;
}
示例13: testMarshalUnmarshal
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
@Test
@SuppressWarnings("resource")
public void testMarshalUnmarshal() throws Exception {
final String msg = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4\r";
final HL7DataFormat format = new HL7DataFormat();
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.marshal(format)
.unmarshal(format)
.to("mock:result");
}
});
camelctx.start();
try {
HapiContext context = new DefaultHapiContext();
Parser p = context.getGenericParser();
Message hapimsg = p.parse(msg);
ProducerTemplate producer = camelctx.createProducerTemplate();
Message result = (Message) producer.requestBody("direct:start", hapimsg);
Assert.assertEquals(hapimsg.toString(), result.toString());
} finally {
camelctx.stop();
}
}
示例14: init
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
public void init(String hl7Body) throws HL7Exception {
Parser p = new PipeParser();
p.setValidationContext(new NoValidation());
msg = (ORU_R01) p.parse(hl7Body.replaceAll( "\n", "\r\n" ).replace("\\.Zt\\", "\t"));
}
示例15: init
import ca.uhn.hl7v2.parser.Parser; //导入方法依赖的package包/类
public void init(String hl7Body) throws HL7Exception {
Parser p = new PipeParser();
p.setValidationContext(new NoValidation());
msg = (ORU_R01) p.parse(hl7Body.replaceAll( "\n", "\r\n" ));
ArrayList<String> labs = getMatchingGDMLLabsByAccessionNo(hl7Body);
headers = new ArrayList<String>();
obrSegMap = new LinkedHashMap<OBR,ArrayList<OBX>>();
obrSegKeySet = new ArrayList<OBR>();
for (int i=0; i < labs.size(); i++){
msg = (ORU_R01) p.parse(( labs.get(i)).replaceAll("\n", "\r\n"));
int obrCount = msg.getRESPONSE().getORDER_OBSERVATIONReps();
for (int j=0; j < obrCount; j++){
// ADD OBR SEGMENTS AND THEIR OBX SEGMENTS TO THE OBRSEGMAP
OBR obrSeg = msg.getRESPONSE().getORDER_OBSERVATION(j).getOBR();
ArrayList<OBX> obxSegs = obrSegMap.get(obrSeg);
// if the obrsegment has not yet been created it will be now
if (obxSegs == null)
obxSegs = new ArrayList<OBX>();
int obxCount = msg.getRESPONSE().getORDER_OBSERVATION(j).getOBSERVATIONReps();
for (int k=0; k < obxCount; k++){
obxSegs.add(msg.getRESPONSE().getORDER_OBSERVATION(j).getOBSERVATION(k).getOBX());
}
obrSegMap.put(obrSeg, obxSegs);
obrSegKeySet.add(obrSeg);
// ADD THE HEADER TO THE HEADERS ARRAYLIST
String header = getString(obrSeg.getUniversalServiceIdentifier().getAlternateIdentifier().getValue());
if (!headers.contains(header)){
headers.add(header);
}
}
}
}