Obs groups

classic Classic list List threaded Threaded
9 messages Options
Burke Mamlin Burke Mamlin
Reply | Threaded
Open this post in threaded view
|

Obs groups

When we introduced obs groups into the data model [1], we ended up embedding obs groups into the obs table. Our initial intent was that a separate obs_group table would distinguish groups from observations and allow a clear space for later addition of group-level attributes (the ORC from HL7).  With obs groups embedded amongst the obs, we're forced to infer whether or not an obs is a group or not [2] -- i.e., all values null and members not null.

I'm working with ThoughtWorks on extending Umashanthi's fine GSoC work on a flowsheet (longitudinal data) viewer. I need to explain to them how to distinguish obs groups from obs -- not just via org.openmrs.Obs, but also if they are fetching the obs directly at the DAO level into different (e.g., lighter weight) objects.

Is there any documentation on how obs groups currently work?  I see hints in the javadocs, but couldn't find a wiki page on the subject. And TRUNK-1357 was closed without describing which solution was implemented.  I'm trying to answer questions like:
  • How are obs groups distinguished from obs in the database?
  • Do we enforce that obs cannot have both value and members [3]? 
  • Can an obs group exist without a grouping obs -- i.e., 2+ obs grouped without a parent?  Or is a parent "grouping" obs required?
  • If I want to render a person's observations showing groupings, what is the recommended way to retrieve the observations and recognize the groups?

Cheers,

-Burke

[hidden email] from OpenMRS Developers' mailing list
Darius Jazayeri-3 Darius Jazayeri-3
Reply | Threaded
Open this post in threaded view
|

Re: Obs groups

Hi Burke,

Off the top of my head, if I recall correctly:
  • This isn't formally documented.
  • Obs that are groups are not supposed to have values, but this isn't enforced
  • According to the API, you must have an actual obs as the parent, and you're not allowed to have an obs group contain itself as a direct or indirect child.
  • The way to tell if something is an obs group in the API is Obs.isObsGrouping() which just does "getGroupMembers() != null && getGroupMembers().size() > 0". So at present there's no efficient way to do this. (Also, if I create what's basically an ORC with no OBX inside it, that will appear to not be an obs group, because it has no members.)
-Darius

On Wed, Nov 10, 2010 at 6:05 AM, Burke Mamlin <[hidden email]> wrote:
When we introduced obs groups into the data model [1], we ended up embedding obs groups into the obs table. Our initial intent was that a separate obs_group table would distinguish groups from observations and allow a clear space for later addition of group-level attributes (the ORC from HL7).  With obs groups embedded amongst the obs, we're forced to infer whether or not an obs is a group or not [2] -- i.e., all values null and members not null.

I'm working with ThoughtWorks on extending Umashanthi's fine GSoC work on a flowsheet (longitudinal data) viewer. I need to explain to them how to distinguish obs groups from obs -- not just via org.openmrs.Obs, but also if they are fetching the obs directly at the DAO level into different (e.g., lighter weight) objects.

Is there any documentation on how obs groups currently work?  I see hints in the javadocs, but couldn't find a wiki page on the subject. And TRUNK-1357 was closed without describing which solution was implemented.  I'm trying to answer questions like:
  • How are obs groups distinguished from obs in the database?
  • Do we enforce that obs cannot have both value and members [3]? 
  • Can an obs group exist without a grouping obs -- i.e., 2+ obs grouped without a parent?  Or is a parent "grouping" obs required?
  • If I want to render a person's observations showing groupings, what is the recommended way to retrieve the observations and recognize the groups?

Cheers,

-Burke

[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list
Burke Mamlin Burke Mamlin
Reply | Threaded
Open this post in threaded view
|

Re: Obs groups

Does an obs group parent row in obs have an obs_group_id that point to its own obs_id?  If not, how is a row in the obs table recognized as an obs group?  Is it implied if any obs_group_id equals obs_id?

We should definitely ensure that the API prevents obs groups from containing values to keep the door open for TRUNK-1858 [1]. I'll go ahead and make a ticket for this. 

-Burke

[1] http://tickets.openmrs.org/browse/TRUNK-1858

On Nov 10, 2010, at 9:17 AM, Darius Jazayeri <[hidden email]> wrote:

Hi Burke,

Off the top of my head, if I recall correctly:
  • This isn't formally documented.
  • Obs that are groups are not supposed to have values, but this isn't enforced
  • According to the API, you must have an actual obs as the parent, and you're not allowed to have an obs group contain itself as a direct or indirect child.
  • The way to tell if something is an obs group in the API is Obs.isObsGrouping() which just does "getGroupMembers() != null && getGroupMembers().size() > 0". So at present there's no efficient way to do this. (Also, if I create what's basically an ORC with no OBX inside it, that will appear to not be an obs group, because it has no members.)
-Darius

On Wed, Nov 10, 2010 at 6:05 AM, Burke Mamlin <[hidden email]> wrote:
When we introduced obs groups into the data model [1], we ended up embedding obs groups into the obs table. Our initial intent was that a separate obs_group table would distinguish groups from observations and allow a clear space for later addition of group-level attributes (the ORC from HL7).  With obs groups embedded amongst the obs, we're forced to infer whether or not an obs is a group or not [2] -- i.e., all values null and members not null.

I'm working with ThoughtWorks on extending Umashanthi's fine GSoC work on a flowsheet (longitudinal data) viewer. I need to explain to them how to distinguish obs groups from obs -- not just via org.openmrs.Obs, but also if they are fetching the obs directly at the DAO level into different (e.g., lighter weight) objects.

Is there any documentation on how obs groups currently work?  I see hints in the javadocs, but couldn't find a wiki page on the subject. And TRUNK-1357 was closed without describing which solution was implemented.  I'm trying to answer questions like:
  • How are obs groups distinguished from obs in the database?
  • Do we enforce that obs cannot have both value and members [3]? 
  • Can an obs group exist without a grouping obs -- i.e., 2+ obs grouped without a parent?  Or is a parent "grouping" obs required?
  • If I want to render a person's observations showing groupings, what is the recommended way to retrieve the observations and recognize the groups?

Cheers,

-Burke

[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list

[hidden email] from OpenMRS Developers' mailing list
Ben Wolfe (openmrs) Ben Wolfe (openmrs)
Reply | Threaded
Open this post in threaded view
|

Re: Obs groups

A row is an obs group if its obs_id is an obs_group_id for another row.

A grouping row has a null obs_group_id (aka does NOT point to itself).

Ben

On Wed, Nov 10, 2010 at 12:58 PM, Burke Mamlin <[hidden email]> wrote:
Does an obs group parent row in obs have an obs_group_id that point to its own obs_id?  If not, how is a row in the obs table recognized as an obs group?  Is it implied if any obs_group_id equals obs_id?

We should definitely ensure that the API prevents obs groups from containing values to keep the door open for TRUNK-1858 [1]. I'll go ahead and make a ticket for this. 

-Burke

[1] http://tickets.openmrs.org/browse/TRUNK-1858


On Nov 10, 2010, at 9:17 AM, Darius Jazayeri <[hidden email]> wrote:

Hi Burke,

Off the top of my head, if I recall correctly:
  • This isn't formally documented.
  • Obs that are groups are not supposed to have values, but this isn't enforced
  • According to the API, you must have an actual obs as the parent, and you're not allowed to have an obs group contain itself as a direct or indirect child.
  • The way to tell if something is an obs group in the API is Obs.isObsGrouping() which just does "getGroupMembers() != null && getGroupMembers().size() > 0". So at present there's no efficient way to do this. (Also, if I create what's basically an ORC with no OBX inside it, that will appear to not be an obs group, because it has no members.)
-Darius

On Wed, Nov 10, 2010 at 6:05 AM, Burke Mamlin <[hidden email][hidden email]> wrote:
When we introduced obs groups into the data model [1], we ended up embedding obs groups into the obs table. Our initial intent was that a separate obs_group table would distinguish groups from observations and allow a clear space for later addition of group-level attributes (the ORC from HL7).  With obs groups embedded amongst the obs, we're forced to infer whether or not an obs is a group or not [2] -- i.e., all values null and members not null.

I'm working with ThoughtWorks on extending Umashanthi's fine GSoC work on a flowsheet (longitudinal data) viewer. I need to explain to them how to distinguish obs groups from obs -- not just via org.openmrs.Obs, but also if they are fetching the obs directly at the DAO level into different (e.g., lighter weight) objects.

Is there any documentation on how obs groups currently work?  I see hints in the javadocs, but couldn't find a wiki page on the subject. And TRUNK-1357 was closed without describing which solution was implemented.  I'm trying to answer questions like:
  • How are obs groups distinguished from obs in the database?
  • Do we enforce that obs cannot have both value and members [3]? 
  • Can an obs group exist without a grouping obs -- i.e., 2+ obs grouped without a parent?  Or is a parent "grouping" obs required?
  • If I want to render a person's observations showing groupings, what is the recommended way to retrieve the observations and recognize the groups?

Cheers,

-Burke

[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list

[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list
Burke Mamlin Burke Mamlin
Reply | Threaded
Open this post in threaded view
|

Re: Obs groups

How do you get the obs group hierarchy from the API?  Does the API return top level obs with children as members of obs that are groups?  Or does it return all obs in a list with obs groups omitted?  Maybe I'm just unable to find it using my iPad on a plane, but I've browsed the javadocs at http://doc.openmrs.org and don't see this explained in ObsService. 

I vaguely recall a plan to leave getObservations alone -- i.e., return all obs as a simple list, omitting the obs groups -- and then add a getObservatonsWithGroupings (or something like that) to return all top level obs with grouped obs within the members property of their parent. 

-Burke

On Nov 10, 2010, at 10:01 AM, Ben Wolfe <[hidden email]> wrote:

A row is an obs group if its obs_id is an obs_group_id for another row.

A grouping row has a null obs_group_id (aka does NOT point to itself).

Ben

On Wed, Nov 10, 2010 at 12:58 PM, Burke Mamlin <[hidden email]> wrote:
Does an obs group parent row in obs have an obs_group_id that point to its own obs_id?  If not, how is a row in the obs table recognized as an obs group?  Is it implied if any obs_group_id equals obs_id?

We should definitely ensure that the API prevents obs groups from containing values to keep the door open for TRUNK-1858 [1]. I'll go ahead and make a ticket for this. 

-Burke

[1] http://tickets.openmrs.org/browse/TRUNK-1858


On Nov 10, 2010, at 9:17 AM, Darius Jazayeri <[hidden email]> wrote:

Hi Burke,

Off the top of my head, if I recall correctly:
  • This isn't formally documented.
  • Obs that are groups are not supposed to have values, but this isn't enforced
  • According to the API, you must have an actual obs as the parent, and you're not allowed to have an obs group contain itself as a direct or indirect child.
  • The way to tell if something is an obs group in the API is Obs.isObsGrouping() which just does "getGroupMembers() != null && getGroupMembers().size() > 0". So at present there's no efficient way to do this. (Also, if I create what's basically an ORC with no OBX inside it, that will appear to not be an obs group, because it has no members.)
-Darius

On Wed, Nov 10, 2010 at 6:05 AM, Burke Mamlin <[hidden email][hidden email]> wrote:
When we introduced obs groups into the data model [1], we ended up embedding obs groups into the obs table. Our initial intent was that a separate obs_group table would distinguish groups from observations and allow a clear space for later addition of group-level attributes (the ORC from HL7).  With obs groups embedded amongst the obs, we're forced to infer whether or not an obs is a group or not [2] -- i.e., all values null and members not null.

I'm working with ThoughtWorks on extending Umashanthi's fine GSoC work on a flowsheet (longitudinal data) viewer. I need to explain to them how to distinguish obs groups from obs -- not just via org.openmrs.Obs, but also if they are fetching the obs directly at the DAO level into different (e.g., lighter weight) objects.

Is there any documentation on how obs groups currently work?  I see hints in the javadocs, but couldn't find a wiki page on the subject. And TRUNK-1357 was closed without describing which solution was implemented.  I'm trying to answer questions like:
  • How are obs groups distinguished from obs in the database?
  • Do we enforce that obs cannot have both value and members [3]? 
  • Can an obs group exist without a grouping obs -- i.e., 2+ obs grouped without a parent?  Or is a parent "grouping" obs required?
  • If I want to render a person's observations showing groupings, what is the recommended way to retrieve the observations and recognize the groups?

Cheers,

-Burke

[hidden email] from OpenMRS Developers' mailing list
Ben Wolfe (openmrs) Ben Wolfe (openmrs)
Reply | Threaded
Open this post in threaded view
|

Re: Obs groups


The Obs object (if it is a grouping obs) has a getGroupMembers or something that has all grouped obs.  If an obs is in a group it can use the Obs.getObsGroup() method to get the grouping obs.

What you're remembering is the way we set up the Encounter.getObs* methods.  Check those javadocs.

I think the ObsService.getsObs methods would return a grouping obs if it matched a query.  But this only comes into play if the user is searching on the concept name/id that is the grouping concept.

Ben

On Wed, Nov 10, 2010 at 2:01 PM, Burke Mamlin <[hidden email]> wrote:
How do you get the obs group hierarchy from the API?  Does the API return top level obs with children as members of obs that are groups?  Or does it return all obs in a list with obs groups omitted?  Maybe I'm just unable to find it using my iPad on a plane, but I've browsed the javadocs at http://doc.openmrs.org and don't see this explained in ObsService. 

I vaguely recall a plan to leave getObservations alone -- i.e., return all obs as a simple list, omitting the obs groups -- and then add a getObservatonsWithGroupings (or something like that) to return all top level obs with grouped obs within the members property of their parent. 

-Burke


On Nov 10, 2010, at 10:01 AM, Ben Wolfe <[hidden email]> wrote:

A row is an obs group if its obs_id is an obs_group_id for another row.

A grouping row has a null obs_group_id (aka does NOT point to itself).

Ben

On Wed, Nov 10, 2010 at 12:58 PM, Burke Mamlin <[hidden email][hidden email]> wrote:
Does an obs group parent row in obs have an obs_group_id that point to its own obs_id?  If not, how is a row in the obs table recognized as an obs group?  Is it implied if any obs_group_id equals obs_id?

We should definitely ensure that the API prevents obs groups from containing values to keep the door open for TRUNK-1858 [1]. I'll go ahead and make a ticket for this. 

-Burke

[1] http://tickets.openmrs.org/browse/TRUNK-1858


On Nov 10, 2010, at 9:17 AM, Darius Jazayeri <[hidden email][hidden email]> wrote:

Hi Burke,

Off the top of my head, if I recall correctly:
  • This isn't formally documented.
  • Obs that are groups are not supposed to have values, but this isn't enforced
  • According to the API, you must have an actual obs as the parent, and you're not allowed to have an obs group contain itself as a direct or indirect child.
  • The way to tell if something is an obs group in the API is Obs.isObsGrouping() which just does "getGroupMembers() != null && getGroupMembers().size() > 0". So at present there's no efficient way to do this. (Also, if I create what's basically an ORC with no OBX inside it, that will appear to not be an obs group, because it has no members.)
-Darius

On Wed, Nov 10, 2010 at 6:05 AM, Burke Mamlin <[hidden email][hidden email][hidden email]> wrote:
When we introduced obs groups into the data model [1], we ended up embedding obs groups into the obs table. Our initial intent was that a separate obs_group table would distinguish groups from observations and allow a clear space for later addition of group-level attributes (the ORC from HL7).  With obs groups embedded amongst the obs, we're forced to infer whether or not an obs is a group or not [2] -- i.e., all values null and members not null.

I'm working with ThoughtWorks on extending Umashanthi's fine GSoC work on a flowsheet (longitudinal data) viewer. I need to explain to them how to distinguish obs groups from obs -- not just via org.openmrs.Obs, but also if they are fetching the obs directly at the DAO level into different (e.g., lighter weight) objects.

Is there any documentation on how obs groups currently work?  I see hints in the javadocs, but couldn't find a wiki page on the subject. And TRUNK-1357 was closed without describing which solution was implemented.  I'm trying to answer questions like:
  • How are obs groups distinguished from obs in the database?
  • Do we enforce that obs cannot have both value and members [3]? 
  • Can an obs group exist without a grouping obs -- i.e., 2+ obs grouped without a parent?  Or is a parent "grouping" obs required?
  • If I want to render a person's observations showing groupings, what is the recommended way to retrieve the observations and recognize the groups?

Cheers,

-Burke

[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list
Burke Mamlin Burke Mamlin
Reply | Threaded
Open this post in threaded view
|

Re: Obs groups

So, if I go to ObsService to get all observations for a patient and the patient has ten observations: 7 simple obs plus BLOOD PRESSURE, a grouping observation containing two obs members (SYSTOLIC BLOOD PRESSURE and DIASTOLIC BLOOD PRESSURE), do I get back 10 obs?  9 obs?  Or 8 obs?

10 obs -- groups and obs, I'm on my own to sort it out

9 obs -- BLOOD PRESSURE omitted; I just get actual (non-grouping obs) and am left to recognize that SYSTOLIC BLOOD PRESSURE and DIASTOLIC BLOOD PRESSURE are part of a group. 

8 obs -- the simple 7 plus BLOOD PRESSURE; the SYSTOLIC BLOOD PRESSURE and DIASTOLIC BLOOD PRESSURE "hidden" as members of BLOOD PRESSURE. 

-Burke

On Nov 10, 2010, at 11:10 AM, Ben Wolfe <[hidden email]> wrote:


The Obs object (if it is a grouping obs) has a getGroupMembers or something that has all grouped obs.  If an obs is in a group it can use the Obs.getObsGroup() method to get the grouping obs.

What you're remembering is the way we set up the Encounter.getObs* methods.  Check those javadocs.

I think the ObsService.getsObs methods would return a grouping obs if it matched a query.  But this only comes into play if the user is searching on the concept name/id that is the grouping concept.

Ben

On Wed, Nov 10, 2010 at 2:01 PM, Burke Mamlin <[hidden email]> wrote:
How do you get the obs group hierarchy from the API?  Does the API return top level obs with children as members of obs that are groups?  Or does it return all obs in a list with obs groups omitted?  Maybe I'm just unable to find it using my iPad on a plane, but I've browsed the javadocs at http://doc.openmrs.org and don't see this explained in ObsService. 

I vaguely recall a plan to leave getObservations alone -- i.e., return all obs as a simple list, omitting the obs groups -- and then add a getObservatonsWithGroupings (or something like that) to return all top level obs with grouped obs within the members property of their parent. 

-Burke


On Nov 10, 2010, at 10:01 AM, Ben Wolfe <[hidden email]> wrote:

A row is an obs group if its obs_id is an obs_group_id for another row.

A grouping row has a null obs_group_id (aka does NOT point to itself).

Ben

On Wed, Nov 10, 2010 at 12:58 PM, Burke Mamlin <[hidden email][hidden email]> wrote:
Does an obs group parent row in obs have an obs_group_id that point to its own obs_id?  If not, how is a row in the obs table recognized as an obs group?  Is it implied if any obs_group_id equals obs_id?

We should definitely ensure that the API prevents obs groups from containing values to keep the door open for TRUNK-1858 [1]. I'll go ahead and make a ticket for this. 

-Burke

[1] http://tickets.openmrs.org/browse/TRUNK-1858


On Nov 10, 2010, at 9:17 AM, Darius Jazayeri <[hidden email][hidden email]> wrote:

Hi Burke,

Off the top of my head, if I recall correctly:
  • This isn't formally documented.
  • Obs that are groups are not supposed to have values, but this isn't enforced
  • According to the API, you must have an actual obs as the parent, and you're not allowed to have an obs group contain itself as a direct or indirect child.
  • The way to tell if something is an obs group in the API is Obs.isObsGrouping() which just does "getGroupMembers() != null && getGroupMembers().size() > 0". So at present there's no efficient way to do this. (Also, if I create what's basically an ORC with no OBX inside it, that will appear to not be an obs group, because it has no members.)
-Darius

On Wed, Nov 10, 2010 at 6:05 AM, Burke Mamlin <[hidden email][hidden email][hidden email]> wrote:
When we introduced obs groups into the data model [1], we ended up embedding obs groups into the obs table. Our initial intent was that a separate obs_group table would distinguish groups from observations and allow a clear space for later addition of group-level attributes (the ORC from HL7).  With obs groups embedded amongst the obs, we're forced to infer whether or not an obs is a group or not [2] -- i.e., all values null and members not null.

I'm working with ThoughtWorks on extending Umashanthi's fine GSoC work on a flowsheet (longitudinal data) viewer. I need to explain to them how to distinguish obs groups from obs -- not just via org.openmrs.Obs, but also if they are fetching the obs directly at the DAO level into different (e.g., lighter weight) objects.

Is there any documentation on how obs groups currently work?  I see hints in the javadocs, but couldn't find a wiki page on the subject. And TRUNK-1357 was closed without describing which solution was implemented.  I'm trying to answer questions like:
  • How are obs groups distinguished from obs in the database?
  • Do we enforce that obs cannot have both value and members [3]? 
  • Can an obs group exist without a grouping obs -- i.e., 2+ obs grouped without a parent?  Or is a parent "grouping" obs required?
  • If I want to render a person's observations showing groupings, what is the recommended way to retrieve the observations and recognize the groups?

Cheers,

-Burke

[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list

[hidden email] from OpenMRS Developers' mailing list
Dave Thomas Dave Thomas
Reply | Threaded
Open this post in threaded view
|

Re: Obs groups

Hi.  I think the key to obsGroups is that you need to know what you're asking for a priori when parsing an encounter with obsGroups.  Thinking about the drug sensitivity test (DST) model from the mdrtb module (which has 2 levels of obsGroups with repeated grouping conceptIds at the bottom level), you have to know what the grouping concepts 'mean' to be able to ask intelligent questions of the encounter.  Receiving all of the encounter obs in a flat list is basically meaningless, because at the bottom level of the obsGroup hierarchy (where you have pairs of drug panel test results and drug concentration obs), if you 'flatten' the observations, you've lost the relationship between which drug result goes with which concentration.

To answer the question below, I think you get 10 obs back, but this 'getAllObs' method wouldn't have been a good way to approach the encounter in the first place.  By habit, I tend to use the 'getTopLevelObs' method, and take it from there based on my knowledge of the expected obsGroup structure.

The hardest problem with obs groups is this:  how do you export (or show) an encounter with an arbitrary number of groups, with arbitrary obsGroup hierarchy depth, where there can be multiple grouping obs with a given conceptId at any given level.  I think the answer to this question, is you have to know what you're asking for up front, and act accordingly.

Similarly, modules that use complicated hierarchical obs models (like mdrtb) should include utility methods for parsing the expected obsGroup hierarchy based on an array of questions that someone might want to ask about the encounter.  Including, in the case of the DST model, a method for flattening the encounter in a presentable way, meaning that the most relevant clinical information is easily to eyeball.

d

On 11/10/2010 9:34 PM, Burke Mamlin wrote:
So, if I go to ObsService to get all observations for a patient and the patient has ten observations: 7 simple obs plus BLOOD PRESSURE, a grouping observation containing two obs members (SYSTOLIC BLOOD PRESSURE and DIASTOLIC BLOOD PRESSURE), do I get back 10 obs?  9 obs?  Or 8 obs?

10 obs -- groups and obs, I'm on my own to sort it out

9 obs -- BLOOD PRESSURE omitted; I just get actual (non-grouping obs) and am left to recognize that SYSTOLIC BLOOD PRESSURE and DIASTOLIC BLOOD PRESSURE are part of a group. 

8 obs -- the simple 7 plus BLOOD PRESSURE; the SYSTOLIC BLOOD PRESSURE and DIASTOLIC BLOOD PRESSURE "hidden" as members of BLOOD PRESSURE. 

-Burke

On Nov 10, 2010, at 11:10 AM, Ben Wolfe <[hidden email]> wrote:


The Obs object (if it is a grouping obs) has a getGroupMembers or something that has all grouped obs.  If an obs is in a group it can use the Obs.getObsGroup() method to get the grouping obs.

What you're remembering is the way we set up the Encounter.getObs* methods.  Check those javadocs.

I think the ObsService.getsObs methods would return a grouping obs if it matched a query.  But this only comes into play if the user is searching on the concept name/id that is the grouping concept.

Ben

On Wed, Nov 10, 2010 at 2:01 PM, Burke Mamlin <[hidden email]> wrote:
How do you get the obs group hierarchy from the API?  Does the API return top level obs with children as members of obs that are groups?  Or does it return all obs in a list with obs groups omitted?  Maybe I'm just unable to find it using my iPad on a plane, but I've browsed the javadocs at http://doc.openmrs.org and don't see this explained in ObsService. 

I vaguely recall a plan to leave getObservations alone -- i.e., return all obs as a simple list, omitting the obs groups -- and then add a getObservatonsWithGroupings (or something like that) to return all top level obs with grouped obs within the members property of their parent. 

-Burke


On Nov 10, 2010, at 10:01 AM, Ben Wolfe <[hidden email]> wrote:

A row is an obs group if its obs_id is an obs_group_id for another row.

A grouping row has a null obs_group_id (aka does NOT point to itself).

Ben

On Wed, Nov 10, 2010 at 12:58 PM, Burke Mamlin <[hidden email]> wrote:
Does an obs group parent row in obs have an obs_group_id that point to its own obs_id?  If not, how is a row in the obs table recognized as an obs group?  Is it implied if any obs_group_id equals obs_id?

We should definitely ensure that the API prevents obs groups from containing values to keep the door open for TRUNK-1858 [1]. I'll go ahead and make a ticket for this. 

-Burke

[1] http://tickets.openmrs.org/browse/TRUNK-1858


On Nov 10, 2010, at 9:17 AM, Darius Jazayeri <[hidden email]> wrote:

Hi Burke,

Off the top of my head, if I recall correctly:
  • This isn't formally documented.
  • Obs that are groups are not supposed to have values, but this isn't enforced
  • According to the API, you must have an actual obs as the parent, and you're not allowed to have an obs group contain itself as a direct or indirect child.
  • The way to tell if something is an obs group in the API is Obs.isObsGrouping() which just does "getGroupMembers() != null && getGroupMembers().size() > 0". So at present there's no efficient way to do this. (Also, if I create what's basically an ORC with no OBX inside it, that will appear to not be an obs group, because it has no members.)
-Darius

On Wed, Nov 10, 2010 at 6:05 AM, Burke Mamlin <[hidden email]> wrote:
When we introduced obs groups into the data model [1], we ended up embedding obs groups into the obs table. Our initial intent was that a separate obs_group table would distinguish groups from observations and allow a clear space for later addition of group-level attributes (the ORC from HL7).  With obs groups embedded amongst the obs, we're forced to infer whether or not an obs is a group or not [2] -- i.e., all values null and members not null.

I'm working with ThoughtWorks on extending Umashanthi's fine GSoC work on a flowsheet (longitudinal data) viewer. I need to explain to them how to distinguish obs groups from obs -- not just via org.openmrs.Obs, but also if they are fetching the obs directly at the DAO level into different (e.g., lighter weight) objects.

Is there any documentation on how obs groups currently work?  I see hints in the javadocs, but couldn't find a wiki page on the subject. And TRUNK-1357 was closed without describing which solution was implemented.  I'm trying to answer questions like:
  • How are obs groups distinguished from obs in the database?
  • Do we enforce that obs cannot have both value and members [3]? 
  • Can an obs group exist without a grouping obs -- i.e., 2+ obs grouped without a parent?  Or is a parent "grouping" obs required?
  • If I want to render a person's observations showing groupings, what is the recommended way to retrieve the observations and recognize the groups?

Cheers,

-Burke

[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list

[hidden email] from OpenMRS Developers' mailing list

[hidden email] from OpenMRS Developers' mailing list
Ben Wolfe (openmrs) Ben Wolfe (openmrs)
Reply | Threaded
Open this post in threaded view
|

Re: Obs groups

Yes, Dave it right.  You will get 10 back from ObsService.getObservationsByPerson.

The webapp takes care of this by calling obsDisplay.jsp recursively for obs and obsgroups.

Ben

On Thu, Nov 11, 2010 at 4:25 AM, David Thomas <[hidden email]> wrote:
Hi.  I think the key to obsGroups is that you need to know what you're asking for a priori when parsing an encounter with obsGroups.  Thinking about the drug sensitivity test (DST) model from the mdrtb module (which has 2 levels of obsGroups with repeated grouping conceptIds at the bottom level), you have to know what the grouping concepts 'mean' to be able to ask intelligent questions of the encounter.  Receiving all of the encounter obs in a flat list is basically meaningless, because at the bottom level of the obsGroup hierarchy (where you have pairs of drug panel test results and drug concentration obs), if you 'flatten' the observations, you've lost the relationship between which drug result goes with which concentration.

To answer the question below, I think you get 10 obs back, but this 'getAllObs' method wouldn't have been a good way to approach the encounter in the first place.  By habit, I tend to use the 'getTopLevelObs' method, and take it from there based on my knowledge of the expected obsGroup structure.

The hardest problem with obs groups is this:  how do you export (or show) an encounter with an arbitrary number of groups, with arbitrary obsGroup hierarchy depth, where there can be multiple grouping obs with a given conceptId at any given level.  I think the answer to this question, is you have to know what you're asking for up front, and act accordingly.

Similarly, modules that use complicated hierarchical obs models (like mdrtb) should include utility methods for parsing the expected obsGroup hierarchy based on an array of questions that someone might want to ask about the encounter.  Including, in the case of the DST model, a method for flattening the encounter in a presentable way, meaning that the most relevant clinical information is easily to eyeball.

d


On 11/10/2010 9:34 PM, Burke Mamlin wrote:
So, if I go to ObsService to get all observations for a patient and the patient has ten observations: 7 simple obs plus BLOOD PRESSURE, a grouping observation containing two obs members (SYSTOLIC BLOOD PRESSURE and DIASTOLIC BLOOD PRESSURE), do I get back 10 obs?  9 obs?  Or 8 obs?

10 obs -- groups and obs, I'm on my own to sort it out

9 obs -- BLOOD PRESSURE omitted; I just get actual (non-grouping obs) and am left to recognize that SYSTOLIC BLOOD PRESSURE and DIASTOLIC BLOOD PRESSURE are part of a group. 

8 obs -- the simple 7 plus BLOOD PRESSURE; the SYSTOLIC BLOOD PRESSURE and DIASTOLIC BLOOD PRESSURE "hidden" as members of BLOOD PRESSURE. 

-Burke

On Nov 10, 2010, at 11:10 AM, Ben Wolfe <[hidden email]> wrote:


The Obs object (if it is a grouping obs) has a getGroupMembers or something that has all grouped obs.  If an obs is in a group it can use the Obs.getObsGroup() method to get the grouping obs.

What you're remembering is the way we set up the Encounter.getObs* methods.  Check those javadocs.

I think the ObsService.getsObs methods would return a grouping obs if it matched a query.  But this only comes into play if the user is searching on the concept name/id that is the grouping concept.

Ben

On Wed, Nov 10, 2010 at 2:01 PM, Burke Mamlin <[hidden email]> wrote:
How do you get the obs group hierarchy from the API?  Does the API return top level obs with children as members of obs that are groups?  Or does it return all obs in a list with obs groups omitted?  Maybe I'm just unable to find it using my iPad on a plane, but I've browsed the javadocs at http://doc.openmrs.org and don't see this explained in ObsService. 

I vaguely recall a plan to leave getObservations alone -- i.e., return all obs as a simple list, omitting the obs groups -- and then add a getObservatonsWithGroupings (or something like that) to return all top level obs with grouped obs within the members property of their parent. 

-Burke


On Nov 10, 2010, at 10:01 AM, Ben Wolfe <[hidden email]> wrote:

A row is an obs group if its obs_id is an obs_group_id for another row.

A grouping row has a null obs_group_id (aka does NOT point to itself).

Ben

On Wed, Nov 10, 2010 at 12:58 PM, Burke Mamlin <[hidden email]> wrote:
Does an obs group parent row in obs have an obs_group_id that point to its own obs_id?  If not, how is a row in the obs table recognized as an obs group?  Is it implied if any obs_group_id equals obs_id?

We should definitely ensure that the API prevents obs groups from containing values to keep the door open for TRUNK-1858 [1]. I'll go ahead and make a ticket for this. 

-Burke

[1] http://tickets.openmrs.org/browse/TRUNK-1858


On Nov 10, 2010, at 9:17 AM, Darius Jazayeri <[hidden email]> wrote:

Hi Burke,

Off the top of my head, if I recall correctly:
  • This isn't formally documented.
  • Obs that are groups are not supposed to have values, but this isn't enforced
  • According to the API, you must have an actual obs as the parent, and you're not allowed to have an obs group contain itself as a direct or indirect child.
  • The way to tell if something is an obs group in the API is Obs.isObsGrouping() which just does "getGroupMembers() != null && getGroupMembers().size() > 0". So at present there's no efficient way to do this. (Also, if I create what's basically an ORC with no OBX inside it, that will appear to not be an obs group, because it has no members.)
-Darius

On Wed, Nov 10, 2010 at 6:05 AM, Burke Mamlin <[hidden email]> wrote:
When we introduced obs groups into the data model [1], we ended up embedding obs groups into the obs table. Our initial intent was that a separate obs_group table would distinguish groups from observations and allow a clear space for later addition of group-level attributes (the ORC from HL7).  With obs groups embedded amongst the obs, we're forced to infer whether or not an obs is a group or not [2] -- i.e., all values null and members not null.

I'm working with ThoughtWorks on extending Umashanthi's fine GSoC work on a flowsheet (longitudinal data) viewer. I need to explain to them how to distinguish obs groups from obs -- not just via org.openmrs.Obs, but also if they are fetching the obs directly at the DAO level into different (e.g., lighter weight) objects.

Is there any documentation on how obs groups currently work?  I see hints in the javadocs, but couldn't find a wiki page on the subject. And TRUNK-1357 was closed without describing which solution was implemented.  I'm trying to answer questions like:
  • How are obs groups distinguished from obs in the database?
  • Do we enforce that obs cannot have both value and members [3]? 
  • Can an obs group exist without a grouping obs -- i.e., 2+ obs grouped without a parent?  Or is a parent "grouping" obs required?
  • If I want to render a person's observations showing groupings, what is the recommended way to retrieve the observations and recognize the groups?

Cheers,

-Burke

[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list

[hidden email] from OpenMRS Developers' mailing list

[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list