From 763037b9f9c83b4a6a9c119c472edc636eefd4db Mon Sep 17 00:00:00 2001 From: drm Date: Tue, 16 Jan 2024 16:47:25 -0500 Subject: [PATCH] Gh-pages changes1 --- Instruction/PF_SPECS.json | 0 Instruction/Sync.py | 43 +++++++ Instruction/centralCalendar.py | 58 ++++++++++ Instruction/fhirCalendar.py | 43 +++++++ Instruction/fhirCalendarTemplate.py | 44 +++++++ Instruction/instruction.html | 171 ++++++++++++++++++++++++++++ Instruction/instruction.py | 17 +++ Instruction/instruction.txt | 170 +++++++++++++++++++++++++++ Instruction/schedule.js | 48 ++++++++ Instruction/schedule.py | 50 ++++++++ 10 files changed, 644 insertions(+) create mode 100644 Instruction/PF_SPECS.json create mode 100644 Instruction/Sync.py create mode 100644 Instruction/centralCalendar.py create mode 100644 Instruction/fhirCalendar.py create mode 100644 Instruction/fhirCalendarTemplate.py create mode 100644 Instruction/instruction.html create mode 100644 Instruction/instruction.py create mode 100644 Instruction/instruction.txt create mode 100644 Instruction/schedule.js create mode 100644 Instruction/schedule.py diff --git a/Instruction/PF_SPECS.json b/Instruction/PF_SPECS.json new file mode 100644 index 0000000..e69de29 diff --git a/Instruction/Sync.py b/Instruction/Sync.py new file mode 100644 index 0000000..77d3008 --- /dev/null +++ b/Instruction/Sync.py @@ -0,0 +1,43 @@ +Sync + +from googleapiclient.discovery import build +from google_auth_oauthlib.flow import InstalledAppFlow +from google.auth.transport.requests import Request +import datetime + +class CalendarSync: + def __init__(self, credentials_file): + # Load credentials from the 'credentials.json' file + flow = InstalledAppFlow.from_client_secrets_file(credentials_file, ['https://www.googleapis.com/auth/calendar']) + creds = flow.run_local_server(port=0) + + # Build the service + self.service = build('calendar', 'v3', credentials=creds) + + def add_appointment(self, appointment): + # Convert the FHIR appointment to a Google Calendar event + event = { + 'summary': 'Appointment', + 'start': { + 'dateTime': appointment['start'], + 'timeZone': 'America/Los_Angeles', + }, + 'end': { + 'dateTime': appointment['end'], + 'timeZone': 'America/Los_Angeles', + }, + } + + # Add the event to the primary calendar + event = self.service.events().insert(calendarId='primary', body=event).execute() + + print('Event created:', event['htmlLink']) + +# Usage +calendar_sync = CalendarSync('credentials.json') +appointment = { + 'start': datetime.datetime.now().isoformat(), + 'end': (datetime.datetime.now() + datetime.timedelta(hours=1)).isoformat(), +} +calendar_sync.add_appointment(appointment) + diff --git a/Instruction/centralCalendar.py b/Instruction/centralCalendar.py new file mode 100644 index 0000000..6b00d58 --- /dev/null +++ b/Instruction/centralCalendar.py @@ -0,0 +1,58 @@ +centralCalendar.py +# +# class CentralCalendar: + def __init__(self, fhir_calendars, variable_calendars): + self.fhir_calendars = fhir_calendars + self.variable_calendars = variable_calendars + + def check_availability(self, start_time, end_time): + # Check availability in all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + if not calendar.check_availability(start_time, end_time): + return False + return True + + def new_appointment(self, patient_id, practitioner_id, start_time, end_time): + # Schedule new appointment in all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + calendar.new_appointment(patient_id, practitioner_id, start_time, end_time) + + def reschedule_appointment(self, appointment_id, new_start_time, new_end_time): + # Reschedule appointment in all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + calendar.reschedule_appointment(appointment_id, new_start_time, new_end_time) + + def cancel_appointment(self, appointment_id): + # Cancel appointment in all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + calendar.cancel_appointment(appointment_id) + + def send_reminder(self, appointment_id): + # Send reminder for appointment in all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + calendar.send_reminder(appointment_id) + + def sync(self): + # Sync all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + calendar.sync() + + def resolve_conflict(self, appointment_id): + # Resolve conflict for appointment in all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + calendar.resolve_conflict(appointment_id) + + def fetch_patient_details(self, patient_id): + # Fetch patient details from all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + calendar.fetch_patient_details(patient_id) + + def fetch_practitioner_details(self, practitioner_id): + # Fetch practitioner details from all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + calendar.fetch_practitioner_details(practitioner_id) + + def fetch_appointment_history(self, patient_id): + # Fetch appointment history from all calendars + for calendar in self.fhir_calendars + self.variable_calendars: + calendar.fetch_appointment_history(patient_id) \ No newline at end of file diff --git a/Instruction/fhirCalendar.py b/Instruction/fhirCalendar.py new file mode 100644 index 0000000..bdbcfd9 --- /dev/null +++ b/Instruction/fhirCalendar.py @@ -0,0 +1,43 @@ +class FhirCalendar: + def __init__(self, fhir_api): + self.fhir_api = fhir_api + + def check_availability(self, start_time, end_time): + # Check availability using the FHIR API + pass + + def new_appointment(self, patient_id, practitioner_id, start_time, end_time): + # Schedule new appointment using the FHIR API + pass + + def reschedule_appointment(self, appointment_id, new_start_time, new_end_time): + # Reschedule appointment using the FHIR API + pass + + def cancel_appointment(self, appointment_id): + # Cancel appointment using the FHIR API + pass + + def send_reminder(self, appointment_id): + # Send reminder for appointment using the FHIR API + pass + + def sync(self): + # Sync with the FHIR API + pass + + def resolve_conflict(self, appointment_id): + # Resolve conflict using the FHIR API + pass + + def fetch_patient_details(self, patient_id): + # Fetch patient details using the FHIR API + pass + + def fetch_practitioner_details(self, practitioner_id): + # Fetch practitioner details using the FHIR API + pass + + def fetch_appointment_history(self, patient_id): + # Fetch appointment history using the FHIR API + pass \ No newline at end of file diff --git a/Instruction/fhirCalendarTemplate.py b/Instruction/fhirCalendarTemplate.py new file mode 100644 index 0000000..6d1ff57 --- /dev/null +++ b/Instruction/fhirCalendarTemplate.py @@ -0,0 +1,44 @@ +#A template for interacting with FHIR API +class FhirCalendar: + def __init__(self, fhir_api): + self.fhir_api = fhir_api + + def check_availability(self, start_time, end_time): + # Check availability using the FHIR API + pass + + def new_appointment(self, patient_id, practitioner_id, start_time, end_time): + # Schedule new appointment using the FHIR API + pass + + def reschedule_appointment(self, appointment_id, new_start_time, new_end_time): + # Reschedule appointment using the FHIR API + pass + + def cancel_appointment(self, appointment_id): + # Cancel appointment using the FHIR API + pass + + def send_reminder(self, appointment_id): + # Send reminder for appointment using the FHIR API + pass + + def sync(self): + # Sync with the FHIR API + pass + + def resolve_conflict(self, appointment_id): + # Resolve conflict using the FHIR API + pass + + def fetch_patient_details(self, patient_id): + # Fetch patient details using the FHIR API + pass + + def fetch_practitioner_details(self, practitioner_id): + # Fetch practitioner details using the FHIR API + pass + + def fetch_appointment_history(self, patient_id): + # Fetch appointment history using the FHIR API + pass \ No newline at end of file diff --git a/Instruction/instruction.html b/Instruction/instruction.html new file mode 100644 index 0000000..e4fc279 --- /dev/null +++ b/Instruction/instruction.html @@ -0,0 +1,171 @@ + + + + + + + + ... + + + + +
+
+
+

[GITHUB USERNAME] Scheduling App

+
+
+
+ + +... + + + + + +Request Authorization Code + + + + + + ... + + + + + + ... + + + +
+
+
+
+
+ + + + + +/scheduling-app/src/js/scheduling-app.js + +// Add missing imports +import FHIR from 'fhirclient'; +import smart from 'fhirclient'; + +FHIR.oauth2.ready(function(smart) { +// Query the FHIR server for Slots +smart.api.fetchAll({ +type: 'Slot', +query: slotParams +}).then( + +// Display Appointment information if the call succeeded +function(slots) { + +... + +}, + +// Display 'Failed to read Slots from FHIR server' if the call failed +function() { + +... + +} +); +}); + +... + + +/scheduling-app/src/js/scheduling-app.js - onReady + +... + +FHIR.oauth2.ready(function(smart) { +// Query the FHIR server for Slots +smart.api.fetchAll({ +type: 'Slot', +query: slotParams +}).then( + +// Display Appointment information if the call succeeded +function(slots) { +// If any Slots matched the criteria, display them +if (slots.length) { +var slotsHTML = ''; + +slots.forEach(function(slot) { +slotsHTML = slotsHTML + slotHTML(slot.id, slot.type.text, slot.start, slot.end); +}); + +renderSlots(slotsHTML); +} +// If no Slots matched the criteria, inform the user +else { +renderSlots('

No Slots found for the selected query parameters.

'); +} +}, + +// Display 'Failed to read Slots from FHIR server' if the call failed +function() { +clearUI(); +$('#errors').html('

Failed to read Slots from FHIR server

'); +$('#errors-row').show(); +} +); +}); + + + +/scheduling-app/index.html + +... + +
+
+
+
+
+

Slots

+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +... +scheduling-app.js - renderSlots + +... + +function renderSlots(slotsHTML) { +clearUI(); +$('#slots').html(slotsHTML); +$('#slots-holder-row').show(); +} + +... +``` + +What code is re \ No newline at end of file diff --git a/Instruction/instruction.py b/Instruction/instruction.py new file mode 100644 index 0000000..dcbd936 --- /dev/null +++ b/Instruction/instruction.py @@ -0,0 +1,17 @@ +#1.) Trigger a GitHub Pages Deployment + + + + + ... + + + +
+
+
+ ->

[GITHUB USERNAME] Scheduling App

+
+
+ + ... \ No newline at end of file diff --git a/Instruction/instruction.txt b/Instruction/instruction.txt new file mode 100644 index 0000000..3558751 --- /dev/null +++ b/Instruction/instruction.txt @@ -0,0 +1,170 @@ + + ```html + + + + + + + ... + + + + +
+
+
+

[GITHUB USERNAME] Scheduling App

+
+
+
+ + +... + + + + + +Request Authorization Code + + + + + + ... + + + + + + ... + + + +
+
+
+
+
+ + + + + +/scheduling-app/src/js/scheduling-app.js + +// Add missing imports +import FHIR from 'fhirclient'; +import smart from 'fhirclient'; + +FHIR.oauth2.ready(function(smart) { + // Query the FHIR server for Slots + smart.api.fetchAll({ + type: 'Slot', + query: slotParams + }).then( + + // Display Appointment information if the call succeeded + function(slots) { + + ... + + }, + + // Display 'Failed to read Slots from FHIR server' if the call failed + function() { + + ... + + } + ); +}); + +... + + +/scheduling-app/src/js/scheduling-app.js - onReady + +... + +FHIR.oauth2.ready(function(smart) { + // Query the FHIR server for Slots + smart.api.fetchAll({ + type: 'Slot', + query: slotParams + }).then( + + // Display Appointment information if the call succeeded + function(slots) { + // If any Slots matched the criteria, display them + if (slots.length) { + var slotsHTML = ''; + + slots.forEach(function(slot) { + slotsHTML = slotsHTML + slotHTML(slot.id, slot.type.text, slot.start, slot.end); + }); + + renderSlots(slotsHTML); + } + // If no Slots matched the criteria, inform the user + else { + renderSlots('

No Slots found for the selected query parameters.

'); + } + }, + + // Display 'Failed to read Slots from FHIR server' if the call failed + function() { + clearUI(); + $('#errors').html('

Failed to read Slots from FHIR server

'); + $('#errors-row').show(); + } + ); +}); + + + +/scheduling-app/index.html + +... + +
+
+
+
+
+

Slots

+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +... +scheduling-app.js - renderSlots + +... + +function renderSlots(slotsHTML) { + clearUI(); + $('#slots').html(slotsHTML); + $('#slots-holder-row').show(); +} + +... +``` \ No newline at end of file diff --git a/Instruction/schedule.js b/Instruction/schedule.js new file mode 100644 index 0000000..e23bc2e --- /dev/null +++ b/Instruction/schedule.js @@ -0,0 +1,48 @@ +//schedule a new visit + +import FHIR from 'fhirclient'; + +// Assume we have a patientId, practitionerId, and slotId +let patientId = 'example-patient-id'; +let practitionerId = 'example-practitioner-id'; +let slotId = 'example-slot-id'; + +// Create a new Appointment resource +let newAppointment = { + resourceType: 'Appointment', + status: 'booked', + slot: [ + { + reference: `Slot/${slotId}` + } + ], + participant: [ + { + actor: { + reference: `Patient/${patientId}` + }, + status: 'accepted' + }, + { + actor: { + reference: `Practitioner/${practitionerId}` + }, + status: 'accepted' + } + ] +}; + +FHIR.oauth2.ready(function(smart) { + // Send the new Appointment to the FHIR server + smart.api.create({ + type: 'Appointment', + resource: newAppointment + }).then( + function(appointment) { + console.log('Appointment created:', appointment); + }, + function(error) { + console.error('Failed to create Appointment:', error); + } + ); +}); \ No newline at end of file diff --git a/Instruction/schedule.py b/Instruction/schedule.py new file mode 100644 index 0000000..c889ada --- /dev/null +++ b/Instruction/schedule.py @@ -0,0 +1,50 @@ +#schedule appointment python + +""" + +""" +# +# import requests +import json + +class Scheduler: + def __init__(self, server_url): + self.server_url = server_url + + def schedule_visit(self, patient_id, practitioner_id, slot_id): + # Create a new Appointment resource + new_appointment = { + 'resourceType': 'Appointment', + 'status': 'booked', + 'slot': [ + { + 'reference': f'Slot/{slot_id}' + } + ], + 'participant': [ + { + 'actor': { + 'reference': f'Patient/{patient_id}' + }, + 'status': 'accepted' + }, + { + 'actor': { + 'reference': f'Practitioner/{practitioner_id}' + }, + 'status': 'accepted' + } + ] + } + + # Send the new Appointment to the FHIR server + response = requests.post(f'{self.server_url}/Appointment', json=new_appointment) + + if response.status_code == 201: + print('Appointment created:', response.json()) + else: + print('Failed to create Appointment:', response.status_code, response.text) + +# Usage +scheduler = Scheduler('https://example.com/fhir') +scheduler.schedule_visit('example-patient-id', 'example-practitioner-id', 'example-slot-id') \ No newline at end of file