001 /*
002 * This class is an auto-generated source file for a HAPI
003 * HL7 v2.x standard structure class.
004 *
005 * For more information, visit: http://hl7api.sourceforge.net/
006 */
007
008 package ca.uhn.hl7v2.model.v231.message;
009
010 import ca.uhn.hl7v2.model.v231.group.*;
011 import ca.uhn.hl7v2.model.v231.segment.*;
012
013 import ca.uhn.log.HapiLogFactory;
014 import ca.uhn.hl7v2.HL7Exception;
015 import ca.uhn.hl7v2.parser.ModelClassFactory;
016 import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
017 import ca.uhn.hl7v2.model.AbstractMessage;
018
019 /**
020 * <p>Represents a CRM_C01 message structure (see chapter ${chapter}). This structure contains the
021 * following elements: </p>
022 * <ul>
023 * <li>1: MSH (MSH - message header segment) <b> </b></li>
024 * <li>2: CRM_C01_PIDPV1CSRCSP (a Group object) <b> repeating</b></li>
025 * </ul>
026 */
027 public class CRM_C01 extends AbstractMessage {
028
029 /**
030 * Creates a new CRM_C01 message with DefaultModelClassFactory.
031 */
032 public CRM_C01() {
033 this(new DefaultModelClassFactory());
034 }
035
036 /**
037 * Creates a new CRM_C01 message with custom ModelClassFactory.
038 */
039 public CRM_C01(ModelClassFactory factory) {
040 super(factory);
041 init(factory);
042 }
043
044 private void init(ModelClassFactory factory) {
045 try {
046 this.add(MSH.class, true, false);
047 this.add(CRM_C01_PIDPV1CSRCSP.class, true, true);
048 } catch(HL7Exception e) {
049 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating CRM_C01 - this is probably a bug in the source code generator.", e);
050 }
051 }
052
053 /**
054 * Returns "2.3.1"
055 */
056 public String getVersion() {
057 return "2.3.1";
058 }
059
060
061
062 /**
063 * Returns
064 * MSH (MSH - message header segment) - creates it if necessary
065 */
066 public MSH getMSH() {
067 MSH ret = null;
068 try {
069 ret = (MSH)this.get("MSH");
070 } catch(HL7Exception e) {
071 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
072 throw new RuntimeException(e);
073 }
074 return ret;
075 }
076
077
078
079
080 /**
081 * Returns
082 * the first repetition of
083 * PIDPV1CSRCSP (a Group object) - creates it if necessary
084 */
085 public CRM_C01_PIDPV1CSRCSP getPIDPV1CSRCSP() {
086 CRM_C01_PIDPV1CSRCSP ret = null;
087 try {
088 ret = (CRM_C01_PIDPV1CSRCSP)this.get("PIDPV1CSRCSP");
089 } catch(HL7Exception e) {
090 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
091 throw new RuntimeException(e);
092 }
093 return ret;
094 }
095
096
097 /**
098 * Returns a specific repetition of
099 * PIDPV1CSRCSP (a Group object) - creates it if necessary
100 *
101 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
102 * @throws HL7Exception if the repetition requested is more than one
103 * greater than the number of existing repetitions.
104 */
105 public CRM_C01_PIDPV1CSRCSP getPIDPV1CSRCSP(int rep) {
106 CRM_C01_PIDPV1CSRCSP ret = null;
107 try {
108 ret = (CRM_C01_PIDPV1CSRCSP)this.get("PIDPV1CSRCSP", rep);
109 } catch(HL7Exception e) {
110 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
111 throw new RuntimeException(e);
112 }
113 return ret;
114 }
115
116 /**
117 * Returns the number of existing repetitions of PIDPV1CSRCSP
118 */
119 public int getPIDPV1CSRCSPReps() {
120 int reps = -1;
121 try {
122 reps = this.getAll("PIDPV1CSRCSP").length;
123 } catch (HL7Exception e) {
124 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
125 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
126 throw new RuntimeException(message);
127 }
128 return reps;
129 }
130
131 /**
132 * Inserts a specific repetition of PIDPV1CSRCSP (a Group object)
133 * @see AbstractGroup\#insertRepetition(Structure, int)
134 */
135 public void insertPIDPV1CSRCSP(CRM_C01_PIDPV1CSRCSP structure, int rep) throws HL7Exception {
136 super.insertRepetition( "PIDPV1CSRCSP", structure, rep);
137 }
138
139
140 /**
141 * Inserts a specific repetition of PIDPV1CSRCSP (a Group object)
142 * @see AbstractGroup\#insertRepetition(Structure, int)
143 */
144 public CRM_C01_PIDPV1CSRCSP insertPIDPV1CSRCSP(int rep) throws HL7Exception {
145 return (CRM_C01_PIDPV1CSRCSP)super.insertRepetition("PIDPV1CSRCSP", rep);
146 }
147
148
149 /**
150 * Removes a specific repetition of PIDPV1CSRCSP (a Group object)
151 * @see AbstractGroup\#removeRepetition(String, int)
152 */
153 public CRM_C01_PIDPV1CSRCSP removePIDPV1CSRCSP(int rep) throws HL7Exception {
154 return (CRM_C01_PIDPV1CSRCSP)super.removeRepetition("PIDPV1CSRCSP", rep);
155 }
156
157
158
159 }
160