Class: Dcm4chee::Api::V1::PatientsController

Inherits:
BaseController show all
Defined in:
app/controllers/dcm4chee/api/v1/patients_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

Restore a patient from the trash.

Examples:

# Request
POST /api/patients HTTP/1.1
Accept: application/vnd.menglifang.org; version=1

{ "trashed_patient_id": ... }

# Response
HTTP/1.1 201 Created


68
69
70
71
72
73
# File 'app/controllers/dcm4chee/api/v1/patients_controller.rb', line 68

def create
  trashed_patient = TrashedPatient.get!(params[:trashed_patient_id])
  trashed_patient.restore_from_trash

  head :created
end

#indexObject

Search for patients. Supported querying conditions:

name
pid
pid_issuer
studies.study_at
studies.accession_no
studies.series.modality
studies.series.source_aet

Check DataMapper::Searcher::ClassMethods for supported querying operators.

pagination:

page    # default 1
limit   # default 20

Examples:

# Request
GET /api/patients?q[name.like]=... HTTP/1.1
Accept: application/vnd.menglifang.org; version=1

# Response
HTTP/1.1 200 OK
{
  "page": ...,
  "limit": ...,
  "patients": [{
    "id": ...,
    "pid": ...,
    "pid_issuer": ...,
    "name": ...,
    "birthday": ...,
    "gender": ...,
    "dcm_elements": [{
      "name": ...,
      "value": ...,
      "tag": ...,
      "value_representation": ...,
      "length": ...
    }, ...]
  }, ...]
}


50
51
52
53
54
55
# File 'app/controllers/dcm4chee/api/v1/patients_controller.rb', line 50

def index
  patients = Patient.search(params[:q]).
    page(params[:page] || 1, per_page: params[:limit] || 20)

  render json: { patients: patients, total: patients.pager.total }
end