Skip to content

Commit

Permalink
adding filter by POS
Browse files Browse the repository at this point in the history
  • Loading branch information
ashaban committed Jun 12, 2020
1 parent 7961b6e commit db951fb
Show file tree
Hide file tree
Showing 14 changed files with 422 additions and 308 deletions.
13 changes: 3 additions & 10 deletions server/config/decisionRules.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,27 @@
}
},
"rules": [{
"matchingType": "probabilistic",
"matchingType": "deterministic",
"fields": {
"given": {
"algorithm": "jaro-winkler-similarity",
"threshold": 0.8,
"mValue": 0.9172,
"uValue": 0.003628206379557255,
"fhirpath": "name.where(use='official').given",
"espath": "given"
},
"family": {
"algorithm": "damerau-levenshtein",
"threshold": 3,
"mValue": 0.9346,
"uValue": 0.0018975910650996456,
"fhirpath": "name.where(use='official').family",
"espath": "family"
},
"phone": {
"algorithm": "normalized-levenshtein-similarity",
"threshold": 0.8,
"mValue": 0.99,
"uValue": 0.00277670269535094,
"algorithm": "exact",
"fhirpath": "telecom.where(system='phone').value",
"espath": "phone"
}
},
"threshold": 102,
"threshold": 1,
"filters": {
"gender": {
"fhirpath": "gender",
Expand Down
26 changes: 17 additions & 9 deletions server/lib/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
/*global process, __dirname*/
const express = require('express');
const bodyParser = require('body-parser');
const moment = require('moment');
Expand All @@ -15,7 +16,6 @@ const fhirWrapper = require('./fhir')();
const medMatching = require('./medMatching')();
const esMatching = require('./esMatching');
const cacheFHIR = require('./tools/cacheFHIR');
const mixin = require('./mixin');
const logger = require('./winston');
const config = require('./config');
const mediatorConfig = require(`${__dirname}/../config/mediator`);
Expand Down Expand Up @@ -468,6 +468,14 @@ function appRoutes() {
logger.error('No client ID found, cant add patient');
return callback(true, responseBundle, operationSummary);
}
let clientName = '';
let clients = config.get('clients');
let clientDetails = clients.find((client) => {
return client.id === clientID;
});
if (clientDetails) {
clientName = clientDetails.displayName;
}
logger.info('Running match for system ' + clientID);

const addLinks = (patient, goldenRecord) => {
Expand Down Expand Up @@ -762,7 +770,7 @@ function appRoutes() {

// Tag this patient with an ID of the system that submitted
const tagExist = newPatient.resource.meta && newPatient.resource.meta.tag && newPatient.resource.meta.tag.find((tag) => {
return tag.code === 'clientid';
return tag.system === URI(config.get("systems:CRBaseURI")).segment('clientid').toString();
});
if (!tagExist) {
if (!newPatient.resource.meta) {
Expand All @@ -774,9 +782,9 @@ function appRoutes() {
newPatient.resource.meta.tag = [];
}
newPatient.resource.meta.tag.push({
system: clientID,
code: 'clientid',
display: clientID
system: URI(config.get("systems:CRBaseURI")).segment('clientid').toString(),
code: clientID,
display: clientName
});
}
const internalIdURI = config.get("systems:internalid:uri");
Expand Down Expand Up @@ -1056,13 +1064,13 @@ function appRoutes() {
return entry.resource.id === id1.split('/').pop();
});
const clientIdTag1 = resource1.resource.meta && resource1.resource.meta.tag && resource1.resource.meta.tag.find((tag) => {
return tag.code === 'clientid';
return tag.system === URI(config.get("systems:CRBaseURI")).segment('clientid').toString();
});
const resource2 = resourceData.entry.find((entry) => {
return entry.resource.id === id2.split('/').pop();
});
const clientIdTag2 = resource2.resource.meta && resource2.resource.meta.tag && resource2.resource.meta.tag.find((tag) => {
return tag.code === 'clientid';
return tag.system === URI(config.get("systems:CRBaseURI")).segment('clientid').toString();
});
if (!clientIdTag1) {
logger.error('Client ID tag is missing, unbreak match failed');
Expand Down Expand Up @@ -1147,10 +1155,10 @@ function appRoutes() {
logger.info('Rematching ' + entry.resource.id);
let clientID;
const clientIdTag = entry.resource.meta && entry.resource.meta.tag && entry.resource.meta.tag.find((tag) => {
return tag.code === 'clientid';
return tag.system === URI(config.get("systems:CRBaseURI")).segment('clientid').toString();
});
if (clientIdTag) {
clientID = clientIdTag.display;
clientID = clientIdTag.code;
}
if (clientID) {
const patientsBundle = {
Expand Down
1 change: 1 addition & 0 deletions server/lib/fhir.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
const request = require('request');
const URI = require('urijs');
const async = require('async');
Expand Down
2 changes: 2 additions & 0 deletions server/lib/mixin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';
/*global process, __dirname*/
const fs = require('fs');
const logger = require('./winston');
const config = require('./config');
Expand Down
2 changes: 1 addition & 1 deletion server/lib/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ router.post("/authenticate", function (req, res, next) {
if (!isJSON(body)) {
logger.error(options);
logger.error(body);
logger.error('Non JSON has been returned while getting data for resource ' + resource);
logger.error('Non JSON has been returned while getting user information for user ' + req.query.username);
return res.status(401).json(body);
}
body = JSON.parse(body);
Expand Down
23 changes: 6 additions & 17 deletions tests/sampleSinglePatient.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
"meta": {
"versionId": "2",
"lastUpdated": "2020-02-25T17:48:18.028+03:00",
"source": "#5YskPxdp2NQaRit7",
"tag": [{
"code": "clientid",
"display": "openmrs"
}]
"source": "#5YskPxdp2NQaRit7"
},
"identifier": [{
"type": {
Expand All @@ -19,26 +15,19 @@
}]
},
"system": "http://openmrs.org/openmrs2",
"value": "1110PJHHJJ"
"value": "gtcvdtrdr5"
}],
"name": [{
"use": "official",
"family": "Namalwa",
"family": "amalwa",
"given": [
"Emmanuel",
"Jakob"
"Emmmanuel"
]
}],
"gender": "male",
"birthDate": "2020-01-02",
"telecom": [{
"system": "phone",
"value": "774 232423"
}],
"link": [{
"other": {
"reference": "Patient/c20a8c2e-2e59-4f55-b0e3-78a43981aec0"
},
"type": "refer"
}]
"gender": "male",
"birthDate": "2020-01-02"
}
2 changes: 1 addition & 1 deletion ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ module.exports = {
// "plugin:vue/recommended"
// ],
// "rules": {}
// }
// }
47 changes: 31 additions & 16 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,53 @@
{{ $store.state.alert.msg }}
</v-alert>
</center>
<v-dialog
v-model="$store.state.progress.enable"
persistent
:width="$store.state.progress.width"
>
<v-card
color="primary"
dark
>
<v-card-text>
{{$store.state.progress.title}}
<v-progress-linear
indeterminate
color="white"
class="mb-0"
></v-progress-linear>
</v-card-text>
</v-card>
</v-dialog>
<router-view />
</v-content>
</v-app>
</template>

<script>
const backendServer = process.env.VUE_APP_BACKEND_SERVER;
import VueCookies from "vue-cookies";
import axios from "axios";
import { generalMixin } from "@/mixins/generalMixin";
export default {
name: "App",
data: () => ({
//
}),
mixins: [generalMixin],
created() {
if (VueCookies.get("token") && VueCookies.get("userID")) {
this.$store.state.auth.token = VueCookies.get("token");
this.$store.state.auth.userID = VueCookies.get("userID");
this.$store.state.auth.username = VueCookies.get("username");
axios.get("/ocrux/isTokenActive/").then(response => {
axios.get("/ocrux/isTokenActive/").then(() => {
this.$store.state.denyAccess = false;
axios.get("/ocrux/getURI").then((response) => {
this.$store.state.systemURI = response.data
}).catch((err) => {
console.log(err);
})
axios.get("/ocrux/getClients").then((response) => {
this.$store.state.clients = response.data
}).catch((err) => {
console.log(err);
})
axios
.get("/ocrux/getURI")
.then(response => {
this.$store.state.systemURI = response.data;
})
.catch(err => {
throw err;
});
this.getClients();
});
}
}
Expand Down
26 changes: 20 additions & 6 deletions ui/src/mixins/generalMixin.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
import axios from "axios";
export const generalMixin = {
methods: {
getClientDisplayName(clientid) {
let clientDet = this.$store.state.clients.find((client) => {
return client.id === clientid
})
if(clientDet) {
if (clientDet) {
return clientDet.displayName
}
return
},
getClients() {
axios
.get("/ocrux/getClients")
.then(response => {
this.$store.state.clients = response.data;
})
.catch(err => {
throw err;
});
},
getSystemURIDisplayName(systemURI) {
let name, id
for(let index in this.$store.state.systemURI) {
for (let index in this.$store.state.systemURI) {
let systemURIDet
if(Array.isArray(this.$store.state.systemURI[index].uri)) {
if (Array.isArray(this.$store.state.systemURI[index].uri)) {
systemURIDet = this.$store.state.systemURI[index].uri.find((uri) => {
return uri === systemURI
})
} else {
if(this.$store.state.systemURI[index].uri === systemURI) {
if (this.$store.state.systemURI[index].uri === systemURI) {
systemURIDet = systemURI
}
}
if(systemURIDet) {
if (systemURIDet) {
name = this.$store.state.systemURI[index].displayName
id = index
break;
}
}
return {name, id}
return {
name,
id
}
}
}
}
5 changes: 5 additions & 0 deletions ui/src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export const store = new Vuex.Store({
dismisible: true,
transition: 'scale-transition'
},
progress: {
enable: false,
width: "300",
title: ''
},
denyAccess: true,
dialogError: false,
errorTitle: '',
Expand Down
Loading

0 comments on commit db951fb

Please sign in to comment.