/** * Sets the data contained by this instance of Varies. If a data object already exists, * then its values are copied to the incoming data object before the old one is replaced. * For example, if getData() returns an ST with the value "19901012" and you call * setData(new DT()), then subsequent calls to getData() will return the same DT, with the value * set to "19901012". * * @param data the data to be set for this Varies instance * @throws DataTypeException if the data could not be set */ public void setData(Type data) throws DataTypeException { if (this.data != null) { if (!(this.data instanceof Primitive) || ((Primitive) this.data).getValue() != null) { ca.uhn.hl7v2.util.DeepCopy.copy(this.data, data); } } this.data = data; }
/** * Sets the data contained by this instance of Varies. If a data object already exists, * then its values are copied to the incoming data object before the old one is replaced. * For example, if getData() returns an ST with the value "19901012" and you call * setData(new DT()), then subsequent calls to getData() will return the same DT, with the value * set to "19901012". * * @param data the data to be set for this Varies instance * @throws DataTypeException if the data could not be set */ public void setData(Type data) throws DataTypeException { if (this.data != null) { if (!(this.data instanceof Primitive) || ((Primitive) this.data).getValue() != null) { ca.uhn.hl7v2.util.DeepCopy.copy(this.data, data); } } this.data = data; }
/** * Copies contents from the source segment to the destination segment. This * method calls copy(Type, Type) on each repetition of each field (see additional * behavioural description there). An attempt is made to copy each repetition of * each field in the source segment, regardless of whether the corresponding * destination field is repeating or even exists. * * @param from the segment from which data are copied * @param to the segment into which data are copied * @throws HL7Exception if an error occurred while copying */ public static void copy(Segment from, Segment to) throws HL7Exception { int n = from.numFields(); for (int i = 1; i <= n; i++) { Type[] reps = from.getField(i); for (int j = 0; j < reps.length; j++) { copy(reps[j], to.getField(i, j)); } } } }
/** * Copies contents from the source segment to the destination segment. This * method calls copy(Type, Type) on each repetition of each field (see additional * behavioural description there). An attempt is made to copy each repetition of * each field in the source segment, regardless of whether the corresponding * destination field is repeating or even exists. * * @param from the segment from which data are copied * @param to the segment into which data are copied * @throws HL7Exception if an error occurred while copying */ public static void copy(Segment from, Segment to) throws HL7Exception { int n = from.numFields(); for (int i = 1; i <= n; i++) { Type[] reps = from.getField(i); for (int j = 0; j < reps.length; j++) { copy(reps[j], to.getField(i, j)); } } } }
/** * @deprecated use {@link Message#generateACK()} */ public static Message makeACK(Segment inboundHeader) throws HL7Exception, IOException { // Make sure that the referenced message is not just a dummy DeepCopy.copy(inboundHeader, (Segment)inboundHeader.getMessage().get("MSH")); return inboundHeader.getMessage().generateACK(); }
/** * @deprecated use {@link Message#generateACK()} */ public static Message makeACK(Segment inboundHeader) throws HL7Exception, IOException { // Make sure that the referenced message is not just a dummy DeepCopy.copy(inboundHeader, (Segment)inboundHeader.getMessage().get("MSH")); return inboundHeader.getMessage().generateACK(); }
private Message getInMessage(Segment inHeader) throws HL7Exception, IOException { Message in; if (inHeader != null) { in = inHeader.getMessage(); // the message may be a dummy message, whose MSH segment is incomplete DeepCopy.copy(inHeader, (Segment) in.get("MSH")); } else { in = Version.highestAvailableVersionOrDefault().newGenericMessage(myParser.getFactory()); ((GenericMessage) in).initQuickstart("ACK", "", ""); } return in; }
private Message getInMessage(Segment inHeader) throws HL7Exception, IOException { Message in; if (inHeader != null) { in = inHeader.getMessage(); // the message may be a dummy message, whose MSH segment is incomplete DeepCopy.copy(inHeader, (Segment) in.get("MSH")); } else { in = Version.highestAvailableVersionOrDefault().newGenericMessage(myParser.getFactory()); ((GenericMessage) in).initQuickstart("ACK", "", ""); } return in; }
/** * Generates an empty response message. This class generates an * ACKnowledgement using the code returned by {@link #getSuccessAcknowledgementCode()}. * * @param request request message, either a {@link String} or a * {@link Message} * @return acknowledgment to the request * @throws HL7Exception */ protected Message generateResponseMessage(Object request) throws HL7Exception { try { Message in; if (request instanceof String) { Segment s = getHapiContext().getGenericParser().getCriticalResponseData( (String)request); in = s.getMessage(); DeepCopy.copy(s, (Segment) in.get("MSH")); } else if (request instanceof Message) { in = (Message) request; } else { throw new HL7Exception("Validated message must be either Message or String"); } return in.generateACK(getSuccessAcknowledgementCode(), null); } catch (IOException e) { throw new HL7Exception(e); } }
/** * Generates an empty response message. This class generates an * ACKnowledgement using the code returned by {@link #getSuccessAcknowledgementCode()}. * * @param request request message, either a {@link String} or a * {@link Message} * @return acknowledgment to the request * @throws HL7Exception */ protected Message generateResponseMessage(Object request) throws HL7Exception { try { Message in; if (request instanceof String) { Segment s = getHapiContext().getGenericParser().getCriticalResponseData( (String)request); in = s.getMessage(); DeepCopy.copy(s, (Segment) in.get("MSH")); } else if (request instanceof Message) { in = (Message) request; } else { throw new HL7Exception("Validated message must be either Message or String"); } return in.generateACK(getSuccessAcknowledgementCode(), null); } catch (IOException e) { throw new HL7Exception(e); } }
private static Transportable makeAcceptAck(Transportable theMessage, String theAckCode, ErrorCode theErrorCode, String theDescription) throws HL7Exception { Segment header = ourParser.getCriticalResponseData(theMessage.getMessage()); Message dummy = header.getMessage(); // MSH header refers to dummy, but not the other way round! DeepCopy.copy(header, (Segment)dummy.get("MSH")); try { HL7Exception hl7e = new HL7Exception(theDescription, theErrorCode); AcknowledgmentCode code = theAckCode == null ? AcknowledgmentCode.CR : AcknowledgmentCode.valueOf(theAckCode); Message out = dummy.generateACK(code, hl7e); String originalEncoding = ourParser.getEncoding(theMessage.getMessage()); String ackText = ourParser.encode(out, originalEncoding); return new TransportableImpl(ackText); } catch (IOException e) { throw new HL7Exception(e); } }
private static Transportable makeAcceptAck(Transportable theMessage, String theAckCode, ErrorCode theErrorCode, String theDescription) throws HL7Exception { Segment header = ourParser.getCriticalResponseData(theMessage.getMessage()); Message dummy = header.getMessage(); // MSH header refers to dummy, but not the other way round! DeepCopy.copy(header, (Segment)dummy.get("MSH")); try { HL7Exception hl7e = new HL7Exception(theDescription, theErrorCode); AcknowledgmentCode code = theAckCode == null ? AcknowledgmentCode.CR : AcknowledgmentCode.valueOf(theAckCode); Message out = dummy.generateACK(code, hl7e); String originalEncoding = ourParser.getEncoding(theMessage.getMessage()); String ackText = ourParser.encode(out, originalEncoding); return new TransportableImpl(ackText); } catch (IOException e) { throw new HL7Exception(e); } }