Find Patient by Fingerprint

Thanks @wyclif.

It returns a json object like {uuid:“0fe8824e-f9f8-42fa-a919-4d2dcdhha5da”} . Here is the server-side.

    	public SimpleObject searchForPatientByFingerPrint(
            @RequestParam(value = "datakey", required = false)String fingerPrintInBase64,
            @SpringBean("patientService") PatientService service,
            UiUtils ui){
    	//String patientSearchPageUrl = "http://localhost:8080/openmrs/coreapps/findpatient/findPatient.page?app=patients.findPatientByFingerprint";
    	String fingerPrintPersonAttributeTypeUUID = "0fe8824e-f9f8-42fa-a919-4d2dcd00a5da";
    	Patient searchedPatient = new Patient();
    	String uuid ="null";
    	 System.out.println("Server reached");
    	try{
    		Context.openSession();
            Context.authenticate("admin", "Admin123");
            

        	//search patient attribute: leftIndexFingerPrint
        	List<Patient> patients = Context.getPatientService().getAllPatients();
    		System.out.println("Number of Patients: "+patients.size());
        	
        	if(fingerPrintInBase64!= null){
        		for(Patient patientInstance : patients){
        			List<PersonAttribute> personAttributes = patientInstance.getActiveAttributes();
        			
        			for(PersonAttribute personAttribute: personAttributes){
        				System.out.println("Person Attribute: "+personAttribute.getValue());
        				
        					System.out.println("Person Attribute Type UUID: "+personAttribute.getAttributeType().getUuid());
        					if(personAttribute.getAttributeType().getUuid().equalsIgnoreCase(fingerPrintPersonAttributeTypeUUID)){
            					System.out.println("Person attributeType passed...");
            					//test if the base64 generated matches our stored base64 text
            					if(personAttribute.getValue() != null ){
            						System.out.println("Patient UUID: "+patientInstance.getUuid());
            						uuid = patientInstance.getUuid();
            						searchedPatient = patientInstance;
            						break;
            					}
            				}
        				
        			}//end person attribute loop
        
        			if(uuid!="null"){
        				break;
        			}
        		}//end patient loop
        	}
    	}catch(Exception e){
    		System.out.println(".......exception..................................................................");
    		e.getStackTrace();
    	}
    		finally{
    	
    		Context.closeSession();
    	}
    	String [] properties = {"uuid"};
    	SimpleObject simplePatientObject = SimpleObject.fromObject(searchedPatient, ui, properties);
    	
    	
    	return simplePatientObject;
    }

I will transferring these to a custom module. I wanted to become comfortable with the round-trip of pulling and pushing data using ajax+fragment controllers.

window.location is a variable and not a function, so you should just assign it a value, you should be using a relative URL by the way.

@wyclif

Thank you.

OpenMRS :1.11.7 UI Framework: 3.6

I have set the window.location as below, but no redirection takes place. window.location = “http://localhost:8080/openmrs/coreapps/clinicianfacing/patient.page?patientId=083c2982-ae98-4a29-9e89-322c97ccbb0d”;

You might want to confirm that your code gets to the line that assigns a value to window.location most likely it is broken and you’re not getting to that line. Please remember to use a relative URL, it’s good practice because different installations have different domain names and might use different ports.

@wyclif

You are right. I did that with @k_joseph . Line was broken. As of now, I have corrected. It is working.

<script type="text/javascript">
    jq = jQuery;
    
    
    
    jq(function() {
    jq('#testAjaxButton').click(function() {
		        jq.getJSON('${ ui.actionLink("searchForPatientByFingerPrint") }',
		            {
		              'datakey': 'searchForPatientByFingerPrint'
		              
		             
		            })
		        .success(function(data) {
		           
		            window.location=".../../coreapps/clinicianfacing/patient.page?patientId=" + data.uuid;
		            
				 
		        })
		        .error(function(xhr, status, err) {
		            alert('AJAX error ' + err);
		        })
		    });
		});
	
</script>  

Thank you all.

Hello,

I felt I should share the finished work here.

  1. openmrs ugandemr module: https://github.com/smuwanga/openmrs-module-ugandaemr-fingerprint.git
  2. openmrs ugandaemr applet: https://github.com/smuwanga/openmrs-module-aijar-finger-print-applet.git

Thanks all.

@carapai @k.joseph @slubwama @ssmusoke @burke @dkayiwa @wyclif

3 Likes

@smuwanga, thanks for sharing! I’d love to have a discussion around integrating fingerprint technology like this into OpenMRS at the conference next week. Is this something you’d be interested in? Will you be there?

Thanks, Mike

Hello @mseaton,

Yes, am very interested. I will be there. I look forward to hearing from you about this cause.

Simon.

thanks for the work @smuwanga

1 Like

@tendomart you are most welcome.

1 Like

Hi @mseaton @smuwanga

There are some problems attaching fingerprint device. Browsers don’t support applets much these days. I was dealing with the same problem few months ago, implementing finger print module with web application. I have ended up using a Small Swing App for Fingerprint authentication. Swing GUI send fingerprint data in server and server matches it in pre stored fingerprint. And another problem with Fingerprint SDK’s are not java based, they will be mostlikely C++.

I am planning to implement Swing Front End using rest API, so that I can use fingerprint/ Chip reader. The only problem is I am very new with openmrs. If I can team up with an experienced person I can do that easily.

@jaks80 is this the Swing UI you are discussing on the other thread?

No, This thread was for a fingerprint Module for Applet/Swing. This one is only for fingerprint which can not be achieved without using Swing. Applet is being deprecated and declared dead. So for fingerprint Swing is the only option.

Swing or any other language … the one that fits better with the fingerprint device.

C++/ Python could be another option. But mixing multiple language is another overhead for the project. JSF is another option without swing, But JSF community is not big yet and support is rare. Where swing community is big and lots of frameworks are already available.

And Javascript? I think you can build UIs in JS without requiring a browser.

1 Like

Hi Lluis, Shall we move on to the other thread for further discussion.

Hello all, i have install the figerprint module in my OpenMRS installation. Can anyone explain me how can i make it fonctional?

Wheni click on Scan right thumb i get this message in console

SEND destination:/calcApp/add content-length:61

{“finger”:5,“patient”:“5fa8c63a-8da8-4cb9-9b1a-55324bd2e65b”}

@slubwama @carapai is Clement using your module?

Not sure but I think he might have picked code from our repo