Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Careplan has:
- - condition_name: string
- - privacy_settings: integer
- - start_date: date
- - treatments[]: Array
- Treatments are build using form which are mapped to the DB. The base for the rest of care_plans is Treatment form:
- class Treatment(models.Model):
- duration = models.DateField(blank=True, null=True)
- prescribed_by = models.TextField(blank=True, null=True)
- plan_details = models.TextField(blank=True, null=True)
- length = models.IntegerField(blank=True, null=True)
- length_unit = models.TextField(blank=True, null=True)
- condition = models.ForeignKey(Condition, related_name='treatments')
- class Meta:
- db_table = 'treatments'
- app_label = 'miamiApp'
- def as_json(self):
- return dict(
- condition=self.condition,
- diagnosis_date=self.diagnosis_date,
- duration=self.duration,
- privacy=self.privacy,
- prescribed_by=self.prescribed_py,
- plan_details=self.plan_details,
- length=self.length,
- length_unit=self.length_unit
- )
- The other care_plans models:
- class Therapy(models.Model):
- type = models.TextField(blank=True, null=True)
- frequency = models.IntegerField(blank=True, null=True)
- frequency_unit = models.TextField(blank=True, null=True)
- session_length = models.IntegerField(blank=True, null=True)
- session_length_unit = models.TextField(blank=True, null=True)
- treatment = models.ForeignKey(Treatment, related_name='therapies')
- class Meta:
- db_table = 'therapies'
- app_label = 'miamiApp'
- def as_json(self):
- return dict(
- type=self.type,
- frequency=self.frequency,
- frequency_unit=self.frequency_unit,
- session_length=self.session_length,
- session_length_unit=self.session_length_unit
- )
- #########################################################################
- class Physical(models.Model):
- frequency = models.IntegerField(blank=True, null=True)
- frequency_unit = models.TextField(blank=True, null=True)
- session_length = models.IntegerField(blank=True, null=True)
- session_length_unit = models.TextField(blank=True, null=True)
- treatment = models.ForeignKey(Treatment, related_name='physical_activities')
- class Meta:
- db_table = 'physical_activities'
- app_label = 'miamiApp'
- def as_json(self):
- return dict(
- frequency=self.frequency,
- frequency_unit=self.frequency_unit,
- session_length=self.session_length,
- session_length_unit=self.session_length_unit
- )
- #########################################################################
- class Other(models.Model):
- type = models.TextField(blank=True, null=True)
- frequency = models.IntegerField(blank=True, null=True)
- frequency_unit = models.TextField(blank=True, null=True)
- session_length = models.IntegerField(blank=True, null=True)
- session_length_unit = models.TextField(blank=True, null=True)
- treatment = models.ForeignKey(Treatment, related_name='other_treatments')
- class Meta:
- db_table = 'other_treatments'
- app_label = 'miamiApp'
- def as_json(self):
- return dict(
- type=self.type,
- frequency=self.frequency,
- frequency_unit=self.frequency_unit,
- session_length=self.session_length,
- session_length_unit=self.session_length_unit
- )
- ########################################################################
- class Nutrition(models.Model):
- calories = models.IntegerField(blank=True, null=True)
- calories_frequency = models.TextField(blank=True, null=True)
- carbohydrates = models.IntegerField(blank=True, null=True)
- fat = models.IntegerField(blank=True, null=True)
- protein = models.IntegerField(blank=True, null=True)
- treatment = models.ForeignKey(Treatment, related_name='nutritions')
- class Meta:
- db_table = 'nutritions'
- app_label = 'miamiApp'
- def as_json(self):
- return dict(
- calories=self.calories,
- calories_frequency=self.calories_frequency,
- carbohydrates=self.carbohydrates,
- fat=self.fat,
- protein=self.protein
- )
- #########################################################
- class Medicine(models.Model):
- name = models.TextField()
- dosage = models.IntegerField(blank=True, null=True)
- dosage_unit = models.TextField(blank=True, null=True)
- frequency = models.IntegerField(blank=True, null=True)
- frequency_unit = models.TextField(blank=True, null=True)
- form = models.TextField(blank=True, null=True)
- days_before_refill = models.IntegerField(blank=True, null=True)
- treatment = models.ForeignKey(Treatment, related_name='medicines')
- class Meta:
- db_table = 'medicines'
- app_label = 'miamiApp'
- def as_json(self):
- return dict(
- name=self.name,
- dosage=self.dosage,
- dosage_unit=self.dosage_unit,
- frequency=self.frequency,
- frequency_unit=self.frequency_unit,
- form=self.form,
- days_before_refill=self.days_before_refill
- )
- ##############################################################
- class Condition(models.Model):
- user = models.ForeignKey(User)
- name = models.TextField(blank=True, null=True)
- diagnosis_date = models.DateField(blank=True, null=True)
- privacy = models.TextField(blank=True, null=True)
- class Meta:
- db_table = 'conditions'
- app_label = 'miamiApp'
- def as_json(self):
- return dict(
- user=self.user.as_json(),
- name=self.name,
- diagnosis_date=self.diagnosis_date,
- privacy=self.privacy
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement