How to edit OpenMRS source code to modify phone number validation and add new registration form?

Hey Everyone, I have downloaded OpenMRS-core source code from Github. I want to modify phone number validation in the patient registration module and create another form in the pharmacy module. How can I do that? How can I edit the source code guys?

@girma after cloning the source code from github, you can open it in your favourite IDE and make changes from there, also have a look at this tutorial,its a good guide for contributing and editing code in openmrs

1 Like

Thanks @gcliff.

@girma however I would add that it is very common to customize the registration process, and this only requires to configure your own registration app.

But the change that you intend to do in regards to changing the validation, that might be different, that might lead you to doing some dev work.

1 Like

Thanks @mksd. For example, I want to modify the phone number format and its character length. How can I do that?? Where can I get the source code to edit and deploy to see its effect?

@ruhanga, how easy is it to RegEx-validate the phone number in the Reg App? You might just know from the top of your head.

1 Like

@mksd, Yeah. I know it is so easy. But I don’t know where the source code is located. I am beginner for OpenMRS. Would you please suggest me a link that shows step by step instructions to edit the source code? I want to customize it for a clinic.

@mksd, @girma, we can achieve this by adding a regex config and class to the phone number field in a custom Reg App definition which may be derived from the existing one for example:

{
  "id": "refApp.registrationapp.registerPatient",
  "instanceOf": "registrationapp.registerPatient",
  "label": "Register Patient",
  "description": "Create a new Patient Record",
  "extensions": [
    {
      "id": "referenceapplication.registrationapp.registerPatient.homepageLink",
      "extensionPointId": "org.openmrs.referenceapplication.homepageLink",
      "type": "link",
      "label": "referenceapplication.app.registerPatient.label",
      "url": "registrationapp/registerPatient.page?appId=refApp.registrationapp.registerPatient",
      "icon": "icon-user",
      "order": 1,
      "requiredPrivilege": "App: registrationapp.registerPatient"
    }
  ],
  "config": {
    "afterCreatedUrl": "/coreapps/clinicianfacing/patient.page?patientId={{patientId}}",
    "sections": [
      {
        "id": "contactInfo",
        "label": "registrationapp.patient.contactInfo.label",
        "questions": [
          {
            "legend": "Person.address",
            "fields": [
              {
                "type": "personAddress",
                "label": "registrationapp.patient.address.question",
                "widget": {
                  "providerName": "uicommons",
                  "fragmentId": "field/personAddress"
                }
              }
            ]
          },
          {
            "legend": "registrationapp.patient.phone.label",
            "id": "phoneNumberLabel",
            "fields": [
              {
                "type": "personAttribute",
                "label": "registrationapp.patient.phone.question",
                "formFieldName": "phoneNumber",
                "uuid": "14d4f066-15f5-102d-96e4-000c29c2a5d7",
                "widget": {
                  "providerName": "uicommons",
                  "fragmentId": "field/text",
                  "config": {
                    "regex": "([(+]*[0-9]+[()+. -]*)"
                  }
                },
                "cssClasses": [
                  "regex"
                ]
              }
            ]
          }
        ]
      },
      {
        "id": "relationships-info",
        "label": "registrationapp.person.relationship",
        "questions": [
          {
            "legend": "registrationapp.person.relationship.label",
            "header": "registrationapp.person.relationship.question",
            "fields": [
              {
                "type": "personRelationships",
                "widget": {
                  "providerName": "registrationapp",
                  "fragmentId": "field/personRelationship"
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
2 Likes

@ruhanga, thank you! I will check it out!

1 Like