コード例 #1
0
  @Override
  public void setAttributeValue(Attribute attribute, Instance instance, Patient patient) {
    RegaService rs = ruleService.getRegaService();

    PatientAttributeValue pav =
        rs.getPatientAttributeValue(
            patient, ClinicalAttributeFactory.CLINICAL_REGA_ATTRIBUTE_RECENT_BLOOD_HB);

    if (pav == null) return; // The is no recent blood hb for this patient

    String strVal = pav.getValue();
    Double dVal;

    if (strVal.equals("N/A")) {
      return; // There is no value
    } else if (strVal.contains("/")) {
      dVal = Double.parseDouble(strVal.replace('/', '.'));
    } else {
      dVal = Double.parseDouble(strVal);
    }

    logger.info("Recent Blood HB for " + patient.getPatientId() + " is " + dVal);
    instance.setValue(attribute, dVal);
  }
コード例 #2
0
  @Override
  public void setAttributeValue(Attribute attribute, Instance instance, Patient patient) {
    RegaService rs = ruleService.getRegaService();

    // Get a list of viral loads in reverse order
    List<TestResult> VLResults =
        rs.getListOfTestResultsSortedByDate(
            RegaService.VIRAL_LOAD_TEST_ID, patient.getPatientIi(), RegaService.SORT_ORDER_DESC);

    Date sequenceDate = rs.getFirstSequenceDate(patient);

    Date initDate = rs.getARTInitiationDate(patient.getPatientIi());

    if (initDate == null) return; // This patient has never been on any treatment

    boolean foundLowVL = false;

    Date previousDate = null;
    Date mostRecentVL = null;

    for (TestResult vl : VLResults) {

      if (mostRecentVL == null) {
        mostRecentVL = vl.getTestDate();
      }

      Double vlValue = Double.parseDouble(stripPrefix(vl.getValue()));

      if (vlValue < TREATMENT_WORKING_VIRAL_LOAD) {
        if (previousDate == null) {
          // this is the most recent VL
          logger.info("TFR for " + patient.getPatientId() + " is 0");

          instance.setValue(attribute, 0);
          return;
        } else {
          foundLowVL = true;
          Double diff;
          if (sequenceDate == null) {
            diff = new Double(getDiffInDays(previousDate, mostRecentVL));
          } else {
            diff = new Double(getDiffInDays(previousDate, sequenceDate));
          }
          logger.info("TFR for " + patient.getPatientId() + " is " + diff);

          instance.setValue(attribute, diff);
          return;
        }
      }

      previousDate = vl.getTestDate();
    }

    if (!foundLowVL) {
      // Viral load never supressed
      Double diff;

      if (sequenceDate == null) {
        diff = new Double(getDiffInDays(initDate, mostRecentVL));
      } else {
        diff = new Double(getDiffInDays(initDate, sequenceDate));
      }

      logger.info("TFR for " + patient.getPatientId() + " is " + diff);
      instance.setValue(attribute, diff);
    }
  }