本文整理汇总了Java中ca.uhn.hl7v2.parser.Parser类的典型用法代码示例。如果您正苦于以下问题:Java Parser类的具体用法?Java Parser怎么用?Java Parser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parser类属于ca.uhn.hl7v2.parser包,在下文中一共展示了Parser类的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: 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"));
}
示例6: 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();
}
}
示例7: 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;
}
示例8: createText
import ca.uhn.hl7v2.parser.Parser; //导入依赖的package包/类
/**
* Creates an OMG_O19 message
*
* @param patient
* @param kostentraeger
* @param rechnungsempfaenger
* @param auftragsNummer
* @param plan
* Abrechnungssystem (MV, UVG, VVG, KVG, usw)
* @param beginDate
* @param vnr
* Versicherungs-, Fall- oder Unfallnr
* @return
*/
public String createText(final HL7Patient patient, final HL7Kostentraeger rechnungsempfaenger,
final HL7Kostentraeger kostentraeger, final String plan, final Date beginDate,
final String fallNr, final long auftragsNummer) throws DataTypeException, HL7Exception{
OML_O21 omg = new OML_O21();
fillMSH(omg.getMSH(), "OML", "O21", mandant, this.uniqueMessageControlID, //$NON-NLS-1$ //$NON-NLS-2$
this.uniqueProcessingID, patient); //$NON-NLS-1$ //$NON-NLS-2$
fillPID(omg.getPATIENT().getPID(), patient);
fillNK1(omg.getPATIENT().getNK1(), rechnungsempfaenger);
fillPV1(omg.getPATIENT().getPATIENT_VISIT().getPV1(), patient, beginDate);
fillIN1(omg.getPATIENT().getINSURANCE().getIN1(), patient, kostentraeger, plan, fallNr);
fillORC(omg.getORDER().getORC(), "1", auftragsNummer); //$NON-NLS-1$
// Now, let's encode the message and look at the output
Parser parser = new PipeParser();
return parser.encode(omg);
}
示例9: createText
import ca.uhn.hl7v2.parser.Parser; //导入依赖的package包/类
/**
* Creates an ORU_R01 message
*
* @param patient
* @param labItem
* @param labwert
*
* @return
*/
public String createText(final HL7Patient patient, final HL7LaborItem labItem,
final HL7LaborWert labwert) throws DataTypeException, HL7Exception{
ORU_R01 oru = new ORU_R01();
// Message
fillMSH(oru.getMSH(), "ORU", "R01", mandant, this.uniqueMessageControlID, //$NON-NLS-1$ //$NON-NLS-2$
this.uniqueProcessingID, patient); //$NON-NLS-1$ //$NON-NLS-2$
// Patient
PID pid = oru.getPATIENT_RESULT().getPATIENT().getPID();
fillPID(pid, patient);
ORU_R01_ORDER_OBSERVATION orderObservation = oru.getPATIENT_RESULT().getORDER_OBSERVATION();
fillORC(orderObservation.getORC(), "RE", null); //$NON-NLS-1$
addResultInternal(oru, patient, labItem, labwert, 0);
// Now, let's encode the message and look at the output
Parser parser = new PipeParser();
return parser.encode(oru);
}
示例10: addResultInternal
import ca.uhn.hl7v2.parser.Parser; //导入依赖的package包/类
/**
* Adds a ORU_R01 observation result
*
* @param oru
* @param patient
* @param labItem
* @param labwert
* @param initial
* @return
*/
private String addResultInternal(final ORU_R01 oru, final HL7Patient patient,
final HL7LaborItem labItem, final HL7LaborWert labwert, int orderObservationIndex)
throws DataTypeException, HL7Exception{
// Observation
ORU_R01_ORDER_OBSERVATION orderObservation =
(ORU_R01_ORDER_OBSERVATION) oru.getPATIENT_RESULT().getORDER_OBSERVATION(
orderObservationIndex);
fillOBR(orderObservation.getOBR(), orderObservationIndex, labItem);
fillOBX(orderObservation.getOBSERVATION().getOBX(), patient, labItem, labwert);
if (labwert.getKommentar() != null && labwert.getKommentar().length() > 0) {
fillNTE(orderObservation.getNTE(), labwert);
}
// Now, let's encode the message and look at the output
Parser parser = new PipeParser();
return parser.encode(oru);
}
示例11: getTestsAndPanels
import ca.uhn.hl7v2.parser.Parser; //导入依赖的package包/类
private void getTestsAndPanels(List<Request> tests, List<Request> panels, String orderMessage, Map<String, String> requesterValuesMap){
HapiContext context = new DefaultHapiContext();
Parser p = context.getGenericParser();
try{
OML_O21 hapiMsg = (OML_O21)p.parse(orderMessage);
ORC commonOrderSegment = hapiMsg.getORDER().getORC();
requesterValuesMap.put(PROVIDER_PHONE, commonOrderSegment.getCallBackPhoneNumber(0).getXtn12_UnformattedTelephoneNumber().getValue());
requesterValuesMap.put(PROVIDER_LAST_NAME, commonOrderSegment.getOrderingProvider(0).getFamilyName().getSurname().getValue());
requesterValuesMap.put(PROVIDER_FIRST_NAME, commonOrderSegment.getOrderingProvider(0).getGivenName().getValue());
OML_O21_OBSERVATION_REQUEST orderRequest = hapiMsg.getORDER().getOBSERVATION_REQUEST();
addToTestOrPanel(tests, panels, orderRequest.getOBR(), orderRequest.getOBSERVATION().getOBX());
List<OML_O21_ORDER_PRIOR> priorOrders = orderRequest.getPRIOR_RESULT().getORDER_PRIORAll();
for(OML_O21_ORDER_PRIOR priorOrder : priorOrders){
addToTestOrPanel(tests, panels, priorOrder.getOBR(), priorOrder.getOBSERVATION_PRIOR().getOBX());
}
}catch(HL7Exception e){
e.printStackTrace();
}
}
示例12: 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;
}
示例13: createRouteBuilder
import ca.uhn.hl7v2.parser.Parser; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
HapiContext hapiContext = new DefaultHapiContext();
hapiContext.setValidationContext(new NoValidation());
Parser p = new GenericParser(hapiContext);
hl7 = new HL7DataFormat();
hl7.setParser(p);
/*
* Let's start by adding a validation rule to the default validation
* that disallows PID-2 to be empty.
*/
ValidationRuleBuilder builder = new ValidationRuleBuilder() {
private static final long serialVersionUID = 1L;
@Override
protected void configure() {
forVersion(Version.V24)
.message("ADT", "*")
.terser("PID-2", not(empty()));
}
};
ValidationContext customValidationContext = ValidationContextFactory.fromBuilder(builder);
HapiContext customContext = new DefaultHapiContext(customValidationContext);
final Parser customParser = new GenericParser(customContext);
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:unmarshalFailed").unmarshal().hl7().to("mock:unmarshal");
from("direct:unmarshalOk").unmarshal().hl7(false).to("mock:unmarshal");
from("direct:unmarshalOkCustom").unmarshal(hl7).to("mock:unmarshal");
from("direct:start1").marshal().hl7(customParser).to("mock:end");
from("direct:start2").marshal().hl7(true).to("mock:end");
}
};
}
示例14: createRouteBuilder
import ca.uhn.hl7v2.parser.Parser; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
HapiContext hapiContext = new DefaultHapiContext();
hapiContext.setValidationContext(new NoValidation());
Parser p = new GenericParser(hapiContext);
hl7 = new HL7DataFormat();
hl7.setParser(p);
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:unmarshalOk").unmarshal().hl7(false).to("mock:unmarshal");
from("direct:unmarshalOkXml").unmarshal(hl7).to("mock:unmarshal");
}
};
}
示例15: 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());
}