{
    "openapi": "3.0.3",
    "info": {
        "title": "CareRx API",
        "version": "v1",
        "description": "Practice data for apps a CareRx practice owner has connected. See https://carerx.caresoft.co.in/developers/docs."
    },
    "servers": [
        {
            "url": "https://carerx.caresoft.co.in/api/v1"
        }
    ],
    "paths": {
        "/me": {
            "get": {
                "summary": "Who you are connected as: app, practice, install id and the permissions the practice gave.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                }
            }
        },
        "/practice": {
            "get": {
                "summary": "The practice: name, country, currency, time zone, locations and doctors (with the locations they sit at).",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "practice.read"
                        ]
                    }
                ]
            }
        },
        "/doctors/{id}/slots": {
            "get": {
                "summary": "Free appointment times for a doctor on a date.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "appointments.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "location_id",
                        "in": "query",
                        "description": "Location (default: the doctor's first).",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "date",
                        "in": "query",
                        "description": "YYYY-MM-DD (default today).",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    }
                ]
            }
        },
        "/patients": {
            "get": {
                "summary": "Patients, oldest first.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "patients.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "mobile",
                        "in": "query",
                        "description": "Find by mobile number.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "record_no",
                        "in": "query",
                        "description": "Find by the practice's record number.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "created_since",
                        "in": "query",
                        "description": "Registered on or after this date.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "after",
                        "in": "query",
                        "description": "Return records with id greater than this (use next_after from the previous page).",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "1 to 100, default 50.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ]
            },
            "post": {
                "summary": "Register a patient. Send \"consent\": true only once the patient has agreed to be registered with the practice. 409 if a patient with the same mobile and a similar name is already registered (the reply gives that patient's id).",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "patients.write"
                        ]
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "description": "string, required",
                                        "type": "string"
                                    },
                                    "gender": {
                                        "description": "male | female | other, required",
                                        "type": "string"
                                    },
                                    "mobile": {
                                        "description": "string",
                                        "type": "string"
                                    },
                                    "email": {
                                        "description": "string",
                                        "type": "string"
                                    },
                                    "city": {
                                        "description": "string",
                                        "type": "string"
                                    },
                                    "date_of_birth": {
                                        "description": "YYYY-MM-DD",
                                        "type": "string"
                                    },
                                    "age_years": {
                                        "description": "integer (if no date of birth)",
                                        "type": "integer"
                                    },
                                    "consent": {
                                        "description": "true, required",
                                        "type": "boolean"
                                    }
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/patients/{id}": {
            "get": {
                "summary": "One patient.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "patients.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ]
            }
        },
        "/appointments": {
            "get": {
                "summary": "Appointments.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "appointments.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "date",
                        "in": "query",
                        "description": "One day.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From date.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To date.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "doctor_id",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "patient_id",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "location_id",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "booked | checked_in | in_consult | done | cancelled | no_show",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "after",
                        "in": "query",
                        "description": "Return records with id greater than this (use next_after from the previous page).",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "1 to 100, default 50.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ]
            },
            "post": {
                "summary": "Book an appointment. The time must be one of the doctor's free slots; without a time the patient joins the day's queue. Patients get the practice's usual confirmation message.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "appointments.write"
                        ]
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "patient_id": {
                                        "description": "integer, required",
                                        "type": "integer"
                                    },
                                    "doctor_id": {
                                        "description": "integer, required",
                                        "type": "integer"
                                    },
                                    "location_id": {
                                        "description": "integer, required",
                                        "type": "integer"
                                    },
                                    "date": {
                                        "description": "YYYY-MM-DD, required",
                                        "type": "string"
                                    },
                                    "time": {
                                        "description": "HH:MM",
                                        "type": "string"
                                    },
                                    "type": {
                                        "description": "new | followup | procedure | tele (default: worked out)",
                                        "type": "string"
                                    },
                                    "notes": {
                                        "description": "string",
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/appointments/{id}": {
            "get": {
                "summary": "One appointment.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "appointments.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ]
            }
        },
        "/appointments/{id}/cancel": {
            "post": {
                "summary": "Cancel an appointment.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "appointments.write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "reason": {
                                        "description": "string, required",
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/prescriptions": {
            "get": {
                "summary": "Finalised prescriptions.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "prescriptions.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "from",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "patient_id",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "doctor_id",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "after",
                        "in": "query",
                        "description": "Return records with id greater than this (use next_after from the previous page).",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "1 to 100, default 50.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ]
            }
        },
        "/prescriptions/{id}": {
            "get": {
                "summary": "One finalised prescription: diagnosis, medicines, advice, follow-up date and the verify link. Add ?format=fhir for an ABDM (NRCES) FHIR R4 PrescriptionRecord bundle.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "prescriptions.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "format",
                        "in": "query",
                        "description": "fhir for a FHIR bundle.",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/bills": {
            "get": {
                "summary": "Bills with items and payments.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "bills.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "from",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "patient_id",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "after",
                        "in": "query",
                        "description": "Return records with id greater than this (use next_after from the previous page).",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "1 to 100, default 50.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ]
            }
        },
        "/bills/{id}": {
            "get": {
                "summary": "One bill.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "bills.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ]
            }
        },
        "/lab-orders": {
            "get": {
                "summary": "Lab tests ordered.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "lab_orders.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "patient_id",
                        "in": "query",
                        "description": "",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "after",
                        "in": "query",
                        "description": "Return records with id greater than this (use next_after from the previous page).",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "1 to 100, default 50.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ]
            }
        },
        "/lab-orders/{id}": {
            "get": {
                "summary": "One lab order.",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Token missing or expired"
                    },
                    "403": {
                        "description": "Permission not given"
                    },
                    "429": {
                        "description": "Too many calls"
                    }
                },
                "security": [
                    {
                        "oauth": [
                            "lab_orders.read"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ]
            }
        }
    },
    "components": {
        "securitySchemes": {
            "oauth": {
                "type": "oauth2",
                "flows": {
                    "authorizationCode": {
                        "authorizationUrl": "https://carerx.caresoft.co.in/oauth/authorize",
                        "tokenUrl": "https://carerx.caresoft.co.in/oauth/token",
                        "refreshUrl": "https://carerx.caresoft.co.in/oauth/token",
                        "scopes": {
                            "practice.read": "Your practice: name, locations, doctors and their specialties",
                            "patients.read": "Patients: name, gender, age or date of birth, mobile, email, city and record number",
                            "patients.write": "Register new patients",
                            "appointments.read": "Appointments and doctors' free slots",
                            "appointments.write": "Book and cancel appointments",
                            "prescriptions.read": "Finalised prescriptions: diagnosis, medicines, advice and follow-up date",
                            "bills.read": "Bills: items, amounts and payments",
                            "lab_orders.read": "Lab tests ordered for patients"
                        }
                    }
                }
            }
        }
    }
}