phc-ingestion 0.10.18__py3-none-any.whl → 0.10.20__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,7 @@ def check_manifest(manifest_file_path: str, case_id, log: Logger):
44
44
  Optional("plasmaTumorFraction"): str,
45
45
  Optional("cellPurity"): float,
46
46
  Optional("hrdStatus"): str,
47
+ Optional("specimenIds"): list[str],
47
48
  }
48
49
  )
49
50
 
@@ -0,0 +1,76 @@
1
+ from typing import Any
2
+ from lifeomic_logging import scoped_logger
3
+ from ingestion.shared_util.lambda_client import LambdaClient
4
+
5
+ # Constants
6
+ DATASET_SYSTEM = "http://lifeomic.com/fhir/dataset"
7
+
8
+
9
+ def fetch_patient(
10
+ *,
11
+ elation_id: str,
12
+ given_name: str,
13
+ birthdate: str,
14
+ project_id: str,
15
+ account_id: str,
16
+ ingestion_id: str,
17
+ ) -> dict[str, Any] | None:
18
+ """
19
+ Fetch a patient from the patient-service lambda using Elation ID AND given name AND
20
+ birthdate.
21
+
22
+ Returns:
23
+ The patient resource if found, None otherwise
24
+
25
+ Raises:
26
+ RuntimeError: When multiple patients are found (ambiguous match)
27
+ """
28
+ log_context = {
29
+ "accountId": account_id,
30
+ "projectId": project_id,
31
+ "elationId": elation_id,
32
+ "ingestionId": ingestion_id,
33
+ }
34
+
35
+ with scoped_logger(__name__, log_context) as log:
36
+ # Create LambdaClient instance with proper headers
37
+ client = LambdaClient(
38
+ "patient-service",
39
+ {
40
+ "Content-Type": "application/json",
41
+ "LifeOmic-Account": account_id,
42
+ "LifeOmic-Correlation-Id": ingestion_id,
43
+ },
44
+ )
45
+
46
+ # Search by Elation ID AND given name AND birthdate
47
+ log.info(
48
+ f"Searching for patient with Elation ID: {elation_id}, given name: {given_name}, birthdate: {birthdate}"
49
+ )
50
+ response = client.invoke(
51
+ f"/{account_id}/dstu3/Patient",
52
+ "get",
53
+ None,
54
+ {
55
+ "_tag": f"{DATASET_SYSTEM}|{project_id}",
56
+ "identifier": elation_id,
57
+ "name": given_name,
58
+ "birthdate": birthdate,
59
+ },
60
+ )
61
+ entries = response.get("entry", [])
62
+
63
+ if len(entries) == 0:
64
+ error_msg = f"No patient found with Elation ID: {elation_id}, given name: {given_name}, birthdate: {birthdate}"
65
+ log.error(error_msg)
66
+ raise RuntimeError(error_msg)
67
+
68
+ if len(entries) > 1:
69
+ error_msg = f"Found multiple patients when one was expected. Found {len(entries)}. Elation ID {elation_id}, given name {given_name}, birthdate {birthdate}."
70
+ log.error(error_msg)
71
+ raise RuntimeError(error_msg)
72
+
73
+ log.info(
74
+ f"Found patient with Elation ID: {elation_id}, given name: {given_name}, birthdate: {birthdate}"
75
+ )
76
+ return entries[0]["resource"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phc-ingestion
3
- Version: 0.10.18
3
+ Version: 0.10.20
4
4
  Summary: Functions for LifeOmic PHC genomic ingestions
5
5
  License: MIT
6
6
  Author-email: LifeOmic Development <development@lifeomic.com>
@@ -25,7 +25,7 @@ ingestion/foundation/util/interpretation.py,sha256=LVVUmMyD6Un1rIKXqiyQDUC6oIJUd
25
25
  ingestion/foundation/util/vcf_etl.py,sha256=GXV5JXswwdyHEEdPsM3Qq8tDPFkvZajrZn5chWgF53k,2266
26
26
  ingestion/generic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  ingestion/generic/process.py,sha256=ZaVnZ_gx9faDUsuresI1A0oCegTa-dPQT7DBFMeZGyY,1777
28
- ingestion/generic/utils.py,sha256=1MEIru7uq38IjUdL8lcHqDH0oTki9uWrz1f2e-pmRoU,2814
28
+ ingestion/generic/utils.py,sha256=_v3dKqlZK0S99_thSMD4ojkuFbBRWadBcS-RF-lTdJk,2862
29
29
  ingestion/nebula/__init__.py,sha256=VauK-rup_N8ZXVohx3HYqHX_PE_WoPyMUhdv2R7al4o,45
30
30
  ingestion/nebula/constants.py,sha256=thKqSwemdaAwAmKvF4FEVI9l1Ph5ergsnMlx6nWte7E,357
31
31
  ingestion/nebula/manifest_assembler.py,sha256=kcRSy6pixHkuVEK9QSoM-i6ZdLWMSYXw39eKGHvam34,7995
@@ -46,6 +46,7 @@ ingestion/resources/GRCh37_map.csv.gz,sha256=JOEkjtbYrJpIdyoZdCvfJhvvz2dNfkSve7l
46
46
  ingestion/resources/GRCh38_map.csv.gz,sha256=qriYO2_buCCb4T6WcuZ-pCwPxMsm0TL2OxAHvJ1cEfA,612373
47
47
  ingestion/shared_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  ingestion/shared_util/coords_to_genes.py,sha256=vz9EfgFm3BS6pEPnslbEka8cJKlQZtHJdH2WRCCUMdE,1669
49
+ ingestion/shared_util/fetch_patient.py,sha256=-E-C2m6-fLfKy-r7rSsjZNu_ACGKvdjl1UuB-2gvaJc,2442
49
50
  ingestion/shared_util/ga4gh.py,sha256=-jNQj79zspxG67MxHzOfwAhLbb9je55M1h4-i5ri-tU,507
50
51
  ingestion/shared_util/gene_to_coords.py,sha256=M-q5ateLSQ4fCF0uMk5TX2uBLRrcZzXqXEf05TPaLsU,876
51
52
  ingestion/shared_util/lambda_client.py,sha256=0EdV5nOqe_w-OoDyi72w1P0lk30g1vlTW2sD3ci_Qqw,2695
@@ -59,6 +60,6 @@ ingestion/vcf_standardization/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQe
59
60
  ingestion/vcf_standardization/util/af_helpers.py,sha256=dpTzoeIQVeBRt0ETF3a9rp5ojZqznHg4x_hCZ8OPcOg,1061
60
61
  ingestion/vcf_standardization/util/dp_helpers.py,sha256=Nq8oLOLObu4_pv16qwwgpALRlUoJVCULrd9cFOD-eoI,823
61
62
  ingestion/vcf_standardization/util/read_write.py,sha256=x3Pf6Dq8tmolblbCS5CrNmrcHS3FGfqBSFpFgvFGC4g,2526
62
- phc_ingestion-0.10.18.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
63
- phc_ingestion-0.10.18.dist-info/METADATA,sha256=ueL73vYHsAoqSag13yqes1-Izpjo-uouBZIIC50VUHM,678
64
- phc_ingestion-0.10.18.dist-info/RECORD,,
63
+ phc_ingestion-0.10.20.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
64
+ phc_ingestion-0.10.20.dist-info/METADATA,sha256=O4v14ntrknbOIU1iPTEoO8kQ8uXVNnNYotDo8YDkQis,678
65
+ phc_ingestion-0.10.20.dist-info/RECORD,,