Write and Read Data

After we've completed setting up object classes and their properties , we are ready to start reading and writing data in the format we just specified. More specifically, we'll create instances of the Prescription class in the Medable cloud.

The following examples use HTTP. This is most applicable for web development. You might issue these HTTP requests using a tool like Fetch or Ajax. If you're doing iOS or Android development, we wrote SDK's that make it easier for you to interact with these endpoints.

Create

Creating prescriptions is a simple matter of a POST request to the object route.

POST https://api.dev.medable.com/{{your_org_name}}/v2/c_prescriptions
{
    "c_rx":"Doxycycline 100mg tab. Take one PO bid.",
    "c_dispense": 60,
    "c_refills": 3,
    "c_date":"2016-07-01",
    "c_patient":"575f58281d0c03a53ccc3ac6",
    "c_provider":"5771495a1d0c03a53ce83f1a"
}
{
    "_id": "577c883c6f3035ee08357dfa",
    "access": 7,
    "c_date": "2016-07-01",
    "c_dispense": 60,
    "c_patient": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "c_provider": {
        "_id": "5771495a1d0c03a53ce83f1a",
        "object": "account",
        "path": "/accounts/5771495a1d0c03a53ce83f1a"
    },
    "c_refills": 3,
    "c_rx": "Doxycycline 100mg tab. Take one PO bid.",
    "created": "2016-07-06T04:25:32.558Z",
    "creator": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "favorite": false,
    "object": "c_prescription",
    "owner": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "shared": false
}

Get Many

To get that prescription we just created back, we can simply do a GET

GET https://api.dev.medable.com/{{your_org_name}}/v2/c_prescriptions
{
    "data": [
        {
            "_id": "577c883c6f3035ee08357dfa",
            "access": 7,
            "c_date": "2016-07-01",
            "c_dispense": 60,
            "c_patient": {
                "_id": "575f58281d0c03a53ccc3ac6",
                "object": "account",
                "path": "/accounts/575f58281d0c03a53ccc3ac6"
            },
            "c_provider": {
                "_id": "5771495a1d0c03a53ce83f1a",
                "object": "account",
                "path": "/accounts/5771495a1d0c03a53ce83f1a"
            },
            "c_refills": 3,
            "c_rx": "Doxycycline 100mg tab. Take one PO bid.",
            "created": "2016-07-06T04:25:32.558Z",
            "creator": {
                "_id": "575f58281d0c03a53ccc3ac6",
                "object": "account",
                "path": "/accounts/575f58281d0c03a53ccc3ac6"
            },
            "favorite": false,
            "object": "c_prescription",
            "owner": {
                "_id": "575f58281d0c03a53ccc3ac6",
                "object": "account",
                "path": "/accounts/575f58281d0c03a53ccc3ac6"
            },
            "shared": false
        }
    ],
    "hasMore": false,
    "object": "list"
}

Get One

Or to get a specific Prescription...

GET https://api.dev.medable.com/{{your_org_name}}/v2/c_prescriptions/{{object_id}}
{
    "_id": "577c883c6f3035ee08357dfa",
    "access": 7,
    "c_date": "2016-07-01",
    "c_dispense": 60,
    "c_patient": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "c_provider": {
        "_id": "5771495a1d0c03a53ce83f1a",
        "object": "account",
        "path": "/accounts/5771495a1d0c03a53ce83f1a"
    },
    "c_refills": 3,
    "c_rx": "Doxycycline 100mg tab. Take one PO bid.",
    "created": "2016-07-06T04:25:32.558Z",
    "creator": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "favorite": false,
    "object": "c_prescription",
    "owner": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "shared": false
}

In-Depth Documentation

For more on CRUD operations on objects, see Cortex API Reference


What’s Next