<xml>
  <workflow>
    <node name='Suspects'></node>
    <node name='firstContact'></node>
    <node name='imaging'></node>
    <node name='patology'></node>
    <node name='surgery'></node>
    <node name='chemotherapy'></node>
    <node name='radiotherapy'></node>
    <node name='followup'></node>
    <node name='dead' type='END'></node>
    <node name='alive'></node>
    <node name='pre Treatment'></node>
    <node name='Treatment'></node>
    
      <trigger name='t_Suspects'>
          <condition>'BEGIN' %in% $st.ACTIVE$</condition>
          <set>'Suspects'</set>
          <set>'pre Treatment'</set>
          <set>'alive'</set>
          <unset>'BEGIN'</unset>
      </trigger>   

      <trigger name='t_firstContact'>
          <condition>'Suspects' %in% $st.ACTIVE$ AND $ev.NOW$=='MedicalVisit'</condition>
          <set>'firstContact'</set>
          <unset>'Suspects'</unset>
      </trigger>   

      <trigger name='t_MedicalExamination'>
          <condition>'Suspects' %in% $st.ACTIVE$ AND $ev.NOW$=='Biopsy'</condition>
          <set>'patology'</set>
          <unset>'Suspects'</unset>
          <unset>'firstContact'</unset>
      </trigger>   
      
      <trigger name='t_surgery'>
          <condition>'patology' %in% $st.ACTIVE$ AND ($ev.NOW$=='total resection' OR $ev.NOW$=='partial resection')</condition>
          <set>'surgery'</set>
          <set>'Treatment'</set>
          <unset>'pre Treatment'</unset>
          <unset>'patology'</unset>
      </trigger>        

      <trigger name='t_radiotherapy'>
          <condition>'Treatment' %in% $st.ACTIVE$ AND $ev.NOW$=='radiotherapy' </condition>
          <set>'radiotherapy'</set>
          <unset>'surgery'</unset>
      </trigger> 
      
      <trigger name='t_chemotherapy'>
          <condition>'Treatment' %in% $st.ACTIVE$ AND $ev.NOW$=='chemotherapy'</condition>
          <set>'chemotherapy'</set>
          <unset>'surgery'</unset>
      </trigger>       
      
      <trigger name='t_followup'>
          <condition>('surgery' %in% $st.ACTIVE$ OR 'radiotherapy' %in% $st.ACTIVE$ OR 'chemotherapy' %in% $st.ACTIVE$)  AND $ev.NOW$=='MedicalVisit'</condition>
          <set>'followup'</set>
          <unset>'surgery'</unset>
          <unset>'Treatment'</unset>
          <unset>'chemotherapy'</unset>
          <unset>'radiotherapy'</unset>
      </trigger>       
      
      <trigger name='t_death'>
          <condition>$ev.NOW$=='death' AND !('BEGIN' %in% $st.ACTIVE$)</condition>
          <set>'dead'</set>
          <unset>'alive'</unset>
      </trigger>             

    </workflow>
</xml>
