← Back to team overview

dhis2-users team mailing list archive

Re: Attribute value "Patient Code" from his "Name" and his "Year of birth" in Individual Records [2.20]

 

Dear Alex,



After customizing program form according to your advise below, attached the Source code that I write in the « design program entry form ».



Launching the Tracker Capture, the code fields doesn’t capture my fonction. Is there something wrong that i miss ?



Regards,



Harivola



De : Alex Tumwesigye [mailto:atumwesigye@xxxxxxxxx]
Envoyé : jeudi 20 août 2015 18:36
À : Harivola RANDRIANJAFY <harivolar@xxxxxx>
Cc : DHIS 2 Users list <dhis2-users@xxxxxxxxxxxxxxxxxxx>; dhis2-devs <dhis2-devs@xxxxxxxxxxxxxxxxxxx>
Objet : Re: [Dhis2-users] Attribute value "Patient Code" from his "Name" and his "Year of birth" in Individual Records [2.20]



Dear Harivola,



You will need a custom form with some JQuery/Javascript that splits the name and takes the first 3 letters in the name and the last two letters in year of birth and inserts into into the patient code fields.



For that to happen, the name and year of birth should be filled first, and on focus in the patient code, you need to call the script/function.



Alex



On Thu, Aug 20, 2015 at 1:55 PM, Harivola RANDRIANJAFY <harivolar@xxxxxx <mailto:harivolar@xxxxxx> > wrote:

Hi all,



In our program, we want to register the attribute patient code. Does someone know how to obtain automatic value in attribute « Patient Code » from his attribute « Name » and « Year of birth » instead of writing the value manually ?

Ex :

Name : SARAH

Year of birth : 1980

*  Patient Code : value should be "SAR80"



Thanks,



Harivola



  _____


 <https://www.avast.com/antivirus>

L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
www.avast.com <https://www.avast.com/antivirus>




_______________________________________________
Mailing list: https://launchpad.net/~dhis2-users
Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx <mailto:dhis2-users@xxxxxxxxxxxxxxxxxxx>
Unsubscribe : https://launchpad.net/~dhis2-users
More help   : https://help.launchpad.net/ListHelp







--

Alex Tumwesigye



Technical Advisor - DHIS2 (Consultant),
Ministry of Health/AFENET

Kampala

Uganda

IT Consultant - BarefootPower Uganda Ltd, SmartSolar, Kenya

IT Specialist (Servers, Networks and Security, Health Information Systems - DHIS2 ) & Solar Consultant

+256 774149 775, + 256 759 800161


"I don't want to be anything other than what I have been - one tree hill "



  _____


 <https://www.avast.com/antivirus>

L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
www.avast.com <https://www.avast.com/antivirus>





---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
<title>Patient register</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js";>
      </script><script type="text/javascript" language="javascript">
			   
			   function code_client(){
						var sName = $("input[attributeid='YxajNu1UcjP']").val().substr(0,3);
						var sFirstName = $("input[attributeid='a1uRlZkvPBf']").val().substr(0,2);
						var sBirthYear = $("input[attributeid='dyvfE1mwpUS']").val().substr(-2);
						var sBirthLoc = $("input[attributeid='SNDrOhwKPV7']").val().substr(0,2);
						var sSex = $("input[attributeid='St6mCYb6SQW']").val().substr(0,1);
						
						if (sName == "") { sName = "XXX"; }
						if (sFirstName == "") { sFirstName = "XX"; }
						if (sBirthLoc == "") { sBirthLoc = "XX"; }

						var sCode = sName;
						sCode = sCode + sFirstName;
						sCode = sCode + sBirthYear;
						sCode = sCode + sBirthLoc;
						sCode = sCode + sSex;
						
				   $("input[attributeid='gX08Z7KKeZj']").val(sCode) ;
				  
			   }
			   
			</script>
<table border="1" cellpadding="1" cellspacing="1" style="width:500px;">
	<tbody>
		<tr>
			<td>Nom</td>
			<td><input attributeid="YxajNu1UcjP" onchange="code_client();" title="Noms  * " value="[Noms  * ]" /></td>
		</tr>
		<tr>
			<td>Prenoms</td>
			<td><input attributeid="a1uRlZkvPBf" onchange="code_client();" title="Prénoms  * " value="[Prénoms * ]" /></td>
		</tr>
		<tr>
			<td>Ann&eacute;e de naissance</td>
			<td><input attributeid="dyvfE1mwpUS" onchange="code_client();" title="Année de naissance  * " value="[Année de naissance * ]" /></td>
		</tr>
		<tr>
			<td>Lieu de naissance</td>
			<td><input attributeid="SNDrOhwKPV7" onchange="code_client();" title="Lieu de naissance  * " value="[Lieu de naissance * ]" /></td>
		</tr>
		<tr>
			<td>Sexe</td>
			<td><input attributeid="St6mCYb6SQW" onchange="code_client();" title="Sexe  * " value="[Sexe * ]" /></td>
		</tr>
		<tr>
			<td>Client ID</td>
			<td><input attributeid="gX08Z7KKeZj" readonly="readonly" title="Client ID  * " value="" /></td>
		</tr>
	</tbody>
</table>

<p>&nbsp;</p>

References