Internal API Documentation
This is the documentation for the internal Casematch API for frontend components (React, ..) within the application itself. The public API for external applications can be found here: API documentation
As well as the public API the internal API is a RESTful HTTPS API with JSON responses. Configuration of rules and user settings is (currently) done in the Rails front-end. Most API calls are private and hence clients ĥave to authorize themselves. Unlike the public API, the internal API authenticates using Cookies instead of tokens. Login and Logout are (at the moment) handled by the Rails frontend.
For development and testing with curl you might need to deactivate authentication in the backend. To test the API on the command line using curl:
Choose your language
Most API calls provide the parameter locale which can be used to select a language.locale=[de|fr|it|en]
Provided languages:
de | German - fully supported, default and fallback language |
fr | French - fully supported |
it | Italian - partially supported. no translations for interface texts and rules |
en | English - partially supported. no translations for ICD/CHOP/DRG catalogues and rules. |
The patient case URL format
Many API calls (all single patient case POST functions) provide the parameter pc which is a description of a patient case with all relevant information for the SwissDRG Grouper . Since 2018 the preferred format for patient cases is the new SwissDRG Batch / URL 2017 format as documented here: SwissDRG Batchgrouper Format 2017 . The URL 2017 format differs from the Batchgrouper 2017 format by the use of different (URL compatible) separators: '_' (underscore) instead of ';' (semicola) for top level column separators, '-' (hyphen) instead of '|' (pipe) for list item separators, '$' (dollar sign) instead of ':' (colon) for structure separators. The new 2017 format includes admission and exit dates and drugs (ATC) codes necessary for the calculation of supplements (Zusatzentgelte) and used as input in some of our prediction models. The same format (URL 2017) can be used when creating links to the WebGUI version of the Casematch platform. (Code proposals : /coding_proposals?locale=de , Case analysis : /patient_cases/analyzenew?locale=de ). ALL the characters used in the URL patient case format are allowed in an URI and do not have to be escaped. If the URL format is invalid and cannot be parsed an HTML status 400 with the following response is sent:
The variables in detail:
- case_number - Fallnummer der Fallkostenstatistik
-
Beliebiger eindeutiger Schlüssel. Bei Import BFS ist dies die Variable 4.6.V01 Fallnummer der Fallkostenstatistik
Datentyp : string - age_years - Alter in Jahren bei Eintritt
-
BFS-medstat: "1.1.V03"
BFS Variable 1.1.V03 - Alter in erfüllten Jahren (Eintrittsdatum-Geburtsdatum) bei
Spitaleintritt
Spiges: "alter: Alter bei Eintritt"
Alter in erfüllten Jahren (Eintrittsdatum-Geburtsdatum) bei Spitaleintritt
Datentyp : number
Range: von 0.0 bis 135.0 - age_days - Alter in Tagen
-
BFS-medstat: "age_days"
Alter bei Eintritt berechnet aus den BFS Variablen 1.2.V01 und 1.1.V02.
Spiges: "alter_u1: Alter in Tagen von Kindern unter 1 Jahr"
Alter bei Eintritt in Tagen. Anzugeben für Kinder, die weniger als ein Jahr alt sind. Der Eintrittstag ist nicht mitzuzählen (Berechnung: Eintrittstag - Geburtstag).
Die Angabe wird für die Gruppierung der SpiGes-Daten nach SwissDRG, TARPSY, ST-Reha und SPLG zwingend benötigt. Beim Upload auf die SpiGes-Plattform ist sie jedoch freiwillig. Beim Download wird sie automatisch ergänzt.
Datentyp : number
Range: von 0.0 bis 365.0 - adm_weight - Aufnahmegewicht
-
BFS-medstat: "4.5.V01"
BFS Variable 2.2.V04 / 4.5.V01
Spiges: "aufnahmegewicht"
in Gramm, Aufnahmegewicht eines Säuglings (eines Kindes bis 12 Monate!). Bei einer Geburt während der aktuellen Hospitalisierung muss das Geburtsgewicht (Variable geburtsgewicht) dem Aufnahmegewicht im aktuellen Feld entsprechen
Datentyp : number
Range: von 0.0 bis 99999.0 - sex - Geschlecht
-
BFS-medstat: "1.1.V01"
BFS Variable 1.1.V01 (1 -> M, 2 -> W)
Spiges: "geschlecht"
Geschlecht des Individuums. Bei Geschlechtsumwandlungen ist das bei Spitaleintritt geltende zivilrechtliche Geschlecht anzugeben.
Datentyp : string
Possible values: M W U
Value descriptions: männlich weiblich unbekannt - adm_mode - Aufnahmeart
-
BFS Variablen 1.2.V03 und 1.2.V02 (Umrechnung gemäss Grouperdokumentation SwissDRG)
Datentyp : string
Possible values: 01 11 06 99
Value descriptions: Normal Verlegt (Aufenthalt länger als 24 Stunden im verlegenden Spital) Verlegt (Aufenthalt kürzer als 24 Stunden im verlegenden Spital) Unbekannt - sep_mode - Entlassart
-
BFS Variable 1.5.V02 und 1.5.V03 (Umrechnung gemäss SwissDRG Grouperdokumentation)
Datentyp : string
Possible values: 07 06 04 00 99
Value descriptions: Verstorben Verlegt (in anderes Spital) Gegen ärztlichen Rat beendet Normal Unbekannt - los - Verweildauer in Tagen
-
Berechnung anhand der BFS Variablen 1.5.V01, 1.2.V01 und 1.3.V04
Datentyp : number
Range: von 1.0 bis 99999.0 - hmv - Beatmungsdauer in Stunden
-
BFS-medstat: "4.4.V01"
BFS 4.4.V01 - Die Dauer der Beatmung wird nach Intensivstation gemäss den
Regeln des aktuell gültigen Kodierungshandbuches berechnet.
In diesem Feld gibt es keine Angaben zur Art der künstlichen
Beatmung.
Spiges: "beatmung: Dauer der künstlichen Beatmung"
Anzahl Stunden, Die Dauer der Beatmung wird nach Intensivstation gemäss den Regeln des aktuell gültigen Kodierungshandbuches berechnet. In diesem Feld gibt es keine Angaben zur Art der künstlichen Beatmung. Definition übernommen von der Schweizerischen Gesellschaft für Intensivmedizin (SGI). Die Daten sind im Datensatz der SGI vorhanden.
Datentyp : number
Range: von 0.0 bis 99999.0 - main_diagnosis - Hauptdiagnose
-
BFS Variable 1.6.V01 - Die Hauptdiagnose ist als derjenige Zustand definiert, der am
Ende des Spitalaufenthalts als Diagnose feststeht und der
Hauptanlass für die Behandlung und Untersuchung des
Patienten war. Sind mehr als ein Zustand aufgeführt, ist
derjenige auszuwählen, der (medizinisch gesehen) den
grössten Aufwand an Mitteln erforderte. Erfolgte keine
Diagnosenstellung, dann ist das Hauptsymptom, der medizi-
nisch schwerwiegendste abnorme Befund oder die
schwerwiegendste Gesundheitsstörung als Hauptdiagnose
auszuwählen.
Die Vergabe der Kodes erfolgt nach den Richtlinien des BFS.
Die Angabe kann bis zu fünfstellige Kodes umfassen.
Entspricht den fünf ersten Stellen der Variable 4.2.V010
Datentyp : code - secondary_diagnoses - Nebendiagnosen
-
BFS Variablen 4.2 - Angabe der wichtigsten Begleitkrankheiten, die mit der
Hauptdiagnose im Zusammenhang stehen. Die Auswahl und
Reihung soll nach medizinischen Kriterien erfolgen.
Eventuelle Kreuz- und Sternkodes werden linear in die
Nebendiagnose-Felder gefügt.
Datentyp : Array Of code - procedures - Prozeduren
-
BFS Variablen 4.3
Datentyp : Array Of code
API call 'analyses' - Statistical and rule based analysis of a coding of a patient case
Creates an analysis of a coding of a patient case and responds with a JSON representation of the result. The result of the analysis is not persisted on the server.URL: internal_api/analyses
Method: POST
Example call: POST /internal_api/analyses?locale=de&pc=AI34221_65_0_0_M__01__00_1_0_I481-Z921-F051_8954-_
The API call 'analyze' provides the core functionality of Casematch for the analysis of single patient cases. The provided patient case is grouped and analyzed with the statistical model and the user defined rules.
Parameters:
Pretty printed sample response:
The second component are the 'grouper_results'. All grouper outputs are stored here:
- drg - DRG
-
Gruppierte DRG
Datentyp : code - mdc - MDC
-
MDC - Major Diagnostic Category
Datentyp : string - pccl - PCCL
-
PCCL - Patient Complexity and Comorbidity Level
Datentyp : number
Range: von 0.0 bis 4.0 - ecw - Effektives Kostengewicht
-
Effektives Kostengewicht nach Abzug/Zuschlag aller Ab- und Zuschläge
Datentyp : number
Range: von 0.0 bis 99999.0 - partition - Partition
-
DRG Partition (M -> Medizinisch, A -> Andere, O -> Operativ)
Datentyp : string
Possible values: M O A
Value descriptions: Medizinisch Operativ Andere - case_flag - Abrechnungsstatus
-
Datentyp : string
Possible values: 01 02 03 04 05
Value descriptions: Normallieger Oberer Outlier Unterer Outler Verlegungsabschlagspflichtig Unbewertete DRG
'grouper_results' and 'patient_case' are also available in the other API calls in the same form.
The third component are the 'analysis_results', all results from the statistical analysis:
- stat_drg - Statistische DRG
-
Wahrscheinlichste DRG gemäss dem statistischen Modell / Klassifikator. Dies ist die DRG mit der grössten Ähnlichkeit zu diesem Fall.
Datentyp : code - rank - Ähnlichkeitsindex
-
Ähnlichkeitsindex: Rang der gruppierten DRG im berechneten Modell. Ein Rang von 1 bedeutet, dass die gruppierte DRG auch die ähnlichste DRG ist. In diesem Fall stimmen das statistische Modell und die DRG-Gruppierung überein.
Datentyp : number
Range: von -1.0 bis 1000.0 - top_ranks - Ähnliche DRGs
-
Liste der 5 ähnlichsten DRGs gemäss dem statistischen Modell.
Datentyp : Array Of string - likelihood - Ähnlichkeit
-
Ähnlichkeit dieses Falles zur gruppierten DRG. Berechnet als Zuweisungswahrscheinlichkeit im statistischen Modell. Der Wert liegt zwischen 0 und 1. Die Ähnlichkeitswerte aller DRGs für einen Fall summieren sich auf 1.
Datentyp : number
Range: von 0.0 bis 1.0 - model_train_number - Fallzahl für DRG-Modell
-
Datentyp : number
Range: von 0.0 bis
API call 'coding_proposals' - Propose codes for a patient case
Creates coding proposals for a coding of a patient case and responds with a JSON representation of the resource. The resource is not persisted on the server.URL: internal_api/coding_proposals
Method: POST
Example call:
The API call 'propose' generates a list of related diagnoses and procedures based on the context of the provided coding (parameter 'pc').
Parameters:
Pretty printed sample response:
API call 'predictions' - Predict length of stay for a patient case
Predicts the length of stay for a patient case and responds with a JSON representation of the resource. The resource is not persisted on the server.URL: internal_api/predictions
Method: POST
Example call:
The API call 'predictions' generates a number based on the context of the provided patient case (parameter 'pc').
Parameters:
Pretty printed sample response: