=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java 2013-09-27 17:04:23 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java 2013-10-25 05:00:41 +0000 @@ -30,10 +30,6 @@ import java.util.Collection; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.PeriodType; -import org.hisp.dhis.program.Program; - /** * @author Abyot Asalefew Gizaw * @version $Id$ @@ -76,7 +72,5 @@ Collection getPatientIdentifiers( Collection identifierTypes, Patient patient ); - - boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier, - Integer patientId, OrganisationUnit organisationUnit, Program program, PeriodType periodType ); + } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java 2013-09-27 17:04:23 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java 2013-10-25 05:00:41 +0000 @@ -28,12 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.Collection; + import org.hisp.dhis.common.GenericIdentifiableObjectStore; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.PeriodType; -import org.hisp.dhis.program.Program; - -import java.util.Collection; /** * @author Abyot Asalefew Gizaw @@ -74,7 +72,4 @@ Collection get( Collection identifierTypes, Patient patient ); - boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier, - Integer patientId, OrganisationUnit organisationUnit, Program program, PeriodType periodType ); - } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java 2013-09-27 17:04:23 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java 2013-10-25 05:00:41 +0000 @@ -28,13 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.PeriodType; -import org.hisp.dhis.program.Program; +import java.util.Collection; + import org.springframework.transaction.annotation.Transactional; -import java.util.Collection; - /** * @author Abyot Asalefew Gizaw * @version $Id$ @@ -143,12 +140,5 @@ { return patientIdentifierStore.get( identifierTypes, patient ); } - - @Override - public boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier, - Integer patientId, OrganisationUnit organisationUnit, Program program, PeriodType periodType ) - { - return patientIdentifierStore.checkDuplicateIdentifier( patientIdentifierType, identifier, patientId, organisationUnit, - program, periodType ); - } + } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2013-10-14 11:20:58 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2013-10-25 05:00:41 +0000 @@ -152,37 +152,4 @@ return getCriteria( Restrictions.in( "identifierType", identifierTypes ), Restrictions.eq( "patient", patient ) ) .list(); } - - public boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier, - Integer patientId, OrganisationUnit organisationUnit, Program program, PeriodType periodType ) - { - String sql = "select count(*) from patientidentifier pi inner join patient p on pi.patientid=p.patientid " - + "inner join programinstance pis on pis.patientid=pi.patientid where pi.patientidentifiertypeid=" - + patientIdentifierType.getId() + " and pi.identifier='" + identifier + "' "; - - if ( patientId != null ) - { - sql += " and pi.patientid!=" + patientId; - } - - if ( patientIdentifierType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) && organisationUnit != null ) - { - sql += " and p.organisationunitid=" + organisationUnit.getId(); - } - - if ( patientIdentifierType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) && program != null ) - { - sql += " and pis.programid=" + program.getId(); - } - - if ( patientIdentifierType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) && periodType != null ) - { - Date currentDate = new Date(); - Period period = periodType.createPeriod( currentDate ); - sql += " and pis.enrollmentdate >='" + period.getStartDateString() + "' and pis.enrollmentdate <='" - + DateUtils.getMediumDateString( period.getEndDate() ) + "'"; - } - - return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? false : true; - } } === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java 2013-10-24 08:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java 1970-01-01 00:00:00 +0000 @@ -1,484 +0,0 @@ -package org.hisp.dhis.caseentry.action.patient; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; -import java.util.Date; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; -import org.apache.struts2.ServletActionContext; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; -import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientAttribute; -import org.hisp.dhis.patient.PatientAttributeOption; -import org.hisp.dhis.patient.PatientAttributeOptionService; -import org.hisp.dhis.patient.PatientAttributeService; -import org.hisp.dhis.patient.PatientIdentifier; -import org.hisp.dhis.patient.PatientIdentifierService; -import org.hisp.dhis.patient.PatientIdentifierType; -import org.hisp.dhis.patient.PatientIdentifierTypeService; -import org.hisp.dhis.patient.PatientService; -import org.hisp.dhis.patient.util.PatientIdentifierGenerator; -import org.hisp.dhis.patientattributevalue.PatientAttributeValue; -import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; -import org.hisp.dhis.relationship.Relationship; -import org.hisp.dhis.relationship.RelationshipService; -import org.hisp.dhis.relationship.RelationshipType; -import org.hisp.dhis.relationship.RelationshipTypeService; -import org.hisp.dhis.setting.SystemSettingManager; -import org.hisp.dhis.user.UserService; - -import com.opensymphony.xwork2.Action; - -public class AddRelationshipPatientAction - implements Action -{ - public static final String PREFIX_ATTRIBUTE = "attr"; - - public static final String PREFIX_IDENTIFIER = "iden"; - - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private I18nFormat format; - - private PatientService patientService; - - private PatientIdentifierService patientIdentifierService; - - private PatientIdentifierTypeService patientIdentifierTypeService; - - private OrganisationUnitSelectionManager selectionManager; - - private PatientAttributeService patientAttributeService; - - private PatientAttributeValueService patientAttributeValueService; - - private PatientAttributeOptionService patientAttributeOptionService; - - private RelationshipService relationshipService; - - private RelationshipTypeService relationshipTypeService; - - private SystemSettingManager systemSettingManager; - - private UserService userService; - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private String fullName; - - private String birthDate; - - private Integer age; - - private Boolean verified; - - private String gender; - - private String[] phoneNumber; - - private String registrationDate; - - private boolean underAge; - - private Integer healthWorker; - - private boolean isDead; - - private String deathDate; - - private Integer relationshipId; - - private Integer relationshipTypeId; - - private boolean relationshipFromA; - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - public void setUserService( UserService userService ) - { - this.userService = userService; - } - - private Patient patient; - - public Patient getPatient() - { - return patient; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); - - patient = new Patient(); - - // --------------------------------------------------------------------- - // Set FullName - // --------------------------------------------------------------------- - - if ( fullName != null ) - { - fullName = fullName.trim(); - patient.setName( fullName ); - } - - // --------------------------------------------------------------------- - // Set Other information for patient - // --------------------------------------------------------------------- - - String phone = ""; - - for ( String _phoneNumber : phoneNumber ) - { - _phoneNumber = (_phoneNumber != null && _phoneNumber.isEmpty() && _phoneNumber.trim().equals( - systemSettingManager.getSystemSetting( SystemSettingManager.KEY_PHONE_NUMBER_AREA_CODE ) )) ? null - : _phoneNumber; - if ( _phoneNumber != null ) - { - phone += _phoneNumber + ";"; - } - } - - phone = (phone.isEmpty()) ? null : phone.substring( 0, phone.length() - 1 ); - - patient.setPhoneNumber( phone ); - patient.setGender( gender ); - patient.setIsDead( false ); - patient.setUnderAge( underAge ); - patient.setOrganisationUnit( organisationUnit ); - patient.setIsDead( isDead ); - if ( deathDate != null ) - { - deathDate = deathDate.trim(); - patient.setDeathDate( format.parseDate( deathDate ) ); - } - - if ( healthWorker != null ) - { - patient.setHealthWorker( userService.getUser( healthWorker ) ); - } - - Date _birthDate = new Date(); - if ( birthDate != null || age != null ) - { - verified = (verified == null) ? false : verified; - - Character dobType = (verified) ? Patient.DOB_TYPE_VERIFIED : Patient.DOB_TYPE_DECLARED; - - if ( !verified && age != null ) - { - dobType = 'A'; - } - - if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED ) - { - birthDate = birthDate.trim(); - patient.setBirthDate( format.parseDate( birthDate ) ); - } - else - { - patient.setBirthDateFromAge( age.intValue(), Patient.AGE_TYPE_YEAR ); - } - - _birthDate = patient.getBirthDate(); - patient.setDobType( dobType ); - } - - // ----------------------------------------------------------------------------- - // Registration Date - // ----------------------------------------------------------------------------- - - if ( registrationDate == null ) - { - patient.setRegistrationDate( new Date() ); - } - else - { - patient.setRegistrationDate( format.parseDate( registrationDate ) ); - } - - // --------------------------------------------------------------------- - // Generate system id with this format : - // (BirthDate)(Gender)(XXXXXX)(checkdigit) - // PatientIdentifierType will be null - // --------------------------------------------------------------------- - - String identifier = PatientIdentifierGenerator.getNewIdentifier( _birthDate, patient.getGender() ); - - PatientIdentifier systemGenerateIdentifier = patientIdentifierService.get( null, identifier ); - while ( systemGenerateIdentifier != null ) - { - identifier = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), patient.getGender() ); - systemGenerateIdentifier = patientIdentifierService.get( null, identifier ); - } - - systemGenerateIdentifier = new PatientIdentifier(); - systemGenerateIdentifier.setIdentifier( identifier ); - systemGenerateIdentifier.setPatient( patient ); - - patient.getIdentifiers().add( systemGenerateIdentifier ); - - // --------------------------------------------------------------------- - // Save Patient Identifiers - // --------------------------------------------------------------------- - - HttpServletRequest request = ServletActionContext.getRequest(); - - String value = null; - - Collection identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); - - PatientIdentifier pIdentifier = null; - - if ( identifierTypes != null && identifierTypes.size() > 0 ) - { - for ( PatientIdentifierType identifierType : identifierTypes ) - { - value = request.getParameter( PREFIX_IDENTIFIER + identifierType.getId() ); - - if ( StringUtils.isNotBlank( value ) ) - { - pIdentifier = new PatientIdentifier(); - pIdentifier.setIdentifierType( identifierType ); - pIdentifier.setPatient( patient ); - pIdentifier.setIdentifier( value.trim() ); - patient.getIdentifiers().add( pIdentifier ); - } - } - } - - patientService.savePatient( patient ); - - // Create relationship - - if ( relationshipId != null && relationshipTypeId != null ) - { - Patient relationship = patientService.getPatient( relationshipId ); - if ( relationship != null ) - { - if ( underAge ) - patient.setRepresentative( relationship ); - - Relationship rel = new Relationship(); - if ( relationshipFromA ) - { - rel.setPatientA( relationship ); - rel.setPatientB( patient ); - } - else - { - rel.setPatientA( patient ); - rel.setPatientB( relationship ); - } - if ( relationshipTypeId != null ) - { - RelationshipType relType = relationshipTypeService.getRelationshipType( relationshipTypeId ); - if ( relType != null ) - { - rel.setRelationshipType( relType ); - relationshipService.saveRelationship( rel ); - } - } - } - } - - // ----------------------------------------------------------------------------- - // Save Patient Attributes - // ----------------------------------------------------------------------------- - - Collection attributes = patientAttributeService.getAllPatientAttributes(); - - PatientAttributeValue attributeValue = null; - - if ( attributes != null && attributes.size() > 0 ) - { - for ( PatientAttribute attribute : attributes ) - { - value = request.getParameter( PREFIX_ATTRIBUTE + attribute.getId() ); - if ( StringUtils.isNotBlank( value ) ) - { - attributeValue = new PatientAttributeValue(); - attributeValue.setPatient( patient ); - attributeValue.setPatientAttribute( attribute ); - - if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - PatientAttributeOption option = patientAttributeOptionService - .get( NumberUtils.toInt( value, 0 ) ); - if ( option != null ) - { - attributeValue.setPatientAttributeOption( option ); - attributeValue.setValue( option.getName() ); - } - else - { - // Someone deleted this option ... - } - } - else - { - attributeValue.setValue( value.trim() ); - } - patientAttributeValueService.savePatientAttributeValue( attributeValue ); - } - } - } - - return SUCCESS; - } - - // ----------------------------------------------------------------------------- - // Getter/Setter - // ----------------------------------------------------------------------------- - - public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService ) - { - this.patientIdentifierTypeService = patientIdentifierTypeService; - } - - public void setRelationshipFromA( boolean relationshipFromA ) - { - this.relationshipFromA = relationshipFromA; - } - - public void setBirthDate( String birthDate ) - { - this.birthDate = birthDate; - } - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - - public void setPatientService( PatientService patientService ) - { - this.patientService = patientService; - } - - public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService ) - { - this.patientIdentifierService = patientIdentifierService; - } - - public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - - public void setPatientAttributeService( PatientAttributeService patientAttributeService ) - { - this.patientAttributeService = patientAttributeService; - } - - public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) - { - this.patientAttributeValueService = patientAttributeValueService; - } - - public void setFullName( String fullName ) - { - this.fullName = fullName; - } - - public void setAge( Integer age ) - { - this.age = age; - } - - public void setGender( String gender ) - { - this.gender = gender; - } - - public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService ) - { - this.patientAttributeOptionService = patientAttributeOptionService; - } - - public void setRelationshipTypeId( Integer relationshipTypeId ) - { - this.relationshipTypeId = relationshipTypeId; - } - - public void setRelationshipService( RelationshipService relationshipService ) - { - this.relationshipService = relationshipService; - } - - public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService ) - { - this.relationshipTypeService = relationshipTypeService; - } - - public void setUnderAge( boolean underAge ) - { - this.underAge = underAge; - } - - public void setRelationshipId( Integer relationshipId ) - { - this.relationshipId = relationshipId; - } - - public void setSystemSettingManager( SystemSettingManager systemSettingManager ) - { - this.systemSettingManager = systemSettingManager; - } - - public void setRegistrationDate( String registrationDate ) - { - this.registrationDate = registrationDate; - } - - public void setPhoneNumber( String[] phoneNumber ) - { - this.phoneNumber = phoneNumber; - } -} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java 2013-10-24 08:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java 2013-10-25 05:00:41 +0000 @@ -185,7 +185,7 @@ // --------------------------------------------------------------------- // Update enrollment-date and incident-date // --------------------------------------------------------------------- - + else { programInstance.setEnrollmentDate( enrollment ); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java 2013-09-27 17:04:23 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java 2013-10-25 05:00:41 +0000 @@ -51,6 +51,8 @@ import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.relationship.RelationshipType; +import org.hisp.dhis.relationship.RelationshipTypeService; import org.hisp.dhis.user.User; import com.opensymphony.xwork2.Action; @@ -115,6 +117,13 @@ this.attributeGroupService = attributeGroupService; } + private RelationshipTypeService relationshipTypeService; + + public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService ) + { + this.relationshipTypeService = relationshipTypeService; + } + private I18n i18n; public void setI18n( I18n i18n ) @@ -236,6 +245,20 @@ return relatedProgram; } + private boolean related; + + public void setRelated( boolean related ) + { + this.related = related; + } + + private Collection relationshipTypes; + + public Collection getRelationshipTypes() + { + return relationshipTypes; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -244,7 +267,7 @@ { organisationUnit = selectionManager.getSelectedOrganisationUnit(); healthWorkers = organisationUnit.getUsers(); - + if ( programId == null ) { patientRegistrationForm = patientRegistrationFormService.getCommonPatientRegistrationForm(); @@ -319,6 +342,11 @@ { relatedProgram = programService.getProgram( relatedProgramId ); } + + if(related) + { + relationshipTypes = relationshipTypeService.getAllRelationshipTypes(); + } return SUCCESS; } === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java 2013-09-27 11:13:20 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java 1970-01-01 00:00:00 +0000 @@ -1,279 +0,0 @@ -package org.hisp.dhis.caseentry.action.patient; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; -import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientAttribute; -import org.hisp.dhis.patient.PatientAttributeGroup; -import org.hisp.dhis.patient.PatientAttributeService; -import org.hisp.dhis.patient.PatientIdentifier; -import org.hisp.dhis.patient.PatientIdentifierType; -import org.hisp.dhis.patient.PatientIdentifierTypeService; -import org.hisp.dhis.patient.PatientService; -import org.hisp.dhis.patientattributevalue.PatientAttributeValue; -import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; -import org.hisp.dhis.program.Program; -import org.hisp.dhis.program.ProgramService; -import org.hisp.dhis.relationship.RelationshipType; -import org.hisp.dhis.relationship.RelationshipTypeService; -import org.hisp.dhis.user.User; - -import com.opensymphony.xwork2.Action; - -/** - * @author Viet - * - * @version $Id$ - */ -public class ShowAddRelationshipPatientAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private PatientService patientService; - - private PatientAttributeService patientAttributeService; - - private PatientIdentifierTypeService patientIdentifierTypeService; - - private RelationshipTypeService relationshipTypeService; - - private PatientAttributeValueService patientAttributeValueService; - - private ProgramService programService; - - private OrganisationUnitSelectionManager selectionManager; - - // ------------------------------------------------------------------------- - // Input/Output - // ------------------------------------------------------------------------- - - private Integer id; - - private Collection noGroupAttributes = new HashSet(); - - private Collection identifierTypes; - - private Collection relationshipTypes; - - private Patient patient; - - private Map identiferMap = new HashMap(); - - private Map attributeMap = new HashMap(); - - private Map> attributeGroupsMap = new HashMap>(); - - private Collection healthWorkers; - - private List programs; - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); - patient = patientService.getPatient( id ); - - identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); - Collection patientAttributes = patientAttributeService.getAllPatientAttributes(); - - programs = new ArrayList( programService.getProgramsByDisplayOnAllOrgunit( true, null ) ); - programs.addAll( programService.getProgramsByDisplayOnAllOrgunit( false, organisationUnit ) ); - programs.retainAll( programService.getProgramsByCurrentUser() ); - programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) ); - - for ( Program program : programs ) - { - identifierTypes.removeAll( program.getPatientIdentifierTypes() ); - patientAttributes.removeAll( program.getPatientAttributes() ); - } - - for ( PatientAttribute patientAttribute : patientAttributes ) - { - PatientAttributeGroup attributeGroup = patientAttribute.getPatientAttributeGroup(); - if ( attributeGroup != null ) - { - if ( attributeGroupsMap.containsKey( attributeGroup ) ) - { - Collection attributes = attributeGroupsMap.get( attributeGroup ); - attributes.add( patientAttribute ); - } - else - { - Collection attributes = new HashSet(); - attributes.add( patientAttribute ); - attributeGroupsMap.put( attributeGroup, attributes ); - } - } - else - { - noGroupAttributes.add( patientAttribute ); - } - } - - relationshipTypes = relationshipTypeService.getAllRelationshipTypes(); - - identiferMap = new HashMap(); - - for ( PatientIdentifier identifier : patient.getIdentifiers() ) - { - if ( identifier.getIdentifierType() != null ) - identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() ); - } - - // ------------------------------------------------------------------------- - // Get patient-attribute values - // ------------------------------------------------------------------------- - - Collection patientAttributeValues = patientAttributeValueService - .getPatientAttributeValues( patient ); - - for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) - { - if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute() - .getValueType() ) ) - { - attributeMap.put( patientAttributeValue.getPatientAttribute().getId(), patientAttributeValue - .getPatientAttributeOption().getName() ); - } - else - { - attributeMap - .put( patientAttributeValue.getPatientAttribute().getId(), patientAttributeValue.getValue() ); - } - } - - healthWorkers = organisationUnit.getUsers(); - - return SUCCESS; - } - - // ------------------------------------------------------------------------- - // Getter/Setter - // ------------------------------------------------------------------------- - - public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - - public List getPrograms() - { - return programs; - } - - public void setProgramService( ProgramService programService ) - { - this.programService = programService; - } - - public Collection getHealthWorkers() - { - return healthWorkers; - } - - public Map> getAttributeGroupsMap() - { - return attributeGroupsMap; - } - - public void setId( Integer id ) - { - this.id = id; - } - - public Collection getIdentifierTypes() - { - return identifierTypes; - } - - public Collection getNoGroupAttributes() - { - return noGroupAttributes; - } - - public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService ) - { - this.relationshipTypeService = relationshipTypeService; - } - - public Collection getRelationshipTypes() - { - return relationshipTypes; - } - - public Patient getPatient() - { - return patient; - } - - public Map getIdentiferMap() - { - return identiferMap; - } - - public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService ) - { - this.patientIdentifierTypeService = patientIdentifierTypeService; - } - - public void setPatientAttributeService( PatientAttributeService patientAttributeService ) - { - this.patientAttributeService = patientAttributeService; - } - - public void setPatientService( PatientService patientService ) - { - this.patientService = patientService; - } - - public Map getAttributeMap() - { - return attributeMap; - } - - public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) - { - this.patientAttributeValueService = patientAttributeValueService; - } -} === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java 2013-09-16 17:07:25 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java 1970-01-01 00:00:00 +0000 @@ -1,358 +0,0 @@ -package org.hisp.dhis.caseentry.action.patient; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.opensymphony.xwork2.Action; -import org.apache.commons.lang.StringUtils; -import org.apache.struts2.ServletActionContext; -import org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; -import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientIdentifier; -import org.hisp.dhis.patient.PatientIdentifierService; -import org.hisp.dhis.patient.PatientIdentifierType; -import org.hisp.dhis.patient.PatientIdentifierTypeService; -import org.hisp.dhis.patient.PatientService; -import org.hisp.dhis.patientattributevalue.PatientAttributeValue; -import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; - -import javax.servlet.http.HttpServletRequest; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -public class ValidateAddRelationshipPatientAction - implements Action -{ - public static final String PATIENT_DUPLICATE = "duplicate"; - - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private OrganisationUnitSelectionManager selectionManager; - - private I18nFormat format; - - private PatientService patientService; - - private PatientAttributeValueService patientAttributeValueService; - - private PatientIdentifierService patientIdentifierService; - - private PatientIdentifierTypeService identifierTypeService; - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private String fullName; - - private Character dobType; - - private String birthDate; - - private char ageType; - - private Integer age; - - private String gender; - - private Integer id; - - private boolean checkedDuplicate; - - private boolean underAge; - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private String message; - - private I18n i18n; - - private Patient patient; - - private Map patientAttributeValueMap = new HashMap(); - - private PatientIdentifier patientIdentifier; - - private Collection patients; - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - - Date dateOfBirth; - - if ( selectionManager.getSelectedOrganisationUnit() == null ) - { - message = i18n.getString( "please_select_a_registering_unit" ); - - return INPUT; - } - - if ( age == null && birthDate == null ) - { - message = i18n.getString( "specfiy_birth_date_or_age" ); - - return INPUT; - } - - if ( dobType == 'V' || dobType == 'D' ) - { - birthDate = birthDate.trim(); - - dateOfBirth = format.parseDate( birthDate ); - - if ( dateOfBirth == null || dateOfBirth.after( new Date() ) ) - { - message = i18n.getString( "please_enter_a_valid_birth_date" ); - - return INPUT; - } - } - - fullName = fullName.trim(); - - if ( fullName.indexOf( ' ' ) == -1 ) - { - message = i18n.getString( "please_enter_a_valid_full_name" ); - - return INPUT; - } - - // --------------------------------------------------------------------- - // Check duplicated patient - // --------------------------------------------------------------------- - - if ( !checkedDuplicate ) - { - // Check duplication name, birthdate, gender - patients = patientService.getPatients( fullName, format.parseDate( birthDate ), gender ); - - if ( patients != null && patients.size() > 0 ) - { - message = i18n.getString( "patient_duplicate" ); - boolean flagDuplicate = false; - - for ( Patient p : patients ) - { - if ( id == null || (id != null && p.getId() != id) ) - { - flagDuplicate = true; - Collection patientAttributeValues = patientAttributeValueService - .getPatientAttributeValues( p ); - - for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) - { - patientAttributeValueMap - .put( p.getId() + "_" + patientAttributeValue.getPatientAttribute().getId(), - patientAttributeValue.getValue() ); - } - } - } - if ( flagDuplicate ) - return PATIENT_DUPLICATE; - } - } - - // Check Identifiers duplicate - - Patient p = new Patient(); - if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED ) - { - birthDate = birthDate.trim(); - p.setBirthDate( format.parseDate( birthDate ) ); - } - else - { - p.setBirthDateFromAge( age, ageType ); - } - - HttpServletRequest request = ServletActionContext.getRequest(); - - Collection identifiers = identifierTypeService.getAllPatientIdentifierTypes(); - - if ( identifiers != null && identifiers.size() > 0 ) - { - String value; - String idDuplicate = ""; - - for ( PatientIdentifierType idType : identifiers ) - { - // If underAge is TRUE : Only check duplicate on - // PatientIdentifierType which related is FALSE - if ( !underAge || (underAge && !idType.isRelated()) ) - { - value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + idType.getId() ); - if ( StringUtils.isNotBlank( value ) ) - { - PatientIdentifier identifier = patientIdentifierService.get( idType, value ); - if ( identifier != null - && (id == null || identifier.getPatient().getId() != id) ) - { - idDuplicate += idType.getName() + ", "; - } - } - } - } - - if ( StringUtils.isNotBlank( idDuplicate ) ) - { - idDuplicate = StringUtils.substringBeforeLast( idDuplicate, "," ); - message = i18n.getString( "identifier_duplicate" ) + ": " + idDuplicate; - return INPUT; - } - } - - // --------------------------------------------------------------------- - // Validation success - // --------------------------------------------------------------------- - - message = i18n.getString( "everything_is_ok" ); - - return SUCCESS; - } - - // --------------------------------------------------------------------- - // Getter/Setter - // --------------------------------------------------------------------- - - public Collection getPatients() - { - return patients; - } - - public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService ) - { - this.identifierTypeService = identifierTypeService; - } - - public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService ) - { - this.patientIdentifierService = patientIdentifierService; - } - - public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - - public void setPatientService( PatientService patientService ) - { - this.patientService = patientService; - } - - public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) - { - this.patientAttributeValueService = patientAttributeValueService; - } - - public void setFullName( String fullName ) - { - this.fullName = fullName; - } - - public void setBirthDate( String birthDate ) - { - this.birthDate = birthDate; - } - - public void setAge( Integer age ) - { - this.age = age; - } - - public String getMessage() - { - return message; - } - - public void setI18n( I18n i18n ) - { - this.i18n = i18n; - } - - public Patient getPatient() - { - return patient; - } - - public Map getPatientAttributeValueMap() - { - return patientAttributeValueMap; - } - - public PatientIdentifier getPatientIdentifier() - { - return patientIdentifier; - } - - public void setId( Integer id ) - { - this.id = id; - } - - public void setCheckedDuplicate( boolean checkedDuplicate ) - { - this.checkedDuplicate = checkedDuplicate; - } - - public void setGender( String gender ) - { - this.gender = gender; - } - - public void setUnderAge( boolean underAge ) - { - this.underAge = underAge; - } - - public void setAgeType( char ageType ) - { - this.ageType = ageType; - } - - public void setDobType( Character dobType ) - { - this.dobType = dobType; - } -} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-10-24 08:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-10-25 05:00:41 +0000 @@ -180,7 +180,7 @@ int errorCode = patientService.validatePatient( patient, program ); - message = errorCode + " "; + message = errorCode + ""; return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java 2013-09-23 04:29:22 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java 2013-10-25 05:00:41 +0000 @@ -30,19 +30,19 @@ import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; import org.apache.struts2.ServletActionContext; -import org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientIdentifier; -import org.hisp.dhis.patient.PatientIdentifierService; import org.hisp.dhis.patient.PatientIdentifierType; import org.hisp.dhis.patient.PatientIdentifierTypeService; +import org.hisp.dhis.patient.PatientService; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; @@ -54,20 +54,16 @@ public class ValidatePatientIdentifierAction implements Action { - public static final String PATIENT_DUPLICATE = "duplicate"; - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- - private PatientIdentifierService patientIdentifierService; + private PatientService patientService; private PatientIdentifierTypeService identifierTypeService; private ProgramService programService; - private OrganisationUnitSelectionManager selectionManager; - // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -82,8 +78,6 @@ private String message; - private I18n i18n; - private Map patientAttributeValueMap = new HashMap(); private PatientIdentifier patientIdentifier; @@ -94,52 +88,44 @@ public String execute() { + Patient patient = patientService.getPatient( patientId ); + Program program = programService.getProgram( programId ); + HttpServletRequest request = ServletActionContext.getRequest(); - Collection identifiers = identifierTypeService.getAllPatientIdentifierTypes(); + Collection identifierTypes = identifierTypeService.getAllPatientIdentifierTypes(); - if ( identifiers != null && identifiers.size() > 0 ) + if ( identifierTypes != null && identifierTypes.size() > 0 ) { String value = null; - String idDuplicate = ""; - - for ( PatientIdentifierType idType : identifiers ) + + Set patientIdentifiers = new HashSet(); + + for ( PatientIdentifierType idType : identifierTypes ) { value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + idType.getId() ); - if ( StringUtils.isNotBlank( value ) ) { - boolean isDuplicate = false; - - OrganisationUnit orgunit = (idType.getOrgunitScope()) ? selectionManager - .getSelectedOrganisationUnit() : null; - - Program program = (idType.getProgramScope()) ? programService.getProgram( programId ) : null; - isDuplicate = patientIdentifierService.checkDuplicateIdentifier( idType, value, patientId, orgunit, - program, idType.getPeriodType() ); - - if ( isDuplicate ) - { - idDuplicate += idType.getName() + ", "; - } + PatientIdentifier patientIdentifier = new PatientIdentifier(); + patientIdentifier.setPatient( patient ); + patientIdentifier.setIdentifierType( idType ); + patientIdentifier.setIdentifier( value ); + + patientIdentifiers.add( patientIdentifier ); } - - } - - if ( StringUtils.isNotBlank( idDuplicate ) ) - { - idDuplicate = StringUtils.substringBeforeLast( idDuplicate, "," ); - message = i18n.getString( "identifier_duplicate" ) + ": " + idDuplicate; - return INPUT; - } + } + + patient.setIdentifiers( patientIdentifiers ); } + int errorCode = patientService.validatePatient( patient, program ); + // --------------------------------------------------------------------- // Validation success // --------------------------------------------------------------------- - message = i18n.getString( "everything_is_ok" ); + message = errorCode + ""; return SUCCESS; } @@ -168,26 +154,11 @@ this.identifierTypeService = identifierTypeService; } - public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService ) - { - this.patientIdentifierService = patientIdentifierService; - } - - public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - public String getMessage() { return message; } - public void setI18n( I18n i18n ) - { - this.i18n = i18n; - } - public Map getPatientAttributeValueMap() { return patientAttributeValueMap; @@ -198,4 +169,9 @@ return patientIdentifier; } + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-10-24 08:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-10-25 05:00:41 +0000 @@ -2,7 +2,7 @@ - + + + + - + @@ -599,15 +603,10 @@ id="org.hisp.dhis.caseentry.action.patient.ValidatePatientIdentifierAction" class="org.hisp.dhis.caseentry.action.patient.ValidatePatientIdentifierAction" scope="prototype"> - - - - + + - - - @@ -698,31 +697,6 @@ - - - - - - - - - - - - - - @@ -790,31 +764,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -824,25 +773,7 @@ - - - - - - - - - - - - - + - + F_PATIENT_ADD, F_RELATIONSHIP_ADD - - - /dhis-web-commons/ajax/xmlResponseSuccess.vm - - - /dhis-web-commons/ajax/xmlResponseError.vm - - - /dhis-web-commons/ajax/xmlResponseInput.vm - - - /dhis-web-caseentry/responseDuplicate.vm - - plainTextError - - - - - /dhis-web-commons/ajax/jsonResponseSuccess.vm - - F_RELATIONSHIP_ADD - -
- -#if($relatedProgram) - - - - -#else - - - -#end + #if($relatedProgram) + + + + + #elseif( $!relationshipTypes) + + + + + + + + #else + + + + #end + #parse( "/dhis-web-caseentry/patientForm.vm" ) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm 2013-09-23 03:15:40 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm 2013-10-25 05:00:41 +0000 @@ -18,7 +18,7 @@

» $i18n.getString( 'seach_available_patient' ) - • $i18n.getString( 'add_new_patient' ) + • $i18n.getString( 'add_new_patient' )

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipPatientForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipPatientForm.vm 2013-09-23 03:15:40 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipPatientForm.vm 1970-01-01 00:00:00 +0000 @@ -1,83 +0,0 @@ - - -
- $i18n.getString( 'patient_management' ) - • $i18n.getString( 'patient_dashboard' ) - • $i18n.getString( "relationship_management" ) -
-

- » $i18n.getString( 'seach_available_patient' ) - • $i18n.getString( 'add_new_patient' ) -

- - - - -
+ +
- - - - - - #parse( "/dhis-web-caseentry/patientForm.vm" ) - - - - - - -
- -

- - -
-
- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm 2013-10-24 08:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm 2013-10-25 05:00:41 +0000 @@ -74,10 +74,10 @@ #set($index=1) #foreach($option in $programStageDataElement.dataElement.optionSet.options) @@ -96,8 +96,7 @@
- $i18n.getString("non_value") + $i18n.getString("non_value")
#else - - #end + #end #elseif($programStageDataElement.dataElement.type=='username') #else === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-10-24 08:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-10-25 05:00:41 +0000 @@ -1700,7 +1700,7 @@ if( relationshipText != "") { - setInnerHTML('patientRelatedStageSpan',"• " + relationshipText + "
 "); + setInnerHTML('patientRelatedStageSpan',"• " + relationshipText + "
 "); } else { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2013-10-24 08:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2013-10-25 05:00:41 +0000 @@ -319,12 +319,13 @@ return false; } -function showAddPatientForm( programId, patientId, relatedProgramId ) +function showAddPatientForm( patientId, programId, relatedProgramId, related ) { hideById('listPatientDiv'); hideById('selectDiv'); hideById('searchDiv'); hideById('migrationPatientDiv'); + hideById('listRelationshipDiv'); setInnerHTML('addRelationshipDiv',''); setInnerHTML('patientDashboard',''); @@ -333,42 +334,19 @@ { programId: programId, patientId: patientId, - relatedProgramId: relatedProgramId + relatedProgramId: relatedProgramId, + related: related }, function() { showById('editPatientDiv'); + if(related){ + setFieldValue('relationshipId',patientId); + } jQuery('#loaderDiv').hide(); }); } -function addRelationship() -{ - jQuery('#loaderDiv').show(); - var params = getParamsForDiv('addRelationshipDiv'); - params += "&relationshipFromA=" + jQuery('#patientForm option:selected').attr("relationshipFromA"); - $.ajax({ - type: "POST", - url: 'addRelationshipPatient.action', - data: params, - success: function( json ) { - hideById('addRelationshipDiv'); - showById('selectDiv'); - showById('searchDiv'); - showById('listPatientDiv'); - jQuery('#loaderDiv').hide(); - - if( getFieldValue( 'isShowPatientList' ) == 'false' ){ - showRelationshipList( getFieldValue('relationshipId') ); - } - else{ - loadPatientList(); - } - }}); - return false; -} - - // ---------------------------------------------------------------- // Click Back to main form // ---------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js 2013-09-16 17:07:25 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js 2013-10-25 05:00:41 +0000 @@ -22,95 +22,6 @@ // Add Relationship Patient // ----------------------------------------------------------------------------- -function showAddRelationshipPatient( patientId, isShowPatientList, programStageInstanceId ) -{ - hideById( 'selectDiv' ); - hideById( 'searchDiv' ); - hideById( 'listPatientDiv' ); - hideById( 'listRelationshipDiv' ); - hideById( 'patientDashboard' ); - hideById( 'enrollmentDiv' ); - setInnerHTML('editPatientDiv', ''); - - jQuery('#loaderDiv').show(); - jQuery('#addRelationshipDiv').load('showAddRelationshipPatient.action', - { - id:patientId, - programStageInstanceId: programStageInstanceId - }, function() - { - showById('addRelationshipDiv'); - setFieldValue( 'isShowPatientList', isShowPatientList ); - jQuery('#loaderDiv').hide(); - }); -} - -function validateAddRelationshipPatient() -{ - $.ajax({ - type: "POST", - url: "validateAddRelationshipPatient.action", - data: getParamsForDiv('addRelationshipDiv'), - dataType: "xml", - success:addRelationshipPatientCompleted - }); - - return false; -} - -function addRelationshipPatientCompleted( messageElement ) -{ - messageElement = messageElement.getElementsByTagName( 'message' )[0]; - var type = messageElement.getAttribute( 'type' ); - var message = messageElement.firstChild.nodeValue; - - if ( type == 'success' ) - { - removeRelationshipDisabledIdentifier(); - addRelationshipPatient(); - } - else if ( type == 'error' ) - { - setHeaderMessage( i18n_adding_patient_failed + ':' + '\n' + message ); - } - else if ( type == 'input' ) - { - setHeaderMessage( message ); - } - else if( type == 'duplicate' ) - { - if( !checkedDuplicate ) - { - showListPatientDuplicate(messageElement, true); - } - } -} - -function addRelationshipPatient() -{ - jQuery('#loaderDiv').show(); - var params = getParamsForDiv('addRelationshipDiv'); - params += "&relationshipFromA=" + jQuery('#patientForm option:selected').attr("relationshipFromA"); - $.ajax({ - type: "POST", - url: 'addRelationshipPatient.action', - data: params, - success: function( json ) { - hideById('addRelationshipDiv'); - showById('selectDiv'); - showById('searchDiv'); - showById('listPatientDiv'); - jQuery('#loaderDiv').hide(); - - if( getFieldValue( 'isShowPatientList' ) == 'false' ){ - showRelationshipList( getFieldValue('relationshipId') ); - } - else{ - loadPatientList(); - } - }}); - return false; -} //remove value of all the disabled identifier fields //an identifier field is disabled when its value is inherited from another person ( underAge is true ) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm 2013-09-23 09:42:21 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm 2013-10-25 05:00:41 +0000 @@ -219,7 +219,7 @@

$i18n.getString("relationships") - #if( $auth.hasAccess( "dhis-web-caseentry", "showAddRelationshipPatient" ) ) + #if( $auth.hasAccess( "dhis-web-caseentry", "showRelationshipList" ) ) • $i18n.getString("add_relative")   #end === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm 2013-09-23 03:15:40 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm 2013-10-25 05:00:41 +0000 @@ -5,7 +5,7 @@

» $i18n.getString( 'seach_available_patient' ) - • $i18n.getString( 'add_new_patient' ) + • $i18n.getString( 'add_new_patient' )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2013-10-21 07:40:21 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2013-10-25 05:00:41 +0000 @@ -12,7 +12,7 @@ - + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm 2013-10-24 08:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm 2013-10-25 05:00:41 +0000 @@ -82,15 +82,14 @@ #elseif($hasOptionSet=='true') #if( $programStageDataElement.dataElement.optionSet.options.size() <= 7 && $program.dataEntryMethod =='false' ) - - #elseif( $programStageDataElement.dataElement.optionSet.options.size() <= 7 && $program.dataEntryMethod =='true' ) + #elseif( $programStageDataElement.dataElement.optionSet.options.size() <= 7 && $program.dataEntryMethod =='true' ) #set($index=1) #foreach($option in $programStageDataElement.dataElement.optionSet.options) @@ -109,10 +108,10 @@
- $i18n.getString("non_value") + $i18n.getString("non_value")
#else - + #end #elseif($programStageDataElement.dataElement.type=='username') - + #else ( programService.getAllPrograms() ); + programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) ); Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java 2013-09-27 17:04:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java 2013-10-25 05:00:41 +0000 @@ -207,7 +207,8 @@ availableAttributes.removeAll( new HashSet( program.getPatientAttributes() ) ); programs = new ArrayList( programService.getAllPrograms() ); - + programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) ); + for ( Program p : programs ) { availableIdentifierTypes