Skip to content

Commit

Permalink
RLPPTM: include commission details in TestFacilityInfo API
Browse files Browse the repository at this point in the history
  • Loading branch information
nursix committed Nov 30, 2022
1 parent 829dd35 commit 3ddd33b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nursix-dev-5554-g9e3545071 (2022-11-30 14:59:28)
nursix-dev-5555-g829dd3571 (2022-11-30 15:21:50)
32 changes: 30 additions & 2 deletions modules/templates/RLPPTM/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,13 @@ def facility_info(r, **attr):
"name": "ORG-NAME", - the organisation name
"type": "ORG-TYPE", - the organisation type
"website": "URL" - the organisation website URL
"commission": [ - commissioning details
{"start": YYYY-MM-DD,
"end": YYYY-MM-DD,
"status": CURRENT|SUSPENDED|REVOKED|EXPIRED,
"status_date": YYYY-MM-DD,
}, ...
]
},
"location":
{"L1": "L1-NAME", - the L1 name (state)
Expand All @@ -2338,7 +2345,7 @@ def facility_info(r, **attr):
"report": ["start","end"], - echoed from input, ISO-format dates YYYY-MM-DD
"activity":
{"tests": NN - the total number of tests reported for the period
}
},
}
"""

Expand Down Expand Up @@ -2431,7 +2438,8 @@ def facility_info(r, **attr):
]
query = (otable.id == facility.organisation_id) & \
(otable.deleted == False)
row = db(query).select(otable.name,
row = db(query).select(otable.id,
otable.name,
otable.website,
ttable.name,
ottable.value,
Expand All @@ -2447,6 +2455,26 @@ def facility_info(r, **attr):
"type": orgtype.name,
"website": organisation.website,
}

# Add commission data
ctable = s3db.org_commission
query = (ctable.organisation_id == organisation.id) & \
(ctable.deleted == False)
commissions = db(query).select(ctable.date,
ctable.end_date,
ctable.status,
ctable.status_date,
)
dtfmt = lambda dt: dt.isoformat() if dt else '--'
clist = []
for commission in commissions:
clist.append({"start": dtfmt(commission.date),
"end": dtfmt(commission.end_date),
"status": commission.status,
"status_date": dtfmt(commission.status_date),
})
orgdata["commission"] = clist

output["organisation"] = orgdata

# Look up location data
Expand Down

0 comments on commit 3ddd33b

Please sign in to comment.