Advertisement
Guest User

CarePlans forms

a guest
Dec 18th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.15 KB | None | 0 0
  1. Careplan has:
  2. - condition_name: string
  3. - privacy_settings: integer
  4. - start_date: date
  5. - treatments[]: Array
  6.  
  7. Treatments are build using form which are mapped to the DB. The base for the rest of care_plans is Treatment form:
  8.  
  9. class Treatment(models.Model):
  10.     duration = models.DateField(blank=True, null=True)
  11.     prescribed_by = models.TextField(blank=True, null=True)
  12.     plan_details = models.TextField(blank=True, null=True)
  13.     length = models.IntegerField(blank=True, null=True)
  14.     length_unit = models.TextField(blank=True, null=True)
  15.     condition = models.ForeignKey(Condition, related_name='treatments')
  16.  
  17.     class Meta:
  18.         db_table = 'treatments'
  19.         app_label = 'miamiApp'
  20.  
  21.     def as_json(self):
  22.         return dict(
  23.             condition=self.condition,
  24.             diagnosis_date=self.diagnosis_date,
  25.             duration=self.duration,
  26.             privacy=self.privacy,
  27.             prescribed_by=self.prescribed_py,
  28.             plan_details=self.plan_details,
  29.             length=self.length,
  30.             length_unit=self.length_unit
  31.         )
  32.  
  33. The other care_plans models:
  34.  
  35. class Therapy(models.Model):
  36.     type = models.TextField(blank=True, null=True)
  37.     frequency = models.IntegerField(blank=True, null=True)
  38.     frequency_unit = models.TextField(blank=True, null=True)
  39.     session_length = models.IntegerField(blank=True, null=True)
  40.     session_length_unit = models.TextField(blank=True, null=True)
  41.     treatment = models.ForeignKey(Treatment, related_name='therapies')
  42.  
  43.     class Meta:
  44.         db_table = 'therapies'
  45.         app_label = 'miamiApp'
  46.  
  47.     def as_json(self):
  48.         return dict(
  49.             type=self.type,
  50.             frequency=self.frequency,
  51.             frequency_unit=self.frequency_unit,
  52.             session_length=self.session_length,
  53.             session_length_unit=self.session_length_unit
  54.         )
  55. #########################################################################
  56. class Physical(models.Model):
  57.     frequency = models.IntegerField(blank=True, null=True)
  58.     frequency_unit = models.TextField(blank=True, null=True)
  59.     session_length = models.IntegerField(blank=True, null=True)
  60.     session_length_unit = models.TextField(blank=True, null=True)
  61.     treatment = models.ForeignKey(Treatment, related_name='physical_activities')
  62.  
  63.     class Meta:
  64.         db_table = 'physical_activities'
  65.         app_label = 'miamiApp'
  66.  
  67.     def as_json(self):
  68.         return dict(
  69.             frequency=self.frequency,
  70.             frequency_unit=self.frequency_unit,
  71.             session_length=self.session_length,
  72.             session_length_unit=self.session_length_unit
  73.         )
  74. #########################################################################
  75. class Other(models.Model):
  76.     type = models.TextField(blank=True, null=True)
  77.     frequency = models.IntegerField(blank=True, null=True)
  78.     frequency_unit = models.TextField(blank=True, null=True)
  79.     session_length = models.IntegerField(blank=True, null=True)
  80.     session_length_unit = models.TextField(blank=True, null=True)
  81.     treatment = models.ForeignKey(Treatment, related_name='other_treatments')
  82.  
  83.     class Meta:
  84.         db_table = 'other_treatments'
  85.         app_label = 'miamiApp'
  86.  
  87.     def as_json(self):
  88.         return dict(
  89.             type=self.type,
  90.             frequency=self.frequency,
  91.             frequency_unit=self.frequency_unit,
  92.             session_length=self.session_length,
  93.             session_length_unit=self.session_length_unit
  94.         )
  95. ########################################################################
  96. class Nutrition(models.Model):
  97.     calories = models.IntegerField(blank=True, null=True)
  98.     calories_frequency = models.TextField(blank=True, null=True)
  99.     carbohydrates = models.IntegerField(blank=True, null=True)
  100.     fat = models.IntegerField(blank=True, null=True)
  101.     protein = models.IntegerField(blank=True, null=True)
  102.     treatment = models.ForeignKey(Treatment, related_name='nutritions')
  103.  
  104.     class Meta:
  105.         db_table = 'nutritions'
  106.         app_label = 'miamiApp'
  107.  
  108.     def as_json(self):
  109.         return dict(
  110.             calories=self.calories,
  111.             calories_frequency=self.calories_frequency,
  112.             carbohydrates=self.carbohydrates,
  113.             fat=self.fat,
  114.             protein=self.protein
  115.         )
  116. #########################################################
  117. class Medicine(models.Model):
  118.     name = models.TextField()
  119.     dosage = models.IntegerField(blank=True, null=True)
  120.     dosage_unit = models.TextField(blank=True, null=True)
  121.     frequency = models.IntegerField(blank=True, null=True)
  122.     frequency_unit = models.TextField(blank=True, null=True)
  123.     form = models.TextField(blank=True, null=True)
  124.     days_before_refill = models.IntegerField(blank=True, null=True)
  125.     treatment = models.ForeignKey(Treatment, related_name='medicines')
  126.  
  127.     class Meta:
  128.         db_table = 'medicines'
  129.         app_label = 'miamiApp'
  130.  
  131.     def as_json(self):
  132.         return dict(
  133.             name=self.name,
  134.             dosage=self.dosage,
  135.             dosage_unit=self.dosage_unit,
  136.             frequency=self.frequency,
  137.             frequency_unit=self.frequency_unit,
  138.             form=self.form,
  139.             days_before_refill=self.days_before_refill
  140.         )
  141. ##############################################################
  142. class Condition(models.Model):
  143.     user = models.ForeignKey(User)
  144.     name = models.TextField(blank=True, null=True)
  145.     diagnosis_date = models.DateField(blank=True, null=True)
  146.     privacy = models.TextField(blank=True, null=True)
  147.  
  148.     class Meta:
  149.         db_table = 'conditions'
  150.         app_label = 'miamiApp'
  151.  
  152.     def as_json(self):
  153.         return dict(
  154.             user=self.user.as_json(),
  155.             name=self.name,
  156.             diagnosis_date=self.diagnosis_date,
  157.             privacy=self.privacy
  158.         )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement