public class Obs extends BaseFormRecordableOpenmrsData
The getObsGroup()
method returns an optional parent. That parent object is also an Obs.
The parent Obs object knows about its child objects through the getGroupMembers()
method.
(Multi-level hierarchies are achieved by an Obs parent object being a member of another Obs (grand)parent object) Read up on the obs table: http://openmrs.org/wiki/Obs_Table_Primer In an OpenMRS installation, there may be an occasion need to change an Obs.
For example, a site may decide to replace a concept in the dictionary with a more specific set of concepts. An observation is part of the official record of an encounter. There may be legal, ethical, and auditing consequences from altering a record. It is recommended that you create a new Obs and void the old one:
Obs newObs = Obs.newInstance(oldObs); //copies values from oldObs newObs.setPreviousVersion(oldObs); Context.getObsService().saveObs(newObs,"Your reason for the change here"); Context.getObsService().voidObs(oldObs, "Your reason for the change here");Encounter
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
Obs.Interpretation |
static class |
Obs.Status |
Modifier and Type | Field and Description |
---|---|
protected String |
accessionNumber |
protected String |
comment |
protected ComplexData |
complexData |
protected Concept |
concept |
protected Encounter |
encounter |
protected Set<Obs> |
groupMembers
The list of obs grouped under this obs.
|
protected Location |
location |
protected Date |
obsDatetime |
protected Obs |
obsGroup
The "parent" of this obs.
|
protected Integer |
obsId |
protected Order |
order |
protected Person |
person |
protected Integer |
personId |
static long |
serialVersionUID |
protected Concept |
valueCoded |
protected ConceptName |
valueCodedName |
protected String |
valueComplex |
protected Date |
valueDatetime |
protected Drug |
valueDrug |
protected Integer |
valueGroupId |
protected String |
valueModifier |
protected Double |
valueNumeric |
protected String |
valueText |
FORM_NAMESPACE_PATH_MAX_LENGTH, FORM_NAMESPACE_PATH_SEPARATOR, formNamespaceAndPath
creator
Constructor and Description |
---|
Obs()
default constructor
|
Obs(Integer obsId)
constructor with id
|
Obs(Person person,
Concept question,
Date obsDatetime,
Location location)
Required parameters constructor A value is also required, but that can be one of: valueCoded,
valueDrug, valueNumeric, or valueText
|
Modifier and Type | Method and Description |
---|---|
void |
addGroupMember(Obs member)
Convenience method to add the given
obs to this grouping. |
String |
getAccessionNumber() |
String |
getComment() |
ComplexData |
getComplexData()
Get the ComplexData.
|
Concept |
getConcept() |
ConceptDescription |
getConceptDescription()
Get the concept description that is tied to the concept name that was used when making this
observation
|
Encounter |
getEncounter() |
Set<Obs> |
getGroupMembers()
Get the non-voided members of the obs group, if this obs is a group.
|
Set<Obs> |
getGroupMembers(boolean includeVoided)
Get the group members of this obs group, if this obs is a group.
|
Integer |
getId() |
Obs.Interpretation |
getInterpretation()
Similar to FHIR's Observation.interpretation.
|
Location |
getLocation() |
Date |
getObsDatetime() |
Obs |
getObsGroup()
An obs grouping occurs when the question (#getConcept()) is a set.
|
Integer |
getObsId() |
Order |
getOrder() |
Person |
getPerson()
Get the person object that this obs is acting on.
|
Integer |
getPersonId()
The person id of the person on this object.
|
Obs |
getPreviousVersion()
When ObsService updates an obs, it voids the old version, creates a new Obs with the updates,
and adds a reference to the previousVersion in the new Obs. getPreviousVersion returns the
last version of this Obs.
|
Set<Obs> |
getRelatedObservations()
Convenience method that returns related Obs If the Obs argument is not an ObsGroup: a
Set<Obs> will be returned containing all of the children of this Obs' parent that are
not ObsGroups themselves.
|
Obs.Status |
getStatus()
Similar to FHIR's Observation.status.
|
Boolean |
getValueAsBoolean()
Coerces a value to a Boolean representation
|
String |
getValueAsString(Locale locale)
Convenience method for obtaining the observation's value as a string If the Obs is complex,
returns the title of the complexData denoted by the section of getValueComplex() before the
first bar '|' character; or returns the entire getValueComplex() if the bar '|' character is
missing.
|
Boolean |
getValueBoolean()
Returns the boolean value if the concept of this obs is of boolean datatype
|
Concept |
getValueCoded() |
ConceptName |
getValueCodedName()
Gets the specific name used for the coded value.
|
String |
getValueComplex()
Get the value for the ComplexData.
|
Date |
getValueDate() |
Date |
getValueDatetime() |
Drug |
getValueDrug() |
Integer |
getValueGroupId() |
String |
getValueModifier() |
Double |
getValueNumeric() |
String |
getValueText() |
Date |
getValueTime() |
boolean |
hasGroupMembers()
A convenience method to check for nullity and length to determine if this obs has group
members.
|
boolean |
hasGroupMembers(boolean includeVoided)
Convenience method that checks for nullity and length to determine if this obs has group
members.
|
Boolean |
hasPreviousVersion() |
boolean |
isComplex() |
boolean |
isDirty()
Returns true if any change has been made to an Obs instance.
|
boolean |
isObsGrouping()
Convenience method that checks for if this obs has 1 or more group members (either voided or
non-voided) Note this method differs from hasGroupMembers(), as that method excludes voided
obs; logic is that while a obs that has only voided group members should be seen as
"having no group members" it still should be considered an "obs grouping"
NOTE: This method could also be called "isObsGroup" for a little less confusion on names.
|
protected void |
markAsDirty(Object oldValue,
Object newValue) |
static Obs |
newInstance(Obs obsToCopy)
This is an equivalent to a copy constructor.
|
void |
removeGroupMember(Obs member)
Convenience method to remove an Obs from this grouping This also removes the link in the
given
obs object to this obs grouper |
void |
setAccessionNumber(String accessionNumber) |
void |
setComment(String comment) |
void |
setComplexData(ComplexData complexData)
Set the ComplexData for this Obs.
|
void |
setConcept(Concept concept) |
void |
setCreator(User creator) |
void |
setDateCreated(Date dateCreated) |
void |
setEncounter(Encounter encounter) |
void |
setFormField(String namespace,
String formFieldPath)
Sets the namespace and path of the form field that was used to capture the obs details in the
form.
|
void |
setGroupMembers(Set<Obs> groupMembers)
Set the members of the obs group, if this obs is a group.
|
void |
setId(Integer id) |
void |
setInterpretation(Obs.Interpretation interpretation) |
void |
setLocation(Location location) |
void |
setObsDatetime(Date obsDatetime) |
void |
setObsGroup(Obs obsGroup)
This method does NOT add this current obs to the list of obs in obsGroup.getGroupMembers().
|
void |
setObsId(Integer obsId) |
void |
setOrder(Order order) |
void |
setPerson(Person person)
Set the person object to this obs object.
|
protected void |
setPersonId(Integer personId)
Set the person id on this obs object.
|
void |
setPreviousVersion(Obs previousVersion)
A previousVersion indicates that this Obs replaces an earlier one.
|
void |
setStatus(Obs.Status status) |
void |
setValueAsString(String s)
Sets the value for the obs from a string depending on the datatype of the question concept
|
void |
setValueBoolean(Boolean valueBoolean)
Sets the value of this obs to the specified valueBoolean if this obs has a boolean concept.
|
void |
setValueCoded(Concept valueCoded) |
void |
setValueCodedName(ConceptName valueCodedName)
Sets the specific name used for the coded value.
|
void |
setValueComplex(String valueComplex)
Set the value for the ComplexData.
|
void |
setValueDate(Date valueDate) |
void |
setValueDatetime(Date valueDatetime) |
void |
setValueDrug(Drug valueDrug) |
void |
setValueGroupId(Integer valueGroupId) |
void |
setValueModifier(String valueModifier) |
void |
setValueNumeric(Double valueNumeric) |
void |
setValueText(String valueText) |
void |
setValueTime(Date valueTime) |
String |
toString()
Returns a string equal to the value of: ClassName{hashCode=...,
uuid=...}
|
getFormFieldNamespace, getFormFieldNamespace, getFormFieldPath, getFormFieldPath, getFormNamespaceAndPath, getFormNamespaceAndPath, setFormNamespaceAndPath
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateVoided, getVoided, getVoidedBy, getVoidReason, isVoided, setChangedBy, setDateChanged, setDateVoided, setVoided, setVoidedBy, setVoidReason
equals, getUuid, hashCode, setUuid
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getUuid, setUuid
public static final long serialVersionUID
protected Integer obsId
protected Concept concept
protected Date obsDatetime
protected String accessionNumber
protected Obs obsGroup
(??)
@AllowDirectAccess protected Set<Obs> groupMembers
protected Concept valueCoded
protected ConceptName valueCodedName
protected Drug valueDrug
protected Integer valueGroupId
protected Date valueDatetime
protected Double valueNumeric
protected String valueModifier
protected String valueText
protected String valueComplex
protected transient ComplexData complexData
protected String comment
protected transient Integer personId
protected Person person
protected Order order
protected Location location
protected Encounter encounter
public Obs()
public Obs(Person person, Concept question, Date obsDatetime, Location location)
person
- The Person this obs is acting onquestion
- The question concept this obs is related toobsDatetime
- The time this obs took placelocation
- The location this obs took placepublic Obs(Integer obsId)
public static Obs newInstance(Obs obsToCopy)
obsToCopy
with a null obs idobsToCopy
- The Obs that is going to be copiedpublic String getComment()
public void setComment(String comment)
comment
- The comment to set.public Concept getConcept()
public void setConcept(Concept concept)
concept
- The concept to set.public ConceptDescription getConceptDescription()
public Encounter getEncounter()
public void setEncounter(Encounter encounter)
encounter
- The encounter to set.public Location getLocation()
public void setLocation(Location location)
location
- The location to set.public Date getObsDatetime()
public void setObsDatetime(Date obsDatetime)
obsDatetime
- The obsDatetime to set.public Obs getObsGroup()
obsGroup
.getGroupMembers()
public void setObsGroup(Obs obsGroup)
obsGroup
- the obsGroup to setpublic boolean isObsGrouping()
NOTE: This method could also be called "isObsGroup" for a little less confusion on names. However, jstl in a web layer (or any psuedo-getter) access isn't good with both an "isObsGroup" method and a "getObsGroup" method. Which one should be returned with a simplified jstl call like ${obs.obsGroup} ? With this setup, ${obs.obsGrouping} returns a boolean of whether this obs is a parent and has members. ${obs.obsGroup} returns the parent object to this obs if this obs is a group member of some other group.
public boolean hasGroupMembers()
hasGroupMembers(boolean)
with value true.public boolean hasGroupMembers(boolean includeVoided)
includeVoided
- determines if Voided members should be considered as group members.public Set<Obs> getGroupMembers()
getGroupMembers(boolean)
with value true.
If it's not a group (i.e. getConcept()
.Concept.getSet()
is not
true, then this returns null.
addGroupMember(Obs)
,
hasGroupMembers()
public Set<Obs> getGroupMembers(boolean includeVoided)
includeVoided
- public void setGroupMembers(Set<Obs> groupMembers)
If it's not a group (i.e. getConcept()
.Concept.getSet()
is not
true, then this returns null.
groupMembers
- the groupedObs to setaddGroupMember(Obs)
,
Should mark the obs as dirty when the set is changed from null to a non empty one
Should not mark the obs as dirty when the set is changed from null to an empty one
Should mark the obs as dirty when the set is replaced with another with different members
Should not mark the obs as dirty when the set is replaced with another with same members
public void addGroupMember(Obs member)
obs
to this grouping. Will implicitly make
this obs an ObsGroup.member
- Obs to add to this groupsetGroupMembers(Set)
,
Should return true when a new obs is added as a member
Should return false when a duplicate obs is added as a member
public void removeGroupMember(Obs member)
obs
object to this obs groupermember
- Obs to remove from this groupsetGroupMembers(Set)
,
Should return true when an obs is removed
Should return false when a non existent obs is removed
public Set<Obs> getRelatedObservations()
public Integer getObsId()
public void setObsId(Integer obsId)
obsId
- The obsId to set.public Order getOrder()
public void setOrder(Order order)
order
- The order to set.public Integer getPersonId()
getPerson()
.getPersonId()
. It is duplicated here for speed and
simplicity reasonsprotected void setPersonId(Integer personId)
setPerson(Person)
method should be used like
setPerson(new Person(personId))
personId
- setPerson(Person)
public Person getPerson()
getPersonId()
public void setPerson(Person person)
person
- the Patient/Person object that this obs is acting onsetPersonId(Integer)
public void setValueBoolean(Boolean valueBoolean)
valueBoolean
- the boolean value matching the boolean coded concept to set topublic Boolean getValueAsBoolean()
public Boolean getValueBoolean()
public Concept getValueCoded()
public void setValueCoded(Concept valueCoded)
valueCoded
- The valueCoded to set.public ConceptName getValueCodedName()
public void setValueCodedName(ConceptName valueCodedName)
valueCodedName
- the name of the coded valuepublic Drug getValueDrug()
public void setValueDrug(Drug valueDrug)
valueDrug
- The valueDrug to set.public Date getValueDatetime()
public void setValueDatetime(Date valueDatetime)
valueDatetime
- The valueDatetime to set.public Date getValueDate()
public void setValueDate(Date valueDate)
valueDate
- The date value to set.public Date getValueTime()
public void setValueTime(Date valueTime)
valueTime
- the time value to setpublic Integer getValueGroupId()
public void setValueGroupId(Integer valueGroupId)
valueGroupId
- The valueGroupId to set.public String getValueModifier()
public void setValueModifier(String valueModifier)
valueModifier
- The valueModifier to set.public Double getValueNumeric()
public void setValueNumeric(Double valueNumeric)
valueNumeric
- The valueNumeric to set.public String getValueText()
public void setValueText(String valueText)
valueText
- The valueText to set.public boolean isComplex()
public String getValueComplex()
getValueAsString(java.util.Locale)
. The URI is the location where the ComplexData is stored.public void setValueComplex(String valueComplex)
getValueAsString(java.util.Locale)
. The URI is the location where the ComplexData is stored.valueComplex
- readable title and URI for the location of the ComplexData binary object.public void setComplexData(ComplexData complexData)
ComplexObsHandler
s that are registered to ConceptComplex
s will persist the
ComplexData.getData()
object to the correct place for the given concept.complexData
- public ComplexData getComplexData()
ComplexObsHandler
from the file system
or another location, not from the database. Obs obsWithComplexData = Context.getObsService().getComplexObs(obsId, OpenmrsConstants.RAW_VIEW);
public String getAccessionNumber()
public void setAccessionNumber(String accessionNumber)
accessionNumber
- The accessionNumber to set.public String getValueAsString(Locale locale)
locale
- locale for locale-specific depictions of value
Should return first part of valueComplex for complex obs
Should return first part of valueComplex for non null valueComplexes
Should return non precise values for NumericConcepts
Should return date in correct format
Should not return long decimal numbers as scientific notation
Should use commas or decimal places depending on locale
Should not use thousand separator
Should return regular number for size of zero to or greater than ten digits
Should return regular number if decimal places are as high as sixpublic void setValueAsString(String s) throws ParseException
s
- the string to coerce to a boolean
Should set value as boolean if the datatype of the question concept is boolean
Should fail if the value of the string is null
Should fail if the value of the string is emptyParseException
public String toString()
BaseOpenmrsObject
ClassName{hashCode=..., uuid=...}
If the uuid
field is null
, it returns:
ClassName{hashCode=...}Should include hashCode if uuid is null Should include uuid if not null
toString
in class BaseOpenmrsObject
Object.toString()
public Integer getId()
OpenmrsObject.getId()
public void setId(Integer id)
id
- - The unique Identifier for the objectOpenmrsObject.setId(java.lang.Integer)
public Obs getPreviousVersion()
public void setPreviousVersion(Obs previousVersion)
previousVersion
- the Obs that this Obs superceedspublic Boolean hasPreviousVersion()
public void setCreator(User creator)
setCreator
in interface Creatable
setCreator
in class BaseOpenmrsData
creator
- Creatable.setCreator(User)
public void setDateCreated(Date dateCreated)
setDateCreated
in interface Creatable
setDateCreated
in class BaseOpenmrsData
dateCreated
- Creatable.setDateCreated(Date)
public void setFormField(String namespace, String formFieldPath)
FormRecordable
setFormField
in interface FormRecordable
setFormField
in class BaseFormRecordableOpenmrsData
namespace
- the namespace of the form fieldformFieldPath
- the path of the form fieldFormRecordable.setFormField(String,String)
public boolean isDirty()
public Obs.Interpretation getInterpretation()
public void setInterpretation(Obs.Interpretation interpretation)
public Obs.Status getStatus()
public void setStatus(Obs.Status status)
Copyright © 2024 OpenMRS Inc.. All rights reserved.