Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task:Add Level of care assessment task #33

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions config/app_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"intervation_admin",
"health_care_worker",
"treatment_support_officer",
"case_manager",
"case_manager",
"clinical_admin"
],
"can_export_forms": [
Expand Down Expand Up @@ -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<t.getTime()+(o+1)*i})).length;return p(e)&&n++,n},total:4},width:6},{label:'contact.profile.risk.title',value:function(){var e=f();return m(e)?'contact.profile.risk.high':'contact.profile.risk.normal'},translate:!0,width:5,icon:function(){var e=f();return m(e)?'risk':''}}],modifyContext:function(e){e.in_pnc_period=!0}},{label:'contact.profile.past_pregnancies',appliesToType:'person',appliesIf:c,fields:function(){var e,t,n,r,a,s,c,f,m,_=[];return reports.forEach((function(h){if(g(h)&&S.indexOf(h.form)>=0){if(0===(c=T(h)).length)return;if(e=P(c),t=d(e),f=I(h),(m=P(f))&&m.reported_date<e.reported_date)return;n=reports.filter((function(e){return F.indexOf(e.form)>=0&&e.reported_date>h.reported_date&&e.reported_date<t.getTime()+i})),r=reports.filter((function(e){return E.indexOf(e.form)>=0&&e.reported_date>t.getTime()&&e.reported_date<t.getTime()+(o+1)*i})),a=n.length,s=r.length,p(e)&&s++,_.push({label:'contact.profile.delivery_code.'+u(e),value:t,filter:'relativeDay',width:6},{label:'contact.profile.anc_visit',value:'contact.profile.visits.of',translate:!0,context:{count:a,total:4},width:3}),l(lineage,'pnc')&&_.push({label:'contact.profile.pnc_visit',value:'contact.profile.visits.of',translate:!0,context:{count:s,total:4},width:3})}})),_}},{label:'contact.profile.immunizations',appliesToType:'person',appliesIf:function(){return k.use_cases.imm&&M()<144},fields:function(){var e,t,n=x();for(e=0;e<reports.length;++e)'immunization_visit'===(t=reports[e]).form?t&&t.fields&&t.fields.vaccines_received&&_(n,t.fields.vaccines_received):'C_IMM'===t.form?_(n,t.fields):_(n,t.form);var i=[];return a.forEach((function(e){if(C(lineage,e)){var t={label:'contact.profile.imm.'+e,translate:!0,width:6};D(e)?t.value=n[e]?'yes':'no':(t.value='contact.profile.imm.doses',t.context={count:V(n,e),total:O(e)}),i.push(t)}})),i.length||i.push({label:'contact.profile.imm.generic',translate:!0,value:N(H,r),width:12}),i}},{label:'contact.profile.growth_monitoring',appliesToType:'person',appliesIf:function(){return k.use_cases.gmp&&M()<60&&!!A(reports,['nutrition_screening'])},fields:function(){var e=[],t=A(reports,['nutrition_screening']);return e.push({label:'contact.profile.weight',translate:!0,width:3,value:t.fields.measurements.weight}),e.push({label:'contact.profile.height',translate:!0,width:3,value:t.fields.measurements.height}),e.push({label:'contact.profile.gender',translate:!0,width:3,value:t.fields.measurements.gender}),Object.hasOwnProperty.call(t.fields.measurements,'muac')&&e.push({label:'contact.profile.muac',translate:!0,width:3,value:t.fields.measurements.muac}),e.push({label:'contact.profile.wfa',translate:!0,width:4,value:t.fields.wfa,icon:t.fields.wfa<-3?'warning':''}),e.push({label:'contact.profile.hfa',translate:!0,width:4,value:t.fields.hfa,icon:t.fields.hfa<-3?'warning':''}),e.push({label:'contact.profile.wfh',translate:!0,width:4,value:t.fields.wfh,icon:t.fields.wfh<-3?'warning':''}),e}},{label:'contact.profile.imam',appliesToType:'person',appliesIf:function(){return!!s()},fields:function(){var e=[],t=h().enrollment;return t&&(e.push({label:'contact.profile.weight',translate:!0,width:3,value:t.fields.measurements.weight}),e.push({label:'contact.profile.height',translate:!0,width:3,value:t.fields.measurements.height}),Object.hasOwnProperty.call(t.fields.measurements,'muac')&&e.push({label:'contact.profile.muac',translate:!0,width:3,value:t.fields.measurements.muac}),e.push({label:'contact.profile.wfh',translate:!0,width:3,value:t.fields.wfh,icon:t.fields.wfh<-3?'risk':''}),e.push({label:'contact.profile.nutrition_program',translate:!0,width:6,value:'OTP'===t.fields.treatment.program?'contact.profile.nutrition_program.otp':'SFP'===t.fields.treatment.program?'contact.profile.nutrition_program.sfp':'SC'===t.fields.treatment.program?'contact.profile.nutrition_program.sc':void 0}),e.push({label:'contact.profile.sessions',value:'contact.profile.visits.of',translate:!0,width:6,context:{count:v(),total:8}})),e}},{label:'contact.profile.imam_history',appliesToType:'person',appliesIf:function(){return!!h().exit},fields:function(){var e=[],t=h().enrollment,n=h().exit,r=new Date(0);return r.setUTCSeconds(n.reported_date/1e3),t&&(e.push({label:'contact.profile.last_treatment',translate:!0,width:6,value:t.fields.treatment.program}),e.push({label:'contact.profile.exit_date',translate:!0,width:6,value:r.toISOString().slice(0,10)}),e.push({label:'contact.profile.weight_at_exit',translate:!0,width:6,value:n.fields.measurements.weight}),e.push({label:'contact.profile.height_at_exit',translate:!0,width:6,value:n.fields.measurements.height}),e.push({label:'contact.profile.wfh',translate:!0,width:12,value:n.fields.measurements.wfh})),e}}];lineage[0]&&lineage[0].contact&&(k.chw_name=lineage[0].contact.name,k.chw_phone=lineage[0].contact.phone),e.exports={context:k,cards:j,fields:U}},function(e,t){var n=Date.now(),r=['P','pregnancy'],i=['D','delivery'],o=[['bcg','BCG'],['cholera_1','CH1'],['cholera_2','CH2'],['cholera_3','CH3'],['hep_a_1','HA1'],['hep_a_2','HA2'],['hep_b','HB'],['hpv_1','HPV1'],['hpv_2','HPV2'],['hpv_3','HPV3'],['ipv_1','IPV1'],['ipv_2','IPV2'],['ipv_3','IPV3'],['fipv_1','FIPV1'],['fipv_2','FIPV2'],['flu','FLU'],['jap_enc','JE'],['meningococcal_1','MN1'],['meningococcal_2','MN2'],['meningococcal_3','MN3'],['meningococcal_4','MN4'],['mmr_1','MMR1'],['mmr_2','MMR2'],['mmrv_1','MMRV1'],['mmrv_2','MMRV2'],['polio_0','OPV0'],['polio_1','OPV1'],['polio_2','OPV2'],['polio_3','OPV3'],['penta_1','PENTA1'],['penta_2','PENTA2'],['penta_3','PENTA3'],['pneumococcal_1','PCV1'],['pneumococcal_2','PCV2'],['pneumococcal_3','PCV3'],['pneumococcal_4','PCV4'],['rotavirus_1','ROTA1'],['rotavirus_2','ROTA2'],['rotavirus_3','ROTA3'],['typhoid_1','TY1'],['typhoid_2','TY2'],['vitamin_a','VITA'],['yellow_fever','YF'],['dpt_4','DPT4'],['dpt_5','DPT5']];function a(e){return e&&!(e.errors&&e.errors.length)}function l(e,t){for(var n=0,r=0;r<e.length;++r)t(e[r])&&++n;return n}function s(e,t){return e&&-1!==e.split(' ').indexOf(t)}var c=function(e,t){return e&&(s(e.use_cases,t)||c(e.parent,t))};function f(e){return e&&i.indexOf(e.form)&&e.fields&&e.fields.delivery_code&&'f'!==e.fields.delivery_code.toLowerCase()}function u(e){var t=e&&(e.birth_date||e.fields.birth_date||e.reported_date);return new Date(t)}function p(e){var t=u(e);return{start:t,end:d(t,45)}}function d(e,t){var n=new Date(e);return n.setUTCDate(n.getUTCDate()+t),n.setUTCHours(0,0,0,0),n}function m(e){return reports.filter((function(t){return('delivery'===t.form||'D'===t.form)&&t.reported_date>e.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_date<t.reported_date)&&(t=e)})),t},isActivePregnancy:function(e){return!('person'!==contact.type||'P'!==e.form&&'pregnancy'!==e.form||m(e).length||_(e).length)},getSubsequentDeliveries:m,getSubsequentPregnancies:_,getAgeInMonths:function(){var e,t;if(contact.date_of_birth&&''!==contact.date_of_birth)return e=new Date(contact.date_of_birth),t=new Date(Date.now()-e.getTime()),12*Math.abs(t.getFullYear()-1970)+t.getMonth()},getNewestDelivery:h,getNewestPncPeriod:function(){return p(h())},getSubsequentVisits:function(e){return reports.filter((function(t){return('pregnancy_visit'===t.form&&t.fields.visit_confirmed&&'yes'===t.fields.visit_confirmed||'V'===t.form)&&t.reported_date>e.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;t<r.length;++t)o=r[t],!(f=o)||f.errors&&f.errors.length||(l=i(e,a,o))&&c.cards.push(l);else{if(!u.includes(s)&&u.length>0)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": [
{
Expand Down
Binary file modified config/forms/app/care.xlsx
Binary file not shown.
4 changes: 4 additions & 0 deletions config/forms/app/care.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
</parent>
</contact>
</inputs>
<patient_id/>
<patient_name/>
<care>
<medical/>
<knowledge/>
Expand Down Expand Up @@ -61,6 +63,8 @@
<bind nodeset="/care/inputs/contact/sex" type="string"/>
<bind nodeset="/care/inputs/contact/parent/contact/phone" type="string"/>
<bind nodeset="/care/inputs/contact/parent/contact/name" type="string"/>
<bind nodeset="/care/patient_id" type="string" calculate="../inputs/contact/patient_id"/>
<bind nodeset="/care/patient_name" type="string" calculate="../inputs/contact/name"/>
<bind nodeset="/care/care/medical" type="select1"/>
<bind nodeset="/care/care/knowledge" type="select1"/>
<bind nodeset="/care/care/adherence" type="select1"/>
Expand Down
21 changes: 21 additions & 0 deletions config/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down