public class FormServiceImpl extends BaseOpenmrsService implements FormService
FormService
This class should not be instantiated alone, get a service class from the Context: Context.getFormService();
Context
,
FormService
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
log |
Constructor and Description |
---|
FormServiceImpl()
Default empty constructor
|
Modifier and Type | Method and Description |
---|---|
void |
createField(Field field)
Deprecated.
|
Form |
createForm(Form form)
Deprecated.
|
void |
createFormField(FormField formField)
Deprecated.
|
void |
deleteField(Field field)
Deprecated.
|
void |
deleteForm(Form form)
Deprecated.
|
void |
deleteFormField(FormField formField)
Deprecated.
|
Form |
duplicateForm(Form form)
Duplicate this form and form_fields associated with this form
|
java.util.List<Field> |
findFields(Concept concept)
Deprecated.
|
java.util.List<Field> |
findFields(java.lang.String searchPhrase)
Deprecated.
|
java.util.List<Form> |
findForms(java.lang.String text,
boolean includeUnpublished,
boolean includeRetired)
Deprecated.
|
java.util.List<Field> |
getAllFields()
Fetches all Fields in the database, including retired ones
|
java.util.List<Field> |
getAllFields(boolean includeRetired)
Fetches all Fields in the database, possibly including retired ones
|
java.util.List<FieldType> |
getAllFieldTypes()
Get all field types in the database including the retired ones
|
java.util.List<FieldType> |
getAllFieldTypes(boolean includeRetired)
Get all field types in the database with or without retired ones
|
java.util.List<FormField> |
getAllFormFields()
Returns all FormFields in the database
|
java.util.List<Form> |
getAllForms()
Gets all Forms, including retired ones.
|
java.util.List<Form> |
getAllForms(boolean includeRetired)
Gets all forms, possibly including retired ones
|
Field |
getField(java.lang.Integer fieldId)
Gets a Field by internal database id
|
FieldAnswer |
getFieldAnswerByUuid(java.lang.String uuid)
Get FieldAnswer by its UUID
|
Field |
getFieldByUuid(java.lang.String uuid)
Get Field by its UUID
|
java.util.List<Field> |
getFields()
Deprecated.
|
java.util.List<Field> |
getFields(java.util.Collection<Form> forms,
java.util.Collection<FieldType> fieldTypes,
java.util.Collection<Concept> concepts,
java.util.Collection<java.lang.String> tableNames,
java.util.Collection<java.lang.String> attributeNames,
java.lang.Boolean selectMultiple,
java.util.Collection<FieldAnswer> containsAllAnswers,
java.util.Collection<FieldAnswer> containsAnyAnswer,
java.lang.Boolean retired)
Returns all Fields that match these (nullable) criteria
|
java.util.List<Field> |
getFields(java.lang.String fuzzySearchPhrase)
Find all Fields whose names are similar to or contain the given phrase.
|
java.util.List<Field> |
getFieldsByConcept(Concept concept)
Finds all Fields that point to the given concept, including retired ones.
|
FieldType |
getFieldType(java.lang.Integer fieldTypeId)
Get fieldType by internal identifier
|
FieldType |
getFieldTypeByUuid(java.lang.String uuid)
Get FieldType by its UUID
|
java.util.List<FieldType> |
getFieldTypes()
Deprecated.
|
Form |
getForm(java.lang.Integer formId)
Get form by internal form identifier
|
Form |
getForm(java.lang.String name)
Get form by exact name match.
|
Form |
getForm(java.lang.String name,
java.lang.String version)
Get form by exact name & version match.
|
Form |
getFormByUuid(java.lang.String uuid)
Get Form by its UUID
|
java.lang.Integer |
getFormCount(java.lang.String partialName,
java.lang.Boolean published,
java.util.Collection<EncounterType> encounterTypes,
java.lang.Boolean retired,
java.util.Collection<FormField> containingAnyFormField,
java.util.Collection<FormField> containingAllFormFields,
java.util.Collection<Field> fields)
Same as
FormService.getForms(String, Boolean, Collection, Boolean, Collection, Collection, Collection)
except that it returns an integer that is the size of the list that would be returned |
FormField |
getFormField(Form form,
Concept concept)
Deprecated.
|
FormField |
getFormField(Form form,
Concept concept,
java.util.Collection<FormField> ignoreFormFields,
boolean force)
Finds the FormField defined for this form/concept combination while discounting any form
field found in the
ignoreFormFields collection This method was added when
needing to relate observations to form fields during a display. |
FormField |
getFormField(java.lang.Integer formFieldId)
Gets a FormField by internal database id
|
FormField |
getFormFieldByUuid(java.lang.String uuid)
Get FormField by its UUID
|
java.util.List<FormField> |
getFormFields(Form form)
Deprecated.
|
FormResource |
getFormResource(Form form,
java.lang.String name)
Finds a FormResource based on a given Form and name
|
FormResource |
getFormResource(java.lang.Integer formResourceId)
Finds a FormResource by its id
|
FormResource |
getFormResourceByUuid(java.lang.String uuid)
Finds a FormResource by its uuid
|
java.util.Collection<FormResource> |
getFormResourcesForForm(Form form)
Finds all FormResources tied to a given form
|
java.util.List<Form> |
getForms()
Deprecated.
|
java.util.List<Form> |
getForms(boolean publishedOnly)
Deprecated.
|
java.util.List<Form> |
getForms(boolean publishedOnly,
boolean includeRetired)
Deprecated.
|
java.util.Set<Form> |
getForms(Concept c)
Deprecated.
|
java.util.List<Form> |
getForms(java.lang.String fuzzyName,
boolean onlyLatestVersion)
Gets all forms with name similar to the given name.
|
java.util.List<Form> |
getForms(java.lang.String partialName,
java.lang.Boolean published,
java.util.Collection<EncounterType> encounterTypes,
java.lang.Boolean retired,
java.util.Collection<FormField> containingAnyFormField,
java.util.Collection<FormField> containingAllFormFields)
|
java.util.List<Form> |
getForms(java.lang.String partialName,
java.lang.Boolean published,
java.util.Collection<EncounterType> encounterTypes,
java.lang.Boolean retired,
java.util.Collection<FormField> containingAnyFormField,
java.util.Collection<FormField> containingAllFormFields,
java.util.Collection<Field> fields)
Gets all forms that match all the (nullable) criteria
|
java.util.List<Form> |
getFormsContainingConcept(Concept concept)
Returns all forms that contain the given concept as a field in their schema.
|
java.util.List<Form> |
getPublishedForms()
Returns all published forms (not including retired ones)
|
int |
mergeDuplicateFields()
Audit form, consolidate similar fields
|
void |
purgeField(Field field)
Completely removes a Field from the database.
|
void |
purgeField(Field field,
boolean cascade)
Completely removes a Field from the database.
|
void |
purgeFieldType(FieldType fieldType)
Deletes the given field type from the database.
|
void |
purgeForm(Form form)
Completely remove a Form from the database.
|
void |
purgeForm(Form form,
boolean cascade)
Completely remove a Form from the database.
|
void |
purgeFormField(FormField formField)
Completely removes the given FormField from the database.
|
void |
purgeFormResource(FormResource formResource)
Purges a form resource
|
Field |
retireField(Field field)
Retires field
|
void |
retireForm(Form form,
java.lang.String reason)
Retires the Form, leaving it in the database, but removing it from data entry screens
|
Field |
saveField(Field field)
Creates or updates the given Field
|
FieldType |
saveFieldType(FieldType fieldType)
Saves the given field type to the database
|
Form |
saveForm(Form form)
Create or update the given Form in the database
|
FormField |
saveFormField(FormField formField)
Creates or updates the given FormField
|
FormResource |
saveFormResource(FormResource formResource)
Saves or updates the given form resource
|
void |
setFormDAO(FormDAO dao)
Method used to inject the data access object.
|
Field |
unretireField(Field field)
Unretires field
|
void |
unretireForm(Form form)
Unretires a Form that had previous been retired.
|
void |
updateField(Field field)
Deprecated.
|
void |
updateForm(Form form)
Deprecated.
|
void |
updateFormField(FormField formField)
Deprecated.
|
onShutdown, onStartup
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onShutdown, onStartup
public void setFormDAO(FormDAO dao)
dao
- @Deprecated public Form createForm(Form form) throws APIException
createForm
in interface FormService
APIException
FormService.createForm(org.openmrs.Form)
public Form getForm(java.lang.Integer formId) throws APIException
FormService
getForm
in interface FormService
formId
- internal identifierAPIException
FormService.getForm(java.lang.Integer)
@Deprecated public java.util.List<Form> getForms(boolean publishedOnly) throws APIException
FormService
getForms
in interface FormService
APIException
FormService.getForms(boolean, boolean)
@Deprecated public java.util.List<Form> getForms(boolean publishedOnly, boolean includeRetired) throws APIException
FormService
getForms
in interface FormService
APIException
FormService.getForms(boolean, boolean)
@Deprecated public void updateForm(Form form) throws APIException
FormService
updateForm
in interface FormService
APIException
FormService.updateForm(org.openmrs.Form)
public Form duplicateForm(Form form) throws APIException
duplicateForm
in interface FormService
form
- APIException
FormService.duplicateForm(org.openmrs.Form)
public void retireForm(Form form, java.lang.String reason) throws APIException
FormService
retireForm
in interface FormService
form
- the Form to retirereason
- the retiredReason to setAPIException
FormService.retireForm(org.openmrs.Form, java.lang.String)
public void unretireForm(Form form) throws APIException
FormService
unretireForm
in interface FormService
form
- the Form to reviveAPIException
FormService.unretireForm(org.openmrs.Form)
@Deprecated public void deleteForm(Form form) throws APIException
FormService
Forms
should be retired and not deleted altogether (since many foreign key
constraints depend on forms, deleting a form would require deleting all traces, and any
historical trail would be lost). This method only clears form roles and attempts to delete
the form record. If the form has been included in any other parts of the database (through a
foreign key), the attempt to delete the form will violate foreign key constraints and fail.deleteForm
in interface FormService
APIException
FormService.deleteForm(org.openmrs.Form)
@Deprecated public java.util.List<FieldType> getFieldTypes() throws APIException
getFieldTypes
in interface FormService
APIException
FormService.getFieldTypes()
public java.util.List<FieldType> getAllFieldTypes() throws APIException
FormService
getAllFieldTypes
in interface FormService
APIException
FormService.getAllFieldTypes()
public java.util.List<FieldType> getAllFieldTypes(boolean includeRetired) throws APIException
FormService
getAllFieldTypes
in interface FormService
includeRetired
- true/false whether to include the retired field typesAPIException
FormService.getAllFieldTypes(boolean)
public FieldType getFieldType(java.lang.Integer fieldTypeId) throws APIException
FormService
getFieldType
in interface FormService
fieldTypeId
- Integer id of FieldType to getAPIException
FormService.getFieldType(java.lang.Integer)
@Deprecated public java.util.List<Form> getForms() throws APIException
getForms
in interface FormService
APIException
FormService.getForms()
@Deprecated public java.util.Set<Form> getForms(Concept c) throws APIException
getForms
in interface FormService
APIException
FormService.getForms(org.openmrs.Concept)
@Deprecated public java.util.List<FormField> getFormFields(Form form) throws APIException
getFormFields
in interface FormService
APIException
FormService.getFormFields(org.openmrs.Form)
@Deprecated public java.util.List<Field> findFields(java.lang.String searchPhrase) throws APIException
findFields
in interface FormService
APIException
FormService.findFields(java.lang.String)
@Deprecated public java.util.List<Field> findFields(Concept concept) throws APIException
findFields
in interface FormService
APIException
FormService.findFields(org.openmrs.Concept)
@Deprecated public java.util.List<Field> getFields() throws APIException
getFields
in interface FormService
APIException
FormService.getFields()
public Field getField(java.lang.Integer fieldId) throws APIException
FormService
getField
in interface FormService
fieldId
- the id of the Field to fetchAPIException
FormService.getField(java.lang.Integer)
@Deprecated public void createField(Field field) throws APIException
createField
in interface FormService
APIException
FormService.createField(org.openmrs.Field)
@Deprecated public void updateField(Field field) throws APIException
updateField
in interface FormService
APIException
FormService.updateField(org.openmrs.Field)
@Deprecated public void deleteField(Field field) throws APIException
deleteField
in interface FormService
APIException
FormService.deleteField(org.openmrs.Field)
public FormField getFormField(java.lang.Integer formFieldId) throws APIException
FormService
getFormField
in interface FormService
formFieldId
- the internal id to search onAPIException
FormService.getFormField(java.lang.Integer)
@Deprecated public FormField getFormField(Form form, Concept concept) throws APIException
FormService
FormService.getFormField(Form, Concept, Collection, boolean)
with an empty ignore list and with
force
set to falsegetFormField
in interface FormService
form
- Form that this concept was found onconcept
- (question) on this form that is being requestedAPIException
FormService.getFormField(org.openmrs.Form, org.openmrs.Concept)
,
getFormField(Form, Concept, Collection, boolean)
public FormField getFormField(Form form, Concept concept, java.util.Collection<FormField> ignoreFormFields, boolean force) throws APIException
FormService
ignoreFormFields
collection This method was added when
needing to relate observations to form fields during a display. The use case would be that
you know a Concept for a obs, which was defined on a form (via a formField). You can relate
the formFields to Concepts easily enough, but if a Form reuses a Concept in two separate
FormFields you don't want to only associate that first formField with that concept. So, keep
a running list of formFields you've seen and pass them back in here to rule them out.getFormField
in interface FormService
form
- Form that this concept was found onconcept
- Concept (question) on this form that is being requestedignoreFormFields
- FormFields to ignore (aka already seen formfields)force
- if true and there are zero matches because all formFields were ignored (because
of ignoreFormFields) than the first result is returnedAPIException
FormService.getFormField(org.openmrs.Form, org.openmrs.Concept,
java.util.Collection, boolean)
@Deprecated public void createFormField(FormField formField) throws APIException
createFormField
in interface FormService
APIException
FormService.createFormField(org.openmrs.FormField)
@Deprecated public void updateFormField(FormField formField) throws APIException
updateFormField
in interface FormService
APIException
FormService.updateFormField(org.openmrs.FormField)
@Deprecated public void deleteFormField(FormField formField) throws APIException
deleteFormField
in interface FormService
APIException
FormService.deleteFormField(org.openmrs.FormField)
public Field getFieldByUuid(java.lang.String uuid) throws APIException
FormService
getFieldByUuid
in interface FormService
APIException
FormService.getFieldByUuid(java.lang.String)
public FieldAnswer getFieldAnswerByUuid(java.lang.String uuid) throws APIException
FormService
getFieldAnswerByUuid
in interface FormService
APIException
public FieldType getFieldTypeByUuid(java.lang.String uuid) throws APIException
FormService
getFieldTypeByUuid
in interface FormService
APIException
FormService.getFieldTypeByUuid(java.lang.String)
public Form getFormByUuid(java.lang.String uuid) throws APIException
FormService
getFormByUuid
in interface FormService
APIException
FormService.getFormByUuid(java.lang.String)
public FormField getFormFieldByUuid(java.lang.String uuid) throws APIException
FormService
getFormFieldByUuid
in interface FormService
APIException
FormService.getFormFieldByUuid(java.lang.String)
@Deprecated public java.util.List<Form> findForms(java.lang.String text, boolean includeUnpublished, boolean includeRetired)
findForms
in interface FormService
FormService.findForms(java.lang.String, boolean, boolean)
public java.util.List<Field> getAllFields() throws APIException
FormService
getAllFields
in interface FormService
APIException
FormService.getAllFields()
public java.util.List<Field> getAllFields(boolean includeRetired) throws APIException
FormService
getAllFields
in interface FormService
includeRetired
- whether or not to include retired FieldsAPIException
FormService.getAllFields(boolean)
public java.util.List<FormField> getAllFormFields() throws APIException
FormService
getAllFormFields
in interface FormService
APIException
FormService.getAllFormFields()
public java.util.List<Form> getAllForms() throws APIException
FormService
getAllForms
in interface FormService
APIException
FormService.getAllForms()
public java.util.List<Form> getAllForms(boolean includeRetired) throws APIException
FormService
getAllForms
in interface FormService
includeRetired
- whether or not to return retired formsAPIException
FormService.getAllForms(boolean)
public java.util.List<Field> getFields(java.util.Collection<Form> forms, java.util.Collection<FieldType> fieldTypes, java.util.Collection<Concept> concepts, java.util.Collection<java.lang.String> tableNames, java.util.Collection<java.lang.String> attributeNames, java.lang.Boolean selectMultiple, java.util.Collection<FieldAnswer> containsAllAnswers, java.util.Collection<FieldAnswer> containsAnyAnswer, java.lang.Boolean retired) throws APIException
FormService
getFields
in interface FormService
forms
- on any of these FormsfieldTypes
- having any of these FieldTypesconcepts
- for any of these ConceptstableNames
- for any of these table namesattributeNames
- for any of these attribute namesselectMultiple
- whether to return only select-multi fieldscontainsAllAnswers
- fields with all the following answerscontainsAnyAnswer
- fields with any of the following answersretired
- only retired/unretired fieldsAPIException
FormService.getFields(java.util.Collection, java.util.Collection,
java.util.Collection, java.util.Collection, java.util.Collection, java.lang.Boolean,
java.util.Collection, java.util.Collection, java.lang.Boolean)
public Form getForm(java.lang.String name) throws APIException
FormService
getForm
in interface FormService
name
- exact name of the form to fetchAPIException
FormService.getForm(java.lang.String)
public Form getForm(java.lang.String name, java.lang.String version) throws APIException
FormService
FormService.getForm(String)
getForm
in interface FormService
name
- exact name of the form to fetchversion
- exact version of the form to fetchAPIException
FormService.getForm(java.lang.String, java.lang.String)
public java.util.List<Form> getForms(java.lang.String fuzzyName, boolean onlyLatestVersion)
FormService
getForms
in interface FormService
fuzzyName
- approximate name to matchonlyLatestVersion
- whether or not to return only the latest version of each form (by
name)FormService.getForms(java.lang.String, boolean)
@Deprecated public java.util.List<Form> getForms(java.lang.String partialName, java.lang.Boolean published, java.util.Collection<EncounterType> encounterTypes, java.lang.Boolean retired, java.util.Collection<FormField> containingAnyFormField, java.util.Collection<FormField> containingAllFormFields)
getForms
in interface FormService
public java.util.List<Form> getForms(java.lang.String partialName, java.lang.Boolean published, java.util.Collection<EncounterType> encounterTypes, java.lang.Boolean retired, java.util.Collection<FormField> containingAnyFormField, java.util.Collection<FormField> containingAllFormFields, java.util.Collection<Field> fields)
FormService
getForms
in interface FormService
partialName
- partial search of namepublished
- whether the form is publishedencounterTypes
- whether the form has any of these encounter typesretired
- whether the form is retiredcontainingAnyFormField
- includes forms that contain any of the specified FormFieldscontainingAllFormFields
- includes forms that contain all of the specified FormFieldsfields
- whether the form has any of these fields. If a field is used more than once on
a form, that form is returning more than once in this listFormService.getForms(java.lang.String, java.lang.Boolean,
java.util.Collection, java.lang.Boolean, java.util.Collection, java.util.Collection,
java.util.Collection)
public java.lang.Integer getFormCount(java.lang.String partialName, java.lang.Boolean published, java.util.Collection<EncounterType> encounterTypes, java.lang.Boolean retired, java.util.Collection<FormField> containingAnyFormField, java.util.Collection<FormField> containingAllFormFields, java.util.Collection<Field> fields)
FormService
FormService.getForms(String, Boolean, Collection, Boolean, Collection, Collection, Collection)
except that it returns an integer that is the size of the list that would be returnedpublic java.util.List<Form> getPublishedForms() throws APIException
FormService
getPublishedForms
in interface FormService
APIException
FormService.getPublishedForms()
public void purgeField(Field field) throws APIException
FormService
purgeField
in interface FormService
field
- the Field to purgeAPIException
FormService.purgeField(org.openmrs.Field)
public void purgeField(Field field, boolean cascade) throws APIException
FormService
purgeField
in interface FormService
field
- the Field to purgecascade
- whether to cascade delete all FormFields pointing to this fieldAPIException
FormService.purgeField(org.openmrs.Field, boolean)
public void purgeForm(Form form) throws APIException
FormService
purgeForm
in interface FormService
APIException
FormService.purgeForm(org.openmrs.Form)
public void purgeForm(Form form, boolean cascade) throws APIException
FormService
purgeForm
in interface FormService
cascade
- whether or not to cascade delete all dependent objects (including encounters!)APIException
FormService.purgeForm(org.openmrs.Form, boolean)
public void purgeFormField(FormField formField) throws APIException
FormService
purgeFormField
in interface FormService
formField
- the FormField to purgeAPIException
FormService.purgeFormField(org.openmrs.FormField)
public Field retireField(Field field) throws APIException
FormService
retireField
in interface FormService
field
- the Field to retireAPIException
FormService.retireField(org.openmrs.Field)
public Field saveField(Field field) throws APIException
FormService
saveField
in interface FormService
field
- the Field to saveAPIException
FormService.saveField(org.openmrs.Field)
public Form saveForm(Form form) throws APIException
FormService
saveForm
in interface FormService
form
- the Form to saveAPIException
FormService.saveForm(org.openmrs.Form)
public FormField saveFormField(FormField formField) throws APIException
FormService
saveFormField
in interface FormService
formField
- the FormField to saveAPIException
FormService.saveFormField(org.openmrs.FormField)
public Field unretireField(Field field) throws APIException
FormService
unretireField
in interface FormService
field
- the Field to unretireAPIException
FormService.unretireField(org.openmrs.Field)
public java.util.List<Field> getFields(java.lang.String fuzzySearchPhrase) throws APIException
FormService
getFields
in interface FormService
APIException
FormService.getFields(java.lang.String)
public java.util.List<Field> getFieldsByConcept(Concept concept) throws APIException
FormService
getFieldsByConcept
in interface FormService
concept
- the concept to search for in the Field tableAPIException
FormService.getFieldsByConcept(org.openmrs.Concept)
public java.util.List<Form> getFormsContainingConcept(Concept concept) throws APIException
FormService
getFormsContainingConcept
in interface FormService
concept
- the concept to search for in formsAPIException
FormService.getFormsContainingConcept(org.openmrs.Concept)
public void purgeFieldType(FieldType fieldType) throws APIException
FormService
purgeFieldType
in interface FormService
fieldType
- the field type to purgeAPIException
FormService.purgeFieldType(org.openmrs.FieldType)
public FieldType saveFieldType(FieldType fieldType) throws APIException
FormService
saveFieldType
in interface FormService
fieldType
- the field type to saveAPIException
FormService.saveFieldType(org.openmrs.FieldType)
public int mergeDuplicateFields() throws APIException
FormService
mergeDuplicateFields
in interface FormService
APIException
org.openmrs.api.FormService#auditForm(org.openmrs.Form)
public FormResource getFormResource(java.lang.Integer formResourceId) throws APIException
FormService
getFormResource
in interface FormService
formResourceId
- the id of the resourceAPIException
FormService.getFormResource(java.lang.Integer)
public FormResource getFormResourceByUuid(java.lang.String uuid) throws APIException
FormService
getFormResourceByUuid
in interface FormService
uuid
- the uuid of the resourceAPIException
FormService.getFormResourceByUuid(java.lang.String)
public FormResource getFormResource(Form form, java.lang.String name) throws APIException
FormService
getFormResource
in interface FormService
form
- the Form that the resource belongs toname
- the name of the resourceAPIException
FormService.getFormResource(org.openmrs.Form, java.lang.String)
public FormResource saveFormResource(FormResource formResource) throws APIException
FormService
saveFormResource
in interface FormService
formResource
- the resource to be savedAPIException
FormService.saveFormResource(org.openmrs.FormResource)
public void purgeFormResource(FormResource formResource) throws APIException
FormService
purgeFormResource
in interface FormService
formResource
- the resource to be purgedAPIException
FormService.purgeFormResource(org.openmrs.FormResource)
public java.util.Collection<FormResource> getFormResourcesForForm(Form form) throws APIException
FormService
getFormResourcesForForm
in interface FormService
APIException
FormService.getFormResourcesForForm(org.openmrs.Form)
Copyright © 2018 OpenMRS Inc.. All Rights Reserved.