Skip to content

Commit

Permalink
Added debug statement
Browse files Browse the repository at this point in the history
ertush committed Aug 2, 2024
1 parent 02577f1 commit 4b9c50d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions facilities/models/facility_models.py
Original file line number Diff line number Diff line change
@@ -136,12 +136,9 @@ def get_org_unit_id(self, code):
}
)
print("Get Org Unit ID Response", r.text, str(code))
raise ValidationError("[DEBUG] Repsonse {}".format(r.text))

if len(r.json()["organisationUnits"]) is 1 and "id" in r.json()["organisationUnits"][0]:
# raise ValidationError(
# {
# "Error!": ["This facility is already available in DHIS2. Please ensure details are correct"]
# }
# )
return [r.json()["organisationUnits"][0]["id"], 'retrieved']
else:
r_generate_orgunit_uid = requests.get(
@@ -190,7 +187,7 @@ def get_parent_id(self, ward_id):
else:
return dhis2_facility[0]["id"]

def push_facility_to_dhis2(self, new_facility_payload, new_facility, isRetrived):
def push_facility_to_dhis2(self, new_facility_payload, new_facility):
if new_facility:
r = requests.post(
settings.DHIS_ENDPOINT+"api/organisationUnits",
@@ -1383,6 +1380,7 @@ def push_new_facility(self, code=None):
facility_code = str(self.code)
new_facility_payload = {
"id": dhis2_org_unit_id[0],
"access": dhis2_org_unit_id[1],
"code": facility_code,
"name": str(self.name),
"shortName": str(self.name[:49]),
@@ -1407,7 +1405,7 @@ def push_new_facility(self, code=None):

if dhis2_org_unit_id[1] == 'retrieved':
new_facility = False
self.dhis2_api_auth.push_facility_to_dhis2(new_facility_payload, new_facility, dhis2_org_unit_id)
self.dhis2_api_auth.push_facility_to_dhis2(new_facility_payload, new_facility)
# facility_uid = self.dhis2_api_auth.get_org_unit_id(self.code)
facility_uid = dhis2_org_unit_id[0]
self.dhis2_api_auth.push_facility_metadata(metadata_payload, facility_uid)

0 comments on commit 4b9c50d

Please sign in to comment.