Chemotherapy Ordering Data Design

These are the Classes

OrderGroup

OrderGroupAttribute

OrderGroupAttributeType

Take a second look at the ticket description and ensure that you have implemented all that is listed there. That should fix it.

Sure thanks.

@dkayiwa @ibacher

Got this observation OrderGroup references OrderSetAttribute through order_set_id Foreign Key.

Data :

openmrs.order_set_attribute PK : order_set_attribute_id

openmrs.order_set_attribute FK : order_set_id (many to one)

openmrs.order_group_id FK: order_set_id (one to Many)

If you execute this dataset with order_set_id="2000"

<dataset>
    <order_group order_group_id="1" **order_set_id="2000"** patient_id="7" encounter_id="3"   creator="1" date_created="2012-02-19 12:24:10.0" voided="false" uuid="1c96f25c-4949-4f72-9931-d808fbcdb613" />
.....
    <dataset/>

you get a "Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referential integrity constraint violation: …"

When you remove order_set_id=“2000” and run the test it passes.

<dataset>
    <order_group order_group_id="1" patient_id="7" encounter_id="3"   creator="1" date_created="2012-02-19 12:24:10.0" voided="false" uuid="1c96f25c-4949-4f72-9931-d808fbcdb613" />
.....
    <dataset/>

Could it have been wrong to have OrderGroup reference OrderSetAttribute through it’s Primary Key (openmrs.order_set_attribute.order_set_attribute_id) instead of using openmrs.order_set_attribute.order_set_id or is it about the value 2000 which does not yet exist in the parent table?

@tendomart - maybe I’m reading the above wrong, but I wouldn’t expect an OrderGroup to reference an OrderSetAttribute. I’d expect OrderGroup to reference OrderGroupAttribute.

1 Like

@mseaton Thanks , this has exactly been my puzzle from this

The Current set tag is like

<set name="attributes" lazy="true" inverse="true" batch-size="100"
            cascade="all-delete-orphan" order-by="voided asc">
            <key column="order_set_id" />
            <one-to-many class="OrderSetAttribute" />
        </set>

I was wondering we would be having something like this

<set name="attributes" lazy="true" inverse="true" batch-size="100"
            cascade="all-delete-orphan" order-by="voided asc">
            <key column="person_attribute_type_id" />
            <one-to-many class="OrderGroupAttribute" />
        </set>

What do you think ?

Correct @tendomart, I think that is just a typo due to copy/paste from the same developer working on the OrderSetAttribute implementation.

I would just change to this:

<set name="attributes" lazy="true" inverse="true" batch-size="100"
             cascade="all-delete-orphan" order-by="voided asc">
             <key column="order_group_id" />
             <one-to-many class="OrderGroupAttribute" />
</set>

This is assuming the order_group_attribute table has an “order_group_id” foreign key.

2 Likes

@mseaton thanks

Yes it does have that foreign Key.

I have a question here. Are Cycle number , Number of cycles in the regimen auto incremented or generated by the doctor from the Dashboard ?