Skip to content

Commit d0bbdcb

Browse files
authored
Migrate the module to use openmrs-contrib-maven-parent (#40)
1 parent 74a883c commit d0bbdcb

154 files changed

Lines changed: 6245 additions & 6436 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ concurrency:
1414
jobs:
1515
build:
1616
uses: openmrs/openmrs-contrib-gha-workflows/.github/workflows/build-backend-module.yml@main
17+
with:
18+
java_versions: '[8]'
1719
secrets:
1820
MAVEN_REPO_USERNAME: ${{ secrets.MAVEN_REPO_USERNAME }}
1921
MAVEN_REPO_API_KEY: ${{ secrets.MAVEN_REPO_API_KEY }}

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.openmrs.module</groupId>
77
<artifactId>xforms</artifactId>
8-
<version>4.3.19-SNAPSHOT</version>
8+
<version>5.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>xforms-api</artifactId>

api/src/main/java/org/openmrs/module/xforms/BasicFormBuilder.java

Lines changed: 78 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* This Source Code Form is subject to the terms of the Mozilla Public License,
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
@@ -30,53 +30,69 @@
3030
import org.openmrs.module.xforms.util.XformsUtil;
3131
import org.openmrs.util.OpenmrsConstants;
3232

33-
3433
/**
3534
* Builds the basic form.
3635
*/
3736
public class BasicFormBuilder {
3837

3938
private static final int FIELD_TYPE_CONCEPT = 1;
39+
4040
private static final int FIELD_TYPE_SECTION = 5;
41+
4142
private static final int FIELD_TYPE_DATABASE_ELEMENT = 2;
4243

4344
private static final String SECTION_NAME_PATIENT = "PATIENT";
45+
4446
private static final String SECTION_NAME_ENCOUNTER = "ENCOUNTER";
47+
4548
private static final String SECTION_NAME_OBS = "OBS";
4649

4750
private static final String TABLE_NAME_PATIENT_NAME = "patient_name";
51+
4852
private static final String TABLE_NAME_PATIENT = "patient";
53+
4954
private static final String TABLE_NAME_PATIENT_IDENTIFIER = "patient_identifier";
55+
5056
private static final String TABLE_NAME_ENCOUNTER = "encounter";
5157

5258
private static final String FIELD_FAMILY_NAME = "PATIENT.FAMILY_NAME";
59+
5360
private static final String FIELD_GIVEN_NAME = "PATIENT.GIVEN_NAME";
61+
5462
private static final String FIELD_MIDDLE_NAME = "PATIENT.MIDDLE_NAME";
63+
5564
private static final String FIELD_MEDICAL_RECORD_NUMBER = "PATIENT.MEDICAL_RECORD_NUMBER";
65+
5666
private static final String FIELD_PATIENT_ID = "PATIENT.PATIENT_ID";
67+
5768
private static final String FIELD_SEX = "PATIENT.SEX";
69+
5870
private static final String FIELD_BIRTHDATE = "PATIENT.BIRTHDATE";
71+
5972
private static final String FIELD_ENCOUNTER_DATETIME = "ENCOUNTER.ENCOUNTER_DATETIME";
73+
6074
private static final String FIELD_LOCATION_ID = "ENCOUNTER.LOCATION_ID";
75+
6176
private static final String FIELD_PROVIDER_ID = "ENCOUNTER.PROVIDER_ID";
6277

6378
private static final int CONCEPT_CLASS_MISC = 11;
79+
6480
private static final int CONCEPT_DATATYPE_NA = 4;
6581

6682
private static final String CONCEPT_NAME_MEDICAL_RECORD_OBSERVATIONS = "MEDICAL RECORD OBSERVATIONS";
6783

68-
69-
public static void addDefaultFields(Form form){
84+
public static void addDefaultFields(Form form) {
7085

7186
FormService formService = Context.getFormService();
7287

7388
//Add patient section.
7489
Field patientSection = getPatientSection(formService);
75-
FormField patientFormField = getNewFormField(); patientSection.toString();
90+
FormField patientFormField = getNewFormField();
91+
patientSection.toString();
7692
patientFormField.setField(patientSection);
7793
patientFormField.setFieldNumber(1);
7894
form.addFormField(patientFormField);
79-
95+
8096
//Add encounter section.
8197
Field encounterSection = getEncounterSection(formService);
8298
FormField encounterFormField = getNewFormField();
@@ -92,27 +108,36 @@ public static void addDefaultFields(Form form){
92108
form.addFormField(obsFormField);
93109

94110
//Add patient section fields.
95-
addDatabaseElementField(formService, form, FIELD_FAMILY_NAME, TABLE_NAME_PATIENT_NAME, "family_name", "$!{patient.getFamilyName()}", patientFormField);
96-
addDatabaseElementField(formService, form, FIELD_GIVEN_NAME, TABLE_NAME_PATIENT_NAME, "given_name", "$!{patient.getGivenName()}", patientFormField);
97-
addDatabaseElementField(formService, form, FIELD_MIDDLE_NAME, TABLE_NAME_PATIENT_NAME, "middle_name", "$!{patient.getMiddleName()}", patientFormField);
98-
addDatabaseElementField(formService, form, FIELD_BIRTHDATE, TABLE_NAME_PATIENT, "birthdate", "$!{date.format($patient.getBirthdate())}", patientFormField);
99-
addDatabaseElementField(formService, form, FIELD_SEX, TABLE_NAME_PATIENT, "gender", "$!{patient.getGender()}", patientFormField);
100-
addDatabaseElementField(formService, form, FIELD_PATIENT_ID, TABLE_NAME_PATIENT, "patient_id", "$!{patient.getPatientId()}", patientFormField);
101-
addDatabaseElementField(formService, form, FIELD_MEDICAL_RECORD_NUMBER, TABLE_NAME_PATIENT_IDENTIFIER, "identifier", "$!{patient.getPatientIdentifier(1).getIdentifier()}", patientFormField);
111+
addDatabaseElementField(formService, form, FIELD_FAMILY_NAME, TABLE_NAME_PATIENT_NAME, "family_name",
112+
"$!{patient.getFamilyName()}", patientFormField);
113+
addDatabaseElementField(formService, form, FIELD_GIVEN_NAME, TABLE_NAME_PATIENT_NAME, "given_name",
114+
"$!{patient.getGivenName()}", patientFormField);
115+
addDatabaseElementField(formService, form, FIELD_MIDDLE_NAME, TABLE_NAME_PATIENT_NAME, "middle_name",
116+
"$!{patient.getMiddleName()}", patientFormField);
117+
addDatabaseElementField(formService, form, FIELD_BIRTHDATE, TABLE_NAME_PATIENT, "birthdate",
118+
"$!{date.format($patient.getBirthdate())}", patientFormField);
119+
addDatabaseElementField(formService, form, FIELD_SEX, TABLE_NAME_PATIENT, "gender", "$!{patient.getGender()}",
120+
patientFormField);
121+
addDatabaseElementField(formService, form, FIELD_PATIENT_ID, TABLE_NAME_PATIENT, "patient_id",
122+
"$!{patient.getPatientId()}", patientFormField);
123+
addDatabaseElementField(formService, form, FIELD_MEDICAL_RECORD_NUMBER, TABLE_NAME_PATIENT_IDENTIFIER, "identifier",
124+
"$!{patient.getPatientIdentifier(1).getIdentifier()}", patientFormField);
102125

103126
//Add encounter section fields.
104-
addDatabaseElementField(formService, form, FIELD_ENCOUNTER_DATETIME, TABLE_NAME_ENCOUNTER, "encounter_datetime", null, encounterFormField);
105-
addDatabaseElementField(formService, form, FIELD_LOCATION_ID, TABLE_NAME_ENCOUNTER, "location_id", null, encounterFormField);
106-
addDatabaseElementField(formService, form, FIELD_PROVIDER_ID, TABLE_NAME_ENCOUNTER, "provider_id", null, encounterFormField);
107-
127+
addDatabaseElementField(formService, form, FIELD_ENCOUNTER_DATETIME, TABLE_NAME_ENCOUNTER, "encounter_datetime",
128+
null, encounterFormField);
129+
addDatabaseElementField(formService, form, FIELD_LOCATION_ID, TABLE_NAME_ENCOUNTER, "location_id", null,
130+
encounterFormField);
131+
addDatabaseElementField(formService, form, FIELD_PROVIDER_ID, TABLE_NAME_ENCOUNTER, "provider_id", null,
132+
encounterFormField);
108133

109134
//Finally save everything.
110135
formService.saveForm(form);
111136
}
112137

113-
private static Field getPatientSection(FormService formService){
138+
private static Field getPatientSection(FormService formService) {
114139
Field field = getField(formService, SECTION_NAME_PATIENT, FIELD_TYPE_SECTION);
115-
if(field == null){
140+
if (field == null) {
116141
field = getNewField();
117142
field.setName(SECTION_NAME_PATIENT);
118143
field.setFieldType(formService.getFieldType(FIELD_TYPE_SECTION));
@@ -122,9 +147,9 @@ private static Field getPatientSection(FormService formService){
122147
return field;
123148
}
124149

125-
private static Field getEncounterSection(FormService formService){
150+
private static Field getEncounterSection(FormService formService) {
126151
Field field = getField(formService, SECTION_NAME_ENCOUNTER, FIELD_TYPE_SECTION);
127-
if(field == null){
152+
if (field == null) {
128153
field = getNewField();
129154
field.setName(SECTION_NAME_ENCOUNTER);
130155
field.setFieldType(formService.getFieldType(FIELD_TYPE_SECTION));
@@ -134,20 +159,19 @@ private static Field getEncounterSection(FormService formService){
134159
return field;
135160
}
136161

137-
private static Field getObsSection(FormService formService){
162+
private static Field getObsSection(FormService formService) {
138163
Field field = getField(formService, SECTION_NAME_OBS, FIELD_TYPE_CONCEPT);
139-
if(field == null) {
164+
if (field == null) {
140165
field = getField(formService, SECTION_NAME_OBS, FIELD_TYPE_CONCEPT);
141166
}
142167

143-
if(field == null){
168+
if (field == null) {
144169
field = getNewField();
145170
field.setName(SECTION_NAME_OBS);
146171
field.setFieldType(formService.getFieldType(FIELD_TYPE_CONCEPT));
147172
field.setConcept(getObsSectionConcept());
148173
field.setDescription("Obs section of form");
149-
}
150-
else if (field.getConcept() == null) {
174+
} else if (field.getConcept() == null) {
151175
field.setConcept(getObsSectionConcept());
152176
}
153177

@@ -160,8 +184,9 @@ private static Concept getObsSectionConcept() {
160184
return concept;
161185
}
162186

163-
String conceptId = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS);
164-
if(conceptId != null && StringUtils.isNumeric(conceptId)) {
187+
String conceptId = Context.getAdministrationService()
188+
.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS);
189+
if (conceptId != null && StringUtils.isNumeric(conceptId)) {
165190
concept = Context.getConceptService().getConcept(Integer.parseInt(conceptId));
166191
if (concept != null) {
167192
return concept;
@@ -170,20 +195,22 @@ private static Concept getObsSectionConcept() {
170195

171196
concept = new Concept();
172197
concept.addName(new ConceptName(CONCEPT_NAME_MEDICAL_RECORD_OBSERVATIONS, Context.getLocale()));
173-
concept.addDescription(new ConceptDescription("General description for clinical observations entered into the system.", Context.getLocale()));
198+
concept.addDescription(new ConceptDescription(
199+
"General description for clinical observations entered into the system.", Context.getLocale()));
174200
concept.setConceptClass(new ConceptClass(CONCEPT_CLASS_MISC));
175201
concept.setDatatype(new ConceptDatatype(CONCEPT_DATATYPE_NA));
176202
concept = Context.getConceptService().saveConcept(concept);
177203

178-
GlobalProperty globalProperty = Context.getAdministrationService().getGlobalPropertyObject(OpenmrsConstants.GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS);
204+
GlobalProperty globalProperty = Context.getAdministrationService()
205+
.getGlobalPropertyObject(OpenmrsConstants.GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS);
179206

180207
if (globalProperty == null) {
181-
globalProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS,
182-
concept.getConceptId().toString(), "The concept id of the MEDICAL_RECORD_OBSERVATIONS concept. " +
183-
"This concept_id is presumed to be the generic grouping (obr) concept in hl7 messages. " +
184-
"An obs_group row is not created for this concept.");
185-
}
186-
else {
208+
globalProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS,
209+
concept.getConceptId().toString(),
210+
"The concept id of the MEDICAL_RECORD_OBSERVATIONS concept. "
211+
+ "This concept_id is presumed to be the generic grouping (obr) concept in hl7 messages. "
212+
+ "An obs_group row is not created for this concept.");
213+
} else {
187214
globalProperty.setPropertyValue(concept.getConceptId().toString());
188215
}
189216

@@ -192,13 +219,12 @@ private static Concept getObsSectionConcept() {
192219
return concept;
193220
}
194221

195-
private static Field getField(FormService formService, String name, int type){
222+
private static Field getField(FormService formService, String name, int type) {
196223
List<Field> fields = formService.getFields(name);
197-
if(fields != null){
198-
for(Field field : fields){
199-
if(field.getFieldType() != null &&
200-
field.getFieldType().getFieldTypeId() == type &&
201-
field.getName().equalsIgnoreCase(name)){
224+
if (fields != null) {
225+
for (Field field : fields) {
226+
if (field.getFieldType() != null && field.getFieldType().getFieldTypeId() == type
227+
&& field.getName().equalsIgnoreCase(name)) {
202228
return field;
203229
}
204230
}
@@ -207,9 +233,10 @@ private static Field getField(FormService formService, String name, int type){
207233
return null;
208234
}
209235

210-
private static void addDatabaseElementField(FormService formService, Form form, String name, String tableName, String attributeName, String defaultValue, FormField parentFormField){
236+
private static void addDatabaseElementField(FormService formService, Form form, String name, String tableName,
237+
String attributeName, String defaultValue, FormField parentFormField) {
211238
Field field = getField(formService, name, FIELD_TYPE_DATABASE_ELEMENT);
212-
if(field == null){
239+
if (field == null) {
213240
field = getNewField();
214241
field.setName(name);
215242
field.setFieldType(formService.getFieldType(FIELD_TYPE_DATABASE_ELEMENT));
@@ -224,7 +251,7 @@ private static void addDatabaseElementField(FormService formService, Form form,
224251
form.addFormField(formField);
225252
}
226253

227-
private static Field getNewField(){
254+
private static Field getNewField() {
228255
Field field = new Field();
229256
field.setUuid(UUID.randomUUID().toString());
230257
field.setCreator(Context.getAuthenticatedUser());
@@ -233,7 +260,7 @@ private static Field getNewField(){
233260
return field;
234261
}
235262

236-
private static FormField getNewFormField(){
263+
private static FormField getNewFormField() {
237264
FormField formField = new FormField();
238265
formField.setUuid(UUID.randomUUID().toString());
239266
formField.setCreator(Context.getAuthenticatedUser());
@@ -243,12 +270,13 @@ private static FormField getNewFormField(){
243270
return formField;
244271
}
245272

246-
public static String getFormXslt(){
273+
public static String getFormXslt() {
247274

248-
try{
275+
try {
249276
String fileName = XformsUtil.isOnePointNineAndAbove() ? "form_xslt.xml" : "form_xslt_pre19.xml";
250277
StringBuffer fileData = new StringBuffer(1000);
251-
BufferedReader reader = new BufferedReader(new InputStreamReader(BasicFormBuilder.class.getResourceAsStream(fileName), XformConstants.DEFAULT_CHARACTER_ENCODING));
278+
BufferedReader reader = new BufferedReader(new InputStreamReader(
279+
BasicFormBuilder.class.getResourceAsStream(fileName), XformConstants.DEFAULT_CHARACTER_ENCODING));
252280

253281
char[] buf = new char[1024];
254282
int numRead = 0;
@@ -260,7 +288,7 @@ public static String getFormXslt(){
260288
reader.close();
261289
return fileData.toString();
262290
}
263-
catch(Exception ex){
291+
catch (Exception ex) {
264292
ex.printStackTrace();
265293
}
266294

api/src/main/java/org/openmrs/module/xforms/DanielLuhnIdentifierValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* This Source Code Form is subject to the terms of the Mozilla Public License,
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
@@ -12,7 +12,7 @@
1212
import org.openmrs.patient.impl.LuhnIdentifierValidator;
1313

1414
public class DanielLuhnIdentifierValidator extends LuhnIdentifierValidator {
15-
15+
1616
/**
1717
* @see org.openmrs.patient.IdentifierValidator#getName()
1818
*/

api/src/main/java/org/openmrs/module/xforms/FormModuleHandler.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* This Source Code Form is subject to the terms of the Mozilla Public License,
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
@@ -12,22 +12,24 @@
1212
import org.openmrs.Form;
1313

1414
public class FormModuleHandler extends Form {
15-
15+
1616
private static final long serialVersionUID = 1L;
17-
17+
1818
private Form form;
19+
1920
private String moduleId;
21+
2022
private boolean appendModuleId;
21-
23+
2224
public FormModuleHandler(Form form, String moduleId) {
2325
this.form = form;
2426
this.moduleId = moduleId;
2527
}
26-
28+
2729
public String getName() {
2830
return form.getName() + (appendModuleId ? " - (" + moduleId + ")" : "");
2931
}
30-
32+
3133
public Integer getFormId() {
3234
return form.getFormId();
3335
}
@@ -39,19 +41,19 @@ public Boolean getPublished() {
3941
public Boolean getRetired() {
4042
return form.getRetired();
4143
}
42-
44+
4345
public boolean isAppendModuleId() {
4446
return appendModuleId;
4547
}
46-
48+
4749
public void setAppendModuleId(boolean appendModuleId) {
4850
this.appendModuleId = appendModuleId;
4951
}
50-
52+
5153
public Form getForm() {
5254
return form;
5355
}
54-
56+
5557
public void setForm(Form form) {
5658
this.form = form;
5759
}

0 commit comments

Comments
 (0)