Skip to content

Commit

Permalink
Merge pull request #96 from KPMP/KPMP-5581_remove_biopsy_query
Browse files Browse the repository at this point in the history
KPMP-5581: remove biopsy query, update field names
  • Loading branch information
zwright authored Oct 7, 2024
2 parents f4e04a0 + 3ecab76 commit 6b3e2d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
5 changes: 0 additions & 5 deletions data_management/lib/spectrack_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ def get_specimen_kit_by_specimen_kit_id(self, specimen_kit_id: str):
self.get_url(self.SPECIMEN_KIT_URL_SUFFIX), {"kit_id": specimen_kit_id}
)

def get_biopsy_by_redcap_id(self, redcap_id: str):
return self.get_results(
self.get_url(self.BIOPSY_URL_SUFFIX), {"redcap_record_id": redcap_id}
)

def get_organization_by_id(self, org_id: int):
return self.get_results(
self.get_url(self.ORGANIZATION_URL_SUFFIX) + "/" + str(org_id)
Expand Down
19 changes: 7 additions & 12 deletions data_management/services/spectrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ def get_sample_type(self, sample_type_id: int):
self.sample_types.update({sample_type_id: sample_type})
return sample_type

def get_biopsy(self, redcap_id: str):
results = self.st.get_biopsy_by_redcap_id(redcap_id)
return results["results"][0]

def get_specimen_kit(self, specimen_kit_id: str):
results = self.st.get_specimen_kit_by_specimen_kit_id(specimen_kit_id)
return results["results"][0]
Expand All @@ -55,23 +51,22 @@ def convert_to_dmd_specimens(self, specimens: list):
dmd_specimens = list()
for specimen in specimens:
# We don't want any records without a kit ID or Redcap ID
if ("specimen_kit_id" in specimen) and (
if ("specimen_collection__specimen_kit__kit_id" in specimen) and (
specimen["redcap_record_id"] is not None
):
specimen_kit = self.get_specimen_kit(specimen["specimen_kit_id"])
if specimen["specimen_kit_id"] and "Biopsy Kit" in specimen_kit["kit_type_name"]:
biopsy = self.get_biopsy(specimen["redcap_record_id"])
site = biopsy["collecting_org"]["org_name"]
disease_category = biopsy["disease_category"]
biopsy_date = biopsy["biopsy_date"]
specimen_kit = self.get_specimen_kit(specimen["specimen_collection__specimen_kit__kit_id"])
if specimen["specimen_collection__specimen_kit__kit_id"] and "Biopsy Kit" in specimen_kit["kit_type_name"]:
site = specimen["specimen_collection__collecting_org__org_name"]
disease_category = specimen["disease_category"]
biopsy_date = specimen["biopsy_date"]
else:
organization = self.st.get_by_url(specimen_kit["site"])
site = organization["org_name"]
disease_category = None
biopsy_date = None

sample_type = self.get_sample_type(specimen["sample_type_id"])
kit_id = "N/A" if specimen['specimen_kit_id'] is None else specimen['specimen_kit_id']
kit_id = "N/A" if specimen['specimen_collection__specimen_kit__kit_id'] is None else specimen['specimen_collection__specimen_kit__kit_id']
dmd_specimen_tuple = (
specimen["id"],
specimen["sample_id"],
Expand Down

0 comments on commit 6b3e2d9

Please sign in to comment.