Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- class ObesMenRelation(Schema):
- id: int
- obestetric_id: int = None #= models.ForeignKey(Obestetric, on_delete=models.CASCADE)
- patient_id: int = None #= models.ForeignKey(Patients, verbose_name='Patient Name:', on_delete=models.CASCADE)
- obdate: date = None # = models.DateField(blank=True, null=True, verbose_name='Follow Up Date:')
- gyn: bool = False #= models.BooleanField(verbose_name='Gyn:', default=False)
- g: int = None #= models.IntegerField(default=0, blank=True, null=True, verbose_name='G:')
- p: int = None # = models.IntegerField(default=0, blank=True, null=True, verbose_name='P:')
- a: int = None # = models.IntegerField(default=0, blank=True, null=True, verbose_name='A:')
- nvd: bool = False # = models.BooleanField(default=False, verbose_name='NVD:')
- cs: bool = False #= models.BooleanField(default=False, verbose_name='CS:')
- ld: str = "" # = models.CharField(max_length=150, blank=True, null=True, verbose_name='LD:')
- lc: str = "" #= models.CharField(max_length=150, blank=True, null=True, verbose_name='LC:')
- hist: str = ""
- lmp: date = None #= models.DateField(blank=True, null=True, verbose_name='LMP:')
- edd: date = None #= models.DateField(blank=True, null=True, verbose_name='EDD:')
- ga: str = "" #= models.CharField(max_length=50, blank=True, null=True, verbose_name='G.A:')
- remain: str = ""
- from typing import List # Important import to get all objects without error
- @api.get('/all/obestetric/', response=List[ObesMenRelation])
- def get_obestetric(request):
- # obs = Obestetric.objects.all().order_by('-id')
- obs = Menstrual.objects.select_related('obestetric')
- return obs
- ## This is my database
- clinicdb=# SELECT * from gyno_obestetric;
- id | gyn | g | p | a | nvd | cs | ld | lc | hist | patient_id | obdate
- ----+-----+---+---+---+-----+----+--------+--------+-----------------------------------+------------+------------
- 1 | f | 1 | 0 | 0 | t | f | any ld | any lc | anything about obestetric history | 8 | 2021-03-12
- 2 | f | 3 | 1 | 1 | f | t | any ld | any lc | any | 5 | 2021-03-12
- (2 rows)
- clinicdb=# SELECT * from gyno_menstrual;
- id | lmp | edd | ga | remain | obestetric_id | patient_id
- ----+------------+------------+----+--------+---------------+------------
- 78 | 2021-01-01 | 2021-10-08 | 10 | 30 | 1 | 8
- 79 | 2020-07-01 | 2021-04-07 | 36 | 4 | 2 | 5
- (2 rows)
- ## This is the result after Execution from here(http://localhost:8000/api/docs#/default/apps_gyno_api_get_obestetric)
- [
- {
- "id": 78,
- "obestetric_id": 1,
- "patient_id": 8,
- "obdate": null,
- "gyn": false,
- "g": null, # why it is null
- "p": null, # why it is null
- "a": null, # why it is null
- "nvd": false, # why it is false
- "cs": false,
- "ld": "", # why it is empty
- "lc": "", # why it is empty
- "hist": "", # why it is empty
- "lmp": "2021-01-01",
- "edd": "2021-10-08",
- "ga": "10",
- "remain": "30"
- },
- {
- "id": 79,
- "obestetric_id": 2,
- "patient_id": 5,
- "obdate": null,
- "gyn": false,
- "g": null,
- "p": null,
- "a": null,
- "nvd": false,
- "cs": false,
- "ld": "",
- "lc": "",
- "hist": "",
- "lmp": "2020-07-01",
- "edd": "2021-04-07",
- "ga": "36",
- "remain": "4"
- }
- ]
Add Comment
Please, Sign In to add comment