示例#1
0
  /**
   * Creates a pet.
   *
   * @param name the pet name
   * @param species the pet species
   * @return a new pet
   */
  private Party createPet(String name, String species) {
    Party pet = TestHelper.createPatient(false);

    pet.setName(name);
    IMObjectBean bean = new IMObjectBean(pet);
    Lookup lookup = TestHelper.getLookup("lookup.species", species.toUpperCase(), species, true);
    bean.setValue("species", lookup.getCode());
    return pet;
  }
示例#2
0
  /**
   * Returns a <tt>CustomerPartyType</tt> corresponding to the passed
   * <em>party.organisationStockLocation</em>.
   *
   * <p>The contact details will be either those of the <em>party.organisationLocation</em> or the
   * parent </em>party.organisationPractice</em>. If the location has a <em>contact.location</em>,
   * then the location's details will be used, otherwise the practice's details will be used.
   *
   * <p>The customer identifier will be that of the stock location.
   *
   * <p>NOTE: the supplied <em>entityRelationship.supplierStockLocation*</em> relationship may have
   * an optional <em>accountId</em> node, used to populate the
   * <tt>SupplierAssignedAccountIDType</tt>
   *
   * @param contactName a contact name to supply with telephone, email and fax details, May be
   *     <tt>null</tt>
   * @param location the practice location
   * @param stockLocation the stock location
   * @param supplierStockLocation an <em>entityRelationship.supplierStockLocation*</em> relationship
   * @return the corresponding <tt>CustomerPartyType</tt>
   */
  private CustomerPartyType getCustomer(
      String contactName,
      Party location,
      Party stockLocation,
      EntityRelationship supplierStockLocation) {
    CustomerPartyType result = new CustomerPartyType();
    Party customer;

    Party practice = locationRules.getPractice(location);
    if (practice == null) {
      throw new IllegalStateException("No practice for location: " + location.getId());
    }

    Contact locationContact =
        partyRules.getContact(location, ContactArchetypes.LOCATION, "BILLING");
    if (locationContact == null) {
      locationContact = partyRules.getContact(practice, ContactArchetypes.LOCATION, "BILLING");
      if (locationContact == null) {
        throw new IllegalStateException("No contact.location for location: " + location.getId());
      }
      customer = practice;
    } else {
      customer = location;
    }
    Contact phoneContact =
        partyRules.getContact(customer, ContactArchetypes.PHONE, false, "FAX", "BILLING");
    Contact faxContact =
        partyRules.getContact(customer, ContactArchetypes.PHONE, true, null, "FAX", "BILLING");
    if (faxContact == null) {
      faxContact = partyRules.getContact(customer, ContactArchetypes.PHONE, true, null, "FAX");
    }
    Contact emailContact = partyRules.getContact(customer, ContactArchetypes.EMAIL, "BILLING");

    CustomerAssignedAccountIDType customerId =
        UBLHelper.initID(new CustomerAssignedAccountIDType(), stockLocation.getId());

    PartyType party = getParty(customer, locationContact);
    party.setContact(getContact(contactName, phoneContact, faxContact, emailContact));

    result.setCustomerAssignedAccountID(customerId);

    IMObjectBean bean = factory.createBean(supplierStockLocation);
    String accountId = bean.getString("accountId");
    if (!StringUtils.isEmpty(accountId)) {
      SupplierAssignedAccountIDType supplierId =
          UBLHelper.initID(new SupplierAssignedAccountIDType(), accountId);
      result.setSupplierAssignedAccountID(supplierId);
    }

    result.setParty(party);
    return result;
  }
示例#3
0
  /** Tests the {@link ListFunctions#sortNamesOf(ExpressionContext, String)} method */
  @Test
  public void testSortNamesOf() {
    Party vet = (Party) create(SupplierArchetypes.SUPPLIER_VET);
    vet.addClassification(createVetSpecialty("Surgery"));
    vet.addClassification(createVetSpecialty("Large Animals"));
    vet.addClassification(createVetSpecialty("Snakes"));

    JXPathContext ctx = createContext(vet);

    assertEquals(
        "Large Animals, Snakes, Surgery", ctx.getValue("list:sortNamesOf('classifications')"));

    assertEquals(
        "(Large Animals, Snakes, Surgery)",
        ctx.getValue("expr:concatIf('(', list:sortNamesOf('classifications'), ')')"));
  }
 /**
  * Invoked when an appointment is selected.
  *
  * <p>If the appointment can be viewed at the current practice location, the appointment workspace
  * will be switched to.
  *
  * @param appointment the appointment
  * @param layoutContext the layout context
  */
 private void onAppointmentSelected(Act appointment, LayoutContext layoutContext) {
   AppointmentRules rules = ServiceHelper.getBean(AppointmentRules.class);
   Context context = layoutContext.getContext();
   ContextSwitchListener listener = layoutContext.getContextSwitchListener();
   ActBean bean = new ActBean(appointment);
   Entity schedule = bean.getNodeParticipant("schedule");
   Party location = context.getLocation();
   if (schedule != null && location != null) {
     Entity view = rules.getScheduleView(location, schedule);
     if (view != null) {
       listener.switchTo(appointment);
     } else {
       Party newLocation = rules.getLocation(schedule);
       String name = (newLocation != null) ? newLocation.getName() : Messages.get("imobject.none");
       InformationDialog.show(Messages.format("customer.info.appointment.wrongLocation", name));
     }
   }
 }
示例#5
0
  /**
   * Returns a <tt>PartyType</tt> for the supplied party and contact.
   *
   * @param party the party
   * @param location the location contact. May be <tt>null</tt>
   * @return the corresponding <tt>PartyType</tt>
   */
  private PartyType getParty(Party party, Contact location) {
    PartyType result = new PartyType();

    PartyNameType partyName = new PartyNameType();
    partyName.setName(UBLHelper.createName(party.getName()));
    result.getPartyName().add(partyName);
    if (location != null) {
      result.setPostalAddress(getAddress(location));
    }
    return result;
  }
示例#6
0
  /**
   * Returns a <tt>SupplierPartyType</tt> corresponding to the passed supplier.
   *
   * @param supplier the supplier
   * @return the corresponding <tt>SupplierPartyType</tt>
   */
  private SupplierPartyType getSupplier(Party supplier) {
    SupplierPartyType result = new SupplierPartyType();

    CustomerAssignedAccountIDType accountId =
        UBLHelper.initID(new CustomerAssignedAccountIDType(), supplier.getId());
    Contact contact = partyRules.getContact(supplier, ContactArchetypes.LOCATION, null);

    result.setCustomerAssignedAccountID(accountId);
    result.setParty(getParty(supplier, contact));
    return result;
  }
示例#7
0
 /**
  * Creates and saves a new stock location.
  *
  * @return a new stock location
  */
 public static Party createStockLocation() {
   Party stockLocation = (Party) create(StockArchetypes.STOCK_LOCATION);
   stockLocation.setName("STOCK-LOCATION-" + stockLocation.hashCode());
   save(stockLocation);
   return stockLocation;
 }
示例#8
0
 /**
  * Constructs an {@link PatientPredicate}.
  *
  * @param patient the patient. May be {@code null}
  */
 public PatientPredicate(Party patient) {
   this.patient = (patient != null) ? patient.getObjectReference() : null;
 }
示例#9
0
 /**
  * Helper to create a new <em>party.organisationTill</em>.
  *
  * @return a new till
  */
 public static Party createTill() {
   Party till = (Party) create("party.organisationTill");
   till.setName("XTill-" + System.currentTimeMillis());
   save(till);
   return till;
 }
示例#10
0
 /**
  * Returns the name of the party associated with a contact, if any.
  *
  * @param contact the contact
  * @return the party name. May be {@code null}
  */
 private String getPartyName(Contact contact) {
   Party party = contact.getParty();
   return (party != null) ? party.getName() : null;
 }