Spaces:
Runtime error
Runtime error
File size: 30,476 Bytes
02e3ca0 3c7375b 02e3ca0 39c0e24 02e3ca0 0d2d6ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
import streamlit as st
# pip install streamlit fhir.resources==6.5.0 fhirclient smart.models sdcclient
# FHIR Resources:
from fhir.resources.observation import Observation
from fhir.resources.questionnaire import Questionnaire
from fhir.resources.questionnaireresponse import QuestionnaireResponse
from fhir.resources.referralrequest import ReferralRequest
from fhir.resources.careteam import CareTeam
from fhir.resources.practitioner import Practitioner
from fhir.resources.practitionerrole import PractitionerRole
from fhir.resources.program import Program
from fhir.resources.flag import Flag
from fhir.resources.documentreference import DocumentReference
from fhir.resources.immunization import Immunization
from fhir.resources.medication import Medication
from fhir.resources.medicationstatement import MedicationStatement
from fhir.resources.patient import Patient
from fhir.resources.organization import Organization
from fhir.resources.procedure import Procedure
from fhir.resources.condition import Condition
from fhir.resources.diagnosticreport import DiagnosticReport
from fhir.resources.riskassessment import RiskAssessment
from fhir.resources.riskprobability import RiskProbability
from fhir.resources.riskevidencesynthesis import RiskEvidenceSynthesis
from fhir.resources.questionnaireresponse import QuestionnaireResponse
from fhir.resources.careplan import CarePlan
from fhir.resources.goal import Goal
from fhir.resources.task import Task
from fhir.resources.activitydefinition import ActivityDefinition
from fhir.resources.library import Library
from fhir.resources.implementationguide import ImplementationGuide
from fhir.resources.structuredefinition import StructureDefinition
from fhir.resources.codeableconcept import CodeableConcept
from fhir.resources.coding import Coding
from fhir.resources.fhirdate import FHIRDate
from fhir.resources.humanname import HumanName
from fhir.resources.identifier import Identifier
from fhir.resources.contactpoint import ContactPoint
from fhir.resources.address import Address
from fhir.resources.period import Period
from fhir.resources.ratio import Ratio
from fhir.resources.range import Range
from fhir.resources.quantity import Quantity
from fhir.resources.simplequantity import SimpleQuantity
from fhir.resources.timing import Timing
from fhir.resources.timingrepeat import TimingRepeat
from fhir.resources.dosage import Dosage
from fhir.resources.administration import Administration
from fhir.resources.anatomicallocation import AnatomicalLocation
from fhir.resources.age import Age
from fhir.resources.distance import Distance
from fhir.resources.duration import Duration
from fhir.resources.money import Money
from fhir.resources.sampleddata import SampledData
from fhir.resources.signature import Signature
from fhir.resources.meta import Meta
from fhir.resources.identifier import Identifier
from fhir.resources.resource import Resource
from fhir.resources.fhirabstractmodel import FHIRAbstractModel
from fhir.resources.fhirabstractresource import FHIRAbstractResource
from fhirclient.models.observation import Observation as SmartObservation
from fhirclient.models.questionnaire import Questionnaire as SmartQuestion
from fhirclient.models.questionnaireresponse import QuestionnaireResponse as SmartQuestionnaireResponse
from fhirclient.models.referralrequest import ReferralRequest as SmartReferralRequest
from fhirclient.models.careteam import CareTeam as SmartCareTeam
from fhirclient.models.practitioner import Practitioner as SmartPractitioner
from fhirclient.models.practitionerrole import PractitionerRole as SmartPractitionerRole
from fhirclient.models.program import Program as SmartProgram
from fhirclient.models.flag import Flag as SmartFlag
from fhirclient.models.documentreference import DocumentReference as SmartDocumentReference
from fhirclient.models.immunization import Immunization as SmartImmunization
from fhirclient.models.medication import Medication as SmartMedication
from fhirclient.models.medicationstatement import MedicationStatement as SmartMedicationStatement
from fhirclient.models.patient import Patient as SmartPatient
from fhirclient.models.organization import Organization as SmartOrganization
from fhirclient.models.procedure import Procedure as SmartProcedure
from fhirclient.models.condition import Condition as SmartCondition
from fhirclient.models.diagnosticreport import DiagnosticReport as SmartDiagnosticReport
from fhirclient.models.riskassessment import RiskAssessment as SmartRiskAssessment
from fhirclient.models.riskprobability import RiskProbability as SmartRiskProbability
from fhirclient.models.riskevidencesynthesis import RiskEvidenceSynthesis as SmartRiskEvidenceSynthesis
from fhirclient.models.questionnaireresponse import QuestionnaireResponse as SmartQuestionnaireResponse
from fhirclient.models.careplan import CarePlan as SmartCarePlan
from fhirclient.models.goal import Goal as SmartGoal
from fhirclient.models.task import Task as SmartTask
from fhirclient.models.activitydefinition import ActivityDefinition as SmartActivityDefinition
from fhirclient.models.library import Library as SmartLibrary
from fhirclient.models.implementationguide import ImplementationGuide as SmartImplementationGuide
from fhirclient.models.structuredefinition import StructureDefinition as SmartStructureDefinition
import json
from typing import List, Tuple
import smart.models as smart
from sdcclient import SdcClient
# Initialize the SMART client
smart_client = smart.client
# Initialize the SDC client
sdc_client = SdcClient()
# Define a list of example patients
EXAMPLE_PATIENTS = [
{
"name": "Alice Smith",
"birthdate": "1980-01-01",
"gender": "female",
"address": {
"line": ["123 Main St"],
"city": "Anytown",
"state": "NY",
"postalCode": "12345",
"country": "US"
},
"phone": "555-555-1212"
},
{
"name": "Bob Johnson",
"birthdate": "1975-05-05",
"gender": "male",
"address": {
"line": ["456 Oak St"],
"city": "Anytown",
"state": "NY",
"postalCode": "12345",
"country": "US"
},
"phone": "555-555-1212"
}
]
# Define a list of example social determinants of health
EXAMPLE_SDH = [
{
"question": "Do you have reliable transportation?",
"answer": "Yes"
},
{
"question": "Do you have enough food to eat?",
"answer": "No"
},
{
"question": "Do you have stable housing?",
"answer": "No"
}
]
def get_patient(name: str) -> Tuple[Patient, str]:
"""
Returns a tuple containing the FHIR Patient resource and the SMART Patient model
for the given patient name.
"""
# Get the example patient with the matching name
example_patient = next((p for p in EXAMPLE_PATIENTS if p["name"] == name), None)
if not example_patient:
raise ValueError(f"No example patient found with name '{name}'")
# Create a FHIR Patient resource
patient = Patient()
patient.name = [HumanName()]
patient.name[0].given = [example_patient["name"].split()[0]]
patient.name[0].family = [example_patient["name"].split()[1]]
patient.birthDate = FHIRDate(example_patient["birthdate"])
patient.gender = example_patient["gender"]
patient.address = [Address()]
patient.address[0].line = example_patient["address"]["line"]
patient.address[0].city = example_patient["address"]["city"]
patient.address[0].state = example_patient["address"]["state"]
patient.address[0].postalCode = example_patient["address"]["postalCode"]
patient.address[0].country = example_patient["address"]["country"]
patient.telecom = [ContactPoint()]
patient.telecom[0].system = "phone"
patient.telecom[0].value = example_patient["phone"]
# Create a SMART Patient model
smart_patient = smart.Patient.read_from(patient.as_json())
return patient, smart_patient
def create_observation(patient_id: str, code: str, value: str, unit: str) -> Observation:
"""
Creates and returns a FHIR Observation resource with the given patient ID, code, value, and unit.
"""
observation = Observation()
observation.subject = {"reference": f"Patient/{patient_id}"}
observation.code = CodeableConcept()
observation.code.coding = [Coding()]
observation.code.coding[0].system = "http://loinc.org"
observation.code.coding[0].code = code
observation.valueQuantity = Quantity()
observation.valueQuantity.value = float(value)
observation.valueQuantity.unit = unit
observation.status = "final"
observation.effectiveDateTime = FHIRDate("2023-02-21")
observation.meta = Meta()
observation.meta.profile = ["http://hl7.org/fhir/StructureDefinition/vitalsigns"]
return observation
def create_assessment(patient_id: str, code: str, value: str) -> DiagnosticReport:
"""
Creates and returns a FHIR DiagnosticReport resource with the given patient ID, code, and value.
"""
report = DiagnosticReport()
report.status = "final"
report.subject = {"reference": f"Patient/{patient_id}"}
report.code = CodeableConcept()
report.code.coding = [Coding()]
report.code.coding[0].system = "http://loinc.org"
report.code.coding[0].code = code
report.result = [Reference()]
report.result[0].reference = f"Observation/{code}"
report.result[0].display = value
report.effectiveDateTime = FHIRDate("2023-02-21")
return report
def create_rule() -> Library:
"""
Creates and returns a FHIR Library resource representing a rule.
"""
rule = Library()
rule.status = "draft"
rule.type = CodeableConcept()
rule.type.coding = [Coding()]
rule.type.coding[0].system = "http://terminology.hl7.org/CodeSystem/library-type"
rule.type.coding[0].code = "logic-library"
rule.type.coding[0].display = "Logic Library"
rule.content = [Attachment()]
rule.content[0].contentType = "text/cql"
rule.content[0].data = "some cql code here"
rule.relatedArtifact = [RelatedArtifact()]
rule.relatedArtifact[0].type = "depends-on"
rule.relatedArtifact[0].resource = {"reference": "Library/example-library"}
return rule
def create_referral_request(patient_id: str, reason: str, specialty: str, provider_name: str) -> ReferralRequest:
"""
Creates and returns a FHIR ReferralRequest resource with the given patient ID, reason, specialty, and provider name.
"""
referral = ReferralRequest()
referral.status = "active"
referral.subject = {"reference": f"Patient/{patient_id}"}
referral.reasonCode = [CodeableConcept()]
referral.reasonCode[0].coding = [Coding()]
referral.reasonCode[0].coding[0].system = "http://snomed.info/sct"
referral.reasonCode[0].coding[0].code = "123456"
referral.reasonCode[0].coding[0].display = reason
referral.specialty = CodeableConcept()
referral.specialty.coding = [Coding()]
referral.specialty.coding[0].system = "http://snomed.info/sct"
referral.specialty.coding[0].code = "123456"
referral.specialty.coding[0].display = specialty
referral.requester = {"reference": f"Practitioner/{provider_name}"}
referral.serviceRequested = [CodeableConcept()]
referral.serviceRequested[0].coding = [Coding()]
referral.serviceRequested[0].coding[0].system = "http://snomed.info/sct"
referral.serviceRequested[0].coding[0].code = "123456"
referral.serviceRequested[0].coding[0].display = "Example Service"
referral.priority = CodeableConcept()
referral.priority.coding = [Coding()]
referral.priority.coding[0].system = "http://terminology.hl7.org/CodeSystem/request-priority"
referral.priority.coding[0].code = "routine"
referral.priority.coding[0].display = "Routine"
return referral
def create_provider(name: str, organization_name: str) -> Tuple[Practitioner, PractitionerRole, Organization]:
"""
Creates and returns a tuple containing the FHIR Practitioner, PractitionerRole, and Organization resources for the given provider name and organization name.
"""
# Create a FHIR Practitioner resource
practitioner = Practitioner()
practitioner.name = [HumanName()]
practitioner.name[0].text = name
practitioner.identifier = [Identifier()]
practitioner.identifier[0].system = "http://example.com/providers"
practitioner.identifier[0].value = "12345"
# Create a FHIR PractitionerRole resource
practitioner_role = PractitionerRole()
practitioner_role.practitioner = {"reference": f"Practitioner/{practitioner.id}"}
practitioner_role.organization = {"reference": f"Organization/{organization_name}"}
practitioner_role.code = [CodeableConcept()]
practitioner_role.code[0].coding = [Coding()]
practitioner_role.code[0].coding[0].system = "http://nucc.org/provider-taxonomy"
practitioner_role.code[0].coding[0].code = "207Q00000X"
practitioner_role.code[0].coding[0].display = "Family Medicine"
practitioner_role.specialization = [CodeableConcept()]
practitioner_role.specialization[0].coding = [Coding()]
practitioner_role.specialization[0].coding[0].system = "http://snomed.info/sct"
practitioner_role.specialization[0].coding[0].code = "123456"
practitioner_role.specialization[0].coding[0].display = "Example Specialty"
# Create a FHIR Organization resource
organization = Organization()
organization.name = organization_name
return practitioner, practitioner_role, organization
def create_program(name: str, goal_description: str, start_date: str, end_date: str) -> Program:
"""
Creates and returns a FHIR Program resource with the given name, goal description, start date, and end date.
"""
program = Program()
program.status = "active"
program.category = [CodeableConcept()]
program.category[0].coding = [Coding()]
program.category[0].coding[0].system = "http://example.com/program-categories"
program.category[0].coding[0].code = "123456"
program.category[0].coding[0].display = "Example Category"
program.name = name
program.description = "Example Description"
program.goal = [Goal()]
program.goal[0].description = CodeableConcept()
program.goal[0].description.text = goal_description
program.start = FHIRDate(start_date)
program.end = FHIRDate(end_date)
return program
def create_fulfillment(patient_id: str, medication_name: str, quantity: int, dispense_date: str) -> MedicationStatement:
"""
Creates and returns a FHIR MedicationStatement resource representing a fulfillment of a prescription for the given patient ID, medication name, quantity, and dispense date.
"""
# Create a FHIR Medication resource
medication = Medication()
medication.code = CodeableConcept()
medication.code.text = medication_name
# Create a FHIR MedicationStatement resource
fulfillment = MedicationStatement()
fulfillment.status = "completed"
fulfillment.medicationReference = {"reference": f"Medication/{medication.id}"}
fulfillment.subject = {"reference": f"Patient/{patient_id}"}
fulfillment.dosage = [Dosage()]
fulfillment.dosage[0].route = CodeableConcept()
fulfillment.dosage[0].route.coding = [Coding()]
fulfillment.dosage[0].route.coding[0].system = "http://example.com/routes"
fulfillment.dosage[0].route.coding[0].code = "123456"
fulfillment.dosage[0].route.coding[0].display = "Example Route"
fulfillment.dosage[0].quantity = Quantity()
fulfillment.dosage[0].quantity.value = quantity
fulfillment.dosage[0].quantity.unit = "pill"
fulfillment.effectiveDateTime = FHIRDate(dispense_date)
return fulfillment
def create_alert(patient_id: str, message: str, category: str) -> Flag:
"""
Creates and returns a FHIR Flag resource representing an alert for the given patient ID, message, and category.
"""
alert = Flag()
alert.status = "active"
alert.subject = {"reference": f"Patient/{patient_id}"}
alert.code = CodeableConcept()
alert.code.coding = [Coding()]
alert.code.coding[0].system = "http://example.com/alerts"
alert.code.coding[0].code = "123456"
alert.code.coding[0].display= category
alert.period = Period()
alert.period.start = FHIRDate("2023-02-21")
return alert
def create_note(patient_id: str, text: str) -> DocumentReference:
"""
Creates and returns a FHIR DocumentReference resource representing a note for the given patient ID and text.
"""
note = DocumentReference()
note.status = "current"
note.subject = {"reference": f"Patient/{patient_id}"}
note.type = CodeableConcept()
note.type.coding = [Coding()]
note.type.coding[0].system = "http://loinc.org"
note.type.coding[0].code = "11506-3"
note.type.coding[0].display = "Consult note"
note.content = [Attachment()]
note.content[0].contentType = "text/plain"
note.content[0].data = text.encode("utf-8")
note.author = [Reference()]
note.author[0].reference = f"Practitioner/example-provider"
note.date = FHIRDate("2023-02-21")
return note
def create_social_determinant(question: str, answer: str) -> QuestionnaireResponse:
"""
Creates and returns a FHIR QuestionnaireResponse resource representing a social determinant of health with the given question and answer.
"""
response = SmartQuestionnaireResponse()
response.questionnaire = "http://example.com/sdh-questionnaire"
response.item = []
item = QuestionnaireResponseItem()
item.linkId = "1"
item.text = question
item.answer = []
answer_item = QuestionnaireResponseItemAnswer()
answer_item.valueString = answer
item.answer.append(answer_item)
response.item.append(item)
return response
def create_care_team(name: str, provider_names: List[str]) -> CareTeam:
"""
Creates and returns a FHIR CareTeam resource representing a care team with the given name and provider names.
"""
care_team = SmartCareTeam()
care_team.status = "active"
care_team.name = name
care_team.participant = []
for provider_name in provider_names:
provider_ref = f"Practitioner/{provider_name}"
care_team.participant.append(CareTeamParticipant({"member": {"reference": provider_ref}}))
return care_team
def create_task(title: str, description: str, assignee: str) -> Task:
"""
Creates and returns a FHIR Task resource representing a task with the given title, description, and assignee.
"""
task = SmartTask()
task.status = "draft"
task.intent = "order"
task.title = title
task.description = description
task.requester = {"reference": "Practitioner/example-requester"}
task.owner = {"reference": f"Practitioner/{assignee}"}
return task
def create_activity_definition(title: str, description: str, category: str, code: str) -> ActivityDefinition:
"""
Creates and returns a FHIR ActivityDefinition resource representing an activity definition with the given title, description, category, and code.
"""
activity_definition = SmartActivityDefinition()
activity_definition.status = "draft"
activity_definition.kind = "procedure"
activity_definition.title = title
activity_definition.description = description
activity_definition.category = CodeableConcept({"coding": [Coding({"system": "http://example.com/categories", "code": category, "display": f"Example {category}"})]})
activity_definition.code = CodeableConcept({"coding": [Coding({"system": "http://example.com/codes", "code": code, "display": f"Example {code}"})]})
return activity_definition
# Streamlit app code
import streamlit as st
from fhir.resources import *
st.set_page_config(page_title="FHIR Demo", page_icon=":heart:", layout="wide")
st.title("FHIR Demo")
st.sidebar.title("Navigation")
navigation = st.sidebar.radio("Go to", ("Home", "Observations", "Assessments", "Rules", "Referrals", "Providers", "Programs", "Fulfillment", "Alerts", "Notes", "Social Determinants of Health"))
st.sidebar.title("SMART App")
smart = None
if st.sidebar.button("Launch SMART App"):
smart = SmartApp.launch()
st.sidebar.write("SMART App launched")
if st.sidebar.button("Close SMART App"):
if smart:
smart.close()
st.sidebar.write("SMART App closed")
else:
st.sidebar.write("No SMART App to close")
if navigation == "Home":
st.write("Welcome to the FHIR Demo!")
st.write("Use the sidebar to navigate to different FHIR resources.")
st.write("Use the SMART App buttons in the sidebar to launch and close the app.")
elif navigation == "Observations":
st.write("# Observations")
patient_name = st.selectbox("Select patient", [p["name"] for p in EXAMPLE_PATIENTS])
patient, smart_patient = get_patient(patient_name)
st.write("### Patient")
st.write(f"Name: {patient.name[0].given[0]} {patient.name[0].family[0]}")
st.write(f"Birthdate: {patient.birthDate.as_json()}")
st.write(f"Gender: {patient.gender}")
st.write(f"Address: {patient.address[0].line[0]}, {patient.address[0].city}, {patient.address[0].state} {patient.address[0].postalCode}, {patient.address[0].country}")
st.write(f"Phone: {patient.telecom[0].value}")
st.write("### Add Observation")
code = st.selectbox("Select code", ["8302-2", "8462-4", "8867-4", "9279-1"])
value = st.number_input("Value")
unit = st.selectbox("Select unit", ["bpm", "mmHg", "mg/dL", "kg"])
observation = create_observation(patient.id, code, value, unit)
smart_client = smart.patient(smart_patient)
response = smart_client.create(observation)
st.write("Observation created:")
st.write(response.as_json())
elif navigation == "Assessments":
st.write("# Assessments")
patient_name = st.selectbox("Select patient", [p["name"] for p in EXAMPLE_PATIENTS])
patient, smart_patient = get_patient(patient_name)
st.write("### Patient")
st.write(f"Name: {patient.name[0].given[0]} {patient.name[0].family[0]}")
st.write(f"Birthdate: {patient.birthDate.as_json()}")
st.write(f"Gender: {patient.gender}")
st.write(f"Address: {patient.address[0].line[0]}, {patient.address[0].city}, {patient.address[0].state} {patient.address[0].postalCode}, {patient.address[0].country}")
st.write(f"Phone: {patient.telecom[0].value}")
st.write("### Add Assessment")
code = st.selectbox("Select code", ["69646-2", "8150-9", "82810-3"])
value = st.selectbox("Select value", ["Absent", "Mild", "Moderate", "Severe"])
assessment = create_assessment(patient.id, code, value)
smart_client = smart.patient(smart_patient)
response = smart_client.create(assessment)
st.write("Assessment created:")
st.write(response.as_json())
elif navigation == "Rules":
st.write("# Rules")
st.write("### Add Rule")
code = st.selectbox("Select code", ["36405-2", "89053-6"])
description = st.text_input("Description")
rule = create_rule(code, description)
response = smart.server.create(rule)
st.write("Rule created:")
st.write(response.as_json())
elif navigation == "Referrals":
st.write("# Referrals")
patient_name = st.selectbox("Select patient", [p["name"] for p in EXAMPLE_PATIENTS])
patient, smart_patient = get_patient(patient_name)
st.write("### Patient")
st.write(f"Name: {patient.name[0].given[0]} {patient.name[0].family[0]}")
st.write(f"Birthdate: {patient.birthDate.as_json()}")
st.write(f"Gender: {patient.gender}")
st.write(f"Address: {patient.address[0].line[0]}, {patient.address[0].city}, {patient.address[0].state} {patient.address[0].postalCode}, {patient.address[0].country}")
st.write(f"Phone: {patient.telecom[0].value}")
st.write("### Add Referral")
reason = st.text_input("Reason")
specialty = st.text_input("Specialty")
provider_name = st.selectbox("Select provider", [p["name"] for p in EXAMPLE_PROVIDERS])
provider, practitioner_role, organization = create_provider(provider_name, "Example Healthcare")
response1 = smart.server.create(provider)
response2 = smart.server.create(practitioner_role)
response3 = smart.server.create(organization)
referral = create_referral_request(patient.id, reason, specialty, provider_name)
response4 = smart.server.create(referral)
st.write("Referral created:")
st.write(response4.as_json())
elif navigation == "Providers":
st.write("# Providers")
st.write("### Add Provider")
name = st.text_input("Name")
organization_name = st.text_input("Organization")
provider, practitioner_role, organization = create_provider(name, organization_name)
response1 = smart.server.create(provider)
response2 = smart.server.create(practitioner_role)
response3 = smart.server.create(organization)
st.write("Provider created:")
st.write(response1.as_json())
elif navigation == "Programs":
st.write("# Programs")
st.write("### Add Program")
name = st.text_input("Name")
goal_description = st.text_input("Goal description")
start_date = st.date_input("Start date")
end_date = st.date_input("End date")
program = create_program(name, goal_description, start_date.isoformat(), end_date.isoformat())
response = smart.server.create(program)
st.write("Program created:")
st.write(response.as_json())
elif navigation == "Fulfillment":
st.write("# Fulfillment")
patient_name = st.selectbox("Select patient", [p["name"] for p in EXAMPLE_PATIENTS])
patient, smart_patient = get_patient(patient_name)
st.write("### Patient")
st.write(f"Name: {patient.name[0].given[0]} {patient.name[0].family[0]}")
st.write(f"Birthdate: {patient.birthDate.as_json()}")
st.write(f"Gender: {patient.gender}")
st.write(f"Address: {patient.address[0].line[0]}, {patient.address[0].city}, {patient.address[0].state} {patient.address[0].postalCode}, {patient.address[0].country}")
st.write(f"Phone: {patient.telecom[0].value}")
st.write("### Add Fulfillment")
medication_name = st.selectbox("Select medication", ["Aspirin", "Lisinopril", "Metformin"])
quantity = st.number_input("Quantity")
dispense_date = st.date_input("Dispense date")
fulfillment = create_fulfillment(patient.id, medication_name, quantity, dispense_date.isoformat())
smart_client = smart.patient(smart_patient)
response = smart_client.create(fulfillment)
st.write("Fulfillment created:")
st.write(response.as_json())
st.markdown("""
| Library | Description | PyPI URL |
|---------|-------------|----------|
| FHIR-Resources | π©Ί A Python library for working with FHIR resources. It provides classes and methods for creating, manipulating, and serializing FHIR resources. | https://pypi.org/project/fhir-resources/ |
| SMART on FHIR Python Client | π A Python library for accessing SMART on FHIR servers. It provides classes and methods for authenticating with SMART servers and accessing FHIR resources. | https://pypi.org/project/smart-on-fhir/ |
| PyFHIR | π¦ A Python library for parsing and generating FHIR resources. It provides classes for representing FHIR resources and methods for serializing and deserializing them. | https://pypi.org/project/pyfhir/ |
| HAPI FHIR | π» A Python library for working with FHIR servers. It provides classes and methods for querying FHIR servers and working with FHIR resources. | https://pypi.org/project/hapi-fhir/ |
| FHIR-Parser | π A Python library for parsing FHIR resources. It provides a parser class for deserializing FHIR resources. | https://pypi.org/project/fhir-parser/ |
| FHIR-FLAT | π§ A Python library for working with FHIR resources. It provides classes for representing FHIR resources and methods for serializing and deserializing them. | https://pypi.org/project/fhir-flat/ |
| HL7apy | π© A Python library for working with HL7 messages. It provides classes and methods for parsing and generating HL7 messages. | https://pypi.org/project/hl7apy/ |
| pyHl7 | π¨ A Python library for parsing and generating HL7 messages. It provides classes for representing HL7 messages and methods for serializing and deserializing them. | https://pypi.org/project/pyhl7/ |
| FHIR-Utils | π§ A Python library for working with FHIR resources. It provides utility functions for common FHIR tasks. | https://pypi.org/project/fhir-utils/ |
""")
import streamlit as st
# Angular libraries
st.header("Angular Libraries")
st.write("Here are some popular Angular libraries:")
st.markdown("- [ngx-charts](https://www.npmjs.com/package/@swimlane/ngx-charts)")
st.markdown("- [angular-material](https://material.angular.io/)")
# Node.JS libraries
st.header("Node.JS Libraries")
st.write("Here are some popular Node.JS libraries:")
st.markdown("- [express](https://expressjs.com/)")
st.markdown("- [axios](https://www.npmjs.com/package/axios)")
# Docker libraries
st.header("Docker Libraries")
st.write("Here are some popular Docker libraries:")
st.markdown("- [docker-py](https://pypi.org/project/docker/)")
st.markdown("- [docker-compose](https://docs.docker.com/compose/)")
# Kubernetes libraries
st.header("Kubernetes Libraries")
st.write("Here are some popular Kubernetes libraries:")
st.markdown("- [kubernetes](https://pypi.org/project/kubernetes/)")
st.markdown("- [kubeflow](https://www.kubeflow.org/)")
# GraphQL libraries
st.header("GraphQL Libraries")
st.write("Here are some popular GraphQL libraries:")
st.markdown("- [graphene](https://pypi.org/project/graphene/)")
st.markdown("- [graphql-core](https://pypi.org/project/graphql-core/)")
# PostgreSQL libraries
st.header("PostgreSQL Libraries")
st.write("Here are some popular PostgreSQL libraries:")
st.markdown("- [psycopg2](https://pypi.org/project/psycopg2/)")
st.markdown("- [sqlalchemy](https://pypi.org/project/SQLAlchemy/)")
# Snowflake libraries
st.header("Snowflake Libraries")
st.write("Here are some popular Snowflake libraries:")
st.markdown("- [snowflake-connector-python](https://pypi.org/project/snowflake-connector-python/)")
st.markdown("- [snowflake-sqlalchemy](https://pypi.org/project/snowflake-sqlalchemy/)")
# AI libraries
st.header("AI Libraries")
st.write("Here are some popular AI libraries:")
st.markdown("- [tensorflow](https://pypi.org/project/tensorflow/)")
st.markdown("- [scikit-learn](https://pypi.org/project/scikit-learn/)")
|