@Test public void shouldCopyCreatorEditableField() throws Exception { final RegimenLineItem savedRegimenLineItem = make(a(defaultRegimenLineItem)); final RegimenLineItem regimenLineItem = make(a(defaultRegimenLineItem, with(patientsOnTreatment, 10), with(patientsStoppedTreatment, 10), with(patientsToInitiateTreatment, 20))); final RegimenColumn patientsOnTreatment = make(a(defaultRegimenColumn, with(RegimenColumnBuilder.name, "patientsOnTreatment"))); final RegimenColumn patientsStoppedTreatment = make(a(defaultRegimenColumn, with(RegimenColumnBuilder.name, "patientsStoppedTreatment"))); RegimenColumn patientsToInitiateTreatment = make(a(defaultRegimenColumn, with(RegimenColumnBuilder.name, "patientsToInitiateTreatment"))); RegimenColumn remarks = make(a(defaultRegimenColumn, with(RegimenColumnBuilder.name, "remarks"))); List<RegimenColumn> regimenColumns = asList(patientsOnTreatment, patientsStoppedTreatment, patientsToInitiateTreatment, remarks); savedRegimenLineItem.copyCreatorEditableFieldsForRegimen(regimenLineItem, new RegimenTemplate(1L, regimenColumns)); assertThat(savedRegimenLineItem.getCode(), is(regimenLineItem.getCode())); assertThat(savedRegimenLineItem.getPatientsOnTreatment(), is(regimenLineItem.getPatientsOnTreatment())); assertThat(savedRegimenLineItem.getPatientsOnTreatment(), is(regimenLineItem.getPatientsStoppedTreatment())); assertThat(savedRegimenLineItem.getPatientsToInitiateTreatment(), is(regimenLineItem.getPatientsToInitiateTreatment())); assertThat(savedRegimenLineItem.getRemarks(), is(regimenLineItem.getRemarks())); }
public void copyCreatorEditableFieldsForRegimen(RegimenLineItem regimenLineItem, RegimenTemplate regimenTemplate) { for (Column regimenColumn : regimenTemplate.getColumns()) { String fieldName = regimenColumn.getName(); if (regimenColumn.getVisible()) copyColumnData(fieldName, regimenLineItem); } }
RegimenLineItem extends LineItem { public void copyCreatorEditableFieldsForRegimen(RegimenLineItem regimenLineItem, RegimenTemplate regimenTemplate) { for (Column regimenColumn : regimenTemplate.getColumns()) { String fieldName = regimenColumn.getName(); if (regimenColumn.getVisible()) copyColumnData(fieldName, regimenLineItem); } } }
RegimenLineItem extends LineItem { public void copyCreatorEditableFieldsForRegimen(RegimenLineItem regimenLineItem, RegimenTemplate regimenTemplate) { for (Column regimenColumn : regimenTemplate.getColumns()) { String fieldName = regimenColumn.getName(); if (regimenColumn.getVisible()) copyColumnData(fieldName, regimenLineItem); } } RegimenLineItem(Long rnrId, RegimenCategory category, Long createdBy, Long modifiedBy); }
RegimenLineItem extends LineItem { public void copyCreatorEditableFieldsForRegimen(RegimenLineItem regimenLineItem, RegimenTemplate regimenTemplate) { for (Column regimenColumn : regimenTemplate.getColumns()) { String fieldName = regimenColumn.getName(); if (regimenColumn.getVisible()) copyColumnData(fieldName, regimenLineItem); } } RegimenLineItem(Long rnrId, RegimenCategory category, Long createdBy, Long modifiedBy); void setRegimenFieldsAccordingToTemplate(RegimenTemplate regimenTemplate); void copyCreatorEditableFieldsForRegimen(RegimenLineItem regimenLineItem, RegimenTemplate regimenTemplate); @Override boolean compareCategory(LineItem lineItem); @Override String getCategoryName(); @Override String getValue(String columnName); @Override boolean isRnrLineItem(); void validate(RegimenTemplate regimenTemplate); void populate(RegimenLineItem regimenLineItem); }
RegimenLineItem extends LineItem { public void copyCreatorEditableFieldsForRegimen(RegimenLineItem regimenLineItem, RegimenTemplate regimenTemplate) { for (Column regimenColumn : regimenTemplate.getColumns()) { String fieldName = regimenColumn.getName(); if (regimenColumn.getVisible()) copyColumnData(fieldName, regimenLineItem); } } RegimenLineItem(Long rnrId, RegimenCategory category, Long createdBy, Long modifiedBy); void setRegimenFieldsAccordingToTemplate(RegimenTemplate regimenTemplate); void copyCreatorEditableFieldsForRegimen(RegimenLineItem regimenLineItem, RegimenTemplate regimenTemplate); @Override boolean compareCategory(LineItem lineItem); @Override String getCategoryName(); @Override String getValue(String columnName); @Override boolean isRnrLineItem(); void validate(RegimenTemplate regimenTemplate); void populate(RegimenLineItem regimenLineItem); static final String ON_TREATMENT; static final String INITIATED_TREATMENT; static final String STOPPED_TREATMENT; static final String TYPE_NUMERIC; static final String REMARKS; }