phc-ingestion 0.10.5__py3-none-any.whl → 0.10.6__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.
@@ -9,6 +9,7 @@ from ingestion.nebula.constants import (
9
9
  NEBULA_BODY_SITE,
10
10
  NEBULA_INDICATION,
11
11
  )
12
+ import re
12
13
 
13
14
 
14
15
  class HumanName(TypedDict):
@@ -99,7 +100,7 @@ class ManifestAssembler:
99
100
  return identifiers[0].get("value", "") if identifiers else ""
100
101
 
101
102
  def __extract_id_from_reference(self, reference: Reference) -> str:
102
- if not reference or not reference.get("reference"):
103
+ if not reference:
103
104
  return ""
104
105
 
105
106
  ref_string = reference.get("reference")
@@ -109,12 +110,39 @@ class ManifestAssembler:
109
110
  parts = ref_string.split("/")
110
111
  return parts[1] if len(parts) > 1 else parts[0]
111
112
 
113
+ def __extract_elation_mrn(self, patient: Patient) -> str:
114
+ if not patient:
115
+ return ""
116
+
117
+ identifier = next(
118
+ (
119
+ x
120
+ for x in patient.get("identifier", [])
121
+ # if matches LRN format for Elation
122
+ if re.search(
123
+ f"lrn:lo:(dev|us):{self.account_id}:ehr:{self.account_id}:{self.project_id}/Patient",
124
+ x.get("system", ""),
125
+ )
126
+ ),
127
+ None,
128
+ )
129
+
130
+ if not identifier:
131
+ return ""
132
+
133
+ return identifier.get("value", "")
134
+
112
135
  def __parse_human_name(self, human_name: list[HumanName] | None):
113
- if not human_name or len(human_name) == 0:
136
+ if not human_name:
137
+ return None
138
+
139
+ human_name = next((x for x in human_name if x.get("use") == "official"), None)
140
+
141
+ if not human_name:
114
142
  return None
115
143
 
116
- last_name = human_name[0].get("family", "")
117
- first_name = human_name[0].get("given", [])[0]
144
+ last_name = human_name.get("family", "")
145
+ first_name = human_name.get("given", [])[0]
118
146
 
119
147
  return {
120
148
  "lastName": last_name,
@@ -149,7 +177,7 @@ class ManifestAssembler:
149
177
  "indexedDate": datetime.now().strftime("%Y-%m-%d"),
150
178
  "reference": "GRCh38",
151
179
  "patientId": patient.get("id"),
152
- "mrn": patient.get("id"),
180
+ "mrn": self.__extract_elation_mrn(patient),
153
181
  "bodySite": NEBULA_BODY_SITE,
154
182
  "bodySiteDisplay": NEBULA_BODY_SITE,
155
183
  "bodySiteSystem": BODY_SITE_SYSTEM,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phc-ingestion
3
- Version: 0.10.5
3
+ Version: 0.10.6
4
4
  Summary: Functions for LifeOmic PHC genomic ingestions
5
5
  License: MIT
6
6
  Author-email: LifeOmic Development <development@lifeomic.com>
@@ -28,7 +28,7 @@ ingestion/generic/process.py,sha256=ZaVnZ_gx9faDUsuresI1A0oCegTa-dPQT7DBFMeZGyY,
28
28
  ingestion/generic/utils.py,sha256=1MEIru7uq38IjUdL8lcHqDH0oTki9uWrz1f2e-pmRoU,2814
29
29
  ingestion/nebula/__init__.py,sha256=VauK-rup_N8ZXVohx3HYqHX_PE_WoPyMUhdv2R7al4o,45
30
30
  ingestion/nebula/constants.py,sha256=thKqSwemdaAwAmKvF4FEVI9l1Ph5ergsnMlx6nWte7E,357
31
- ingestion/nebula/manifest_assembler.py,sha256=sGZdeMpMT4osOBXlxY9CPZKUJSQXaShT77JJVB30I1s,5704
31
+ ingestion/nebula/manifest_assembler.py,sha256=OPUnuvzL1Bti_1-4N3fDP22wHtaK__4Bwh5K21Mg-C4,6416
32
32
  ingestion/nebula/process.py,sha256=D2ct9tF60ZIP_jZdjvgjfTkhEAkNNEhxaSqa04CtNR8,2237
33
33
  ingestion/nextgen/__init__.py,sha256=7LQ-h_Bvc5P1QcHMdzsqi1Qm4fTJn04-ozar2ty9wSc,59
34
34
  ingestion/nextgen/process.py,sha256=5Z0RfclwTAYZruGDiLPutjPCYFh1DJpoWY9dnttghT4,3993
@@ -59,6 +59,6 @@ ingestion/vcf_standardization/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQe
59
59
  ingestion/vcf_standardization/util/af_helpers.py,sha256=dpTzoeIQVeBRt0ETF3a9rp5ojZqznHg4x_hCZ8OPcOg,1061
60
60
  ingestion/vcf_standardization/util/dp_helpers.py,sha256=Nq8oLOLObu4_pv16qwwgpALRlUoJVCULrd9cFOD-eoI,823
61
61
  ingestion/vcf_standardization/util/read_write.py,sha256=x3Pf6Dq8tmolblbCS5CrNmrcHS3FGfqBSFpFgvFGC4g,2526
62
- phc_ingestion-0.10.5.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
63
- phc_ingestion-0.10.5.dist-info/METADATA,sha256=qf_dLgOkjhiTmAL2LjoyPJWs-38ggs82qXsc8wc66eg,677
64
- phc_ingestion-0.10.5.dist-info/RECORD,,
62
+ phc_ingestion-0.10.6.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
63
+ phc_ingestion-0.10.6.dist-info/METADATA,sha256=IhIQUPLXKsepjBwgwe4ARhaZ2fKrmvsJhsgey1Yui7o,677
64
+ phc_ingestion-0.10.6.dist-info/RECORD,,