ca.uhn.hl7v2.model.Primitive Java Examples

The following examples show how to use ca.uhn.hl7v2.model.Primitive. 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: HL7Reader.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Collects all potential not null name values and adds them to the OrcMessage. All not null
 * values like firstName, secondName and combination of firstName and secondName will also be
 * added to the OrcMessage.
 * 
 * Example firstName is Max and secondName is Muster: Method collects: Max, Muster, Max Muster
 * in OrcMessage
 * 
 * @param firstName
 * @param secondName
 * @param orcMessage
 */
public void addNameValuesToOrcMessage(Primitive firstName, Primitive secondName,
	OrcMessage orcMessage){
	if (orcMessage != null) {
		String name = extractName(firstName);
		if (name != null) {
			orcMessage.getNames().add(name);
		}
		
		String name2 = extractName(secondName);
		if (name2 != null) {
			orcMessage.getNames().add(name2);
			if (name != null) {
				orcMessage.getNames().add(name + " " + name2);
			}
		}
	}
}
 
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: 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);
}
 
Example #4
Source File: HL7Reader.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Extracts and trims the String value from a {@link Primitive}
 * 
 * @param nameObj
 * @return
 */
public String extractName(Primitive nameObj){
	if (nameObj != null) {
		String val = nameObj.getValue();
		if (val != null) {
			return val.trim();
		}
	}
	return null;
}