Package org.openmrs

Examples of org.openmrs.Location


    @Test
    public void encounterLocationTag_shouldShowRetiredLocationIfPreviouslySelected() throws Exception {

        // create an encounter associated with a retired location
        Location location = Context.getLocationService().getLocation(3);
        Patient patient = Context.getPatientService().getPatient(2);
        Encounter encounter = Context.getEncounterService().getEncounter(101);

        // (sanity check)
        Assert.assertTrue(location.isRetired());

        // set the location on this encounter to the retired location
        encounter.setLocation(location);

        // now render a form using that encounter
View Full Code Here


    }
    else if (FIELD_IDENTIFIER_LOCATION.equalsIgnoreCase(field)) {
      identifierLocationWidget = new DropdownWidget();
      identifierLocationErrorWidget = new ErrorWidget();

            Location defaultLocation = existingPatient != null
          && existingPatient.getPatientIdentifier() != null ? existingPatient.getPatientIdentifier().getLocation() : null;
      defaultLocation = defaultLocation == null ? context.getDefaultLocation() : defaultLocation;
            identifierLocationWidget.setInitialValue(defaultLocation);

            List<Option> locationOptions = new ArrayList<Option>();
View Full Code Here

        patientIdentifier = new PatientIdentifier();
        patient.addIdentifier(patientIdentifier);
      }

      Object locationString = identifierLocationWidget.getValue(context, request);
      Location location = (Location) HtmlFormEntryUtil.convertToType(locationString.toString().trim(), Location.class);
      patientIdentifier.setLocation(location);
      patientIdentifier.setPreferred(true);

    }
View Full Code Here

    } else if (HtmlFormEntryConstants.COMPLEX_UUID.equals(dt.getUuid())) {
      obs.setComplexData((ComplexData) value);
      obs.setValueComplex(obs.getComplexData().getTitle());
    } else if (dt.isText()) {
      if (value instanceof Location) {
        Location location = (Location) value;
        obs.setValueText(location.getId().toString() + " - " + location.getName());
      } else if (value instanceof Person) {
        Person person = (Person) value;
        obs.setValueText(person.getId().toString() + " - " + person.getPersonName().toString());
      } else {
        obs.setValueText(value.toString());
View Full Code Here

   * @return the "fake" person
   */
  public static Patient getFakePerson() {
    Patient demo = new Patient(12345);
    demo.addName(new PersonName("Demo", "The", "Person"));
    Location l = Context.getLocationService().getAllLocations().iterator().next();
    for (PatientIdentifierType pit : Context.getPatientService().getAllPatientIdentifierTypes()) {
      if (StringUtils.isEmpty(pit.getValidator())) {
        demo.addIdentifier(new PatientIdentifier("Testing" + pit.getName() + "123", pit, l));
      }
    }
View Full Code Here

     * @should not fail if trying to find a location by session attribute and we have no session
     * @should return null otherwise
     */
  public static Location getLocation(String id, FormEntryContext context) {

    Location location = null;
   
    if (id != null) {

            id = id.trim();

View Full Code Here

            // If the "order" attribute is passed in, limit to the specified locations in order
            else if (parameters.get("order") != null) {

                String[] temp = ((String) parameters.get("order")).split(",");
                for (String s : temp) {
                    Location loc = HtmlFormEntryUtil.getLocation(s, context);
                    if (loc == null) {
                        throw new RuntimeException("Cannot find location: " + loc);
                    }
                    locations.add(loc);
                }

            }

            // if no locations have been specified by the order attribute, use all non-retired locations
            if (locations.isEmpty()) {
                locations = Context.getLocationService().getAllLocations(false);
            }

            // Set default values
            Location defaultLocation = null;
            if (context.getExistingEncounter() != null) {
                defaultLocation = context.getExistingEncounter().getLocation();
            } else {
                String defaultLocId = (String) parameters.get("default");
                if (StringUtils.hasText(defaultLocId)) {
View Full Code Here

        }

        try {
            if (locationWidget != null) {
                Object value = locationWidget.getValue(context, submission);
                Location location = (Location) HtmlFormEntryUtil.convertToType(value.toString().trim(), Location.class);
                if (location == null)
                    throw new Exception("required");
            }
        } catch (Exception ex) {
            ret.add(new FormSubmissionError(context.getFieldName(locationErrorWidget), Context.getMessageSourceService()
View Full Code Here

            Person person = (Person) convertValueToProvider(value);
            session.getSubmissionActions().getCurrentEncounter().setProvider(person);
        }
        if (locationWidget != null) {
            Object value = locationWidget.getValue(session.getContext(), submission);
            Location location = (Location) HtmlFormEntryUtil.convertToType(value.toString().trim(), Location.class);
            session.getSubmissionActions().getCurrentEncounter().setLocation(location);
        }
        if (encounterTypeWidget != null) {
            EncounterType encounterType = (EncounterType) encounterTypeWidget.getValue(session.getContext(), submission);
            session.getSubmissionActions().getCurrentEncounter().setEncounterType(encounterType);
View Full Code Here

    HtmlForm form = new HtmlForm();
   
    form.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "metadataSharingTestForm.xml"));
    HtmlFormSubstitutionUtils.replaceIdsWithUuids(form);
   
    Location location1 = Context.getLocationService().getLocation(1);
   
    TestUtil.assertFuzzyContains("<encounterLocation default=\"9356400c-a5a2-4532-8f2b-2361b3446eb8\" order=\"" + location1.getUuid() + ",9356400c-a5a2-4532-8f2b-2361b3446eb8,Never Never Land\"",form.getXmlData());
    TestUtil.assertFuzzyContains("<encounterProvider role=\"Provider\" default=\"c04ee3c8-b68f-43cc-bff3-5a831ee7225f\"", form.getXmlData());
   
    // test to make sure that underlying matcher is case-insensitive
    TestUtil.assertFuzzyContains("GROUPINGCONCEPTID=\"32296060-03aa-102d-b0e3-001ec94a0cc1\"", form.getXmlData());
    TestUtil.assertFuzzyContains("conceptId=\"32296060-03aa-102d-b0e3-001ec94a0cc4\"", form.getXmlData());
View Full Code Here

TOP

Related Classes of org.openmrs.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.