@@ -104,6 +104,7 @@ public class ContactCreateForm extends AbstractEditForm<ContactDto> {
104104 private Disease disease ;
105105 private final Boolean hasCaseRelation ;
106106 private final boolean asSourceContact ;
107+ private final boolean isPersonReadOnly ;
107108 private NullableOptionGroup contactCategory ;
108109 private TextField contactProximityDetails ;
109110
@@ -123,10 +124,19 @@ public class ContactCreateForm extends AbstractEditForm<ContactDto> {
123124 private final boolean showPersonSearchButton ;
124125 private Window warningSimilarPersons ;
125126
127+ public ContactCreateForm (Disease disease , boolean hasCaseRelation , boolean asSourceContact , boolean showPersonSearchButton ) {
128+ this (disease , hasCaseRelation , asSourceContact , showPersonSearchButton , false );
129+ }
130+
126131 /**
127132 * TODO use disease and case relation information given in ContactDto
128133 */
129- public ContactCreateForm (Disease disease , boolean hasCaseRelation , boolean asSourceContact , boolean showPersonSearchButton ) {
134+ public ContactCreateForm (
135+ Disease disease ,
136+ boolean hasCaseRelation ,
137+ boolean asSourceContact ,
138+ boolean showPersonSearchButton ,
139+ boolean isPersonReadOnly ) {
130140 super (
131141 ContactDto .class ,
132142 ContactDto .I18N_PREFIX ,
@@ -137,6 +147,7 @@ public ContactCreateForm(Disease disease, boolean hasCaseRelation, boolean asSou
137147 this .disease = disease ;
138148 this .hasCaseRelation = hasCaseRelation ;
139149 this .asSourceContact = asSourceContact ;
150+ this .isPersonReadOnly = isPersonReadOnly ;
140151 this .showPersonSearchButton = showPersonSearchButton ;
141152
142153 addFields ();
@@ -158,11 +169,18 @@ protected void addFields() {
158169 addField (ContactDto .DISEASE_DETAILS , TextField .class );
159170
160171 personCreateForm = new PersonCreateForm (false , false , false , showPersonSearchButton );
172+ if (isPersonReadOnly ) {
173+ personCreateForm .setPersonDetailsReadOnly ();
174+ }
161175 personCreateForm .setWidth (100 , Unit .PERCENTAGE );
162176 personCreateForm .setValue (new PersonDto ());
163177 getContent ().addComponent (personCreateForm , ContactDto .PERSON );
164178
165179 personCreateForm .getNationalHealthIdField ().addTextFieldValueChangeListener (e -> {
180+ // Only check if the health ID can be edited
181+ if (!personCreateForm .getNationalHealthIdField ().isEnabled ()) {
182+ return ;
183+ }
166184 warningSimilarPersons = PersonFormHelper
167185 .warningSimilarPersons (personCreateForm .getNationalHealthIdField ().getValue (), null , () -> warningSimilarPersons = null );
168186 });
@@ -406,10 +424,6 @@ public void setPerson(PersonDto person, boolean isNewPerson) {
406424 personCreateForm .setPerson (person , isNewPerson );
407425 }
408426
409- public void setPersonDetailsReadOnly () {
410- personCreateForm .setPersonDetailsReadOnly ();
411- }
412-
413427 public void setDiseaseReadOnly () {
414428 getField (CaseDataDto .DISEASE ).setEnabled (false );
415429 }
0 commit comments