=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java 2010-04-19 09:54:45 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java 2010-06-16 12:16:35 +0000 @@ -198,8 +198,15 @@ { for ( PatientIdentifierType identifierType : identifierTypes ) { - value = request.getParameter( PREFIX_IDENTIFIER + identifierType.getId() ); - + if(identifierType.getFormat().equals("State Format")) + { + value = organisationUnit.getCode()+request.getParameter( "progcode" )+request.getParameter( "yearcode" )+request.getParameter( "benicode" ); + System.out.println( "value = "+value ); + } + else + { + value = request.getParameter( PREFIX_IDENTIFIER + identifierType.getId() ); + } if ( StringUtils.isNotBlank( value ) ) { pIdentifier = new PatientIdentifier(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java 2010-04-05 12:33:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java 2010-06-16 12:16:35 +0000 @@ -100,6 +100,14 @@ private String systemIdentifier; + private String benicode; + + private String yearcode; + + private String progcode; + + private String orgunitcode; + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -126,6 +134,7 @@ if( representativeIdentifier.getIdentifierType() != null && representativeIdentifier.getIdentifierType().isRelated() ) { identiferMap.put( representativeIdentifier.getIdentifierType().getId(), representativeIdentifier.getIdentifier() ); + //System.out.println( "if patient uderage "+representativeIdentifier.getIdentifierType().getId()+ representativeIdentifier.getIdentifier() ); } } } @@ -136,6 +145,15 @@ if ( idType != null ) { identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() ); + //System.out.println( "if type is not null "+identifier.getIdentifierType().getId()+ identifier.getIdentifier() ); + if(idType.getFormat().equals("State Format")) + { + String iden = identifier.getIdentifier(); + benicode = iden.substring( 12,16 );//abcdefghi1121111 + yearcode = iden.substring( 10, 12 ); + progcode = iden.substring( 9, 10 ); + orgunitcode = iden.substring( 0, 9); + } } else systemIdentifier = identifier.getIdentifier(); @@ -269,4 +287,24 @@ { return systemIdentifier; } + + public String getBenicode() { + return benicode; + } + + public String getOrgunitcode() + { + return orgunitcode; + } + + public String getProgcode() + { + return progcode; + } + + public String getYearcode() + { + return yearcode; + } + } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java 2010-04-05 12:33:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java 2010-06-16 12:16:35 +0000 @@ -39,6 +39,10 @@ import org.hisp.dhis.patient.PatientIdentifierTypeService; import com.opensymphony.xwork2.Action; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import org.hisp.dhis.organisationunit.OrganisationUnit; /** * @author Abyot Asalefew Gizaw @@ -95,6 +99,12 @@ private Collection attributeGroups; private Collection identifierTypes; + + private OrganisationUnit organisationUnit; + + private String year; + + private boolean showMsg; // ------------------------------------------------------------------------- // Action implementation @@ -102,13 +112,29 @@ public String execute() { - + + showMsg = false; identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup(); attributeGroups = patientAttributeGroupService.getAllPatientAttributeGroups(); + organisationUnit = selectionManager.getSelectedOrganisationUnit(); + + for(PatientIdentifierType identifierType :identifierTypes) + { + if(identifierType.getFormat().equals("State Format") && identifierType.isMandatory()==true ) + { + if(organisationUnit.getCode()==null || organisationUnit.getCode().length() < 9) + showMsg = true; + } + } + //System.out.println( "ou = "+organisationUnit.getCode() + organisationUnit.getName()); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat dataFormat = new SimpleDateFormat("y"); + year = dataFormat.format(new Date()); return SUCCESS; } @@ -129,4 +155,17 @@ { return noGroupAttributes; } + public OrganisationUnit getOrganisationUnit() + { + return organisationUnit; + } + + public String getYear() { + return year; + } + + public boolean isShowMsg() { + return showMsg; + } + } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java 2010-04-05 12:33:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java 2010-06-16 12:16:35 +0000 @@ -181,7 +181,16 @@ { for ( PatientIdentifierType identifierType : identifierTypes ) { - value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + identifierType.getId() ); + if(identifierType.getFormat().equals("State Format")) + { + value = request.getParameter( "orgunitcode" )+request.getParameter( "progcode" )+request.getParameter( "yearcode" )+request.getParameter( "benicode" ); + //System.out.println( "value = "+value ); + } + else + { + value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + identifierType.getId() ); + } + //value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + identifierType.getId() ); if ( StringUtils.isNotBlank( value ) ) { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java 2010-04-19 09:54:45 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java 2010-06-16 12:16:35 +0000 @@ -279,6 +279,19 @@ for ( PatientIdentifierType idType : identifiers ) { // If underAge is TRUE : Only check duplicate on PatientIdentifierType which related is FALSE + /*if(idType.getFormat().equals("State Format")) + { + String orgUnitCodeValue = request.getParameter( "orgunitcode" ); + if(orgUnitCodeValue!=null) + { + System.out.println("orgUnitCodeValue = "+orgUnitCodeValue ); + if(orgUnitCodeValue.length()<9) + { + message = i18n.getString( "oucode_must_be_valid" ); + return INPUT; + } + } + }*/ if( !underAge || ( underAge && !idType.isRelated() ) ) { value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + idType.getId() ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2010-06-09 19:41:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2010-06-16 12:16:35 +0000 @@ -380,4 +380,5 @@ total_result = Total number of results no_of_pages = No. of pages size_of_page = Size of page -jump_to_page = Jump to page \ No newline at end of file +jump_to_page = Jump to page +oucode_must_be_valid = Please set valid 9 digit organisation unit code to add new patient \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm 2010-04-05 12:33:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm 2010-06-16 12:16:35 +0000 @@ -12,6 +12,10 @@ {validate:{required:true}} #end #end + +#if($showMsg == "true" ) +
$i18n.getString( "oucode_must_be_valid" )
+#else \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js 2010-05-17 02:59:28 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js 2010-06-16 12:16:35 +0000 @@ -262,7 +262,14 @@ } } +// ----------------------------------------------------------------------------- +// Disable form +// ----------------------------------------------------------------------------- +function disableForm() +{ + $('#firstName').attr("disabled", true); +} // ----------------------------------------------------------------------------- // Add Patient // ----------------------------------------------------------------------------- @@ -271,7 +278,7 @@ { var age = document.getElementById( 'age' ); - + var orgunitcode = document.getElementById('orgunitcode'); if( age.value != '' ) { if( !isInt( age.value ) ) @@ -282,7 +289,7 @@ return false; } - } + } var params = '&checkedDuplicate='+checkedDuplicate +'&firstName=' + getFieldValue( 'firstName' ) @@ -418,7 +425,7 @@ var fromList = document.getElementById(listId); - if ( fromList.selectedIndex == -1 ) { return; } + if ( fromList.selectedIndex == -1 ) {return;} if ( ! availableList ) { @@ -570,7 +577,7 @@ } jQuery("#thickboxContainer","#hiddenModalContent").html("").append(sPatient); if( !validate ) jQuery("#btnCreateNew","#hiddenModalContent").click(function(){window.parent.tb_remove();}); - else jQuery("#btnCreateNew","#hiddenModalContent").click(function(){window.parent.tb_remove();window.parent.checkedDuplicate = true; window.parent.validatePatient();}); + else jQuery("#btnCreateNew","#hiddenModalContent").click(function(){window.parent.tb_remove();window.parent.checkedDuplicate = true;window.parent.validatePatient();}); tb_show( message, "#TB_inline?height=500&width=500&inlineId=hiddenModalContent", null); } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm 2010-04-05 12:33:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm 2010-06-16 12:16:35 +0000 @@ -120,8 +120,14 @@ #set( $identifier = "" ) #set( $identifier = $identiferMap.get( $identifierType.id ) ) - - + + #if($identifierType.format == "State Format") + + #else + + #end + #end
+ ---