

Create a note:  lstTemplates.ItemIndex from btnClickNoteClick

string:  strItem := lstTemplates.Items[lstTemplates.ItemIndex];
         'HBPC KT NOTE'
         
string:  strNote := RenderTemplate(GetTemplateXML(strItem));   <-- this does the whole thing!


uTemplateXML.GetTemplateXML(name:sting): string


integer:      i := xmlTemplateNames.IndexOf(name);   
              5
              
string:       Result := xmlTemplates.Strings[i];
              
'<CPRS_TEMPLATE>'#$D#$A'  <TEMPLATE NAME="HBPC KT NOTE">'#$D#$A'    <TYPE>T</TYPE>'#$D#$A'    <STATUS>A</STATUS>'#$D#$A'    <BOILERPLATE_TEXT>'#$D#$A'      <p>Patient History:{FLD:WORD-3}</p>'#$D#$A'      <p></p>'#$D#$A'      <p>S:{FLD:WORD-3}</p>'#$D#$A'      <p></p>'#$D#$A'      <p></p>'#$D#$A'      <p>O:Current Status:</p>'#$D#$A'      <p>AROM:'#9'Upper Extremity - (Degrees)      Right   Left</p>'#$D#$A'      <p>     Shoulder Flexion - (180*)           {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>     Shoulder Extension - (60*)          {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>     Elbow Flexion - (150*)              {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>     Wrist Flexion - (80*)               {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>     Wrist Extension -                   {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>     Hand/Finger Flexion                 {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}   </p>'#$D#$A'      <p>     Hand/Finger Extension               {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>Comments:{FLD:WORD PROCESSING3}</p>'#$D#$A'      <p></p>'#$D#$A'      <p>Lower Extremity - (Degrees)              Right   Left</p>'#$D#$A'      <p>   Hip Flexion - (120*)                  {FLD:WORD FLD EDIT 5}      {FLD:WORD FLD EDIT 5}'#9'</p>'#$D#$A'      <p>   Hip Extension - (30*)                 {FLD:WORD FLD EDIT 5}      {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>   Knee Flexion - (135*)                 {FLD:WORD FLD EDIT 5}      {FLD:WORD FLD EDIT 5}'#9'</p>'#$D#$A'      <p>   Ankle Dorsi flexion - (20*)           {FLD:WORD FLD EDIT 5}      {FLD:WORD FLD EDIT 5}'#9'</p>'#$D#$A'      <p>   Ankle Plantar flexion - (50*)         {FLD:WORD FLD EDIT 5}      {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>Comments:{FLD:WORD PROCESSING3}</p>'#$D#$A'      <p></p>'#$D#$A'      <p>STRENGTH: SCALE (0=ZERO,1=TRACE,2=POOR,3=FAIR,4=GOOD,5=NORMAL)</p>'#$D#$A'      <p>  General Strength                       Right   Left'#9'       </p>'#$D#$A'      <p>    UE                                   {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}                </p>'#$D#$A'      <p>    Hand/Finger Flexion                  {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>    Hand/Finger Extension                {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}                      </p>'#$D#$A'      <p>    LE                                   {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}      </p>'#$D#$A'      <p>    Hip Extension                        {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>    Knee Extension                       {FLD:WORD FLD EDIT 5}'#9'{FLD:WORD FLD EDIT 5}              </p>'#$D#$A'      <p>Comments:{FLD:WORD PROCESSING3}</p>'#$D#$A'      <p></p>'#$D#$A'      <p>BALANCE: SCALE (0=MAX ASSIST,P=MOD ASSIST,F=W/OUT ASSIST,G=MOD CHALLENGE,G+=MAX CHALLENGE,N=NORM)</p>'#$D#$A'      <p>         Sitting - Static - {FLD:WORDFLD_EDIT_50}</p>'#$D#$A'      <p>                  Dynamic - {FLD:WORDFLD_EDIT_50}</p>'#$D#$A'      <p>        Standing - Static - {FLD:WORDFLD_EDIT_50}</p>'#$D#$A'      <p>                  Dynamic - {FLD:WORDFLD_EDIT_50}</p>'#$D#$A'      <p></p>'#$D#$A'      <p>GAIT ANALYSIS:</p>'#$D#$A'      <p>'#9'Assistive Device -{FLD:WORDFLD_EDIT_50}</p>'#$D#$A'      <p>'#9'Distance Walked -{FLD:WORDFLD_EDIT_50}</p>'#$D#$A'      <p>'#9'Deviation:{FLD:WORDFLD_EDIT_50}</p>'#$D#$A'      <p>Comments:{FLD:WORD PROCESSING3}</p>'#$D#$A'      <p></p>'#$D#$A'      <p>SAFETY: Recent Falls:{FLD:YES, NO, *} While performing {FLD:WORDFLD_EDIT_50} </p>'#$D#$A'      <p></p>'#$D#$A'      <p>PAIN LEVEL:{FLD:WORD FLD EDIT 5} AREA:{FLD:WORDFLD_EDIT_50}</p>'#$D#$A'      <p></p>'#$D#$A'      <p>FUNCTIONAL INDEPENDENCE MEASURE (FIM)</p>'#$D#$A'      <p></p>'#$D#$A'      <p>Self-Care</p>'#$D#$A'      <p> Eating              {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p> Grooming            {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p> Bathing             {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p> Dressing-Upper Body {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p> Dressing-Lower Body {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p> Toileting           {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>Sphincter Control</p>'#$D#$A'      <p> Bladder Management  {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p> Bowel Management    {FLD:WORD FLD EDIT 5}</p>'#$D#$A'      <p>Mobility</p>'#$D#$A'      <p> Bed,Chair,Wheelchair{FLD:WORD FLD EDIT 5}</p>'#$D#$A'   '...              

fMed.RenderTmplate

  xmlTemplate : IXMLDOMDocument;
  tmpTemplate : TTemplate;
  RootElement: IXMLDOMElement;
  FXMLElement: IXMLDOMNode;
  fldNew: TTemplateField;
  Children: IXMLDOMNodeList;
  Child: IXMLDOMNode;
  count:integer;
  i:integer;

  uTemplateFields.ClearTemplateFields();
  	 ReleaseFields(uTmplFlds);   uTemplateFields.uTmplFlds: TTemplateFieldArr = array of TTemplateField;
  	 SetLength(uTmplFlds,0);         
  	 
    xmlTemplate := CoDOMDocument.Create;
    xmlTemplate.preserveWhiteSpace := TRUE;
    xmlTemplate.loadXML(strXML);

 //Create our template  
    RootElement := xmlTemplate.documentElement;
    FXMLElement := FindXMLElement(RootElement, XMLTemplateTag);
                                                 'TEMPLATE'
    tmpTemplate := TTemplate.CreateFromXML(FXMLElement,'12345'); 

  //Create our fields    
    FXMLElement := FindXMLElement(RootElement, XMLTemplateFieldsTag); 
                                               'TEMPLATE_FIELDS'	  

          //Get our children
						Children := FXMLElement.Get_childNodes;
						
						count := Children.Get_length;
						  11  
						  
							for i := 0 to count-1 do
              begin
								Child := Children.Get_item(i);
								if assigned(Child) and (CompareText(Child.Get_nodeName, 'FIELD') = 0) then
								begin
                  fldNew := TTemplateField.Create(Child);
                  AddTemplateField(fldNew);
								end;						  
								
								
								
uTemplate.GetText

	   CheckBoilerplate4Fields(TmpSL,'Template: ' + FPrintName,False);  displasy text here....								                    