<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE FreeMedForms>

<FreeMedForms>

  <formdescription>
    <!-- Non translatable values -->
    <authors>Eric Maeker, MD</authors>
    <version>0.9.0</version>
    <fmfv>0.6.0</fmfv>
    <cdate>2011-12-21</cdate>
    <lmdate>2011-12-21</lmdate>
    <icon>geriatrics.png</icon>
    <weblink></weblink>
    <bibliography pmid=""></bibliography>

    <!-- Translatable values -->
    <license>GPLv3</license>
    <description lang="fr">Test des widgets de calcul</description>
    <description lang="xx">Calcul widget test</description>
    <category lang="xx">Test</category>
    <category lang="fr">Test</category>
    <specialties lang="fr">Test</specialties>
    <specialties lang="xx">Test</specialties>

  </formdescription>


  <MedForm name="Test::Calculation::Sum">
    <label lang="xx">Test Calcul (sum)</label>
    <label lang="fr">Test Calcul (sum)</label>
    <options>col=2;DontPrintEmptyValues;UseFormNameAsNameSpace</options>

    <Item name="Phone" type="radio">
      <label lang="xx">&lt;b&gt;Téléphone&lt;/b&gt;</label>
      <options>vertical;labelontop;DontPrintEmptyValues</options>
      <value>
        <uuid id="0">P0</uuid>
        <uuid id="1">P1</uuid>
        <uuid id="2">P2</uuid>
        <uuid id="3">P3</uuid>

        <possible id="0" lang="fr">Se sert du téléphone de sa propre initiative. Recherche des numéros et les compose, etc.</possible>
        <possible id="1" lang="fr">Compose seulement quelques numéros de téléphone bien connus.</possible>
        <possible id="2" lang="fr">Peut répondre au téléphone, mais ne peut pas appeler.</possible>
        <possible id="3" lang="fr">Ne se sert pas du tout du téléphone.</possible>

        <possible id="0" lang="xx">Operates telephone on own initiative; looks up and dials numbers.</possible>
        <possible id="1" lang="xx">Dials a few well-known numbers.</possible>
        <possible id="2" lang="xx">Answers telephone, but does not dial.</possible>
        <possible id="3" lang="xx">Does not use telephone at all.</possible>

        <numerical id="0">1</numerical>
        <numerical id="1">1</numerical>
        <numerical id="2">1</numerical>
        <numerical id="3">0</numerical>
      </value>
    </Item>

    <Item name="Shopping" type="radio">
      <label lang="xx">&lt;b&gt;Shopping&lt;/b&gt;</label>
      <label lang="fr">&lt;b&gt;Courses&lt;/b&gt;</label>
      <options>vertical;labelontop;DontPrintEmptyValues</options>
      <value>
        <uuid id="0">S0</uuid>
        <uuid id="1">S1</uuid>
        <uuid id="2">S2</uuid>
        <uuid id="3">S3</uuid>

        <possible id="0" lang="fr">Peut faire toutes les courses nécessaires de façon autonome.</possible>
        <possible id="1" lang="fr">N'est indépendant que pour certaines courses.</possible>
        <possible id="2" lang="fr">A besoin d'être accompagné pour faire ses courses.</possible>
        <possible id="3" lang="fr">Est complètement incapable de faire des courses.</possible>

        <possible id="0" lang="xx">Takes care of all shopping needs independently.</possible>
        <possible id="1" lang="xx">Shops independently for small purchases.</possible>
        <possible id="2" lang="xx">Needs to be accompanied on any shopping trip.</possible>
        <possible id="3" lang="xx">Is completely unable to shop.</possible>

        <numerical id="0">1</numerical>
        <numerical id="1">0</numerical>
        <numerical id="2">0</numerical>
        <numerical id="3">0</numerical>
      </value>
    </Item>

    <Item name="Total" type="sum">
      <label lang="fr">&lt;b&gt;Résultat&lt;/b&gt;</label>
      <label lang="xx">&lt;b&gt;Total&lt;/b&gt;</label>
      <options>vertical;labelontop;changeepisodelabel;DontPrintEmptyValues</options>
      <sumof_regexp>Test::Calculation::Sum::*</sumof_regexp>
    </Item>

 </MedForm>

  <MedForm name="Test::Calculation::Script">
    <label lang="xx">Test Calcul (script)</label>
    <label lang="fr">Test Calcul (script)</label>
    <options>col=2;DontPrintEmptyValues;UseFormNameAsNameSpace</options>

    <Item name="First" type="radio">
      <label lang="xx">First item</label>
      <options>vertical;labelontop;DontPrintEmptyValues</options>
      <value>
        <uuid id="0">P0</uuid>
        <uuid id="1">P1</uuid>
        <uuid id="2">P2</uuid>
        <uuid id="3">P3</uuid>

        <possible id="0" lang="xx">-1</possible>
        <possible id="1" lang="xx">0</possible>
        <possible id="2" lang="xx">+1</possible>
        <possible id="3" lang="xx">+2</possible>

        <numerical id="0">-1</numerical>
        <numerical id="1">0</numerical>
        <numerical id="2">1</numerical>
        <numerical id="3">2</numerical>
      </value>
    </Item>

    <Item name="Second" type="combo">
      <label lang="xx">Second Item</label>
      <options>vertical;labelontop;DontPrintEmptyValues</options>
      <value>
        <uuid id="0">S0</uuid>
        <uuid id="1">S1</uuid>
        <uuid id="2">S2</uuid>
        <uuid id="3">S3</uuid>
        <uuid id="4">S4</uuid>

        <possible id="0" lang="xx">-3</possible>
        <possible id="1" lang="xx">-1</possible>
        <possible id="2" lang="xx">1</possible>
        <possible id="3" lang="xx">3</possible>
        <possible id="4" lang="xx">5</possible>

        <numerical id="0">-3</numerical>
        <numerical id="1">-1</numerical>
        <numerical id="2">1</numerical>
        <numerical id="3">3</numerical>
        <numerical id="4">5</numerical>
      </value>
    </Item>

    <Item name="Formula" type="combo">
      <label lang="xx">Select formula</label>
      <options>vertical;labelontop;DontPrintEmptyValues</options>
      <value>
        <uuid id="0">S0</uuid>
        <uuid id="1">S1</uuid>
        <uuid id="2">S2</uuid>
        <uuid id="3">S3</uuid>
        <uuid id="4">S4</uuid>

        <possible id="0" lang="xx">first*second</possible>
        <possible id="1" lang="xx">((+first)+(+second))*(second-1)</possible>
        <possible id="2" lang="xx">first/second</possible>
        <possible id="3" lang="xx">(first*second)/(second*2.3)</possible>
        <possible id="4" lang="xx">(+first)+(+second)</possible>
      </value>
    </Item>

    <Item name="Total" type="scriptcalculation">
      <label lang="xx">Result</label>
      <options>vertical;labelontop;changeepisodelabel;DontPrintEmptyValues</options>
      <connect_regexp>Test::Calculation::Script::*</connect_regexp>
      <calcScript>
        var s = "Script test: ";
        freemedforms.forms.namespaceInUse = "Test::Calculation::Script";
        var first = freemedforms.forms.item("First").currentValue;
        var second = freemedforms.forms.item("Second").currentValue;
        var calc = freemedforms.forms.item("Formula").currentText;
        var tmp = calc;
        tmp = tmp.replace(/first/g, first.toString());
        tmp = tmp.replace(/second/g, second.toString());
        s += "(Formula:"+calc+"="+tmp+") = " + eval(calc);
        s;
      </calcScript>
    </Item>

 </MedForm>

</FreeMedForms>
