Ali2206 commited on
Commit
2c31d96
·
1 Parent(s): 377ac21
Files changed (1) hide show
  1. api/routes/patients.py +32 -32
api/routes/patients.py CHANGED
@@ -258,21 +258,21 @@ async def process_synthea_patient(bundle: dict, file_path: str) -> Optional[dict
258
  raw_full_name = f"{' '.join(name.get('given', ['']))} {name.get('family', '')}".strip()
259
  clean_full_name = re.sub(r'\d+', '', raw_full_name).strip()
260
 
261
- patient_data = {
262
- 'fhir_id': resource.get('id'),
263
- 'full_name': clean_full_name,
264
- 'gender': resource.get('gender', 'unknown'),
265
- 'date_of_birth': resource.get('birthDate', ''),
266
- 'address': ' '.join(address.get('line', [''])),
267
- 'city': address.get('city', ''),
268
- 'state': address.get('state', ''),
269
- 'postal_code': address.get('postalCode', ''),
270
- 'country': address.get('country', ''),
271
- 'source': 'synthea',
272
- 'status': 'active',
273
- 'created_at': datetime.utcnow(),
274
- 'updated_at': datetime.utcnow()
275
- }
276
 
277
  elif resource_type == 'Encounter':
278
  encounter = {
@@ -318,23 +318,23 @@ async def process_synthea_patient(bundle: dict, file_path: str) -> Optional[dict
318
  logger.error(f"Error processing {resource_type} in {file_path}: {str(e)}")
319
  continue
320
 
321
- if patient_data:
322
- patient_data.update({
323
- 'allergies': [], # Convert conditions to allergies if needed
324
- 'chronic_conditions': conditions,
325
- 'medications': medications,
326
- 'symptoms': [],
327
- 'vital_signs': {},
328
- 'medical_notes': '',
329
- 'emergency_contact_name': '',
330
- 'emergency_contact_phone': '',
331
- 'national_id': '',
332
- 'blood_type': ''
333
- })
334
- logger.info(f"Successfully processed patient {patient_data.get('fhir_id')} from {file_path}")
335
- return patient_data
336
- logger.warning(f"No valid patient data found in {file_path}")
337
- return None
338
 
339
  @router.post("/import", status_code=status.HTTP_201_CREATED)
340
  async def import_patients(
 
258
  raw_full_name = f"{' '.join(name.get('given', ['']))} {name.get('family', '')}".strip()
259
  clean_full_name = re.sub(r'\d+', '', raw_full_name).strip()
260
 
261
+ patient_data = {
262
+ 'fhir_id': resource.get('id'),
263
+ 'full_name': clean_full_name,
264
+ 'gender': resource.get('gender', 'unknown'),
265
+ 'date_of_birth': resource.get('birthDate', ''),
266
+ 'address': ' '.join(address.get('line', [''])),
267
+ 'city': address.get('city', ''),
268
+ 'state': address.get('state', ''),
269
+ 'postal_code': address.get('postalCode', ''),
270
+ 'country': address.get('country', ''),
271
+ 'source': 'synthea',
272
+ 'status': 'active',
273
+ 'created_at': datetime.utcnow(),
274
+ 'updated_at': datetime.utcnow()
275
+ }
276
 
277
  elif resource_type == 'Encounter':
278
  encounter = {
 
318
  logger.error(f"Error processing {resource_type} in {file_path}: {str(e)}")
319
  continue
320
 
321
+ if patient_data:
322
+ patient_data.update({
323
+ 'allergies': [], # Convert conditions to allergies if needed
324
+ 'chronic_conditions': conditions,
325
+ 'medications': medications,
326
+ 'symptoms': [],
327
+ 'vital_signs': {},
328
+ 'medical_notes': '',
329
+ 'emergency_contact_name': '',
330
+ 'emergency_contact_phone': '',
331
+ 'national_id': '',
332
+ 'blood_type': ''
333
+ })
334
+ logger.info(f"Successfully processed patient {patient_data.get('fhir_id')} from {file_path}")
335
+ return patient_data
336
+ logger.warning(f"No valid patient data found in {file_path}")
337
+ return None
338
 
339
  @router.post("/import", status_code=status.HTTP_201_CREATED)
340
  async def import_patients(