---
title: Labs for Internal use.
description: "I suspect that this is not a completely new result but a reprocess of a result and the prior processing of the result was not cleared out completely. ``` SQL> set serveroutput on SQL> exec labresult.process Start of processing: ++++…"
url: "https://docs.pertexa.net/docs/labs-for-internal-use/"
updated: "2021-12-28"
category: Clinical
---

# Labs for Internal use.

I suspect that this is not a completely new result but a reprocess of a result and the prior processing of the result was not cleared out completely.

```
SQL> set serveroutput on
SQL> exec labresult.process
Start of processing: ++++
Process exteral lab order: F2DC0BC13BAB48DCB35B31977BCDC223 with lab_order_number: WD055935A, accession number: 021584300 and pms_id = WD055935A
Results received.  Will be processed. F2DC0BC13BAB48DCB35B31977BCDC223.  which = 1
Process exteral lab order: F2DC0BC13BAB48DCB35B31977BCDC223 with lab_order_number: WD055935A, accession number: 021584300 and pms_id = WD055935A
Results received.  Will be processed. F2DC0BC13BAB48DCB35B31977BCDC223.  which = 2
Process exteral lab order: F2DC0BC13BAB48DCB35B31977BCDC223 with lab_order_number: WD055935A, accession number: 021584300 and pms_id = WD055935A
Results received.  Will be processed. F2DC0BC13BAB48DCB35B31977BCDC223.  which = 3
Process exteral lab order: F2DC0BC13BAB48DCB35B31977BCDC223 with lab_order_number: WD055935A, accession number: 021584300 and pms_id = WD055935A
At start of orders
At fmv_guid with: 801, reflex
Value returned: AA0952A4F1517A8BE0530100007FDE3B*
Past multiplier
Past recurrence count
801, reflex
Past ordertype_id
Past specialty_id
Past orders required
Past lab_test_guid
Past lab_name
At fu_guid: AA0952A4F1517A8BE0530100007FDE3B
Past fu_guid
Past orders nullable
Past result required
Past result nullable
Past result_detail required
Past result_detail nullable
Past result_enconter_map
Past orders_pending_review
Past orders_filed_review
End of assigning values
Error creating record in ORDERS with guid = 8C87B2E5312B458AA60825F06E4DFD83:  ORA-00001: unique constraint (B_MULTIONC.ORDERS_PK) violated
zzzzz before
Error creating record in RESULT with guid = zc87b2e5312b458aa60825f06e4dfd8z:  ORA-00001: unique constraint (B_MULTIONC.RESULT_PK) violated
Error creating record in RESUKT_DETAIL with guid = zc87b2e5312b458aa60825f06e4dfd8z:  ORA-00001: unique constraint (B_MULTIONC.RSLTDTL_PK) violated
^^^^^ c_rec_rem.result_guid is: zc87b2e5312b458aa60825f06e4dfd8z
Error creating record in RESUKT_ENCOUNTER_MAP with guid = zc87b2e5312b458aa60825f06e4dfd8z:  ORA-00001: unique constraint (B_MULTIONC.REM_REM_2_UK) violated
Error creating record in ORDERS_PENDING_REVIEW with orders_guid = 8C87B2E5312B458AA60825F06E4DFD83:  ORA-00001: unique constraint (B_MULTIONC.ORDPENDREV_PK) violated
Error creating record in ORDERS_FILED_REVIEW with orders_guid = 8C87B2E5312B458AA60825F06E4DFD83:  ORA-00001: unique constraint (B_MULTIONC.ORDFILEREV_PK) violated
Results received.  Will be processed. F2DC0BC13BAB48DCB35B31977BCDC223.  which = 4
Process exteral lab order: 3CBACCED02AE4ECD8154F1DB0861318E with lab_order_number: CS0000TC3, accession number: 8529631470 and pms_id =
Results received.  Will be processed. 3CBACCED02AE4ECD8154F1DB0861318E.  which = 1
Process exteral lab order: 3CBACCED02AE4ECD8154F1DB0861318E with lab_order_number: CS0000TC3, accession number: 8529631470 and pms_id =
Results received.  Will be processed. 3CBACCED02AE4ECD8154F1DB0861318E.  which = 2
Process exteral lab order: 3CBACCED02AE4ECD8154F1DB0861318E with lab_order_number: CS0000TC3, accession number: 8529631470 and pms_id =
Results received.  Will be processed. 3CBACCED02AE4ECD8154F1DB0861318E.  which = 3
Process exteral lab order: 3CBACCED02AE4ECD8154F1DB0861318E with lab_order_number: CS0000TC3, accession number: 8529631470 and pms_id =
Results received.  Will be processed. 3CBACCED02AE4ECD8154F1DB0861318E.  which = 4
Process exteral lab order: FC6D47F84285495182D887B78644D831 with lab_order_number: CS0000TC3, accession number: 8529631471 and pms_id =
Results received.  Will be processed. FC6D47F84285495182D887B78644D831.  which = 1
Process exteral lab order: FC6D47F84285495182D887B78644D831 with lab_order_number: CS0000TC3, accession number: 8529631471 and pms_id =
Results received.  Will be processed. FC6D47F84285495182D887B78644D831.  which = 2
Process exteral lab order: FC6D47F84285495182D887B78644D831 with lab_order_number: CS0000TC3, accession number: 8529631471 and pms_id =
Results received.  Will be processed. FC6D47F84285495182D887B78644D831.  which = 3
Process exteral lab order: FC6D47F84285495182D887B78644D831 with lab_order_number: CS0000TC3, accession number: 8529631471 and pms_id =
Results received.  Will be processed. FC6D47F84285495182D887B78644D831.  which = 4
End of processing: ++++
```

 Notice the multiple ORA-00001: unique constraint errors in the above.Here is part of my code that gets executed when unsolicited result come in:

```
             -- Not null columns for ORDERS
            c_rec_order.GUID := p_guid_elt;
dbms_output.put_line('At fmv_guid with: ' || c_rec_elo.lab_id || ', ' || v_testcode);
            c_rec_order.FMV_GUID := labresult.get_fmv_guid(c_rec_elo.lab_id, v_testcode);
dbms_output.put_line('Value returned: ' || c_rec_order.FMV_GUID || '*');
            c_rec_order.ORDERSTTS_ID := 18;
            c_rec_order.RESULTMODE_ID := 1;
            c_rec_order.ORDERSRCE_ID := 1;
            c_rec_order.MULTIPLIER := 1;
dbms_output.put_line('Past multiplier');
            c_rec_order.CLINIC_GUID := c_rec_elo.CLINIC_GUID;
            c_rec_order.PATIENT_GUID := c_rec_plo.PATIENT_GUID;
            c_rec_order.RECMGR_HIDE := 'N';
            c_rec_order.ABN_STATUS_ID := -1;
            c_rec_order.ORDERSTATE_ID := 1;
            c_rec_order.ABN_REASON_ID := -1;
            c_rec_order.RECURRENCE_COUNT := 0;
dbms_output.put_line('Past recurrence count');
dbms_output.put_line(c_rec_elo.lab_id || ', ' || v_testcode);
            c_rec_order.ORDERTYPE_ID := nvl(labresult.get_ordertype(c_rec_elo.lab_id, v_testcode), 1);
dbms_output.put_line('Past ordertype_id');
            c_rec_order.SPECIALTY_ID := 65;
dbms_output.put_line('Past specialty_id');
            c_rec_order.DXLINKTYP_ID := 0;
            c_rec_order.NUM_LAB_QUESTIONS := 0;
dbms_output.put_line('Past orders required');
```

 Notice that orders.guid gets created from external_lab_order.guid
 When reusing a result either

1.  it needs to be completely cleaned out from both the external_lab\* and orders/results tables
2. A different value assigned to external_lab_test.guid

 What you are seeing is consistent with neither 1 and 2 being done.Also note the guids of the form z%z.  This is the format of guids for records created by my process to handle unsolicited result.
 That fact that they already exist supports my guess that this is an attempt to reuse already processed data and neither 1 or 2 done.I am sure that if I delete the record with orders.guid = '8C87B2E5312B458AA60825F06E4DFD83' and all children then my code will do its job without errors.  ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------             The current results that we are attempting to process is not the normal flow because [@Kamil - IT](https://pertexa-group.slack.com/team/UVBEU5SDT) did not clean everything out before he reprocessed.  So we have a patch work of  manual steps.
 [@Raychelle](https://pertexa-group.slack.com/team/UM3UN9LLT) said on Friday:  "[@Jatin Miyanee](https://pertexa-group.slack.com/team/UK7DPN5NC) some issue occurs. Still unlinked."
 I assume that "Still unlinked." means the external_lab_patient.rm\* columns are not populated.  So she would need to go into RM to link to the correct patient"
 [@Jatin Miyanee](https://pertexa-group.slack.com/team/UK7DPN5NC) said this morning "Can i do anything for next step ?"  At that time, I assumed that Raychelle's friday comment was correct.
 Upon further investigation this afternoon I find that the external_lab_patient.rm\* columns are still populated.  So that means we need to execute my code:  labresult.process
 As this is not the normal processing, we need to do something manual.  Either:

1. execute labresult.process by hand.  Jatin, Kent, Kamil, or I can do.
2. relink the results to the patient in RM which will call labresult.process.  I don't know if this functionality is available in RM or if it is needed.
3. wait to another result comes in and Kamil calls docpadmgr.manager.process which call labresult.process all customers.

 Whatever we do, it will not be the normal process and I would think we would need to have another set of results that we can process w/o any manual intervention.                  [4:19](https://pertexa-group.slack.com/archives/CSEHF43R8/p1640645359461100)        I guess simultaneous execution is possible, put I am not going to worry about it. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[Jatin Miyanee](https://app.slack.com/team/UK7DPN5NC)  [8:40 AM](https://pertexa-group.slack.com/archives/CSEHF43R8/p1640661043463700)

      [@Arthur Gurney](https://pertexa-group.slack.com/team/UBZ3UU561):  relink the results from RM, everytime labresult.process will call.

[Arthur Gurney](https://app.slack.com/team/UBZ3UU561)  [9:12 AM](https://pertexa-group.slack.com/archives/CSEHF43R8/p1640662930464900)

      I dont know how to relink from RM.  Can you do?  I assume you know how since you wrote the app.

[Arthur Gurney](https://app.slack.com/team/UBZ3UU561)  [9:18 AM](https://pertexa-group.slack.com/archives/CSEHF43R8/p1640663290465700)

      I can call labresult.process but I rather have it called from the UI which is closer to normal processing.
