# Guide¶

## Grouper Kernel¶

The IGrouperKernel interface provides methods to group a PatientCase into a DRG. You can obtain a grouper kernel instance via an IGrouperReader. The following snipped loads a SwissDRG grouper kernel:

IGrouperReader reader = new SpecificationReader();


where WORKSPACE_FOLDER is a string pointing to the root of a SwissDRG specification.

To obtain a TARPSY grouper kernel, use:

...


## Patient Case¶

A PatientCase is a wrapper for all variables that describe a patient case. You can either construct a patient case yourself or parse a patient case from a string representation by using one of the provided patient case parsers.

### Constructing a patient case¶

After instantiating an PatientCase instance, you can use setter methods to construct the desired patient case:

PatientCase pc = new PatientCase();
pc.setBirthHouse(true);
pc.setId("1337");
pc.setEntryDate("20170101");
pc.setExitDate("20170105");
pc.setLos(0);
pc.setLeaveDays(12);
pc.setAgeYears(100);
pc.setAgeDays(10);
pc.setGestAge(34);
pc.setHmv(56);
pc.setBirthDate("20000101");
pc.setSep("02");
pc.setSex("M");
pc.setPdx("B260");


### Parsing a patient case¶

If you have a string representation of a patient case in one of the supported Input Formats, you can obtain an IPatientCaseParser to parse the string into an instance of PatientCase. These parsers are provided through a factory PatientCaseParserFactory, which will return an appropriate parser for the provided input format and tariff structure. The following snippet shows how to obtain a parser for the Batchgrouper input format.

IPatientCaseParser parser = PatientCaseParserFactory.getParserFor(InputFormat.BATCH, Tariff.SWISSDRG);


The tariff structure needs to be passed to the factory since some parsers operate differently with respect to the tariff structure (ex. BFS). Additional input formats include InputFormat.BATCH_2017, InputFormat.BFS, InputFormat.URL and InputFormat.TARPSY_MB.

After you have obtained a parser instance, you can parse your patient case string:

...
PatientCase patient = parser.parse("...");


Coming Soon™

## Grouping¶

Once you have obtained an IGrouperKernel and a PatientCase, you can group the patient case into the appropriate DRG (according to the specification passed to the Grouper Kernel):

grouper.groupByReference(patient);
GrouperResult result = patient.getGrouperResult();

// Or

PatientCase copy = grouper.groupByValue(patient);
GrouperResult result = copy.getGrouperResult();


The first method passes the created PatientCase directly to the grouper kernel. As a consequence, this passed PatientCase instance will be used (and modified) during the grouping process.

In contrast, the second method will copy the created patient case and use that copy in the grouping process. The original patient case will not be modified. Note that in this case, the grouping result is attached to the copied patient case, and not the original patient case.

## Computing Effective Cost Weights¶

Now that the patient case is grouped into the appropriate DRG, we can determine the effective cost weight of the patient case. We do this by querying the Catalog with the obtained DRG of the patient case:

Map<String, WeightingRelation> catalogue = Catalogue.createFrom(CATALOGUE_FILE);

String drg = result.getDrg();
EffectiveCostWeight ecw = EffectiveCostWeight.calculateEffectiveCostWeight(patient, catalogue.get(drg));

int effectiveCostWeight = ecw.getEffectiveCostWeight();


To see everything come together, take a look at the Examples.

## Computing Transfer Discounts¶

According to the Regeln und Definitionen zur Fallabrechnung unter SwissDRG the transfer discounts (“Verlegungsabschläge”) for transferred patients with a given DRG is calculated like this:

$Transfer discount = daily\_transfer\_discount * (MLOS - LOS)$

where

• daily_transfer_discount is defined by the relevant DRG catalogue
• MLOS is the mean length of stay for the given DRG – but see note below!
• LOS is the length of stay of the given patient case

NOTE: The mean length of stay (“MLOS”) per DRG is given in the catalogue on the SwissDRG homepage, see e.g. here for SwissDRG 8.0. But the MLOS provided there are rounded to one decimal, whereas the grouper uses the MLOS rounded down to the preceding integer!

This new way to calculate the transfer discount was introduced with SwissDRG 8.0. Section 2.2.3 of the “Bericht zur Weiterentwicklung der SwissDRG Tarifstruktur 8.0” describes the changes in detail:

Please note that the application of this updated calculation is mandatory: Grouper users cannot use the old way of calculation, lest they get invalid effective cost weights which differ from the public SwissDRG version.

### Example¶

Given SwissDRG 8.0 and a transferred patient case with

• LOS: 5 days
• DRG: A92B. So according to the catalogue of SwissDRG 8.0:
• cost weight: 1.151
• daily transfer discount: 0.115
• MLOS: 10.8 => grouper uses 10.0

So the transfer discount is

(10 - 5) * 0.115 = 0.575


Therefore the effective cost weight will be

1.151 - 0.575 = 0.576