Search in sources :

Example 6 with AddressHierarchyLevel

use of org.openmrs.module.addresshierarchy.AddressHierarchyLevel in project openmrs-module-pihcore by PIH.

the class SectionsHaiti method getBirthplaceQuestion.

@Override
public Question getBirthplaceQuestion() {
    Question q = new Question();
    q.setId("birthplaceLabel");
    q.setHeader("zl.registration.patient.birthplace.question");
    q.setLegend("zl.registration.patient.birthplace.label");
    Field f = new Field();
    // f.setFormFieldName("obsgroup.PIH:PATIENT CONTACTS CONSTRUCT.obs.PIH:ADDRESS OF PATIENT CONTACT");
    f.setLabel("zl.registration.patient.birthplace.label");
    f.setType("personAddress");
    // If there are address hierarchy levels configured, use the address hierarchy widget, otherwise use the standard address widget
    List<AddressHierarchyLevel> levels = Context.getService(AddressHierarchyService.class).getAddressHierarchyLevels();
    if (levels != null && levels.size() > 0) {
        // q.setDisplayTemplate(getAddressHierarchyDisplayTemplate(levels));
        f.setWidget(getAddressHierarchyWidget(levels, getPlaceOfBirthAddressFieldMappings(), true));
    } else {
        Map<String, String> m = new HashMap<String, String>();
        m.put("providerName", "uicommons");
        m.put("fragmentId", "field/personAddress");
        f.setWidget(toObjectNode(m));
    }
    q.addField(f);
    return q;
}
Also used : AddressField(org.openmrs.module.addresshierarchy.AddressField) Field(org.openmrs.module.registrationapp.model.Field) HashMap(java.util.HashMap) Question(org.openmrs.module.registrationapp.model.Question) AddressHierarchyLevel(org.openmrs.module.addresshierarchy.AddressHierarchyLevel) AddressHierarchyService(org.openmrs.module.addresshierarchy.service.AddressHierarchyService)

Example 7 with AddressHierarchyLevel

use of org.openmrs.module.addresshierarchy.AddressHierarchyLevel in project openmrs-module-mirebalais by PIH.

the class PatientRegistrationApp method getContactAddress.

public Question getContactAddress(Config config, boolean required) {
    Question q = new Question();
    q.setId("contactQuestionLabel");
    q.setHeader("zl.registration.patient.contactPerson.address.question");
    q.setLegend("zl.registration.patient.contactPerson.address.label");
    if (config.getCountry().equals(ConfigDescriptor.Country.HAITI)) {
        Field f = new Field();
        // f.setFormFieldName("obsgroup.PIH:PATIENT CONTACTS CONSTRUCT.obs.PIH:ADDRESS OF PATIENT CONTACT");
        f.setLabel("zl.registration.patient.contactPerson.address.label");
        f.setType("personAddress");
        // If there are address hierarchy levels configured, use the address hierarchy widget, otherwise use the standard address widget
        List<AddressHierarchyLevel> levels = Context.getService(AddressHierarchyService.class).getAddressHierarchyLevels();
        if (levels != null && levels.size() > 0) {
            // q.setDisplayTemplate(getAddressHierarchyDisplayTemplate(levels));
            f.setWidget(getAddressHierarchyWidget(levels, getContactAddressFieldMappings(config), true));
        } else {
            Map<String, String> m = new HashMap<String, String>();
            m.put("providerName", "uicommons");
            m.put("fragmentId", "field/personAddress");
            f.setWidget(toObjectNode(m));
            if (required) {
                f.setCssClasses(Arrays.asList("required"));
            }
        }
        q.addField(f);
    } else {
        Field f = new Field();
        f.setFormFieldName("obsgroup.PIH:PATIENT CONTACTS CONSTRUCT.obs.PIH:ADDRESS OF PATIENT CONTACT");
        f.setLabel("zl.registration.patient.contactPerson.address.label");
        f.setType("obsgroup");
        f.setWidget(getTextAreaWidget(250));
        if (required) {
            f.setCssClasses(Arrays.asList("required"));
        }
        q.addField(f);
    }
    return q;
}
Also used : AddressField(org.openmrs.module.addresshierarchy.AddressField) Field(org.openmrs.module.registrationapp.model.Field) HashMap(java.util.HashMap) Question(org.openmrs.module.registrationapp.model.Question) AddressHierarchyLevel(org.openmrs.module.addresshierarchy.AddressHierarchyLevel) AddressHierarchyService(org.openmrs.module.addresshierarchy.service.AddressHierarchyService)

Example 8 with AddressHierarchyLevel

use of org.openmrs.module.addresshierarchy.AddressHierarchyLevel in project openmrs-module-mirebalais by PIH.

the class WristbandTemplateTest method setupAddressHierarchyLevels.

private void setupAddressHierarchyLevels() {
    AddressHierarchyLevel country = new AddressHierarchyLevel();
    country.setAddressField(AddressField.COUNTRY);
    AddressHierarchyLevel state = new AddressHierarchyLevel();
    state.setAddressField(AddressField.STATE_PROVINCE);
    state.setParent(country);
    AddressHierarchyLevel city = new AddressHierarchyLevel();
    city.setAddressField(AddressField.CITY_VILLAGE);
    city.setParent(state);
    AddressHierarchyLevel address3 = new AddressHierarchyLevel();
    address3.setAddressField(AddressField.ADDRESS_3);
    address3.setParent(city);
    AddressHierarchyLevel address1 = new AddressHierarchyLevel();
    address1.setAddressField(AddressField.ADDRESS_1);
    address1.setParent(address3);
    AddressHierarchyLevel address2 = new AddressHierarchyLevel();
    address2.setAddressField(AddressField.ADDRESS_2);
    address2.setParent(address1);
    when(addressHierarchyService.getBottomAddressHierarchyLevel()).thenReturn(address2);
    when(addressHierarchyService.getAddressHierarchyLevelsCount()).thenReturn(6);
}
Also used : AddressHierarchyLevel(org.openmrs.module.addresshierarchy.AddressHierarchyLevel)

Example 9 with AddressHierarchyLevel

use of org.openmrs.module.addresshierarchy.AddressHierarchyLevel in project openmrs-module-pihcore by PIH.

the class SectionsHaiti method getContactAddress.

@Override
public Question getContactAddress() {
    Question q = new Question();
    q.setId("contactQuestionLabel");
    q.setHeader("zl.registration.patient.contactPerson.address.question");
    q.setLegend("zl.registration.patient.contactPerson.address.label");
    Field f = new Field();
    // f.setFormFieldName("obsgroup.PIH:PATIENT CONTACTS CONSTRUCT.obs.PIH:ADDRESS OF PATIENT CONTACT");
    f.setLabel("zl.registration.patient.contactPerson.address.label");
    f.setType("personAddress");
    // If there are address hierarchy levels configured, use the address hierarchy widget, otherwise use the standard address widget
    List<AddressHierarchyLevel> levels = Context.getService(AddressHierarchyService.class).getAddressHierarchyLevels();
    if (levels != null && levels.size() > 0) {
        // q.setDisplayTemplate(getAddressHierarchyDisplayTemplate(levels));
        f.setWidget(getAddressHierarchyWidget(levels, getContactAddressFieldMappings(), true));
    } else {
        Map<String, String> m = new HashMap<String, String>();
        m.put("providerName", "uicommons");
        m.put("fragmentId", "field/personAddress");
        f.setWidget(toObjectNode(m));
        if (config.getRegistrationConfig().getContactPerson() != null && config.getRegistrationConfig().getContactPerson().getRequired() == true) {
            f.setCssClasses(Arrays.asList("required"));
        }
    }
    q.addField(f);
    return q;
}
Also used : AddressField(org.openmrs.module.addresshierarchy.AddressField) Field(org.openmrs.module.registrationapp.model.Field) HashMap(java.util.HashMap) Question(org.openmrs.module.registrationapp.model.Question) AddressHierarchyLevel(org.openmrs.module.addresshierarchy.AddressHierarchyLevel) AddressHierarchyService(org.openmrs.module.addresshierarchy.service.AddressHierarchyService)

Example 10 with AddressHierarchyLevel

use of org.openmrs.module.addresshierarchy.AddressHierarchyLevel in project openmrs-module-pihcore by PIH.

the class SectionsDefault method getAddressQuestion.

public Question getAddressQuestion() {
    Question q = new Question();
    q.setId("personAddressQuestion");
    q.setLegend("registrationapp.patient.address");
    q.setHeader("registrationapp.patient.address.question");
    Field f = new Field();
    f.setType("personAddress");
    // If there are address hierarchy levels configured, use the address hierarchy widget, otherwise use the standard address widget
    List<AddressHierarchyLevel> levels = Context.getService(AddressHierarchyService.class).getAddressHierarchyLevels();
    if (levels != null && levels.size() > 0) {
        q.setDisplayTemplate(getAddressHierarchyDisplayTemplate(levels));
        f.setWidget(getAddressHierarchyWidget(levels, null, true));
    } else {
        Map<String, String> m = new HashMap<String, String>();
        m.put("providerName", "uicommons");
        m.put("fragmentId", "field/personAddress");
        f.setWidget(toObjectNode(m));
    }
    q.addField(f);
    return q;
}
Also used : Field(org.openmrs.module.registrationapp.model.Field) HashMap(java.util.HashMap) Question(org.openmrs.module.registrationapp.model.Question) AddressHierarchyLevel(org.openmrs.module.addresshierarchy.AddressHierarchyLevel) AddressHierarchyService(org.openmrs.module.addresshierarchy.service.AddressHierarchyService)

Aggregations

AddressHierarchyLevel (org.openmrs.module.addresshierarchy.AddressHierarchyLevel)15 AddressHierarchyService (org.openmrs.module.addresshierarchy.service.AddressHierarchyService)13 HashMap (java.util.HashMap)7 Field (org.openmrs.module.registrationapp.model.Field)7 Question (org.openmrs.module.registrationapp.model.Question)7 AddressField (org.openmrs.module.addresshierarchy.AddressField)6 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 PatientIdentifier (org.openmrs.PatientIdentifier)2 PersonAddress (org.openmrs.PersonAddress)2