Here's an approach that should work (if I understand your problem correctly). Exact syntax not guaranteed...
1. Add a HIT or DAMMAGED eventhandler to the desired units. When a unit is hit, you the eventHandler will call the unitHealedDetector.sqs script.
this addEventHandler ["hit", {[_this select 0] exec "unitHealedDetector.sqs"}]
2. The script:
;*****************************************************************************
; unitHealedDetector.sqs
;*****************************************************************************
_unit = _this select 0;
;*****************************************************************************
; Remove EH so it only runs once per Heal tracking usage. After unit goes to MASH unit for
; serious healing, you can re-add the eventhandler to the unit.
;*****************************************************************************
_unit removeEventHandler ["hit", 0]
_damageBeforeHeal := getDammage _unit;
;*****************************************************************************
; Use loop to wait until unit has been healed (i.e., dammage reset to zero). Sleep 1 second for each
; loop iteration.
;*****************************************************************************
#loop1
~1
? (getDammage _unit >= 0): goto "loop1"
;*****************************************************************************
; If damage was light (<=.5) then unit was healed by medic, but does not need to go to the MASH,
; so we skip the MASH code, and jump to bottom of script to re-add the eventhandler.
;*****************************************************************************
?(_damageBeforeHeal <= .5): goto "AddEH"
;*****************************************************************************
; Injury is a Heavy Injury, so put your code here that sends unit to MASH.
;*****************************************************************************
<MASH code goes here>
;*****************************************************************************
; After unit is healed (at MASH, or light injury healed by medic), we re-add the EventHandler.
;*****************************************************************************
#AddEH
_unit addEventHandler ["hit", {[_this select 0] exec "unitHealedDetector.sqs"}]
exit