Can I do this with FHIR Newbie question

144 views
Skip to first unread message

Dean-O Rochester

unread,
Jul 20, 2023, 9:55:17 AM7/20/23
to SMART on FHIR

Quick question to see if FHIR is the right tool for me to use

 My quest is as follows...

 I have a list of patients I am trying to see if the labs that were ordered in one EMR were actually performed in another EMR   Namely ordered in Nextgen, but the lab work was to be done in Cerner.

 

Trying to answer the question of did the Nextgen ordered lab get performed in Cerner

 

Thanks in advance for your time

Josh Mandel

unread,
Jul 20, 2023, 9:57:12 AM7/20/23
to Dean-O Rochester, SMART on FHIR
If your end user actually has accounts in both systems, or if your application is able to register in a way that it is authorized to see data from both systems, you could use SMART on FHIR for this.

Alternatively, if both systems participate in the same health information exchange for data sharing network p, that would be another option.

--
You received this message because you are subscribed to the Google Groups "SMART on FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smart-on-fhi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smart-on-fhir/b9f9a2c4-e3d0-4aad-875e-75a2f640a6d0n%40googlegroups.com.

Dean-O Rochester

unread,
Jul 20, 2023, 10:51:46 AM7/20/23
to SMART on FHIR
Hi
Thanks
I have access to both nextgen and cerner, so I was looking to create a python script that would do fhir calls if you will to iterate through my list of nextgen patients and their order to see if they were performed in cerner

Is this still something I can do with Fhir?
Thanks
Dean-O

Richard Braman

unread,
Jul 20, 2023, 7:28:04 PM7/20/23
to Dean-O Rochester, SMART on FHIR
Hey Dean-O,

goto @FHIR-GPT4 on the Fly Health Discord server (https://discord.fly.health) and write:

Write a python script to loop through a list of patients in csv with patient medical record numbers. for each patient medical record number (MRN), call the nextgen fhir server and execute a FHIR GET to search Patients by identifier=urn:ietf:rfc:3986|[MRN].  Loop through the FHIR Bundle which should have exactly one patient and for each patient id call GET /ServiceRequest?subject=[patient.id].  Store the patient id and the ServiceRequest keys and values in a dictionary."

It will output something like this which is close to what you need.  Note you still have to write code to add security headers to the FHIR api request and call cerner.  I would guess you are looking for a FHIR DiagnosticReport or an Observation in Cerner but it wasn't clear what data you were looking for.  Also you would need to know the MRN or SSN or some common identifier for the Cerner and the NextGen system.

import csv
import requests

FHIR_SERVER_URL = 'https://example.com/fhir'  # Replace with your NextGen FHIR server URL

def get_patient_service_requests(mrn):
    # Search Patients by identifier
    url = f"{FHIR_SERVER_URL}/Patient?identifier=urn:ietf:rfc:3986|{mrn}" #you might need to check the NextGen FHIR docs to make sure they use this rfc code system for MRN
    response = requests.get(url)
    bundle = response.json()

    # Extract patient ID from the search results
    if bundle.get('entry'):
        patient_id = bundle['entry'][0]['resource']['id']

        # Fetch ServiceRequests for the patient Service Request is the Order info, There are medication and device orders too, but under MedicationRequest and DeviceRequest
        url = f"{FHIR_SERVER_URL}/ServiceRequest?subject={patient_id}"
        response = requests.get(url)
        bundle = response.json()

        # Extract ServiceRequest keys and values -
        service_requests = []
        if bundle.get('entry'):
            for entry in bundle['entry']:
                service_request = entry['resource']
                service_requests.append(service_request)

        return {'patient_id': patient_id, 'service_requests': service_requests}

    return None

# Read patient MRNs from a CSV file
with open('patients.csv', 'r') as file:
    reader = csv.reader(file)
    next(reader)  # Skip header row
    for row in reader:
        mrn = row[0]
        result = get_patient_service_requests(mrn)
        if result:
            print(f"Patient ID: {result['patient_id']}")
            print("Service Requests:")
            for service_request in result['service_requests']:
                print(f" - {service_request}")
            print()
        else:
            print(f"No patient found with MRN: {mrn}")

--

rocki...@gmail.com

unread,
Aug 4, 2023, 2:33:55 PM8/4/23
to Richard Braman, SMART on FHIR
Hi Richard

Thanks
Newbie here... I understand about fhir resources etc, but not sure where to start writing the code.  Do you suggest a starting point for a python programmer to get into writing python fhir code?

Thanks in advance for your assistance
Reply all
Reply to author
Forward
0 new messages