Java Code Examples for ca.uhn.hl7v2.parser.PipeParser#encode()

The following examples show how to use ca.uhn.hl7v2.parser.PipeParser#encode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XdsTest.java    From openxds with Apache License 2.0 6 votes vote down vote up
protected void createPatient(String patientId) throws Exception {
	if (!validatePatient)
		return ;
	
	patientId = patientId.replace("&", "&");
	//If it is a valid patient, then no need to re-create.
	if (isValidPatient(patientId))
		return; 
	
	String msg = "MSH|^~\\&|OTHER_KIOSK|HIMSSSANDIEGO|PAT_IDENTITY_X_REF_MGR_MISYS|ALLSCRIPTS|20090512132906-0300||ADT^A04^ADT_A01|7723510070655179915|P|2.3.1\r" + 
      "EVN||20090512132906-0300\r" +
      "PID|||"+ patientId +"||FARNSWORTH^STEVE||19781208|M|||820 JORIE BLVD^^CHICAGO^IL^60523\r" +
      "PV1||O|";
	PipeParser pipeParser = new PipeParser();
	Message adt = pipeParser.parse(msg);
	ConnectionHub connectionHub = ConnectionHub.getInstance();
	Connection connection = connectionHub.attach(hostName, pixRegistryPort, new PipeParser(), MinLowerLayerProtocol.class);
	Initiator initiator = connection.getInitiator();
	Message response = initiator.sendAndReceive(adt);
	String responseString = pipeParser.encode(response);	        
	System.out.println("Received response:\n" + responseString);
		MSA msa = (MSA)response.get("MSA");
	assertEquals("AA", msa.getAcknowledgementCode().getValue());
}
 
Example 2
Source File: HapiField.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public HapiField(final Type type) {
    this.value = PipeParser.encode(type, EncodingCharacters.defaultInstance());

    final List<HL7Component> componentList = new ArrayList<>();
    if (type instanceof Composite) {
        final Composite composite = (Composite) type;

        for (final Type component : composite.getComponents()) {
            componentList.add(new HapiField(component));
        }
    }

    final ExtraComponents extra = type.getExtraComponents();
    if (extra != null && extra.numComponents() > 0) {
        final String singleFieldValue;
        if (type instanceof Primitive) {
            singleFieldValue = ((Primitive) type).getValue();
        } else {
            singleFieldValue = this.value;
        }
        componentList.add(new SingleValueField(singleFieldValue));

        for (int i = 0; i < extra.numComponents(); i++) {
            final Varies varies = extra.getComponent(i);
            componentList.add(new HapiField(varies));
        }
    }

    this.components = Collections.unmodifiableList(componentList);
}
 
Example 3
Source File: MergePatientTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
private void SendPIX(String msg) throws Exception {
PipeParser pipeParser = new PipeParser();
Message adt = pipeParser.parse(msg);
ConnectionHub connectionHub = ConnectionHub.getInstance();
Connection connection = connectionHub.attach(hostName, pixRegistryPort, new PipeParser(), MinLowerLayerProtocol.class);
Initiator initiator = connection.getInitiator();
Message response = initiator.sendAndReceive(adt);
String responseString = pipeParser.encode(response);	        
System.out.println("Received response:\n" + responseString);
MSA msa = (MSA)response.get("MSA");
assertEquals("AA", msa.getAcknowledgementCode().getValue());    	
  }
 
Example 4
Source File: HapiField.java    From nifi with Apache License 2.0 5 votes vote down vote up
public HapiField(final Type type) {
    this.value = PipeParser.encode(type, EncodingCharacters.defaultInstance());

    final List<HL7Component> componentList = new ArrayList<>();
    if (type instanceof Composite) {
        final Composite composite = (Composite) type;

        for (final Type component : composite.getComponents()) {
            componentList.add(new HapiField(component));
        }
    }

    final ExtraComponents extra = type.getExtraComponents();
    if (extra != null && extra.numComponents() > 0) {
        final String singleFieldValue;
        if (type instanceof Primitive) {
            singleFieldValue = ((Primitive) type).getValue();
        } else {
            singleFieldValue = this.value;
        }
        componentList.add(new SingleValueField(singleFieldValue));

        for (int i = 0; i < extra.numComponents(); i++) {
            componentList.add(new HapiField(extra.getComponent(i)));
        }
    }

    this.components = Collections.unmodifiableList(componentList);
}