Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Gh-pages #14

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Instruction/PF_SPECS.json
Empty file.
43 changes: 43 additions & 0 deletions Instruction/Sync.py
Original file line number Diff line number Diff line change
@@ -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)

58 changes: 58 additions & 0 deletions Instruction/centralCalendar.py
Original file line number Diff line number Diff line change
@@ -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)
43 changes: 43 additions & 0 deletions Instruction/fhirCalendar.py
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions Instruction/fhirCalendarTemplate.py
Original file line number Diff line number Diff line change
@@ -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
171 changes: 171 additions & 0 deletions Instruction/instruction.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@

<!-- Trigger a GitHub Pages Deployment -->
<!DOCTYPE html>
<html lang='en' hidden>

<head>

...

</head>

<body>
<div class='container'>
<div class='row'>
<div class='col'>
<h1>[GITHUB USERNAME] Scheduling App</h1>
</div>
</div>
</div>
</body>

...


<!-- Register App -->


Request Authorization Code
<!DOCTYPE html>
<html lang='en' hidden>

<head>

...

</head>

<body>

...

<script>
FHIR.oauth2.authorize({
'client_id': '[CLIENT ID]',
'scope': 'user/Appointment.write user/Patient.read user/Patient.write user/Slot.read launch online_access openid profile'
});
</script>

<div class='spinner'>
<div class='bounce1'></div>
<div class='bounce2'></div>
<div class='bounce3'></div>
</div>
</body>

</html>

<!--scheduling app-->
/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('<p>No Slots found for the selected query parameters.</p>');
}
},

// Display 'Failed to read Slots from FHIR server' if the call failed
function() {
clearUI();
$('#errors').html('<p>Failed to read Slots from FHIR server</p>');
$('#errors-row').show();
}
);
});


<!--Displaying FHIR Resources-->
/scheduling-app/index.html

...

<div id='slots-holder-row' class='row mt-5'>
<div class='col'>
<div id='slots-holder'>
<div class='row'>
<div class='col'>
<h2>Slots</h2>
</div>
</div>
<div class='row'>
<div class='col'>
<button class='btn btn-danger' id='clear-slots'>Clear Results</button>
</div>
</div>
<div class='row'>
<div class='col'>
<div id='slots'></div>
</div>
</div>
</div>
</div>
</div>

...
scheduling-app.js - renderSlots

...

function renderSlots(slotsHTML) {
clearUI();
$('#slots').html(slotsHTML);
$('#slots-holder-row').show();
}

...
```

What code is re
17 changes: 17 additions & 0 deletions Instruction/instruction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#1.) Trigger a GitHub Pages Deployment
<!DOCTYPE html>
<html lang='en' hidden>
<head>

...

</head>
<body>
<div class='container'>
<div class='row'>
<div class='col'>
-> <h1>[GITHUB USERNAME] Scheduling App</h1>
</div>
</div>

...
Loading