A common module has been developed to help developers with the patient generation part of their simulators. Indeed, some simulators require the creation and saving of patients. In order to save developers' time and to make this part of the simulators quite uniform, a small maven project named PatientGeneration has been developed.
This project is divided into two parts: a jar module and a war module.
EJB and WAR archives at available on Gazelle's Nexus release repository but if you need to check out the files, URL to use is https://scm.gforge.inria.fr/svn/gazelle/Maven/simulators/PatientGeneration/trunk
The PatientGeneration module calls SVSSimulator tool to get the display names for sex, race etc. Make sure you have a class annotated @MetaInfServices(PreferenceProvider.class) to retrieve the preferences of your application ; in particular, PatientGeneration will look for svs_repository_url.
Note that the given examples are extracted from PAMSimulator project that you can find on the INRIA's Forge at https://scm.gforge.inria.fr/svn/gazelle/Maven/simulators/PAMSimulator/trunk.
To use the PatientGeneration project, you first have to add the following Maven dependencies to your project.
pom parent:
<dependency> <groupId>net.ihe.gazelle.maven</groupId> <artifactId>PatientGeneration-ejb</artifactId> <version>${patientGeneratorVersion}</version> <type>ejb</type> </dependency> <dependency> <groupId>net.ihe.gazelle.maven</groupId> <artifactId>PatientGeneration-war</artifactId> <version>${patientGeneratorVersion}</version> <type>war</type> </dependency>
pom.xml of the EJB module:
<dependency> <groupId>net.ihe.gazelle.maven</groupId> <artifactId>PatientGeneration-ejb</artifactId> <type>ejb</type> </dependency>
pom.xml of the WAR module:
<dependency> <groupId>net.ihe.gazelle.maven</groupId> <artifactId>PatientGeneration-war</artifactId> <type>war</type> </dependency>
The method which generate the patient by calling DDS returns an AbstractPatient object. The AbstractPatient class is annotated with @Entity and @Inheritance(strategy = InheritanceType.SINGLE_TABLE), so that when you create an entity which extends this abstract class, data will be stored in pat_patient table. Your new entity requires a constructor which takes the AbstractPatient returned by the PatientGenerator bean as parameter, and the attributes of the abstract patients have to be copied into the attributes of your patient.
@Entity @DiscriminatorValue("my_app_patient") public class Patient extends AbstractPatient { public Patient() { } public Patient(AbstractPatient abPatient){ this.firstName = abPatient.getFirstName(); this.lastName = abPatient.getLastName(); this.motherMaidenName = abPatient.getMotherMaidenName(); this.city = abPatient.getCity(); this.state = abPatient.getState(); this.street = abPatient.getStreet(); this.countryCode = abPatient.getCountryCode(); this.zipCode = abPatient.getZipCode(); this.genderCode = abPatient.getGenderCode(); this.religionCode = abPatient.getReligionCode(); this.raceCode = abPatient.getRaceCode(); this.dateOfBirth = abPatient.getDateOfBirth(); this.creationDate = abPatient.getCreationDate(); this.nationalPatientIdentifier = abPatient.getNationalPatientIdentifier(); this.characterSet = abPatient.getCharacterSet(); this.ddsIdentifier = abPatient.getDdsIdentifier(); } }
You can notice that only the code (and not the display name) is stored for the race, the religion, and the gender. Actually, we only need the code because using the repository part of SVSSimulator we can retrieve the display name according to the language selected by the user (when the translation exists in SVS). If you take a look into the edit(show)AbstractPatientDemographic.xhtml files, you will see that a method is called for those properties instead of only displaying it. Those methods calls the SVSRepository. Concerning the country, only the code is stored too and the display name is retrieved from the JVM thanks to the Locale instance. That means that, by now, when you change one of those attributes, you need to give the code and not the display name. In the future, the repository will be used to display the list of available codes.
Then, when you write the java parts of your code, the java beans in which you need to generate a patient have to extend the PatientGenerator class from net.ihe.gazelle.patient package. If your bean is stateful and implements an interface annotated @Local, this interface is expected to extends PatientGeneratorLocal interface. When you will write the presentation part of your application, you will have to include /patient/patientGenerator.xhtml and add a button which calls a method which makes a call to generatePatient() from PatientGenerator.java to retrieve the AbstractPatient object.
See below an abstract from PAMSimulator.
@Name("creationManager") @Scope(ScopeType.PAGE) public class CreationManager extends PatientGenerator implements Serializable{ private Patient selectedPatient; public void generateAndSavePatient(){ AbstractPatient aPatient = generatePatient(); if (aPatient != null) { selectedPatient = new Patient(aPatient); } } }
Here is the presentation part.
<s:div id="ddsDiv"> <rich:panel id="ddsPanel" rendered="#{creationManager.displayDDSPanel}"> <f:facet name="header">Patient Generation with DDS</f:facet> <ui:include src="/patient/patientGenerator.xhtml"> <ui:param name="patientGeneratorBean" value="#{creationManager}" /> </ui:include> <a4j:commandButton id="generateButton" value="Generate patient" actionListener="#{creationManager.generateAndSavePatient()}" onclick="Richfaces.showModalPanel('panelLoading');" oncomplete="Richfaces.hideModalPanel('panelLoading');" styleClass="commandButton" reRender="selectedPatientDiv, ddsDiv, sendMessageButtonDiv"/> </rich:panel> </s:div>
When the patient is created, you can display or edit his/her informations using at least the XHTML files provided in the patient folder of PatientGeneration-war module. Those files need the patient object as a parameter, use <ui:param name="patient" value="#{yourPatient}"/>