Demonstration of using React and openmrs.js
💡 This is a small app hacked together in a group programming session during the Stripe Open-Source Retreat. You probably shouldn't use it for anything.
Clone the repository and then run npm install
to install all the dependencies.
Run npm start
to start the application on localhost:3001
.
The OpenMRS server details are as follows:
- Host: https://openmrs.psbrandt.io/openmrs
- User: admin
- Pass: Admin123
npm install openmrs.js
The web bundle will be at node_modules/openmrs.js/lib/openmrs.bundle.min.js
.
const o = new OpenMRS('https://openmrs.psbrandt.io/openmrs');
const deferred = o.login('admin', 'Admin123');
deferred.then(() => {
// do stuff
});
Notes
- Patient identifiers must be have a valid Luhn mod 30 check digit. See this example of how it's generated using
luhn-mod-n
.- Long
UUID
s should be used as-is.
const patient = {
"person": {
"names": [{
"givenName": "Nik",
"familyName": "Graf",
}],
"gender": "M",
},
"identifiers": [{
"identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334", // fixed value
"identifier": "9AW2N9PHC7WJ2FC7YLV", // valid Luhn mod 30 check digit
"location": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f", // fixed value
}]
};
o.api.patient.createPatient({
resource: patient,
}).then(() => {
// do more suff
}).catch((err) => {
console.log(err);
});
const patient = {
"person": {
"names": [{
"givenName": "Pascal",
"familyName": "Brandt",
}],
"gender": "M",
"birthdate": "1986-7-18",
"addresses": [{
"preferred": true,
"address1": "546 Awejug Park",
"cityVillage": "Cilbugaz",
"stateProvince": "MB",
"country": "Saint Lucia",
"postalCode": "41156",
}],
"attributes": [{
"attributeType": {
"uuid": "14d4f066-15f5-102d-96e4-000c29c2a5d7", // fixed value
},
"value": "(319) 498-9859",
}]
},
"identifiers": [{
"identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334", // fixed value
"identifier": "9AW2N9PHC7WJ2FC7YLV", // valid Luhn mod 30 check digit
"location": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f", // fixed value
}]
};
o.api.patient.createPatient({
resource: patient,
}).then(() => {
// do more suff
}).catch((err) => {
console.log(err);
});
o.api.patient.getAllPatients({
q: "Nik", // search query
v: "full",
}).then((results) => {
console.log(results.obj);
}).catch((err) => {
console.log(err);
});
- Static docs: https://psbrandt.io/openmrs-refapp-docker/
- Interactive docs: https://openmrs.psbrandt.io/openmrs/module/webservices/rest/apiDocs.htm