Я не уверен, почему моя простая функция вызывает «Синтаксическая ошибка рядом с неожиданным« myArr ». Я принимаю массив, значение ключа поиска и имя раздела элемента строки в качестве аргументов. Каждая строка в массиве является строкой с разделителями«, »Я проверяю, равна ли первая строка значению ключа поиска. Если это так, я распечатаю строку в свой выходной файл. Я использую awk. У меня есть функция вне сценария awk, являющегося скриптом.
#!/usr/bin/gawk -f
Authorization="Authorization.csv";
LineItem="LineItem.csv";
ModifierCode="ModifierCode.csv";
Decision="Decision.csv";
LineItemReview_CRLI="LineItemReview.csv";
LineItemReview_ARLI="LineItemReview.csv";
#AuthorizationNotification
#InformationSource
#LineItemNotification
#LineItemReview
#Note & NoteComment
OUTFILE="output.csv"
function LineItems(myArr, AuthKey, LIsection){
for (LI in myArr)
{
split(myArr[LI], a, ",")
if (a[1] == AuthKey)
{
print LIsection"," myArr[LI] > "output.csv"
}
}
}
awk 'BEGIN { NR>1
while (getline < "'"$Authorization"'" )
{
split($0,ft,",");
Auth_num=ft[4];
request_date=ft[5];
status=ft[8];
state=ft[9];
state_date=ft[10];
request_source=ft[12];
method=ft[13];
level_of_urgency=ft[17];
urgency_requested_by=ft[18];
primary_diagnosis=ft[19];
primary_code=ft[20];
continuity_of_care=ft[21];
court_ordered=ft[22];
member_eligibility_and_benifits_verified=ft[23];
single_case_agreement=ft[24];
case_name=ft[25];
requesting_provider=ft[28];
requesting_provider_id=ft[29];
requesting_provider_npi=ft[30];
requesting_provider_phone=ft[32];
requesting_provider_phone_ext=ft[34];
requesting_provider_fax_number=ft[36];
Authorization_Arr[Auth_num]=Auth_num","request_date","status","state","state_date","request_source","method","level_of_urgency","urgency_requested_by","primary_diagnosis","primary_code","continuity_of_care","court_ordered","member_eligibility_and_benifits_verified","single_case_agreement","case_name","requesting_provider","requesting_provider_id","requesting_provider_npi","requesting_provider_phone","requesting_provider_phone_ext","requesting_provider_fax_number;
}
close("'"$Authorization"'");
LineItCounter=0;
while (getline < "'"$LineItem"'")
{
split($0,li,",");
LineItCounter=LineItCounter+1
LI_Auth_num=li[4];
LI_ID=li[5];
line_item_number=li[6];
requested_from_date=li[7];
requested_to_date=li[8];
type=li[9];
requested_date=li[10];
determination_due_date=li[12];
service_type=li[13];
status=li[14];
level_of_urgency=li[15];
urgency_requested_by=li[16];
primary_procedure=li[18];
code=li[19];
applied_eligibility=li[20];
servicing_provider=li[21];
provider_id=li[22];
npi=li[23];
in_network=li[24];
servicing_provider_phone=li[26];
place_of_service=li[28];
comments=li[29];
method=li[30];
out_of_network_reason=li[31];
preliminary_requested_units=li[33];
request_source=li[34];
determined_from_date=li[35];
determined_to_date=li[36];
determination=li[37];
requested_units=li[39];
recommended_units=li[40];
determined_units=li[41];
type_of_decision=li[42];
LineItem_Arr[LI_ID]=LI_Auth_num","LI_ID","line_item_number","requested_from_date","type","requested_date","determination_due_date","service_type","status","level_of_urgency","urgency_requested_by","primary_procedure","code","applied_eligibility","servicing_provider","provider_id","npi","in_network","servicing_provider_phone","place_of_service","comments","method","out_of_network_reason","preliminary_requested_units","request_source","determined_from_date","determined_to_date","determination","requested_units","recommended_units","determined_units","type_of_decision;
}
close("'"$LineItem"'");
Modcounter=0;
while (getline < "'"$ModifierCode"'")
{
split($0,mi,",");
Modcounter=Modcounter+1
Mod_Auth_num=mi[4];
Modifier_ID=mi[5];
modifier_code=mi[7];
ModifierCode_Arr[Modcounter]=Mod_Auth_num","Modifier_ID","modifier_code;
}
close("'"$ModifierCode"'");
Deccounter=0;
while (getline < "'"$Decision"'")
{
split($0,di,",");
Deccounter=Deccounter+1;
Dec_Auth_num=di[4];
Dec_LineItemID=di[5];
Decision_ID=di[7];
decision2=di[8];
units=di[9];
decision_date=di[10];
claim_information=di[11];
explanation=di[12];
Decision_Arr[Deccounter]=Dec_Auth_num","Dec_LineItemID","determined_units","decision2","units","decision_date","claim_information","explanation;
}
close("'"$Decision"'");
LIR_counter=0;
while (getline < "'"$LineItemReview_CRLI"'")
{
split($0,ri,",");
LIR_counter=LIR_counter+1;
LIR_Auth_num=ri[4];
date_of_review_CRLI=ri[7];
reviewed_by_lastname_CRLI=ri[8];
reviewed_by_firstname_CRLI=ri[9];
external_reviewer_CRLI=ri[10];
criteria_met_CRLI=ri[12];
method_CRLI=ri[14];
administrative_denial_CRLI=ri[15];
criteria_source_CRLI=ri[16];
review_summary_CRLI=ri[17];
review_notes_CRLI=ri[18];
rationale_CRLI=ri[19];
LineItemReview_CRLI_Arr[LIR_counter]=LIR_Auth_num","date_of_review_CRLI","reviewed_by_lastname_CRLI","reviewed_by_firstname_CRLI","external_reviewer_CRLI","criteria_met_CRLI","method_CRLI","administrative_denial_CRLI","criteria_source_CRLI","review_summary_CRLI","review_notes_CRLI","rationale_CRLI;
}
close("'"$LineItemReview_CRLI"'");
ARLI_counter=0;
while (getline < "'"$LineItemReview_ARLI"'")
{
split($0,ai,",");
ARLI_counter=ARLI_counter+1;
ARLI_Auth_num=ai[4];
date_of_review_ARLI=ai[7];
reviewed_by_lastname_ARLI=ai[8];
reviewed_by_firstname_ARLI=ai[9];
external_reviewer_ARLI=ai[10];
reviewer_specialty_ARLI=ai[11];
criteria_met_ARLI=ai[12];
review_reason_ARLI=ai[13];
criteria_source_ARL=ai[16];
review_summary_ARLI=ai[17];
review_notes_ARLI=ai[18];
rationale_ARLI=ai[19];
LineItemReview_ARLI_Arr[ARLI_counter]=ARLI_Auth_num","date_of_review_ARLI","reviewed_by_lastname_ARLI","reviewed_by_firstname_ARLI","external_reviewer_ARLI","criteria_met_ARLI","reviewer_specialty_ARLI","review_reason_ARLI","criteria_source_ARL","review_summary_ARLI","review_notes_ARLI","rationale_ARLI;
}
close("'"$LineItemReview_ARLI"'");
for (key in Authorization_Arr)
{
if (key != "authorization_num")
{
print "SASH," Authorization_Arr[key] > "output.csv"
for (LI in LineItem_Arr)
{
split(LineItem_Arr[LI], a, ",")
if (a[1] == key)
{
print "SPLI," LineItem_Arr[LI] > "output.csv"
}
}
for (Mod in ModifierCode_Arr)
{
split(ModifierCode_Arr[Mod], p, ",")
if (p[1]== key)
{
print "SPLI_Mod," ModifierCode_Arr[Mod] > "output.csv"
}
}
for (Dec in Decision_Arr)
{
split(Decision_Arr[Dec], d, ",")
if (d[1]== key)
{
print "SPLI_Dec," Decision_Arr[Dec] > "output.csv"
}
}
for (CRLI in LineItemReview_CRLI_Arr)
{
split(LineItemReview_CRLI_Arr[CRLI], u, ",")
if (u[1]== key)
{
print "CRLI," LineItemReview_CRLI_Arr[CRLI] > "output.csv"
}
}
for (ARLI in LineItemReview_ARLI_Arr)
{
split(LineItemReview_ARLI_Arr[ARLI], c, ",")
if (c[1]== key)
{
print "ARLI," LineItemReview_ARLI_Arr[ARLI] > "output.csv"
}
}
}
}
}'