@@ -0,0 +1,1129 @@
+from radar.concepts.core import Concept%0Afrom radar.sda.models import SDAEncounter%0Afrom radar.validators import required%0A%0A%0Aclass HospitalisationConcept(Concept):%0A    validators = %7B%0A        'date_of_admission': %5Brequired%5D,%0A    %7D%0A%0A    def __init__(self, date_of_admission, date_of_discharge):%0A        super(HospitalisationConcept, self).__init__()%0A%0A        self.date_of_admission = date_of_admission%0A        self.date_of_discharge = date_of_discharge%0A%0A    def validate(self):%0A        if not super(HospitalisationConcept, self).validate():%0A            return False%0A%0A        if self.date_of_discharge is not None and self.date_of_discharge %3C self.date_of_admission:%0A            self.errors%5B'date_of_discharge'%5D.append('Must be on or after date of admission.')%0A%0A        return not self.errors%0A%0A    def to_sda(self, sda_bundle):%0A        sda_encounter = SDAEncounter()%0A%0A        data = %7B%0A            'from_date': self.date_of_admission,%0A        %7D%0A%0A        if self.date_of_discharge is not None:%0A            data%5B'to_date'%5D = self.date_of_discharge%0A%0A        sda_encounter.data = data%0A        sda_bundle.sda_encounters.append(sda_encounter)

Add hospitalisation concept