Skip to content

Instantly share code, notes, and snippets.

@swhume
swhume / odmlib_first_define.py
Created April 2, 2022 17:34
PHUSE 2022 OS01 odmlib example
# Copyright 2022 Sam Hume. Licensed under the MIT-0 license https://opensource.org/licenses/MIT-0
import odmlib.define_2_1.model as DEFINE
import datetime
"""
This is the code presented at the PHUSE US Connect 2022 and described in paper PAP_OS01.
The purpose of this code is to demonstrate using odmlib to create and process a very simple Define-XML v2.1 file.
NOTE: In places where paths are referenced, you will need to update them to reflect your system.
"""
import lxml.etree as ET
import argparse
import os
"""
Example Cmd-line Args:
example: -x ./data/some.xml -o ./data/some.html -s ./data/transform.xslt
"""
import sys
import xml.etree.ElementTree as ET
""" Simple program snippet to demonstrate parsing the CXL XML CMAP export format """
ET.register_namespace('', "http://cmap.ihmc.us/xml/cmap/")
# get the CXL file to parse from the command-line
if len(sys.argv) > 1:
cxl_file = sys.argv[1]
else:
# scrape XML from a spec grabber generated wiki page
from bs4 import BeautifulSoup
import os
import sys
import getopt
# get the command-line arguments - page id is required
scrape_xml_file = "scrape.xml"
path = ""
page_id = None
from fhirclient import client
import fhirclient.models.patient as p
settings = {
'app_id': 'rof_adapter',
'api_base': 'https://api-v5-stu3.hspconsortium.org/rofphir/open'
}
smart = client.FHIRClient(settings=settings)
patient = p.Patient.read('SMART-1288992', smart.server)
package json2xml;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;
/**
import requests
import json
USERNAME = "username"
PWD = "password"
URL = "http://68.183.158.128:5000/odm"
# create ItemDef
itemdef = {
"_use": "collection",
from fhirclient import client
import fhirclient.models.observation as ob
settings = {
'app_id': 'rof_adapter',
'api_base': 'https://api-v5-stu3.hspconsortium.org/rofphir/open'
}
def get_observations(patient_id, loinc_code):
smart = client.FHIRClient(settings=settings)
search_obs = ob.Observation.where(struct=dict(patient=patient_id, code=loinc_code))
import requests
import json
USERNAME = "username"
PWD = "password"
URL = "http://68.183.158.128:5000/odm"
codelist = {
"_use": "collection",
"OID": "CL.Test.02",