Database

[{"_id":{"$oid":"671693da49497e37ab515f5c"},"program_name":"bw_xxx_xxx1205_post_acxxxx_xxx","drop_program_names":["xxx_xxx1205_post_acxxx_xxx"],"create_program_names":["xxx_xxx1205_post_acxxx_xxx"],"record_structure":{"recset":{"rs_patname":"vc","rs_dob":"vc","rs_mrn":"vc","rs_fin":"vc","rs_encntrid":"f8","rs_payors":"vc","rs_dischdisp":"vc","rs_dischdate":"vc","rs_refsnf":"vc","rs_refhh":"vc","rs_refhosp":"vc","rs_refltacs":"vc","rs_refira":"vc","rs_refhi":"vc","rs_refdme":"vc","rs_reftrans":"vc","rs_refoutther":"vc","rs_refothserv":"vc","rs_reftodial":"vc","rs_reftoboard":"vc","rs_reftoshelt":"vc","rs_refhi_nomid":"vc","rs_refhi_evid":"f8","rs_refoutther_nomid":"vc","rs_refoutther_evid":"f8","rs_reftrans_nomid":"vc","rs_reftrans_evid":"f8","rs_reftoboard_nomid":"vc","rs_reftoboard_evid":"f8","rs_reftodial_nomid":"vc","rs_reftodial_evid":"f8","rs_refhosp_nomid":"vc","rs_refhosp_evid":"f8","rs_refltacs_nomid":"vc","rs_refltacs_evid":"f8","rs_refothserv_nomid":"vc","rs_refothserv_evid":"f8","rs_reftoshelt_nomid":"vc","rs_reftoshelt_evid":"f8","rs_refsnf_nomid":"vc","rs_refsnf_evid":"f8","rs_refhh_nomid":"vc","rs_refhh_evid":"f8","rs_refira_nomid":"vc","rs_refira_evid":"f8"}},"code_values":{"138905880.00":"Referral For DME","138907783.00":"Referral For Transportation","258503279.00":"Referral For Outpatient Therapy","258503152.00":"Referral To Other Service","12502729907.00":"Referral To Dialysis","12502729999.00":"Referral To Shelter","12502729857.00":"Referral To Boarding Home"},"email_addresses":{"Payor_1":["Postxxxxx@xxxxx.eyy","bww_reports@xxxxx.eyy"],"Payor_2_Hxxxxx":["bxxxxx@hxxxx.com","cxxxs@hxxxx.com","rxxx@uxxxx.edyy","cyxxxxx@uxxxx.eyy"],"Payor_3_Unxxxx":["ljxxxxx@uxxxx.eyy","jyxxxx@uxxxxx.eyy","rdxxx@uxxxxx.eyy","cxxxxx@ucxxxxx.eyy","dxxxxxxx@uxxxxx.eyy"]},"uar_functions":["uar_get_code_display"],"file_paths":{"output_file":"","base_path":"","backup_path":""},"csv_header":["Name","DOB","MRN","FIN","Payors","Discharge Disp","Discharge Date","Referral To Skilled Nursing Facility","Referral For Home Health","Referral To Hospice","Referral To LTACS","Referral To Inpatient Rehab Acute","Referral For Home Infusion","Referral For DME","Referral For Transportation","Referral For Outpatient Therapy","Referral To Other Service","Referral To Dialysis","Referral To Boarding Home","Referral To Shelter","Referral To SNF NomenclatureID","Referral For Home Health NomenclatureID","Referral To Hospice NomenclatureID","Referral To LTACS NomenclatureID","Referral To Inpatient Rehab Acute NomenclatureID","Referral For Home Infusion NomenclatureID","Referral For Transportation NomenclatureID","Referral For Outpatient Therapy NomenclatureID","Referral To Other Service NomenclatureID","Referral To Dialysis NomenclatureID","Referral To Boarding Home NomenclatureID","Referral To Shelter NomenclatureID"]},{"_id":{"$oid":"671693da49497e37ab515e5c"},"program_name":"bw_xxx_xxx1205_post_acxxxx_xxx","drop_program_names":["xxx_xxx1205_post_acxxx_xxx"],"create_program_names":["xxx_xxx1205_post_acxxx_xxx"],"record_structure":{"recset":{"rs_patname":"vc","rs_dob":"vc","rs_mrn":"vc","rs_fin":"vc","rs_encntrid":"f8","rs_payors":"vc","rs_dischdisp":"vc","rs_dischdate":"vc","rs_refsnf":"vc","rs_refhh":"vc","rs_refhosp":"vc","rs_refltacs":"vc","rs_refira":"vc","rs_refhi":"vc","rs_refdme":"vc","rs_reftrans":"vc","rs_refoutther":"vc","rs_refothserv":"vc","rs_reftodial":"vc","rs_reftoboard":"vc","rs_reftoshelt":"vc","rs_refhi_nomid":"vc","rs_refhi_evid":"f8","rs_refoutther_nomid":"vc","rs_refoutther_evid":"f8","rs_reftrans_nomid":"vc","rs_reftrans_evid":"f8","rs_reftoboard_nomid":"vc","rs_reftoboard_evid":"f8","rs_reftodial_nomid":"vc","rs_reftodial_evid":"f8","rs_refhosp_nomid":"vc","rs_refhosp_evid":"f8","rs_refltacs_nomid":"vc","rs_refltacs_evid":"f8","rs_refothserv_nomid":"vc","rs_refothserv_evid":"f8","rs_reftoshelt_nomid":"vc","rs_reftoshelt_evid":"f8","rs_refsnf_nomid":"vc","rs_refsnf_evid":"f8","rs_refhh_nomid":"vc","rs_refhh_evid":"f8","rs_refira_nomid":"vc","rs_refira_evid":"f8"}},"code_values":{"138906674.00":"Referral To Skilled Nursing Facility","138906232.00":"Referral For Home Health","138907783.00":"Referral For Transportation","258503279.00":"Referral For Outpatient Therapy","258503152.00":"Referral To Other Service","12502729907.00":"Referral To Dialysis","12502729999.00":"Referral To Shelter","12502729857.00":"Referral To Boarding Home"},"email_addresses":{"Payor_1":["Postxxxxx@xxxxx.eyy","bww_reports@xxxxx.eyy"],"Payor_2_Hxxxxx":["bxxxxx@hxxxx.com","cxxxs@hxxxx.com","rxxx@uxxxx.edyy","cyxxxxx@uxxxx.eyy"],"Payor_3_Unxxxx":["ljxxxxx@uxxxx.eyy","jyxxxx@uxxxxx.eyy","rdxxx@uxxxxx.eyy","cxxxxx@ucxxxxx.eyy","dxxxxxxx@uxxxxx.eyy"]},"uar_functions":["uar_get_code_display"],"file_paths":{"output_file":"","base_path":"","backup_path":""},"csv_header":["Name","DOB","MRN","FIN","Payors","Discharge Disp","Discharge Date","Referral To Skilled Nursing Facility","Referral For Home Health","Referral To Hospice","Referral To LTACS","Referral To Inpatient Rehab Acute","Referral For Home Infusion","Referral For DME","Referral For Transportation","Referral For Outpatient Therapy","Referral To Other Service","Referral To Dialysis","Referral To Boarding Home","Referral To Shelter","Referral To SNF NomenclatureID","Referral For Home Health NomenclatureID","Referral To Hospice NomenclatureID","Referral To LTACS NomenclatureID","Referral To Inpatient Rehab Acute NomenclatureID","Referral For Home Infusion NomenclatureID","Referral For Transportation NomenclatureID","Referral For Outpatient Therapy NomenclatureID","Referral To Other Service NomenclatureID","Referral To Dialysis NomenclatureID","Referral To Boarding Home NomenclatureID","Referral To Shelter NomenclatureID"]}]

Query

db.collection.aggregate([{$project:{"newField":{"$objectToArray":"$code_values"}}},{$unwind:"$newField"},{$group:{_id:"$newField.v"}}])

Result