2121
2222 const patientRep = " (uuid,display,person:(display),identifiers:(identifier,preferred,identifierType:(uuid,display,auditInfo:(dateCreated))))" ;
2323 const conceptRep = " (id,uuid,allowDecimal,display,names:(id,uuid,name,locale,localePreferred,voided,conceptNameType))" ;
24+ const orderRep = " id,uuid,display,orderNumber,dateActivated,scheduledDate,dateStopped,autoExpireDate,fulfillerStatus,orderType:(id,uuid,display,name),encounter:(id,uuid,display,encounterDatetime),careSetting:(uuid,name,careSettingType,display),accessionNumber,urgency,action,patient:(uuid,display,person:(display),identifiers:(identifier,preferred,identifierType:(uuid,display,auditInfo:(dateCreated)))),concept:" + conceptRep
25+
2426 const labOrderConfigRep = " (labTestOrderType:(uuid),availableLabTestsByCategory:(category:" + conceptRep + " ,labTests:" + conceptRep + " ),orderStatusOptions:(status,display),fulfillerStatusOptions:(status,display),orderFulfillmentStatusOptions:(status,display),testLocationQuestion:(uuid,answers:(uuid,display)),specimenCollectionEncounterType:(uuid),specimenCollectionEncounterRole:(uuid),estimatedCollectionDateQuestion:(uuid),estimatedCollectionDateAnswer:(uuid),testOrderNumberQuestion:(uuid),labIdentifierConcept:(uuid),specimenReceivedDateQuestion:(uuid),reasonTestNotPerformedQuestion:(uuid,answers:(uuid,display)))" ;
2527 const pihAppsConfigRep = " dateFormat,dateTimeFormat,primaryIdentifierType:(uuid),labOrderConfig:" + labOrderConfigRep;
2628
3234
3335 const viewSpecimenEncounter = function (encounterUuid ) {
3436 const encounterRep = " id,uuid,patient:" + patientRep + " ,encounterDatetime,encounterType:(uuid),location:(uuid,display),encounterProviders:(provider:(uuid,display),encounterRole:(uuid,display)),obs:(uuid,concept:(uuid,datatype:(name)),value,comment,formNamespaceAndPath)" ;
35- const orderRep = " id,uuid,display,orderNumber,dateActivated,scheduledDate,dateStopped,autoExpireDate,fulfillerStatus,orderType:(id,uuid,display,name),encounter:(id,uuid,display,encounterDatetime),careSetting:(uuid,name,careSettingType,display),accessionNumber,urgency,action,patient:(uuid,display,person:(display),identifiers:(identifier,preferred,identifierType:(uuid,display,auditInfo:(dateCreated)))),concept:" + conceptRep
3637 const rep = " encounter:(" + encounterRep + " ),orders:(" + orderRep + " )" ;
3738 jq .get (openmrsContextPath + " /ws/rest/v1/pihapps/config?v=custom:(" + pihAppsConfigRep + " )" , function (pihAppsConfig ) {
3839 jq .get (openmrsContextPath + " /ws/rest/v1/encounterFulfillingOrders/" + encounterUuid + " ?v=custom:(" + rep + " )" , function (encAndOrders ) {
39- jq (" #view-orders-section" ).hide ();
40- jq (" #specimen-edit-emr-id" ).html (patientUtils .getPreferredIdentifier (encAndOrders .encounter .patient , pihAppsConfig .primaryIdentifierType ? .uuid ?? ' ' ));
41- jq (" #specimen-edit-patient-name" ).html (encAndOrders .encounter .patient .person .display );
40+ jq (" .specimen-edit-emr-id" ).html (patientUtils .getPreferredIdentifier (encAndOrders .encounter .patient , pihAppsConfig .primaryIdentifierType ? .uuid ?? ' ' ));
41+ jq (" .specimen-edit-patient-name" ).html (encAndOrders .encounter .patient .person .display );
4242 initializeSpecimenCollectionForm ({
4343 patientUuid: encAndOrders .encounter .patient .uuid ,
4444 orders: encAndOrders .orders ,
4545 encounter: encAndOrders .encounter ,
4646 pihAppsConfig: pihAppsConfig,
4747 onSuccessFunction : () => { closeEncounterEdit (); pagingDataTable .updateTable (); }
4848 });
49+ jq (" #view-orders-section" ).hide ();
4950 jq (" #edit-specimen-encounter-section" ).show ();
5051 });
5152 });
5253 };
5354
55+ const viewOrderNotPerformed = function (orderUuid ) {
56+ const rep = orderRep + " ,reasonOrderNotFulfilled:(uuid,concept:" + conceptRep + " ,valueCoded:" + conceptRep + " )" ;
57+ jq .get (openmrsContextPath + " /ws/rest/v1/pihapps/config?v=custom:(" + pihAppsConfigRep + " )" , function (pihAppsConfig ) {
58+ jq .get (openmrsContextPath + " /ws/rest/v1/order/" + orderUuid + " ?v=custom:(" + rep + " )" , function (order ) {
59+ jq (" .specimen-edit-emr-id" ).html (patientUtils .getPreferredIdentifier (order .patient , pihAppsConfig .primaryIdentifierType ? .uuid ?? ' ' ));
60+ jq (" .specimen-edit-patient-name" ).html (order .patient .person .display );
61+ initializeOrderNotFulfilledForm ({
62+ orders: [order],
63+ reason: order .reasonOrderNotFulfilled ,
64+ pihAppsConfig: pihAppsConfig,
65+ onSuccessFunction : () => { closeReasonNotPerformed (); pagingDataTable .updateTable (); }
66+ });
67+ jq (" #view-orders-section" ).hide ();
68+ jq (" #edit-reason-not-performed-section" ).show ();
69+ });
70+ });
71+ }
72+
5473 const closeEncounterEdit = function () {
5574 jq (" #edit-specimen-encounter-section" ).hide ();
5675 jq (" #view-orders-section" ).show ();
5776 }
5877
78+ const closeReasonNotPerformed = function () {
79+ jq (" #edit-reason-not-performed-section" ).hide ();
80+ jq (" #view-orders-section" ).show ();
81+ }
82+
5983 jq (document ).ready (function () {
6084
6185 jq .get (openmrsContextPath + " /ws/rest/v1/pihapps/config?v=custom:(" + pihAppsConfigRep + " )" , function (pihAppsConfig ) {
7498 const getAccessionNumber = (order ) => { return order .accessionNumber ; }
7599 const getOrderStatus = (order ) => { return patientUtils .getOrderStatusOption (order, orderStatusOptions).display ; };
76100 const getFulfillerStatus = (order ) => { return patientUtils .getFulfillerStatusOption (order, fulfillerStatusOptions).display ; };
77- const getOrderFulfillmentStatus = ( order ) => { return patientUtils . getOrderFulfillmentStatusOption (order, orderFulfillmentStatusOptions). display ; };
101+
78102 const getLabTest = function (order ) {
79103 const urgency = order .urgency === ' STAT' ? ' <i class="fas fa-fw fa-exclamation" style="color: red;"></i>' : ' ' ;
80104 return urgency + conceptUtils .getConceptShortName (order .concept , window .sessionContext ? .locale );
88112 return " <a href=\" javascript:viewSpecimenEncounter('" + fulfillerEncounter .uuid + " ')\" >" + specimenDate + " </a>" ;
89113 };
90114
115+ const getOrderFulfillmentStatus = (order ) => {
116+ const statusDisplay = patientUtils .getOrderFulfillmentStatusOption (order, orderFulfillmentStatusOptions).display ;
117+ if (order .fulfillerStatus === ' EXCEPTION' ) {
118+ return " <a href=\" javascript:viewOrderNotPerformed('" + order .uuid + " ')\" >" + statusDisplay + " </a>" ;
119+ }
120+ return statusDisplay;
121+ };
122+
91123 const getFilterParameterValues = function () {
92124 return {
93125 " orderType" : pihAppsConfig .labOrderConfig .labTestOrderType ? .uuid ,
149181 });
150182< / script>
151183
184+ < style>
185+ #edit- specimen- encounter- section { display: none; }
186+ #edit- reason- not- performed- section { display: none; }
187+ < / style>
188+
152189< div id= " view-orders-section" >
153190 < div class = " row justify-content-between" >
154191 < div class = " col-6" >
249286 < div class = " col-6" >
250287 < h3>
251288 ${ ui .message (" pihapps.specimenCollectionDetails" ) } -
252- < span id = " specimen-edit-patient-name" >< / span>
253- (< span id = " specimen-edit-emr-id" >< / span> )
289+ < span class = " specimen-edit-patient-name" >< / span>
290+ (< span class = " specimen-edit-emr-id" >< / span> )
254291 < / h3>
255292 < / div>
256293 < / div>
257294 ${ ui .includeFragment (" pihapps" , " labs/specimenCollectionEncounter" , [" id" : " specimen-encounter-section" ])}
295+ < / div>
296+
297+ < div id= " edit-reason-not-performed-section" >
298+ < div class = " row justify-content-between" >
299+ < div class = " col-6" >
300+ < h3>
301+ ${ ui .message (" pihapps.removeSelectedOrders" ) } -
302+ < span class = " specimen-edit-patient-name" >< / span>
303+ (< span class = " specimen-edit-emr-id" >< / span> )
304+ < / h3>
305+ < / div>
306+ < / div>
307+ ${ ui .includeFragment (" pihapps" , " labs/recordOrderNotFulfilled" , [" id" : " reason-not-performed-section" ])}
258308< / div>
0 commit comments