diff --git a/config/app_settings.json b/config/app_settings.json index be9bc61..706c2de 100644 --- a/config/app_settings.json +++ b/config/app_settings.json @@ -106,7 +106,7 @@ "intervation_admin", "health_care_worker", "treatment_support_officer", - "case_manager", + "case_manager", "clinical_admin" ], "can_export_forms": [ @@ -7563,10 +7563,10 @@ "contact_summary": "var ContactSummary = {}; !function(e,t){if('object'==typeof exports&&'object'==typeof module)module.exports=t();else if('function'==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)('object'==typeof exports?exports:e)[r]=n[r]}}(ContactSummary,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&'object'==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,'default',{enumerable:!0,value:e}),2&t&&'string'!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p='',n(n.s=0)}([function(e,t,n){var r=n(1),i=n(3);e.exports=i(r,contact,reports)},function(e,t,n){const{now:r,MS_IN_DAY:i,DAYS_IN_PNC:o,IMMUNIZATION_LIST:a,isCoveredByUseCaseInLineage:l,getTreatmentProgram:s,getNewestDelivery:c,getNewestPncPeriod:f,getDeliveryCode:u,isFacilityDelivery:p,getBirthDate:d,isHighRiskPostnatal:m,addImmunizations:_,getMostRecentNutritionEnrollment:h,isReportValid:g,countNutritionFollowups:v,isActivePregnancy:y,getSubsequentVisits:w,isHighRiskPregnancy:b,getSubsequentDeliveries:T,getOldestReport:P,getSubsequentPregnancies:I,getAgeInMonths:M,initImmunizations:x,isVaccineInLineage:C,isSingleDose:D,countDosesReceived:V,countDosesPossible:O,countReportsSubmittedInWindow:N,getMostRecentReport:A,getTreatmentEnrollmentDate:R,pregnancyForms:S,antenatalForms:F,postnatalForms:E,immunizationForms:H}=n(2);var k={use_cases:{anc:l(lineage,'anc'),pnc:l(lineage,'pnc'),imm:l(lineage,'imm'),gmp:l(lineage,'gmp')},treatment_program:s(),enrollment_date:R()},U=[{appliesToType:'person',label:'patient_id',value:contact.patient_id,width:4},{appliesToType:'person',label:'contact.age',value:contact.date_of_birth,width:4,filter:'age'},{appliesToType:'person',label:'Phone Number',value:contact.phone,width:4,filter:'phone'},{appliesToType:'person',label:'Notes',value:contact.notes,width:12},{appliesToType:'person',label:'contact.parent',value:lineage,filter:'lineage'},{appliesToType:'!person',label:'Notes',value:contact.notes,width:12},{appliesToType:'!person',appliesIf:function(){return contact.parent&&lineage[0]},label:'contact.parent',value:lineage,filter:'lineage'}],j=[{label:'contact.profile.pregnancy',appliesToType:'report',appliesIf:y,fields:[{label:'contact.profile.edd',value:function(e){return e.expected_date||e.fields.edd_8601},filter:'relativeDay',width:12},{label:'contact.profile.visit',value:'contact.profile.visits.of',translate:!0,context:{count:function(e){return w(e).length},total:4},width:6},{label:'contact.profile.risk.title',value:function(e){return b(e)?'contact.profile.risk.high':'contact.profile.risk.normal'},translate:!0,width:5,icon:function(e){return b(e)?'risk':''}}],modifyContext:function(e){e.pregnant=!0}},{label:'contact.profile.postnatal',appliesToType:'person',appliesIf:function(){if(k.use_cases.pnc){var e=f();return r>=e.start&&r<=e.end}},fields:[{label:function(){return'contact.profile.delivery_code.'+u(c())},value:function(){var e=c();return d(e).getTime()},filter:'relativeDay',width:12},{label:'contact.profile.pnc_visit',value:'contact.profile.visits.of',translate:!0,context:{count:function(){var e=c(),t=d(e),n=reports.filter((function(e){return('M'===e.form||'postnatal_visit'===e.form)&&e.reported_date>t.getTime()&&e.reported_date=0){if(0===(c=T(h)).length)return;if(e=P(c),t=d(e),f=I(h),(m=P(f))&&m.reported_date=0&&e.reported_date>h.reported_date&&e.reported_date=0&&e.reported_date>t.getTime()&&e.reported_datee.reported_date}))}function _(e){return reports.filter((function(t){return r.indexOf(t.form)>=0&&t.reported_date>e.reported_date}))}function h(){var e;if('person'===contact.type)return reports.forEach((function(t){a(t)&&('D'!==t.form&&'delivery'!==t.form||(!e||t.fields&&e.fields&&t.fields.date_of_birth>e.fields.date_of_birth)&&(e=t))})),e}function g(){var e={enrollment:null,exit:null},t=[];return reports.forEach((function(n){'nutrition_screening'!==n.form||n.deleted||e.enrollment&&!(n.reported_date>e.enrollment.reported_date&&'yes'===n.fields.treatment.enroll)||(e.enrollment=n),'nutrition_exit'===n.form&&t.push(n)})),e.enrollment&&(e.exit=t.find((function(t){return t.reported_date>e.enrollment.reported_date}))),e}e.exports={now:n,pregnancyForms:r,antenatalForms:['V','pregnancy_visit'],deliveryForms:i,postnatalForms:['M','postnatal_visit'],immunizationForms:['IMM','C_IMM','immunization_visit','PENTA1','PENTA2','PENTA3','BCG','OPV0','OPV1','OPV2','OPV3','IPV1','IPV2','IPV3','FIPV1','FIPV2','PCV1','PCV2','PCV3','PCV4','ROTA1','ROTA2','ROTA3','VITA','MMR1','MMR2','MMRV1','MMRV2','MN1','MN2','MN3','MN4','FLU','HA1','HA2','HB','JE','YF','TY1','TY2','HPV1','HPV2','HPV3','CH1','CH2','CH3','DPT4','DPT5'],MS_IN_DAY:864e5,MAX_DAYS_IN_PREGNANCY:308,DAYS_IN_PNC:45,IMMUNIZATION_DOSES:o,IMMUNIZATION_LIST:['bcg','cholera','hep_a','hep_b','hpv','ipv','fipv','flu','jap_enc','meningococcal','mmr','mmrv','polio','penta','pneumococcal','rotavirus','typhoid','vitamin_a','yellow_fever','dpt'],count:l,isVaccineInLineage:function(e,t){return e&&e.some((function(e){return e&&s(e.vaccines,t)}))},isCoveredByUseCaseInLineage:function(e,t){return e&&e.some((function(e){return e&&s(e.use_cases,t)}))},contains:s,isCoveredByUseCase:c,isFacilityDelivery:function(e){return e&&e.fields&&e.fields.delivery_code&&'f'===e.fields.delivery_code.toLowerCase()},isNonFacilityDelivery:f,getBirthDate:u,isReportValid:a,getPNCperiod:p,isHighRiskPregnancy:function(e){return'pregnancy'===e.form&&e.fields&&(e.fields.risk_factors||e.fields.danger_signs)||reports.some((function(t){return a(t)&&t.reported_date>e.reported_date&&t.reported_date<=d(e.reported_date,308).getTime()&&('F'===t.form.toUpperCase()||'pregnancy_visit'===t.form&&t.fields&&t.fields.danger_signs)}))},isHighRiskPostnatal:function(e){return e&&e.start&&e.end&&reports.some((function(t){return a(t)&&(f(t)||'F'===t.form.toUpperCase()&&t.reported_date>=e.end.getTime()&&t.reported_date<=e.end.getTime()||'postnatal_visit'===t.form&&t.fields&&(t.fields.danger_signs_mom||t.fields.danger_signs_baby))}))},getDeliveryCode:function(e){return(e&&e.fields&&(e.fields.group_note&&e.fields.group_note.default_chw_sms||e.fields.delivery_code)||'unknown').toLowerCase().replace('anc_only_','')},initImmunizations:function(){var e={};return o.forEach((function(t){e[t[0]]=!1})),e},addImmunizations:function(e,t){o.forEach((function(n){e[n[0]]||(e[n[0]]='string'==typeof t?t.toUpperCase()===n[1]:'yes'===t['received_'+n[0]])}))},countDosesReceived:function(e,t){return l(o,(function(n){return e[n[0]]&&0===n[0].indexOf(t+'_')}))},countDosesPossible:function(e){return l(o,(function(t){return 0===t[0].indexOf(e+'_')}))},isSingleDose:function(e){return o.some((function(t){return t[0]===e}))},countReportsSubmittedInWindow:function(e,t){return l(reports,(function(n){return n.reported_date<=t&&-1!==e.indexOf(n.form)}))},addDate:d,getOldestReport:function(e){var t;return e.forEach((function(e){a(e)&&(!t||e.reported_datee.reported_date}))},getTreatmentEnrollmentDate:function(){var e='',t=g().enrollment;if(t){var n=new Date(0);n.setUTCSeconds(t.reported_date/1e3),e=n.toISOString().slice(0,10)}return e},getTreatmentProgram:function(){var e='',t=g().enrollment,n=g().exit;return t&&!n&&(e=t.fields.treatment.program),e},countNutritionFollowups:function(){var e=0,t=g().enrollment;return reports.forEach((function(n){'nutrition_followup'===n.form&&n.reported_date>t.reported_date&&(e+=1)})),e},getMostRecentReport:function(e,t){var n=null;return e.forEach((function(e){t.indexOf(e.form)>=0&&!e.deleted&&(!n||e.reported_date>n.reported_date)&&(n=e)})),n},getMostRecentNutritionEnrollment:g}},function(e,t){function n(e){return e?Array.isArray(e)?e:[e]:[]}function r(e,t){switch(typeof e){case'undefined':return!0;case'function':return e(t);default:return e}}function i(e,t,n){if(r(e.appliesIf,n)){var i='function'==typeof e.fields?e.fields(n):e.fields.filter((function(e){return r(e.appliesIf,n)})).map((function(e){var t={};return o(e,t,'label'),o(e,t,'value'),o(e,t,'translate'),o(e,t,'filter'),o(e,t,'width'),o(e,t,'icon'),e.context&&(t.context={},o(e.context,t.context,'count'),o(e.context,t.context,'total')),t}));return e.modifyContext&&e.modifyContext(t,n),{label:e.label,fields:i}}function o(e,t,r){switch(typeof e[r]){case'undefined':return;case'function':t[r]=e[r](n);break;default:t[r]=e[r]}}}e.exports=function(e,t,r){var o=e.fields||[],a=e.context||{},l=e.cards||[],s=t&&('contact'===t.type?t.contact_type:t.type),c={cards:[],fields:o.filter((function(e){var t=n(e.appliesToType),r=t.filter((function(e){return e&&'!'===e.charAt(0)}));if((0===t.length||t.includes(s)||r.length>0&&!r.includes('!'+s))&&(!e.appliesIf||e.appliesIf()))return delete e.appliesToType,delete e.appliesIf,!0}))};return l.forEach((function(e){var t,o,l,f,u=n(e.appliesToType);if(u.includes('report')&&u.length>1)throw new Error('You cannot set appliesToType to an array which includes the type \\'report\\' and another type.');if(u.includes('report'))for(t=0;t0)return;(l=i(e,a))&&c.cards.push(l)}})),c.context=a,c}}])})); return ContactSummary;", "multi_report_alerts": [], "sms": { - "outgoing_service": "rapidpro", - "rapidpro": { - "url": "https://textit.com/" - } + "outgoing_service": "rapidpro", + "rapidpro": { + "url": "https://textit.com/" + } }, "contact_types": [ { diff --git a/config/forms/app/care.xlsx b/config/forms/app/care.xlsx index 9cdce04..0d11aea 100644 Binary files a/config/forms/app/care.xlsx and b/config/forms/app/care.xlsx differ diff --git a/config/forms/app/care.xml b/config/forms/app/care.xml index 9850647..7571516 100644 --- a/config/forms/app/care.xml +++ b/config/forms/app/care.xml @@ -30,6 +30,8 @@ + + @@ -61,6 +63,8 @@ + + diff --git a/config/tasks.js b/config/tasks.js index 4e60898..0c28c92 100644 --- a/config/tasks.js +++ b/config/tasks.js @@ -16,6 +16,27 @@ const { } = require('./nools-extras'); module.exports = [ + { + name: 'care-assessment-task', + title: 'Level of care assessment task', + icon: 'immunization', + appliesTo: 'contacts', + appliesToType: ['person'], + appliesIf: c => c.contact.role ==='patient' && !c.contact.date_of_death && !c.contact.muted, + actions: [{ form: 'care', }], + events: [{ + start: 0, + days: 0, + end: 5, + }], + resolvedIf: function(c, r, event, dueDate) { + // Resolved if there is care received in time window + return isFormFromArraySubmittedInWindow(c.reports, 'care', + Utils.addDate(dueDate, -event.start).getTime(), + Utils.addDate(dueDate, event.end+1).getTime()); + }, + }, + { name: 'pregnancy_danger_sign', icon: 'mother-child',