Exemplo n.º 1
0
  public Patients Search(
      Patient searchParams, boolean AllowSearchByDemographics, boolean includeOptOutPatient) {
    Patients results = new Patients();

    // if not results, try a demographics search
    log.info("should we perform an demographic search?");
    if ((AllowSearchByDemographics) && (hasDemographicInfo(searchParams))) {
      log.info("attempt demographic search");
      results = SearchByDemographics(searchParams, includeOptOutPatient);
      if (results == null) {
        log.info("results==null");
      } else {
        log.info("results.size()=" + results.size());
      }
    } else {
      log.info("no attempt on demographic search");
    }

    // perform a id search
    log.info("should we perform an id search?");
    if ((results.size() == 0) && (searchParams.getIdentifiers().size() > 0)) {
      log.info("attempt id search");
      results = SearchById(searchParams, includeOptOutPatient);
      if (results == null) {
        log.info("results==null");
      } else {
        log.info("results.size()=" + results.size());
      }
    } else {
      log.info("no attempt on id search");
    }

    log.info("result size=" + results.size());
    return results;
  }
Exemplo n.º 2
0
 private void tabPatients_SaveActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_tabPatients_SaveActionPerformed
   try {
     Patients patients = new Patients();
     patients.setVisible(true);
   } catch (Exception ex) {
     Logger.getLogger(MainMenu.class.getName()).log(Level.SEVERE, null, ex);
   }
 } // GEN-LAST:event_tabPatients_SaveActionPerformed
Exemplo n.º 3
0
  public void run(String xmlFile, String context) throws JAXBException, FileNotFoundException {
    Patients patients = new Patients();
    List<Patient> patientList = patients.getPatient();

    Patient p = new Patient();
    p.setId(BigInteger.valueOf(1));
    p.setName("John Doe");
    p.setDiagnosis("Schizophrenia");

    patientList.add(p);

    JAXBContext jc = JAXBContext.newInstance(context);
    Marshaller m = jc.createMarshaller();
    m.marshal(patients, new FileOutputStream(xmlFile));
  }
Exemplo n.º 4
0
 private Patients SearchByDemographics(Patient searchParams, boolean includeOptOutPatient) {
   Patients results = new Patients();
   log.info("performing a demograpics search");
   if (includeOptOutPatient) {
     for (Patient patient : this.getPatients()) {
       if (PatientMatcher.IsSearchMatchByDemographics(patient, searchParams)) {
         results.add(patient);
       }
     }
   } else {
     for (Patient patient : this.getPatients()) {
       if (PatientMatcher.IsSearchMatchByDemographics(patient, searchParams)) {
         results.add(patient);
       }
     }
   }
   return results;
 }
Exemplo n.º 5
0
 private Patients SearchById(Patient searchParams, boolean includeOptOutPatient) {
   Patients results = new Patients();
   // System.out.println("performing an id search");
   log.info("performing an id search");
   if (includeOptOutPatient) {
     for (Patient patient : this.getPatients()) {
       if (PatientMatcher.IsSearchMatchByIds(patient, searchParams)) {
         results.add(patient);
       }
     }
   } else {
     for (Patient patient : this.getPatients()) {
       if (PatientMatcher.IsSearchMatchByIds(patient, searchParams)) {
         results.add(patient);
       }
     }
   }
   return results;
 }
Exemplo n.º 6
0
  public void Delete(Patient patient, String homeCommunityId) {
    log.info(
        "Attemping to Delete identifiers for community: "
            + homeCommunityId
            + " for patient: "
            + patient.getName().getFirstName()
            + " "
            + patient.getName().getLastName());
    Patients existingPatients = Search(patient, true, true);
    int patIdx = 0;
    int idIdx = 0;

    if (existingPatients.size() > 1) {
      log.info("ERROR: Multiple instances of the patient were found");
    } else if (existingPatients.size() == 1) {
      log.info("Found 1 entry in MPI for the patient");
      for (Patient tmpPatient : getPatients()) {
        if (existingPatients.get(0) == tmpPatient) {
          log.info("Found a match in index " + patIdx);

          for (Identifier id : getPatients().get(patIdx).getIdentifiers()) {
            if (homeCommunityId.contentEquals(id.getOrganizationId())) {
              log.info("Found a match for identifiers in index" + idIdx);
              Identifier result = getPatients().get(patIdx).getIdentifiers().remove(idIdx);
              break;
            }
            idIdx++;
          }
          break;
        }
        patIdx++;
      }
    } else {
      // System.out.println("ERROR: Patient not found in MPI");
      log.info("ERROR: Patient not found in MPI");
    }

    SaveData();
  }
Exemplo n.º 7
0
  public Patient AddUpdate(Patient newPatient) {
    Patient resultPatient = null;
    ValidateNewPatient(newPatient);

    Patients existingPatients = Search(newPatient, true, true);

    if (existingPatients.size() == 2) {
      // throw exception
    } else if (existingPatients.size() == 1) {
      resultPatient = existingPatients.get(0);
      resultPatient.getIdentifiers().add(newPatient.getIdentifiers());
      resultPatient.setName(newPatient.getName());
      resultPatient.setGender(newPatient.getGender());
      resultPatient.setOptedIn(newPatient.isOptedIn());
    } else {
      getPatients().add(newPatient);
      resultPatient = newPatient;
    }

    SaveData();

    return resultPatient;
  }