Are there any restrictions on the Segments that should be used for a Specific message type? For Ex: If I have to create a sample HL7 ADT^A05 or REF message.. Can I include a
1. HL7 defines sets of messages and recommended segments. Exact valid form depends on the HL7 conformance profile that your and the-other system support.
For an example of conformance profiles and some tool to use it see e.g. http://hl7api.sourceforge.net/conformance.html
2. For list of conceptually valid segments in particular messages check appropriate version of the HL7 specification at http://www.hl7.org/implement/standards/product_brief.cfm?product_id=185.
In case of your message take a look at "HL7 Messaging Standard Version 2.3.1". For more up-to-date specification with better description look at "HL7 Messaging Standard Version 2.5" as this version is said to be (no proof available) most elaborate out of the HL7 2.x range.
3. For conceptual overview of messages and their meaning and system-wide IHE integration profiles refer to recommendations provided by http://www.ihe.net/Technical_Frameworks/
4. Useful piece of software that can help you diagnose/validate basic HL7 structure is Inner Harbour Software's HL7Spy
I'm not an expert just providing some links to get you started
This will be helpful The segments list with their specification composites/fields.
http://www.mexi.be/documents/hl7/htindex.htm or this other one http://www.hosinc.com/products/interfaces/interface_documentation.htm
There are restrictions defined by HL7 on the segment to use. That being said, your messages will also be defined by the data exchange needs of the systems you are interfacing, and for that you should develop a specification.
The specification (conformance profile) would contain:
This article explains what goes into a spec: http://caristix.com/blog/2013/02/hl7-survival-guide-chapter-6-hl7-interface-specifications/. It gives several reference sources.