Examples

SwissDRG Example

Here is a simple example of how to use the grouper API to group a SwissDRG patient case (“Akutsomatik”):

import org.swissdrg.grouper.*;
import org.swissdrg.grouper.tarpsy.TarpsyCatalogue;
import org.swissdrg.grouper.tarpsy.TarpsyEffectiveCostWeight;
import org.swissdrg.grouper.tarpsy.TarpsyWeightingRelation;
import org.swissdrg.zegrouper.api.ISupplementGroupResult;
import org.swissdrg.zegrouper.api.ISupplementGrouper;
import org.swissdrg.zegrouper.api.SupplementGrouperLoader;
import java.math.BigDecimal;
import java.util.Map;


public class ApiExample {

    private static final String WORKSPACE_FOLDER = "/home/madonna/spec-7pv1";
    private static final String CATALOGUE_FILE   = "/home/madonna/spec-7pv1/catalogue-acute.csv";

    public static void main(String[] args) throws Exception {

      /*
       * "BATCH_2017" is the input parser format; it contains medications.
       * Alternatives:
       * - "BATCH" for the old Batchgrouper format
       * - "URL" for a UrlPatientCaseParser,
       * - "BFS" for a BFSPatientCaseParser
       */
      IPatientCaseParser pcParser = PatientCaseParserFactory.getParserFor(
          PatientCaseParserFactory.InputFormat.BATCH_2017,
          IGrouperKernel.Tariff.SWISSDRG
      );

      // Input string in the Batch grouper input format as described in
      // https://grouper-docs.swissdrg.org/batchgrouper2017-format.html
      String inputLine = "123456;;3;3100|293;W;20170101;01;20170105;00;4;0;D650|M0694|I1090;815421:L:20151026;B02BD02:Plas:IV:10000:U|J02AC04:Susp:O:500:mg";

      PatientCase patient = pcParser.parse(inputLine);

      IGrouperReader reader = new SpecificationReader();
      IGrouperKernel grouper = reader.loadGrouper(
          WORKSPACE_FOLDER,
          IGrouperKernel.Tariff.SWISSDRG
      );

      grouper.groupByReference(patient);

      GrouperResult result = patient.getGrouperResult();

      assertEquals("P05C", result.getDrg());

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

      System.out.println("DRG: " + result.getDrg());
      EffectiveCostWeight ecw = EffectiveCostWeight.calculateEffectiveCostWeight(patient, catalogue.get(result.getDrg()));

      assertEquals(30660, ecw.getEffectiveCostWeight());

      System.out.println("ECW: " + ecw.getEffectiveCostWeight());

      // group supplements:
      ISupplementGrouper supplGrouper = SupplementGrouperLoader.load(WORKSPACE_FOLDER + "/ze-logic.json");
      ISupplementGroupResult supplResult = supplGrouper.group(
          new SupplementPatientCase(
              patient,
              result.getDrg(),
              result.getMdc()
          )
      );

      ISupplementGroupResult.Charge charge1 = supplResult.getCharges().get(0);
      assertEquals("ZE-2018-32.03", charge1.getSupplementName());
      assertEquals("B02BD02_IV_Plas", charge1.getCausedCode());
      assertEquals(new BigDecimal(10847.5), charge1.getValue());

      System.out.println(
          "Zusatzentgelt 1: "
          + charge1.getSupplementName() + ", "
          + charge1.getCausedCode() + ", "
          + charge1.getValue()
      );

      /** should print:
       *
       *     DRG: P05C
       *     ECW: 31600
       *     Zusatzentgelt 1: ZE-2018-32.03, B02BD02_IV_Plas, 10847.5
       */
    }
}

TARPSY

import org.swissdrg.grouper.*;
import org.swissdrg.grouper.IGrouperKernel.Tariff;
import org.swissdrg.grouper.PatientCaseParserFactory.InputFormat;
import org.swissdrg.grouper.tarpsy.HoNOSPreprocessor;
import org.swissdrg.grouper.tarpsy.HoNOSPreprocessor.HoNOSAssessment;
import org.swissdrg.grouper.tarpsy.HoNOSPreprocessor.HoNOSStatus;
import org.swissdrg.grouper.tarpsy.TarpsyCatalogue;
import org.swissdrg.grouper.tarpsy.TarpsyEffectiveCostWeight;
import org.swissdrg.grouper.tarpsy.TarpsyWeightingRelation;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class TarpsyApiExample {

    private static final String WORKSPACE_FOLDER      = "/path/to/t1.3";
    private static final String TARPSY_CATALOGUE_FILE = "/path/to/t1.3/catalogue.csv";

    public static void main(String[] args) throws Exception {

        /*
         * "BATCH_2017" is an input format which can include medication data.
         * Alternatives:
         * - "BATCH" for the old Batchgrouper format
         * - "URL" for a UrlPatientCaseParser,
         * - "BFS" for a BFSPatientCaseParser
         */
        IPatientCaseParser pcParser = PatientCaseParserFactory.getParserFor(
            PatientCaseParserFactory.InputFormat.BATCH_2017,
            IGrouperKernel.Tariff.TARPSY
        );

        // Input string in the Batchgrouper2017 input format as described in
        // https://grouper-docs.swissdrg.org/batchgrouper2017-format.html
        String patientInputLine = "123456;40;0;;W;20180101;01;20180108;00;8;0;F110;94A114:L:20180101;";

        PatientCase patient = pcParser.parse(patientInputLine);

        IGrouperReader reader = new SpecificationReader();
        IGrouperKernel grouper = reader.loadGrouper(
            WORKSPACE_FOLDER,
            IGrouperKernel.Tariff.TARPSY
        );

        grouper.groupByReference(patient);

        GrouperResult result = patient.getGrouperResult();

        Map<String, TarpsyWeightingRelation> catalogue = TarpsyCatalogue.createFrom(
            TARPSY_CATALOGUE_FILE
        );

        String pcg = result.getDrg();
        System.out.println("PCG: " + pcg);
        TarpsyEffectiveCostWeight ecw = TarpsyEffectiveCostWeight.calculateTarpsyEffectiveCostWeight(
            patient, catalogue.get(pcg));
        System.out.println("ECW: " + ecw.getEffectiveCostWeight());
        System.out.println("Daily cost weight: " + ecw.getDayCostWeight());

        /** should print:
         *
         *    PCG: TP70Z
         *    ECW: 121320
         *    Daily cost weight: 13480
         *
         */
    }
}