Skip to content

Commit

Permalink
refactor: update printing of pme result
Browse files Browse the repository at this point in the history
  • Loading branch information
jofftiquez committed Sep 18, 2023
1 parent e377965 commit 2b29626
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/pages/pme/PrintReport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import {
export default {
setup () {
const route = useRoute();
const router = useRouter();
const userStore = useUserStore();
const currentUser = computed(() => userStore.$state.user);
const encounterId = route.params.encounter;
const loading = ref(false);
const encounter = ref({});
Expand All @@ -32,9 +36,11 @@ export default {
const encounterPatient = ref({});
const encounterDiagnosticOrders = ref([]);
const router = useRouter();
const userStore = useUserStore();
const currentUser = computed(() => userStore.$state.user);
// const apeReportValues = computed(() => encounterApeReport.value?.values || []);
const apeReportTemplateData = computed(() => encounterApeReport.value?.templateData);
// const apeReportTemplateDataItems = computed(() => encounterApeReport.value?.templateData?.items || []);
const selectedApeReportTemplate = computed(() => apeReportTemplateData?.value?.template);
const { TEMPLATE_TOKENS_MAP } = pmeHelper();
Expand All @@ -48,8 +54,18 @@ export default {
};
const templateWithValues = computed(() => {
const regex = /(?<=\{)\w+(?=\})/g;
let report = encounterApeReport.value?.report || '';
const values = encounterApeReport.value?.values || [];
const tokens = selectedApeReportTemplate.value?.match(regex) || [];
// const values = encounterApeReport.value?.values || [];
const values = tokens.map(token => {
const found = encounterApeReport.value?.values.find(value => value.id === token);
if (found) return found;
return {
id: token,
answer: '',
};
});
// UI Components
const medicalHistoryGroupRegex = new RegExp(UI_COMPONENT_GROUP_MEDICAL_RECORD_MEDICAL_HISTORY_ID, 'gi');
Expand Down Expand Up @@ -207,8 +223,6 @@ export default {
let answer = '';
console.warn('item', item.answer);
if (matchedToken?.dataSource === 'patient') {
answer = item.answer || matchedToken.format(dataSource?.value);
report = report.replace(`{${item.id}}`, answer);
Expand Down Expand Up @@ -243,7 +257,6 @@ export default {
encounterDiagnosticOrders.value = result.diagnosticOrders;
await fakeAwait(3000);
// await print();
window.focus();
window.print();
router.go(-1);
Expand Down

0 comments on commit 2b29626

Please sign in to comment.