Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.47 KB | None | 0 0
  1. /**
  2. * The contents of this file are subject to the OpenMRS Public License
  3. * Version 1.0 (the "License"); you may not use this file except in
  4. * compliance with the License. You may obtain a copy of the License at
  5. * http://license.openmrs.org
  6. *
  7. * Software distributed under the License is distributed on an "AS IS"
  8. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  9. * License for the specific language governing rights and limitations
  10. * under the License.
  11. *
  12. * Copyright (C) OpenMRS, LLC. All Rights Reserved.
  13. */
  14. package org.openmrs.api;
  15.  
  16. import java.util.Collection;
  17. import java.util.Date;
  18. import java.util.List;
  19. import java.util.Set;
  20.  
  21. import org.openmrs.Cohort;
  22. import org.openmrs.Concept;
  23. import org.openmrs.ConceptStateConversion;
  24. import org.openmrs.Patient;
  25. import org.openmrs.PatientProgram;
  26. import org.openmrs.PatientState;
  27. import org.openmrs.Program;
  28. import org.openmrs.ProgramWorkflow;
  29. import org.openmrs.ProgramWorkflowState;
  30. import org.openmrs.User;
  31. import org.openmrs.annotation.Authorized;
  32. import org.openmrs.api.db.ProgramWorkflowDAO;
  33. import org.openmrs.util.PrivilegeConstants;
  34.  
  35. /**
  36. * Contains methods pertaining to management of Programs, ProgramWorkflows, ProgramWorkflowStates,
  37. * PatientPrograms, PatientStates, and ConceptStateConversions Use:<br/>
  38. *
  39. * <pre>
  40. * Program program = new Program();
  41. * program.set___(___);
  42. * ...etc
  43. * Context.getProgramWorkflowService().saveProgram(program);
  44. * </pre>
  45. */
  46. public interface ProgramWorkflowService extends OpenmrsService {
  47.  
  48. /**
  49. * Setter for the ProgramWorkflow DataAccessObject (DAO). The DAO is used for saving and
  50. * retrieving from the database
  51. *
  52. * @param dao - The DAO for this service
  53. */
  54. public void setProgramWorkflowDAO(ProgramWorkflowDAO dao);
  55.  
  56. // **************************
  57. // PROGRAM
  58. // **************************
  59.  
  60. /**
  61. * Save <code>program</code> to database (create if new or update if changed)
  62. *
  63. * @param program is the Program to be saved to the database
  64. * @return The Program that was saved
  65. * @throws APIException
  66. * @should create program workflows
  67. * @should save program successfully
  68. * @should save workflows associated with program
  69. * @should save states associated with program
  70. * @should update detached program
  71. */
  72. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  73. public Program saveProgram(Program program) throws APIException;
  74.  
  75. /**
  76. * Returns a program given that programs primary key <code>programId</code> A null value is
  77. * returned if no program exists with this programId.
  78. *
  79. * @param programId integer primary key of the program to find
  80. * @return Program object that has program.programId = <code>programId</code> passed in.
  81. * @throws APIException
  82. * @should return program matching the given programId
  83. * @should return null when programId does not exist
  84. */
  85. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  86. public Program getProgram(Integer programId) throws APIException;
  87.  
  88. /**
  89. * @deprecated use {@link #getProgramByName(String)}
  90. */
  91. public Program getProgram(String name);
  92.  
  93. /**
  94. * Returns a program given the program's exact <code>name</code> A null value is returned if
  95. * there is no program with this name
  96. *
  97. * @param name the exact name of the program to match on
  98. * @return Program matching the <code>name</code> to Program.name
  99. * @throws APIException
  100. * @throws ProgramNameDuplicatedException when there are more than one program in the dB with the given name.
  101. * @should return program when name matches
  102. * @should return null when program does not exist with given name
  103. * @should fail when two programs found with same name
  104. */
  105. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  106. public Program getProgramByName(String name) throws APIException;
  107.  
  108. /**
  109. * Returns all programs, includes retired programs. This method delegates to the
  110. * #getAllPrograms(boolean) method
  111. *
  112. * @return List<Program> of all existing programs, including retired programs
  113. * @throws APIException
  114. */
  115. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  116. public List<Program> getAllPrograms() throws APIException;
  117.  
  118. /**
  119. * Returns all programs
  120. *
  121. * @param includeRetired whether or not to include retired programs
  122. * @return List<Program> all existing programs, including retired based on the input parameter
  123. * @throws APIException
  124. * @should return all programs including retired when includeRetired equals true
  125. * @should return all programs excluding retired when includeRetired equals false
  126. */
  127. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  128. public List<Program> getAllPrograms(boolean includeRetired) throws APIException;
  129.  
  130. /**
  131. * Returns programs that match the given string. A null list will never be returned. An empty
  132. * list will be returned if there are no programs matching this <code>nameFragment</code>
  133. *
  134. * @param nameFragment is the string used to search for programs
  135. * @return List<Program> - list of Programs whose name matches the input parameter
  136. * @throws APIException
  137. * @should return all programs with partial name match
  138. * @should return all programs when exact name match
  139. * @should return empty list when name does not match
  140. * @should not return a null list
  141. * @should return programs when nameFragment matches beginning of program name
  142. * @should return programs when nameFragment matches ending of program name
  143. * @should return programs when nameFragment matches middle of program name
  144. * @should return programs when nameFragment matches entire program name
  145. * @should return programs ordered by name
  146. * @should return empty list when nameFragment does not match any
  147. */
  148. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  149. public List<Program> getPrograms(String nameFragment) throws APIException;
  150.  
  151. /**
  152. * Completely remove a program from the database (not reversible) This method delegates to
  153. * #purgeProgram(program, boolean) method
  154. *
  155. * @param program the Program to clean out of the database.
  156. * @throws APIException
  157. * @should delete program successfully
  158. */
  159. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  160. public void purgeProgram(Program program) throws APIException;
  161.  
  162. /**
  163. * Completely remove a program from the database (not reversible)
  164. *
  165. * @param cascade <code>true</code> to delete related content
  166. * @throws APIException
  167. * @should delete program successfully
  168. * @should not delete child associations when cascade equals false
  169. * @should throw APIException when given cascade equals true
  170. */
  171. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  172. public void purgeProgram(Program program, boolean cascade) throws APIException;
  173.  
  174. /**
  175. * Retires the given program
  176. *
  177. * @param program Program to be retired
  178. * @return the Program which has been retired
  179. * @throws APIException
  180. * @should retire program successfully
  181. * @should retire workflows associated with given program
  182. * @should retire states associated with given program
  183. */
  184. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  185. public Program retireProgram(Program program) throws APIException;
  186.  
  187. /**
  188. * Unretires the given program
  189. *
  190. * @param program Program to be unretired
  191. * @return the Program which has been unretired
  192. * @throws APIException
  193. * @should unretire program successfully
  194. * @should unretire workflows associated with given program
  195. * @should unretire states associated with given program
  196. */
  197. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  198. public Program unRetireProgram(Program program) throws APIException;
  199.  
  200. // **************************
  201. // PATIENT PROGRAM
  202. // **************************
  203.  
  204. /**
  205. * Get a program by its uuid. There should be only one of these in the database. If multiple are
  206. * found, an error is thrown.
  207. *
  208. * @param uuid the universally unique identifier
  209. * @return the program which matches the given uuid
  210. * @should find object given valid uuid
  211. * @should return null if no object found with given uuid
  212. * @should return program with given uuid
  213. * @should throw error when multiple programs with same uuid are found
  214. */
  215. public Program getProgramByUuid(String uuid);
  216.  
  217. /**
  218. * Get a program state by its uuid. There should be only one of these in the database. If
  219. * multiple are found, an error is thrown.
  220. *
  221. * @param uuid the universally unique identifier
  222. * @return the program which matches the given uuid
  223. * @should find object given valid uuid
  224. * @should return null if no object found with given uuid
  225. * @should return program state with the given uuid
  226. * @should throw error when multiple program states with same uuid are found
  227. */
  228. public PatientState getPatientStateByUuid(String uuid);
  229.  
  230. /**
  231. * Save patientProgram to database (create if new or update if changed)
  232. *
  233. * @param patientProgram is the PatientProgram to be saved to the database
  234. * @return PatientProgram - the saved PatientProgram
  235. * @throws APIException
  236. * @should update patient program
  237. * @should save patient program successfully
  238. * @should return patient program with assigned patient program id
  239. */
  240. @Authorized( { PrivilegeConstants.ADD_PATIENT_PROGRAMS, PrivilegeConstants.EDIT_PATIENT_PROGRAMS })
  241. public PatientProgram savePatientProgram(PatientProgram patientProgram) throws APIException;
  242.  
  243. /**
  244. * Returns a PatientProgram given that PatientPrograms primary key <code>patientProgramId</code>
  245. * A null value is returned if no PatientProgram exists with this patientProgramId.
  246. *
  247. * @param patientProgramId integer primary key of the PatientProgram to find
  248. * @return PatientProgram object that has patientProgram.patientProgramId =
  249. * <code>patientProgramId</code> passed in.
  250. * @throws APIException
  251. * @should return patient program with given patientProgramId
  252. * @should get patient program with given identifier
  253. * @should return null if program does not exist
  254. */
  255. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  256. public PatientProgram getPatientProgram(Integer patientProgramId) throws APIException;
  257.  
  258. /**
  259. * Returns PatientPrograms that match the input parameters. If an input parameter is set to
  260. * null, the parameter will not be used. Calling this method will all null parameters will
  261. * return all PatientPrograms in the database A null list will never be returned. An empty list
  262. * will be returned if there are no programs matching the input criteria
  263. *
  264. * @param patient if supplied all PatientPrograms returned will be for this Patient
  265. * @param program if supplied all PatientPrograms returned will be for this Program
  266. * @param minEnrollmentDate if supplied will limit PatientPrograms to those with enrollments on
  267. * or after this Date
  268. * @param maxEnrollmentDate if supplied will limit PatientPrograms to those with enrollments on
  269. * or before this Date
  270. * @param minCompletionDate if supplied will limit PatientPrograms to those completed on or
  271. * after this Date OR not yet completed
  272. * @param maxCompletionDate if supplied will limit PatientPrograms to those completed on or
  273. * before this Date
  274. * @param includeVoided if true, will also include voided PatientPrograms
  275. * @return List<PatientProgram> of PatientPrograms that match the passed input parameters
  276. * @throws APIException
  277. * @should return patient programs for given patient
  278. * @should return patient programs for given program
  279. * @should return patient programs with dateEnrolled on or before minEnrollmentDate
  280. * @should return patient programs with dateEnrolled on or after maxEnrollmentDate
  281. * @should return patient programs with dateCompleted on or before minCompletionDate
  282. * @should return patient programs with dateCompleted on or after maxCompletionDate
  283. * @should return patient programs with dateCompleted
  284. * @should return patient programs not yet completed
  285. * @should return voided patient programs
  286. * @should return all patient programs when all parameters are null
  287. * @should return empty list when matches not found
  288. */
  289. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  290. public List<PatientProgram> getPatientPrograms(Patient patient, Program program, Date minEnrollmentDate,
  291. Date maxEnrollmentDate, Date minCompletionDate, Date maxCompletionDate, boolean includeVoided)
  292. throws APIException;
  293.  
  294. /**
  295. * Completely remove a patientProgram from the database (not reversible) This method delegates
  296. * to #purgePatientProgram(patientProgram, boolean) method
  297. *
  298. * @param patientProgram the PatientProgram to clean out of the database.
  299. * @throws APIException
  300. * @should delete patient program from database without cascade
  301. */
  302. @Authorized( { PrivilegeConstants.PURGE_PATIENT_PROGRAMS })
  303. public void purgePatientProgram(PatientProgram patientProgram) throws APIException;
  304.  
  305. /**
  306. * Completely remove a patientProgram from the database (not reversible)
  307. *
  308. * @param patientProgram the PatientProgram to clean out of the database.
  309. * @param cascade <code>true</code> to delete related content
  310. * @throws APIException
  311. * @should delete patient program from database
  312. * @should cascade delete patient program states when cascade equals true
  313. * @should not cascade delete patient program states when cascade equals false
  314. */
  315. @Authorized( { PrivilegeConstants.PURGE_PATIENT_PROGRAMS })
  316. public void purgePatientProgram(PatientProgram patientProgram, boolean cascade) throws APIException;
  317.  
  318. /**
  319. * Voids the given patientProgram
  320. *
  321. * @param patientProgram patientProgram to be voided
  322. * @param reason is the reason why the patientProgram is being voided
  323. * @return the voided PatientProgram
  324. * @throws APIException
  325. * @should void patient program when reason is valid
  326. * @should fail when reason is empty
  327. */
  328. @Authorized( { PrivilegeConstants.DELETE_PATIENT_PROGRAMS })
  329. public PatientProgram voidPatientProgram(PatientProgram patientProgram, String reason) throws APIException;
  330.  
  331. /**
  332. * Unvoids the given patientProgram
  333. *
  334. * @param patientProgram patientProgram to be un-voided
  335. * @return the voided PatientProgram
  336. * @throws APIException
  337. * @should void patient program when reason is valid
  338. */
  339. @Authorized( { PrivilegeConstants.DELETE_PATIENT_PROGRAMS })
  340. public PatientProgram unvoidPatientProgram(PatientProgram patientProgram) throws APIException;
  341.  
  342. /**
  343. * Get all possible outcome concepts for a program. Will return all concept answers
  344. * {@link org.openmrs.Concept#getAnswers()} if they exist, then all concept set members
  345. * {@link org.openmrs.Concept#getSetMembers()} if they exist, then empty List.
  346. *
  347. * @param programId
  348. * @return outcome concepts or empty List if none exist
  349. */
  350. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  351. public List<Concept> getPossibleOutcomes(Integer programId);
  352.  
  353. // **************************
  354. // CONCEPT STATE CONVERSION
  355. // **************************
  356.  
  357. /**
  358. * Get ProgramWorkflow by its UUID
  359. *
  360. * @param uuid
  361. * @return
  362. * @should find object given valid uuid
  363. * @should return null if no object found with given uuid
  364. */
  365. public ProgramWorkflow getWorkflowByUuid(String uuid);
  366.  
  367. /**
  368. * Save ConceptStateConversion to database (create if new or update if changed)
  369. *
  370. * @param conceptStateConversion - The ConceptStateConversion to save
  371. * @return ConceptStateConversion - The saved ConceptStateConversion
  372. * @throws APIException
  373. * @should save state conversion
  374. */
  375. @Authorized( { PrivilegeConstants.ADD_PATIENT_PROGRAMS, PrivilegeConstants.EDIT_PATIENT_PROGRAMS })
  376. public ConceptStateConversion saveConceptStateConversion(ConceptStateConversion conceptStateConversion)
  377. throws APIException;
  378.  
  379. /**
  380. * Returns a conceptStateConversion given that conceptStateConversions primary key
  381. * <code>conceptStateConversionId</code> A null value is returned if no conceptStateConversion
  382. * exists with this conceptStateConversionId.
  383. *
  384. * @param conceptStateConversionId integer primary key of the conceptStateConversion to find
  385. * @return ConceptStateConversion object that has
  386. * conceptStateConversion.conceptStateConversionId =
  387. * <code>conceptStateConversionId</code> passed in.
  388. * @throws APIException
  389. * @should return concept state conversion for given identifier
  390. */
  391. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  392. public ConceptStateConversion getConceptStateConversion(Integer conceptStateConversionId) throws APIException;
  393.  
  394. /**
  395. * Returns all conceptStateConversions
  396. *
  397. * @return List<ConceptStateConversion> of all ConceptStateConversions that exist
  398. * @throws APIException
  399. * @should return all concept state conversions
  400. */
  401. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  402. public List<ConceptStateConversion> getAllConceptStateConversions() throws APIException;
  403.  
  404. /**
  405. * Completely remove a conceptStateConversion from the database (not reversible) This method
  406. * delegates to #purgeConceptStateConversion(conceptStateConversion, boolean) method
  407. *
  408. * @param conceptStateConversion the ConceptStateConversion to clean out of the database.
  409. * @throws APIException
  410. */
  411. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  412. public void purgeConceptStateConversion(ConceptStateConversion conceptStateConversion) throws APIException;
  413.  
  414. /**
  415. * Completely remove a conceptStateConversion from the database (not reversible)
  416. *
  417. * @param conceptStateConversion the ConceptStateConversion to clean out of the database.
  418. * @param cascade <code>true</code> to delete related content
  419. * @throws APIException
  420. * @should cascade delete given concept state conversion when given cascade is true
  421. * @should not cascade delete given concept state conversion when given cascade is false
  422. */
  423. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  424. public void purgeConceptStateConversion(ConceptStateConversion conceptStateConversion, boolean cascade)
  425. throws APIException;
  426.  
  427. /**
  428. * Triggers any ConceptStateConversion that exists for the passed <code>reasonForExit</code>
  429. * concept and any ProgramWorkflow in the PatientPrograms for the <code>patient</code>
  430. *
  431. * @param patient - the Patient to trigger the ConceptStateConversion on
  432. * @param reasonForExit - the Concept to trigger the ConceptStateConversion
  433. * @param dateConverted - the Date of the ConceptStateConversion
  434. * @throws APIException
  435. * @should trigger state conversion successfully
  436. * @should fail if patient is invalid
  437. * @should fail if trigger is invalid
  438. * @should fail if date converted is invalid
  439. * @should skip past patient programs that are already completed
  440. */
  441. public void triggerStateConversion(Patient patient, Concept reasonForExit, Date dateConverted) throws APIException;
  442.  
  443. /**
  444. * Retrieves the ConceptStateConversion that matches the passed <code>ProgramWorkflow</code> and
  445. * <code>Concept</code>
  446. *
  447. * @param workflow - the ProgramWorkflow to check
  448. * @param trigger - the Concept to check
  449. * @return ConceptStateConversion that matches the passed <code>ProgramWorkflow</code> and
  450. * <code>Concept</code>
  451. * @throws APIException
  452. * @should return concept state conversion for given workflow and trigger
  453. */
  454. public ConceptStateConversion getConceptStateConversion(ProgramWorkflow workflow, Concept trigger) throws APIException;
  455.  
  456. // **************************
  457. // DEPRECATED PROGRAM
  458. // **************************
  459.  
  460. /**
  461. * Create a new program
  462. *
  463. * @param program Program to create
  464. * @throws APIException
  465. * @deprecated use {@link #saveProgram(Program)}
  466. */
  467. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  468. public void createOrUpdateProgram(Program program) throws APIException;
  469.  
  470. /**
  471. * Returns all programs, includes retired programs.
  472. *
  473. * @return List<Program> of all existing programs
  474. * @deprecated use {@link #getAllPrograms()}
  475. * @throws APIException
  476. */
  477. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  478. public List<Program> getPrograms() throws APIException;
  479.  
  480. // **************************
  481. // DEPRECATED PROGRAM WORKFLOW
  482. // **************************
  483.  
  484. /**
  485. * Create a new programWorkflow
  486. *
  487. * @param programWorkflow - The ProgramWorkflow to create
  488. * @deprecated use {@link Program#addWorkflow(ProgramWorkflow) followed by @link
  489. * #saveProgram(Program)}
  490. * @throws APIException
  491. */
  492. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  493. public void createWorkflow(ProgramWorkflow programWorkflow) throws APIException;
  494.  
  495. /**
  496. * Update a programWorkflow
  497. *
  498. * @param programWorkflow - The ProgramWorkflow to update
  499. * @deprecated use {@link #saveProgram(Program) to save changes to all ProgramWorkflows for the
  500. * given Program}
  501. * @throws APIException
  502. */
  503. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  504. public void updateWorkflow(ProgramWorkflow programWorkflow) throws APIException;
  505.  
  506. /**
  507. * Returns a programWorkflow given that programWorkflows primary key
  508. * <code>programWorkflowId</code>
  509. *
  510. * @param id integer primary key of the ProgramWorkflow to find
  511. * @return ProgramWorkflow object that has an id that matches the input parameter
  512. * @deprecated ProgramWorkflows should not be retrieved directly, but rather through the
  513. * programs they belong to: use {@link org.openmrs.Program#getWorkflows()}
  514. * @throws APIException
  515. */
  516. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  517. public ProgramWorkflow getWorkflow(Integer id) throws APIException;
  518.  
  519. /**
  520. * Returns a programWorkflow with the given name within the given Program
  521. *
  522. * @param program - The Program of the ProgramWorkflow to return
  523. * @param name - The name of the ProgramWorkflow to return
  524. * @return ProgramWorkflow - The ProgramWorkflow that matches the passed Program and name
  525. * @deprecated use {@link Program#getWorkflowByName(String)}
  526. * @throws APIException
  527. */
  528. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  529. public ProgramWorkflow getWorkflow(Program program, String name) throws APIException;
  530.  
  531. /**
  532. * Retires the given programWorkflow
  533. *
  534. * @param programWorkflow - The ProgramWorkflow to retire
  535. * @param reason - The reason for retiring the ProgramWorkflow
  536. * @deprecated use {@link ProgramWorkflow#setRetired(Boolean) followed by @link
  537. * #saveProgram(Program)}
  538. * @throws APIException
  539. */
  540. @Authorized( { PrivilegeConstants.MANAGE_PROGRAMS })
  541. public void voidWorkflow(ProgramWorkflow programWorkflow, String reason) throws APIException;
  542.  
  543. /**
  544. * Get a state by its uuid. There should be only one of these in the database. If multiple are
  545. * found, an error is thrown.
  546. *
  547. * @param uuid the universally unique identifier
  548. * @return the program workflow state which matches the given uuid
  549. * @should find object given valid uuid
  550. * @should return null if no object found with given uuid
  551. * @should return a state with the given uuid
  552. * @should throw an error when multiple states with same uuid are found
  553. */
  554. public ProgramWorkflowState getStateByUuid(String uuid);
  555.  
  556. /**
  557. * Returns all ProgramWorkflowStates
  558. *
  559. * @return List<ProgramWorkflowState> - all ProgramWorkflowStates that exist
  560. * @deprecated ProgramWorkflowStates should be retrieved from the {@link ProgramWorkflow} they
  561. * belong to
  562. * @see ProgramWorkflow#getStates()
  563. * @throws APIException
  564. */
  565. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  566. public List<ProgramWorkflowState> getStates() throws APIException;
  567.  
  568. /**
  569. * Returns all ProgramWorkflowStates
  570. *
  571. * @param includeVoided - if false, only returns non-voided ProgramWorkflowStates
  572. * @return List<ProgramWorkflowState> - all ProgramWorkflowStates that exist, including voided
  573. * based on the input parameter
  574. * @deprecated ProgramWorkflowStates should be retrieved from the {@link ProgramWorkflow} they
  575. * belong to
  576. * @see ProgramWorkflow#getStates(boolean)
  577. * @throws APIException
  578. */
  579. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  580. public List<ProgramWorkflowState> getStates(boolean includeVoided) throws APIException;
  581.  
  582. /**
  583. * Returns ProgramWorkflowState with the passed primary key id
  584. *
  585. * @param id - The primary key id of the ProgramWorkflowState to return
  586. * @return ProgramWorkflowState - returns ProgramWorkflowState whose primary key id matches the
  587. * passed id
  588. * @deprecated ProgramWorkflowStates should be retrieved from the {@link ProgramWorkflow} they
  589. * belong to
  590. * @see ProgramWorkflow#getState(Integer)
  591. * @throws APIException
  592. */
  593. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  594. public ProgramWorkflowState getState(Integer id) throws APIException;
  595.  
  596. /**
  597. * Returns ProgramWorkflowState with the passed <code>name</code> in the passed
  598. * <code>programWorkflow</code>
  599. *
  600. * @param programWorkflow - The programWorkflow to check for ProgramWorkflowState
  601. * @param name - the name of the programWorkflowState to look for
  602. * @return ProgramWorkflowState - the ProgramWorkflowState with the passed <code>name</code> in
  603. * the passed <code>programWorkflow</code>
  604. * @deprecated ProgramWorkflowStates should be retrieved from the {@link ProgramWorkflow} they
  605. * belong to
  606. * @see ProgramWorkflow#getStateByName(String)
  607. * @throws APIException
  608. */
  609. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  610. public ProgramWorkflowState getState(ProgramWorkflow programWorkflow, String name) throws APIException;
  611.  
  612. /**
  613. * Returns List of ProgramWorkflowStates that a patient is allowed to transition into given
  614. * their current program
  615. *
  616. * @param patientProgram - the PatientProgram to retrieve possible next transitions from
  617. * @param workflow - the ProgramWorkflow to retrieve possible next transitions from
  618. * @return List<ProgramWorkflowState> - returns List<ProgramWorkflowState> that a patient with
  619. * the given PatientProgram and ProgramWorkflow is allowed to transition into
  620. * @deprecated use {@link ProgramWorkflow#getPossibleNextStates(PatientProgram)}
  621. * @throws APIException
  622. */
  623. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  624. public List<ProgramWorkflowState> getPossibleNextStates(PatientProgram patientProgram, ProgramWorkflow workflow)
  625. throws APIException;
  626.  
  627. @Authorized( { PrivilegeConstants.DELETE_PROGRAMWORKFLOWSTATE })
  628. public void deleteProgramWorkflowState(ProgramWorkflowState state) throws APIException;
  629.  
  630. /**
  631. * Returns boolean indicating whether it is legal to transition from one ProgramWorkflowState to
  632. * another
  633. *
  634. * @param fromState - the ProgramWorkflowState to use as the state to check transitions from
  635. * @param toState - the ProgramWorkflowState to use as the state to check transitions into from
  636. * <code>fromState</code>
  637. * @return boolean - returns true if a legal transition exists from <code>fromState</code> to
  638. * <code>toState</code>
  639. * @deprecated use
  640. * {@link ProgramWorkflow#isLegalTransition(ProgramWorkflowState, ProgramWorkflowState)}
  641. * @throws APIException
  642. */
  643. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  644. public boolean isLegalTransition(ProgramWorkflowState fromState, ProgramWorkflowState toState) throws APIException;
  645.  
  646. // **************************
  647. // DEPRECATED PATIENT PROGRAM
  648. // **************************
  649.  
  650. /**
  651. * Create a new patientProgram
  652. *
  653. * @param patientProgram - The PatientProgram to create
  654. * @deprecated use {@link #savePatientProgram(PatientProgram)}
  655. * @throws APIException
  656. */
  657. @Authorized( { PrivilegeConstants.ADD_PATIENT_PROGRAMS })
  658. public void createPatientProgram(PatientProgram patientProgram) throws APIException;
  659.  
  660. /**
  661. * Update a patientProgram
  662. *
  663. * @param patientProgram - The PatientProgram to update
  664. * @deprecated use {@link #savePatientProgram(PatientProgram)}
  665. * @throws APIException
  666. */
  667. @Authorized( { PrivilegeConstants.EDIT_PATIENT_PROGRAMS })
  668. public void updatePatientProgram(PatientProgram patientProgram) throws APIException;
  669.  
  670. /**
  671. * Create a new PatientProgram
  672. *
  673. * @param patient - The Patient to enroll
  674. * @param program - The Program to enroll the <code>patient</code> into
  675. * @param enrollmentDate - The Date to use as the enrollment date in the <code>program</code>
  676. * for the <code>patient</code>
  677. * @param completionDate - The Date to use as the completion date in the <code>program</code>
  678. * for the <code>patient</code>
  679. * @param creator - The User who is enrolling this <code>patient</code>
  680. * @deprecated use {new PatientProgram(...) followed by @link
  681. * #savePatientProgram(PatientProgram)}
  682. * @throws APIException
  683. */
  684. @Authorized( { PrivilegeConstants.ADD_PATIENT_PROGRAMS })
  685. public void enrollPatientInProgram(Patient patient, Program program, Date enrollmentDate, Date completionDate,
  686. User creator) throws APIException;
  687.  
  688. /**
  689. * Returns a Collection<PatientProgram> of all PatientPrograms for the passed
  690. * <code>patient</code>
  691. *
  692. * @param patient - The Patient to retrieve all PatientPrograms for
  693. * @return Collection<PatientProgram> of all PatientPrograms for the passed <code>patient</code>
  694. * @deprecated use
  695. * {@link #getPatientPrograms(Patient, Program, Date, Date, Date, Date, boolean)}
  696. * @throws APIException
  697. */
  698. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  699. public Collection<PatientProgram> getPatientPrograms(Patient patient) throws APIException;
  700.  
  701. /**
  702. * Get Collection<Integer> of PatientIds for patients who are enrolled in program between
  703. * fromDate and toDate
  704. *
  705. * @param program - The Program to check for patient enrollment
  706. * @param fromDate - Used to check whether patients were enrolled in the <code>program</code> on
  707. * or after this Date
  708. * @param toDate - Used to check whether patients were enrolled in the <code>program</code> on
  709. * or before this Date
  710. * @return Collection<Integer> containing all patientIds for patients who were enrolled in the
  711. * <code>program</code> between <code>fromDate</code> and <code>toDate</code>
  712. * @deprecated use
  713. * {@link #getPatientPrograms(Patient, Program, Date, Date, Date, Date, boolean)}
  714. * which can be Iterated across to return collection of patient ids
  715. * @throws APIException
  716. */
  717. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  718. public Collection<Integer> patientsInProgram(Program program, Date fromDate, Date toDate) throws APIException;
  719.  
  720. /**
  721. * Get Collection of PatientPrograms for patients that are current as of the passed Date
  722. *
  723. * @param patient - The Patient to check for program enrollment
  724. * @param onDate - Specifies only to return programs that the patient is in as of this Date
  725. * @return Collection<PatientProgram> that contains all PatientPrograms are current for the
  726. * <code>patient</code> as of <code>onDate</code>
  727. * @deprecated use
  728. * {@link #getPatientPrograms(Patient, Program, Date, Date, Date, Date, boolean)}
  729. * @throws APIException
  730. */
  731. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  732. public Collection<PatientProgram> getCurrentPrograms(Patient patient, Date onDate) throws APIException;
  733.  
  734. /**
  735. * Return boolean indicating if Patient was enrolled into the Program between Date and Date
  736. *
  737. * @param patient - The Patient to check for enrollment
  738. * @param program - The Program to check for enrollment
  739. * @param fromDate - Used to check whether patients were enrolled in the <code>program</code> on
  740. * or after this Date
  741. * @param toDate - Used to check whether patients were enrolled in the <code>program</code> on
  742. * or before this Date
  743. * @return boolean - Returns true if the <code>patient</code> was enrolled in the
  744. * <code>program</code> between <code>fromDate</code> and <code>toDate</code>
  745. * @deprecated use
  746. * {@link #getPatientPrograms(Patient, Program, Date, Date, Date, Date, boolean)}
  747. * @throws APIException
  748. */
  749. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  750. public boolean isInProgram(Patient patient, Program program, Date fromDate, Date toDate) throws APIException;
  751.  
  752. // **************************
  753. // DEPRECATED PATIENT STATE
  754. // **************************
  755.  
  756. /**
  757. * Get a PatientState by patientStateId
  758. *
  759. * @see PatientProgram
  760. * @param patientStateId - The primary key id of the PatientState to return
  761. * @return The PatientState whose primary key id matches the input <code>patientStateId</code>
  762. * @deprecated use {@link PatientProgram#getPatientState(Integer)}
  763. * @throws APIException
  764. */
  765. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  766. public PatientState getPatientState(Integer patientStateId) throws APIException;
  767.  
  768. /**
  769. * Get the most recent PatientState for a given PatientProgram and ProgramWorkflow
  770. *
  771. * @param patientProgram - The PatientProgram whose states to check
  772. * @param programWorkflow - The ProgramWorkflow whose current state to check within the given
  773. * <code>patientProgram</code>
  774. * @return PatientState - The PatientState that is most recent for the
  775. * <code>programWorkflow</code> within the given <code>patientProgram</code>
  776. * @deprecated use {@link PatientProgram#getCurrentState(ProgramWorkflow)}
  777. * @throws APIException
  778. */
  779. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  780. public PatientState getLatestState(PatientProgram patientProgram, ProgramWorkflow programWorkflow) throws APIException;
  781.  
  782. /**
  783. * Returns a Set of current ProgramWorkflows for the given Patient
  784. *
  785. * @param patient - The Patient to check
  786. * @return Set<ProgramWorkflow> containing all of the current ProgramWorkflows for the
  787. * <code>patient</code>
  788. * @deprecated No current use outside of this service. Should be retrieved from Patient,
  789. * PatientProgram, and PatientState
  790. * @throws APIException
  791. */
  792. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  793. public Set<ProgramWorkflow> getCurrentWorkflowsByPatient(Patient patient) throws APIException;
  794.  
  795. /**
  796. * Returns a Set of current ProgramWorkflows for the given PatientProgram
  797. *
  798. * @param program - The PatientProgram to check
  799. * @return Set<ProgramWorkflow> containing all of the current ProgramWorkflows for the
  800. * <code>program</code>
  801. * @deprecated No current use outside of this service. Should be retrieved from Patient,
  802. * PatientProgram, and PatientState
  803. * @throws APIException
  804. */
  805. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  806. public Set<ProgramWorkflow> getCurrentWorkflowsByPatientProgram(PatientProgram program) throws APIException;
  807.  
  808. /**
  809. * Change the state of the passed PatientPrograms ProgramWorkflow to the passed
  810. * ProgramWorkflowState on the passed Date
  811. *
  812. * @param patientProgram - The PatientProgram whose state you wish to change
  813. * @param workflow - The ProgramWorkflow whose within the <code>patientProgram</code> whose
  814. * state you wish to change
  815. * @param state - The ProgramWorkflowState you wish to change the ProgramWorkflow to
  816. * @param onDate - The Date that you wish the State change to take place
  817. * @deprecated use {@link PatientProgram#transitionToState(ProgramWorkflowState, Date)}
  818. * @throws APIException
  819. */
  820. @Authorized( { PrivilegeConstants.ADD_PATIENT_PROGRAMS, PrivilegeConstants.EDIT_PATIENT_PROGRAMS })
  821. public void changeToState(PatientProgram patientProgram, ProgramWorkflow workflow, ProgramWorkflowState state,
  822. Date onDate) throws APIException;
  823.  
  824. /**
  825. * Get a patient program by its uuid. There should be only one of these in the database. If
  826. * multiple are found, an error is thrown.
  827. *
  828. * @param uuid the universally unique identifier
  829. * @return the patient program which matches the given uuid
  830. * @should find object given valid uuid
  831. * @should return null if no object found with given uuid
  832. * @should return a patient program with the given uuid
  833. * @should throw an error when multiple patient programs with same uuid are found
  834. */
  835. public PatientProgram getPatientProgramByUuid(String uuid);
  836.  
  837. /**
  838. * TODO: refactor?
  839. *
  840. * @param cohort
  841. * @param programs
  842. * @return List<PatientProgram> for all Patients in the given Cohort that are in the given
  843. * programs
  844. * @should return patient programs with patients in given cohort and programs
  845. * @should return patient programs with patients in given cohort
  846. * @should return patient programs with programs in given programs
  847. * @should return empty list when there is no match for given cohort and programs
  848. * @should not return null when there is no match for given cohort and program
  849. * @should not throw NullPointerException when given cohort and programs are null
  850. * @should not fail when given cohort is empty
  851. * @should not fail when given program is empty
  852. */
  853. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  854. public List<PatientProgram> getPatientPrograms(Cohort cohort, Collection<Program> programs);
  855.  
  856. /**
  857. * Terminatate the passed PatientPrograms ProgramWorkflow to the passed ProgramWorkflowState on
  858. * the passed Date
  859. *
  860. * @param patientProgram - The PatientProgram whose state you wish to change
  861. * @param finalState - The ProgramWorkflowState you wish to change the ProgramWorkflow to
  862. * @param terminatedOn - The Date that you wish the State change to take place
  863. * @deprecated use {@link PatientProgram#transitionToState(ProgramWorkflowState, Date)}
  864. * @throws APIException
  865. */
  866. @Authorized( { PrivilegeConstants.ADD_PATIENT_PROGRAMS, PrivilegeConstants.EDIT_PATIENT_PROGRAMS })
  867. public void terminatePatientProgram(PatientProgram patientProgram, ProgramWorkflowState finalState, Date terminatedOn);
  868.  
  869. /**
  870. * Voids the last non-voided ProgramWorkflowState in the given ProgramWorkflow for the given
  871. * PatientProgram, and clears the endDate of the next-to-last non-voided state.
  872. *
  873. * @param patientProgram - The patientProgram to check
  874. * @param wf - The ProgramWorkflow to check
  875. * @param voidReason - The reason for voiding
  876. * @deprecated use {@link PatientProgram#voidLastState(ProgramWorkflow, User, Date, String)}
  877. * @throws APIException
  878. */
  879. @Authorized( { PrivilegeConstants.EDIT_PATIENT_PROGRAMS })
  880. public void voidLastState(PatientProgram patientProgram, ProgramWorkflow wf, String voidReason) throws APIException;
  881.  
  882. /**
  883. * Returns a list of Programs that are using a particular concept.
  884. *
  885. * @param concept - The Concept being used.
  886. * @return - A List of Programs
  887. */
  888. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  889. public List<Program> getProgramsByConcept(Concept concept);
  890.  
  891. /**
  892. * Returns a list of ProgramWorkflows that are using a particular concept.
  893. *
  894. * @param concept - The Concept being used.
  895. * @return - A List of ProgramWorkflows
  896. */
  897. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  898. public List<ProgramWorkflow> getProgramWorkflowsByConcept(Concept concept);
  899.  
  900. /**
  901. * Returns a list of ProgramWorkflowStates that are using a particular concept.
  902. *
  903. * @param concept - The Concept being used.
  904. * @return - A List of ProgramWorkflowStates
  905. */
  906. @Authorized( { PrivilegeConstants.VIEW_PATIENT_PROGRAMS })
  907. public List<ProgramWorkflowState> getProgramWorkflowStatesByConcept(Concept concept);
  908.  
  909. // **************************
  910. // DEPRECATED CONCEPT STATE CONVERSION
  911. // **************************
  912.  
  913. /**
  914. * Create a new ConceptStateConversion
  915. *
  916. * @param conceptStateConversion - The ConceptStateConversion to create
  917. * @deprecated use {@link #saveConceptStateConversion(ConceptStateConversion)}
  918. * @throws APIException
  919. */
  920. @Authorized( { PrivilegeConstants.ADD_PATIENT_PROGRAMS })
  921. public void createConceptStateConversion(ConceptStateConversion conceptStateConversion) throws APIException;
  922.  
  923. /**
  924. * Update a ConceptStateConversion
  925. *
  926. * @param conceptStateConversion - The ConceptStateConversion to update
  927. * @deprecated use {@link #saveConceptStateConversion(ConceptStateConversion)}
  928. * @throws APIException
  929. */
  930. @Authorized( { PrivilegeConstants.EDIT_PATIENT_PROGRAMS })
  931. public void updateConceptStateConversion(ConceptStateConversion conceptStateConversion) throws APIException;
  932.  
  933. /**
  934. * Returns all conceptStateConversions, includes retired conceptStateConversions.
  935. *
  936. * @return List<ConceptStateConversion> of all ConceptStateConversions that exist, including
  937. * retired
  938. * @see #getAllConceptStateConversions()
  939. * @deprecated use {@link #getAllConceptStateConversions()}
  940. * @throws APIException
  941. */
  942. @Authorized( { PrivilegeConstants.VIEW_PROGRAMS })
  943. public List<ConceptStateConversion> getAllConversions() throws APIException;
  944.  
  945. /**
  946. * Delete a ConceptStateConversion
  947. *
  948. * @param csc - The ConceptStateConversion to delete from the database
  949. * @deprecated use {@link #purgeConceptStateConversion(ConceptStateConversion)}
  950. * @throws APIException
  951. */
  952. public void deleteConceptStateConversion(ConceptStateConversion csc) throws APIException;
  953.  
  954. /**
  955. * Get a concept state conversion by its uuid. There should be only one of these in the
  956. * database. If multiple are found, an error is thrown.
  957. *
  958. * @param uuid the universally unique identifier
  959. * @return the concept state conversion which matches the given uuid
  960. * @should find object given valid uuid
  961. * @should return null if no object found with given uuid
  962. * @should return a program state with the given uuid
  963. * @should throw an error when multiple program states with same uuid are found
  964. */
  965. public ConceptStateConversion getConceptStateConversionByUuid(String uuid);
  966. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement