Skip to content
33 changes: 29 additions & 4 deletions api/src/main/java/org/openmrs/ProgramWorkflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,49 @@
import org.hibernate.envers.Audited;
import org.openmrs.util.NaturalStrings;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderBy;
import jakarta.persistence.Table;

/**
* ProgramWorkflow
*/
@Audited
@Entity
@Table(name = "program_workflow")
public class ProgramWorkflow extends BaseChangeableOpenmrsMetadata {

private static final long serialVersionUID = 1L;

// ******************
// Properties
// ******************

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "program_workflow_id")
private Integer programWorkflowId;

@ManyToOne
@JoinColumn(name = "program_id" ,nullable = false)
private Program program;

@ManyToOne
@JoinColumn(name = "concept_id" ,nullable = false)
private Concept concept;

@OneToMany(
mappedBy = "programWorkflow",
fetch = FetchType.EAGER,
cascade = CascadeType.ALL,
orphanRemoval = true
)
@OrderBy("date_created asc")
private Set<ProgramWorkflowState> states = new HashSet<>();

// ******************
Expand Down
1 change: 0 additions & 1 deletion api/src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<mapping resource="org/openmrs/api/db/hibernate/LocationAttribute.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/EncounterType.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/EncounterProvider.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ProgramWorkflow.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ProgramWorkflowState.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Cohort.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/CohortMembership.hbm.xml"/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
<column name="retired_by" type="INT" />
</addColumn>
</changeSet>
<changeSet id="TRUNK-5842-2025-09-15" author="elai">
<addColumn tableName="program_workflow">
<column name="name" type="VARCHAR(255)" />
<column name="description" type="text" />
<column name="date_retired" type="DATETIME" />
<column name="retire_reason" type="VARCHAR(255)" />
<column name="retired_by" type="INT" />
</addColumn>
</changeSet>

<changeSet id="TRUNK-5890-2025-09-14" author="Deborah Nakamatte">
<addColumn tableName="privilege">
Expand Down
2 changes: 2 additions & 0 deletions api/src/test/java/org/openmrs/api/OrderServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import org.openmrs.Privilege;
import org.openmrs.Program;
import org.openmrs.ProgramAttributeType;
import org.openmrs.ProgramWorkflow;
import org.openmrs.Provider;
import org.openmrs.ProviderAttributeType;
import org.openmrs.ProviderRole;
Expand Down Expand Up @@ -2790,6 +2791,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(LocationTag.class)
.addAnnotatedClass(org.openmrs.Field.class)
.addAnnotatedClass(Privilege.class)
.addAnnotatedClass(ProgramWorkflow.class)
.getMetadataBuilder().build();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ public void savePatientProgram_shouldSetEndDateOfAllRecentStatesWhenCompletingTh
program.setConcept(cs.getConcept(3));

ProgramWorkflow workflow1 = new ProgramWorkflow();
workflow1.setName("WORKFLOW1 NAME");
workflow1.setConcept(cs.getConcept(4));
program.addWorkflow(workflow1);

ProgramWorkflow workflow2 = new ProgramWorkflow();
workflow2.setName("WORKFLOW2 NAME");
workflow2.setConcept(cs.getConcept(4));
program.addWorkflow(workflow2);

Expand Down Expand Up @@ -281,14 +283,17 @@ public void savePatientProgram_shouldSetEndDateOfAllRecentStatesOnTransitionToTe
program.setConcept(cs.getConcept(3));

ProgramWorkflow workflow1 = new ProgramWorkflow();
workflow1.setName("WORKFLOW1 NAME");
workflow1.setConcept(cs.getConcept(4));
program.addWorkflow(workflow1);

ProgramWorkflow workflow2 = new ProgramWorkflow();
workflow2.setName("WORKFLOW2 NAME");
workflow2.setConcept(cs.getConcept(4));
program.addWorkflow(workflow2);

ProgramWorkflow workflow3 = new ProgramWorkflow();
workflow3.setName("WORKFLOW3 NAME");
workflow3.setConcept(cs.getConcept(4));
program.addWorkflow(workflow3);

Expand Down Expand Up @@ -398,6 +403,7 @@ public void saveProgram_shouldCreateProgramWorkflows() {
program.setConcept(cs.getConcept(3));

ProgramWorkflow workflow = new ProgramWorkflow();
workflow.setName("WORKFLOW NAME");
workflow.setConcept(cs.getConcept(4));
program.addWorkflow(workflow);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,15 @@
<program program_id="6" concept_id="1647" creator="1128" date_created="2007-03-28 10:08:06.0" changed_by="1128" date_changed="2007-03-28 11:03:03.0" retired="false" uuid="cf7c13da-2700-102b-80cb-0017a47871b2" name="PMTCT PROGRAM" description="PMTCT PROGRAM"/>
<program program_id="9" concept_id="2708" creator="15971" date_created="2007-10-04 14:29:35.0" retired="false" uuid="cf7c1560-2700-102b-80cb-0017a47871b2" name="ORACTA STUDY" description="ORACTA STUDY"/>
<program program_id="10" concept_id="2685" creator="15887" date_created="2007-10-29 22:29:37.0" changed_by="6" date_changed="2008-05-18 18:15:19.0" retired="false" uuid="cf7c16e6-2700-102b-80cb-0017a47871b2" name="HIV PEDIATRIC PROGRAM" description="HIV PEDIATRIC PROGRAM"/>
<program_workflow program_workflow_id="3" program_id="3" concept_id="1484" creator="6" date_created="2006-09-27 20:34:45.0" retired="false" uuid="cf8f2664-2700-102b-80cb-0017a47871b2"/>
<program_workflow program_workflow_id="4" program_id="4" concept_id="1484" creator="6" date_created="2006-09-27 20:35:03.0" retired="false" uuid="cf8f2934-2700-102b-80cb-0017a47871b2"/>
<program_workflow program_workflow_id="5" program_id="5" concept_id="1846" creator="1128" date_created="2007-03-12 21:48:00.0" retired="false" uuid="cf8f2ad8-2700-102b-80cb-0017a47871b2"/>
<program_workflow program_workflow_id="6" program_id="6" concept_id="1484" creator="1128" date_created="2007-03-28 10:11:39.0" retired="false" uuid="cf8f2c72-2700-102b-80cb-0017a47871b2"/>
<program_workflow program_workflow_id="7" program_id="6" concept_id="5272" creator="1128" date_created="2007-03-28 11:03:03.0" retired="false" uuid="cf8f2e16-2700-102b-80cb-0017a47871b2"/>
<program_workflow program_workflow_id="9" program_id="3" concept_id="3070" creator="1128" date_created="2007-05-03 09:35:38.0" retired="false" uuid="cf8f2fa6-2700-102b-80cb-0017a47871b2"/>
<program_workflow program_workflow_id="10" program_id="4" concept_id="1378" creator="1128" date_created="2007-05-03 10:05:42.0" retired="false" uuid="cf8f3140-2700-102b-80cb-0017a47871b2"/>
<program_workflow program_workflow_id="19" program_id="10" concept_id="1484" creator="15887" date_created="2007-10-29 22:31:52.0" retired="false" uuid="cf8f32da-2700-102b-80cb-0017a47871b2"/>
<program_workflow program_workflow_id="20" program_id="10" concept_id="3070" creator="6" date_created="2008-05-18 18:15:19.0" retired="false" uuid="25bce7b8-bddf-440a-b939-a9cc11f03a27"/>
<program_workflow program_workflow_id="3" program_id="3" concept_id="1484" creator="6" date_created="2006-09-27 20:34:45.0" retired="false" uuid="cf8f2664-2700-102b-80cb-0017a47871b2" name="WORKFLOW1 NAME" />
<program_workflow program_workflow_id="4" program_id="4" concept_id="1484" creator="6" date_created="2006-09-27 20:35:03.0" retired="false" uuid="cf8f2934-2700-102b-80cb-0017a47871b2" name="WORKFLOW2 NAME" />
<program_workflow program_workflow_id="5" program_id="5" concept_id="1846" creator="1128" date_created="2007-03-12 21:48:00.0" retired="false" uuid="cf8f2ad8-2700-102b-80cb-0017a47871b2" name="WORKFLOW3 NAME" />
<program_workflow program_workflow_id="6" program_id="6" concept_id="1484" creator="1128" date_created="2007-03-28 10:11:39.0" retired="false" uuid="cf8f2c72-2700-102b-80cb-0017a47871b2" name="WORKFLOW4 NAME" />
<program_workflow program_workflow_id="7" program_id="6" concept_id="5272" creator="1128" date_created="2007-03-28 11:03:03.0" retired="false" uuid="cf8f2e16-2700-102b-80cb-0017a47871b2" name="WORKFLOW5 NAME" />
<program_workflow program_workflow_id="9" program_id="3" concept_id="3070" creator="1128" date_created="2007-05-03 09:35:38.0" retired="false" uuid="cf8f2fa6-2700-102b-80cb-0017a47871b2" name="WORKFLOW6 NAME" />
<program_workflow program_workflow_id="10" program_id="4" concept_id="1378" creator="1128" date_created="2007-05-03 10:05:42.0" retired="false" uuid="cf8f3140-2700-102b-80cb-0017a47871b2" name="WORKFLOW7 NAME" />
<program_workflow program_workflow_id="19" program_id="10" concept_id="1484" creator="15887" date_created="2007-10-29 22:31:52.0" retired="false" uuid="cf8f32da-2700-102b-80cb-0017a47871b2" name="WORKFLOW8 NAME" />
<program_workflow program_workflow_id="20" program_id="10" concept_id="3070" creator="6" date_created="2008-05-18 18:15:19.0" retired="false" uuid="25bce7b8-bddf-440a-b939-a9cc11f03a27" name="WORKFLOW9 NAME" />
<program_workflow_state program_workflow_state_id="5" program_workflow_id="3" concept_id="1490" initial="true" terminal="false" creator="6" date_created="2006-09-27 21:20:39.0" retired="false" uuid="cfa241f4-2700-102b-80cb-0017a47871b2"/>
<program_workflow_state program_workflow_state_id="6" program_workflow_id="3" concept_id="1710" initial="true" terminal="false" creator="6" date_created="2006-09-27 21:20:39.0" retired="false" uuid="cfa244b0-2700-102b-80cb-0017a47871b2"/>
<program_workflow_state program_workflow_state_id="7" program_workflow_id="3" concept_id="1708" initial="true" terminal="false" creator="6" date_created="2006-09-27 21:20:39.0" retired="false" uuid="cfa24690-2700-102b-80cb-0017a47871b2"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

-->
<dataset>
<program_workflow program_workflow_id="3" program_id="2" concept_id="12" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="2b98bc76-245c-11e1-9cf0-00248140a5eb"/>
<program_workflow program_workflow_id="3" program_id="2" concept_id="12" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="2b98bc76-245c-11e1-9cf0-00248140a5eb" name="WORKFLOW NAME"/>
<program_workflow_state program_workflow_state_id="6" program_workflow_id="3" concept_id="16" initial="false" terminal="true" creator="1" date_created="2008-08-15 17:04:02.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="31c82d66-245c-11e1-9cf0-00248140a5eb"/>
</dataset>
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@
<program program_id="1" concept_id="9" creator="1" date_created="2008-08-15 16:07:11.0" changed_by="1" date_changed="2008-08-15 17:04:50.0" retired="false" name="HIV PROGRAM" description="hiv program" uuid="da4a0391-ba62-4fad-ad66-1e3722d16380"/>
<program program_id="2" concept_id="10" creator="1" date_created="2008-08-15 16:07:34.0" retired="false" name="MDR-TB PROGRAM" description="MDR-TB program" uuid="71779c39-d289-4dfe-91b5-e7cfaa27c78b"/>
<program program_id="3" concept_id="11" creator="1" date_created="2008-08-15 16:08:51.0" changed_by="1" date_changed="2008-08-15 16:09:00.0" retired="true" name="MALARIA PROGRAM" description="Malaria program" uuid="f386c3d2-dd75-441f-a582-2237824edfb0"/>
<program_workflow program_workflow_id="1" program_id="1" concept_id="13" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="84f0effa-dd73-46cb-b931-7cd6be6c5f81"/>
<program_workflow program_workflow_id="2" program_id="1" concept_id="12" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="c66c8713-7df4-40de-96f6-dc4cce3432da"/>
<program_workflow program_workflow_id="1" program_id="1" concept_id="13" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="84f0effa-dd73-46cb-b931-7cd6be6c5f81" name="WORKFLOW1 NAME"/>
<program_workflow program_workflow_id="2" program_id="1" concept_id="12" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="c66c8713-7df4-40de-96f6-dc4cce3432da" name="WORKFLOW2 NAME"/>
<program_workflow_state program_workflow_state_id="1" program_workflow_id="1" concept_id="16" initial="false" terminal="true" creator="1" date_created="2008-08-15 17:04:02.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="92584cdc-6a20-4c84-a659-e035e45d36b0"/>
<program_workflow_state program_workflow_state_id="2" program_workflow_id="1" concept_id="17" initial="true" terminal="false" creator="1" date_created="2008-08-15 17:04:02.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="e938129e-248a-482a-acea-f85127251472"/>
<program_workflow_state program_workflow_state_id="4" program_workflow_id="1" concept_id="14" initial="false" terminal="false" creator="1" date_created="2008-08-15 17:04:02.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="0d5f1bb4-2edb-4dd1-8d9f-34489bb4d9ea"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@
<program program_id="1" concept_id="9" creator="1" date_created="2008-08-15 16:07:11.0" changed_by="1" date_changed="2008-08-15 17:04:50.0" retired="false" name="HIV Program" description="hiv program" uuid="da4a0391-ba62-4fad-ad66-1e3722d16380"/>
<program program_id="2" concept_id="10" creator="1" date_created="2008-08-15 16:07:34.0" retired="false" name="MDR program" description="MDR-TB program" uuid="71779c39-d289-4dfe-91b5-e7cfaa27c78b"/>
<program program_id="3" concept_id="11" creator="1" date_created="2008-08-15 16:08:51.0" changed_by="1" date_changed="2008-08-15 16:09:00.0" retired="true" name="Malaria program" description="Malaria program" uuid="f386c3d2-dd75-441f-a582-2237824edfb0"/>
<program_workflow program_workflow_id="1" program_id="1" concept_id="13" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="84f0effa-dd73-46cb-b931-7cd6be6c5f81"/>
<program_workflow program_workflow_id="2" program_id="1" concept_id="12" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="c66c8713-7df4-40de-96f6-dc4cce3432da"/>
<program_workflow program_workflow_id="1" program_id="1" concept_id="13" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="84f0effa-dd73-46cb-b931-7cd6be6c5f81" name="WORKFLOW1 NAME"/>
<program_workflow program_workflow_id="2" program_id="1" concept_id="12" creator="1" date_created="2008-08-15 17:01:00.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="c66c8713-7df4-40de-96f6-dc4cce3432da" name="WORKFLOW2 NAME" />
<program_workflow_state program_workflow_state_id="1" program_workflow_id="1" concept_id="16" initial="false" terminal="true" creator="1" date_created="2008-08-15 17:04:02.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="92584cdc-6a20-4c84-a659-e035e45d36b0"/>
<program_workflow_state program_workflow_state_id="2" program_workflow_id="1" concept_id="17" initial="true" terminal="false" creator="1" date_created="2008-08-15 17:04:02.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="e938129e-248a-482a-acea-f85127251472"/>
<program_workflow_state program_workflow_state_id="4" program_workflow_id="1" concept_id="14" initial="false" terminal="false" creator="1" date_created="2008-08-15 17:04:02.0" retired="false" changed_by="1" date_changed="2008-08-15 17:04:50.0" uuid="0d5f1bb4-2edb-4dd1-8d9f-34489bb4d9ea"/>
Expand Down
Loading